diff --git a/src/app/browser/window/tab/item.rs b/src/app/browser/window/tab/item.rs index f6df991a..a2543417 100644 --- a/src/app/browser/window/tab/item.rs +++ b/src/app/browser/window/tab/item.rs @@ -91,16 +91,22 @@ impl Item { }); action.ident.connect_activate({ + let client = client.clone(); let page = page.clone(); let parent = tab_view.clone().upcast::(); let profile = profile.clone(); - let window_action = window_action.clone(); move || { - if let Some(uri) = page.navigation.uri() { - let scheme = uri.scheme(); - if scheme == "gemini" || scheme == "titan" { - return identity::default(&window_action, &profile, &uri) - .present(Some(&parent)); + if let Some(request) = page.navigation.uri() { + if ["gemini", "titan"].contains(&request.scheme().as_str()) { + return identity::default(&profile, &request, { + let client = client.clone(); + let page = page.clone(); + move || { + page.navigation.update(); // update indicators immediately + client.handle(&page.navigation.request(), false); + } // on apply + }) + .present(Some(&parent)); } } identity::unsupported().present(Some(&parent)); diff --git a/src/app/browser/window/tab/item/identity.rs b/src/app/browser/window/tab/item/identity.rs index 13ed006f..ab179b1a 100644 --- a/src/app/browser/window/tab/item/identity.rs +++ b/src/app/browser/window/tab/item/identity.rs @@ -4,13 +4,13 @@ mod unsupported; use default::Default; use unsupported::Unsupported; -use super::{Profile, WindowAction}; +use super::Profile; use gtk::glib::Uri; use std::rc::Rc; /// Create new identity widget for Gemini protocol match given URI -pub fn default(window_action: &Rc, profile: &Rc, request: &Uri) -> Default { - Default::build(window_action, profile, request) +pub fn default(profile: &Rc, request: &Uri, on_apply: impl Fn() + 'static) -> Default { + Default::build(profile, request, on_apply) } /// Create new identity widget for unknown request diff --git a/src/app/browser/window/tab/item/identity/default.rs b/src/app/browser/window/tab/item/identity/default.rs index 18133e90..06e029a4 100644 --- a/src/app/browser/window/tab/item/identity/default.rs +++ b/src/app/browser/window/tab/item/identity/default.rs @@ -1,7 +1,7 @@ mod widget; use widget::{form::list::item::value::Value, Widget}; -use super::{Profile, WindowAction}; +use super::Profile; use gtk::{glib::Uri, prelude::IsA}; use std::rc::Rc; @@ -14,7 +14,7 @@ impl Default { // Construct /// Create new `Self` for given `Profile` - pub fn build(window_action: &Rc, profile: &Rc, request: &Uri) -> Self { + pub fn build(profile: &Rc, request: &Uri, on_apply: impl Fn() + 'static) -> Self { // Init widget let widget = Rc::new(Widget::build(profile, request)); @@ -23,7 +23,6 @@ impl Default { let profile = profile.clone(); let request = request.clone(); let widget = widget.clone(); - let window_action = window_action.clone(); move |response| { // Get option match user choice let option = match response { @@ -64,8 +63,8 @@ impl Default { } } - // Apply changes - window_action.reload.activate(); + // Run callback function + on_apply() } });