connect focus action

This commit is contained in:
yggverse 2024-12-13 00:36:45 +02:00
parent e606ef5fa9
commit bcf8dcb83a
2 changed files with 12 additions and 7 deletions

View File

@ -1,4 +1,4 @@
use gtk::{gio::SimpleAction, glib::uuid_string_random};
use gtk::{gio::SimpleAction, glib::uuid_string_random, prelude::ActionExt};
/// [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) wrapper for `Focus` action of `Browser` group
pub struct Focus {
@ -15,6 +15,14 @@ impl Focus {
}
}
// Actions
/// Emit [activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal
/// with formatted for this action [Variant](https://docs.gtk.org/glib/struct.Variant.html) value
pub fn activate(&self) {
self.gobject.activate(None); // @TODO custom value
}
// Events
/// Define callback function for

View File

@ -149,14 +149,11 @@ impl Page {
const DEFAULT_MAX_REDIRECT_COUNT: usize = 10;
// Move focus out from navigation entry
// self.navigation.reload.widget.gobject.grab_focus();
self.browser_action.focus.activate();
// Reset widgets
self.input.unset();
// Create shared variant value
let id = self.id.clone();
// Prevent infinitive redirection
if self.meta.redirects() > DEFAULT_MAX_REDIRECT_COUNT {
todo!()
@ -184,7 +181,7 @@ impl Page {
// Update
self.meta.set_status(Status::Reload).set_title("Loading..");
self.browser_action.update.activate(Some(&id));
self.browser_action.update.activate(Some(&self.id));
// Route by request
match request {
@ -217,7 +214,7 @@ impl Page {
.set_title(&status.title());
// Update window
self.browser_action.update.activate(Some(&id));
self.browser_action.update.activate(Some(&self.id));
}
}
}