diff --git a/src/app/browser/window/tab/item.rs b/src/app/browser/window/tab/item.rs index 8ac6b4d0..75e1c389 100644 --- a/src/app/browser/window/tab/item.rs +++ b/src/app/browser/window/tab/item.rs @@ -91,6 +91,11 @@ impl Item { } }); + action.identity.connect_activate({ + let page = page.clone(); + move |_, _| page.navigation.identity() + }); + action.reload.connect_activate({ let page = page.clone(); let client = client.clone(); diff --git a/src/app/browser/window/tab/item/action/identity.rs b/src/app/browser/window/tab/item/action/identity.rs index 45134e28..69e6dbe1 100644 --- a/src/app/browser/window/tab/item/action/identity.rs +++ b/src/app/browser/window/tab/item/action/identity.rs @@ -6,8 +6,6 @@ pub trait Identity { impl Identity for SimpleAction { fn identity() -> Self { - let identity = SimpleAction::new(&uuid_string_random(), None); - identity.set_enabled(false); - identity + SimpleAction::new(&uuid_string_random(), None) } } diff --git a/src/app/browser/window/tab/item/page/navigation.rs b/src/app/browser/window/tab/item/page/navigation.rs index 3ae50976..c0af5924 100644 --- a/src/app/browser/window/tab/item/page/navigation.rs +++ b/src/app/browser/window/tab/item/page/navigation.rs @@ -137,6 +137,10 @@ impl Navigation { self.request.grab_focus() } + pub fn identity(&self) { + self.request.identity(&self.profile) + } + pub fn update(&self) { self.bookmark.update(&self.profile, &self.request); self.request.update(&self.profile); diff --git a/src/app/browser/window/tab/item/page/navigation/request.rs b/src/app/browser/window/tab/item/page/navigation/request.rs index 0996b63a..79db4341 100644 --- a/src/app/browser/window/tab/item/page/navigation/request.rs +++ b/src/app/browser/window/tab/item/page/navigation/request.rs @@ -43,6 +43,7 @@ pub trait Request { ) -> Result<(), String>; fn update(&self, profile: &Profile); + fn identity(&self, profile: &Rc); // Setters @@ -72,27 +73,12 @@ impl Request for Entry { // Connect events entry.connect_icon_release({ - let item_action = item_action.clone(); let profile = profile.clone(); move |this, position| match position { - EntryIconPosition::Primary => { - if let Some(request) = this.uri() { - if ["gemini", "titan"].contains(&request.scheme().as_str()) { - return identity::default(&profile, &request, { - let item_action = item_action.clone(); - let profile = profile.clone(); - let this = this.clone(); - move || { - this.update(&profile); - item_action.load.activate(Some(&this.text()), false); - } // on apply - }) - .present(Some(this)); - } - } - identity::unsupported().present(Some(this)); + EntryIconPosition::Primary => this.identity(&profile), + EntryIconPosition::Secondary => { + this.activate(); } - EntryIconPosition::Secondary => item_action.load.activate(Some(&this.text()), true), _ => todo!(), // unexpected } }); @@ -121,15 +107,15 @@ impl Request for Entry { entry.connect_activate({ let item_action = item_action.clone(); - move |entry| { - item_action.load.activate(Some(&entry.text()), true); + move |this| { + item_action.load.activate(Some(&this.text()), true); } }); entry.connect_state_flags_changed({ // Define last focus state container let has_focus = Cell::new(false); - move |entry, state| { + move |this, state| { // Select entire text on first click (release) // this behavior implemented in most web-browsers, // to simply overwrite current request with new value @@ -138,9 +124,9 @@ impl Request for Entry { // * This is experimental feature does not follow native GTK behavior @TODO make optional if !has_focus.take() && state.contains(StateFlags::ACTIVE | StateFlags::FOCUS_WITHIN) - && entry.selection_bounds().is_none() + && this.selection_bounds().is_none() { - entry.select_region(0, entry.text_length().into()); + this.select_region(0, this.text_length().into()); } // Update last focus state has_focus.replace(state.contains(StateFlags::FOCUS_WITHIN)); @@ -258,6 +244,23 @@ impl Request for Entry { } } + fn identity(&self, profile: &Rc) { + if let Some(uri) = self.uri() { + if ["gemini", "titan"].contains(&uri.scheme().as_str()) { + return identity::default(profile, &uri, { + let profile = profile.clone(); + let this = self.clone(); + move || { + this.update(&profile); + this.emit_activate(); + } // on apply + }) + .present(Some(self)); + } + } + identity::unsupported().present(Some(self)); + } + // Setters fn to_download(&self) {