From 01307f49256879975090df9c05addc7310cf3cd9 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 28 Sep 2024 14:22:14 +0300 Subject: [PATCH] use actionable object --- src/browser/main/tab/page/navigation.rs | 2 +- src/browser/main/tab/page/navigation/request.rs | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/browser/main/tab/page/navigation.rs b/src/browser/main/tab/page/navigation.rs index 6b59bdfe..18875edf 100644 --- a/src/browser/main/tab/page/navigation.rs +++ b/src/browser/main/tab/page/navigation.rs @@ -40,7 +40,7 @@ impl Navigation { let base = Base::new(); let history = History::new(); let reload = Reload::new(action_tab_page_reload); - let request = Request::new(request_text); + let request = Request::new(request_text, action_update); let bookmark = Bookmark::new(); // Init widget diff --git a/src/browser/main/tab/page/navigation/request.rs b/src/browser/main/tab/page/navigation/request.rs index 80eb631f..11abc78d 100644 --- a/src/browser/main/tab/page/navigation/request.rs +++ b/src/browser/main/tab/page/navigation/request.rs @@ -1,16 +1,19 @@ use gtk::{ + gio::SimpleAction, glib::{GString, Uri, UriFlags}, - prelude::{EditableExt, EntryExt, WidgetExt}, + prelude::{ActionExt, EditableExt, EntryExt, WidgetExt}, Entry, }; +use std::sync::Arc; + pub struct Request { widget: Entry, } impl Request { // Construct - pub fn new(text: Option) -> Self { + pub fn new(text: Option, action_update: Arc) -> Self { // GTK let widget = Entry::builder() .placeholder_text("URL or search term...") @@ -24,15 +27,13 @@ impl Request { .build(); // Connect events - widget.connect_changed(|entry| { - entry - .activate_action("win.update", None) - .expect("Action `win.update` not found") + widget.connect_changed(move |_| { + action_update.activate(None); }); widget.connect_activate(|entry| { entry - .activate_action("win.tab_page_reload", None) + .activate_action("win.tab_page_reload", None) // @TODO .expect("Action `win.tab_page_reload` not found") });