From c466982fbc3501db21383fb4734a275487324aab Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 28 Sep 2024 14:25:02 +0300 Subject: [PATCH] use actionable object --- src/browser/main/tab/page/navigation.rs | 8 ++++++-- src/browser/main/tab/page/navigation/request.rs | 14 ++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/browser/main/tab/page/navigation.rs b/src/browser/main/tab/page/navigation.rs index 18875edf..cd215d91 100644 --- a/src/browser/main/tab/page/navigation.rs +++ b/src/browser/main/tab/page/navigation.rs @@ -39,8 +39,12 @@ impl Navigation { // Init components let base = Base::new(); let history = History::new(); - let reload = Reload::new(action_tab_page_reload); - let request = Request::new(request_text, action_update); + let reload = Reload::new(action_tab_page_reload.clone()); + let request = Request::new( + request_text, + action_update.clone(), + action_tab_page_reload.clone(), + ); 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 11abc78d..a490bc5e 100644 --- a/src/browser/main/tab/page/navigation/request.rs +++ b/src/browser/main/tab/page/navigation/request.rs @@ -1,7 +1,7 @@ use gtk::{ gio::SimpleAction, glib::{GString, Uri, UriFlags}, - prelude::{ActionExt, EditableExt, EntryExt, WidgetExt}, + prelude::{ActionExt, EditableExt, EntryExt}, Entry, }; @@ -13,7 +13,11 @@ pub struct Request { impl Request { // Construct - pub fn new(text: Option, action_update: Arc) -> Self { + pub fn new( + text: Option, + action_update: Arc, + tab_page_reload: Arc, + ) -> Self { // GTK let widget = Entry::builder() .placeholder_text("URL or search term...") @@ -31,10 +35,8 @@ impl Request { action_update.activate(None); }); - widget.connect_activate(|entry| { - entry - .activate_action("win.tab_page_reload", None) // @TODO - .expect("Action `win.tab_page_reload` not found") + widget.connect_activate(move |_| { + tab_page_reload.activate(None); }); // Result