diff --git a/src/app/browser/window/action/close.rs b/src/app/browser/window/action/close.rs index dacf6395..8743e634 100644 --- a/src/app/browser/window/action/close.rs +++ b/src/app/browser/window/action/close.rs @@ -53,27 +53,23 @@ impl Close { /// Define callback function for /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal pub fn connect_activate(&self, callback: impl Fn(Option) + 'static) { - let state = self.state(); - self.gobject.connect_activate(move |_, _| callback(state)); + self.gobject.connect_activate(move |this, _| { + let state = this + .state() + .expect("State value required") + .get::() + .expect("Parameter type does not match `i32`"); + + callback(if state == DEFAULT_STATE { + None + } else { + Some(state) + }) + }); } // Getters - pub fn state(&self) -> Option { - let state = self - .gobject - .state() - .expect("State value required") - .get::() - .expect("Parameter type does not match `i32`"); - - if state != DEFAULT_STATE { - Some(state) - } else { - None - } - } - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject pub fn gobject(&self) -> &SimpleAction { &self.gobject diff --git a/src/app/browser/window/action/close_all.rs b/src/app/browser/window/action/close_all.rs index 6301af94..7add060a 100644 --- a/src/app/browser/window/action/close_all.rs +++ b/src/app/browser/window/action/close_all.rs @@ -53,27 +53,23 @@ impl CloseAll { /// Define callback function for /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal pub fn connect_activate(&self, callback: impl Fn(Option) + 'static) { - let state = self.state(); - self.gobject.connect_activate(move |_, _| callback(state)); + self.gobject.connect_activate(move |this, _| { + let state = this + .state() + .expect("State value required") + .get::() + .expect("Parameter type does not match `i32`"); + + callback(if state == DEFAULT_STATE { + None + } else { + Some(state) + }) + }); } // Getters - pub fn state(&self) -> Option { - let state = self - .gobject - .state() - .expect("State value required") - .get::() - .expect("Parameter type does not match `i32`"); - - if state != DEFAULT_STATE { - Some(state) - } else { - None - } - } - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject pub fn gobject(&self) -> &SimpleAction { &self.gobject diff --git a/src/app/browser/window/action/history_back.rs b/src/app/browser/window/action/history_back.rs index ee59c0a4..cb7e3745 100644 --- a/src/app/browser/window/action/history_back.rs +++ b/src/app/browser/window/action/history_back.rs @@ -52,27 +52,23 @@ impl HistoryBack { /// Define callback function for /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal pub fn connect_activate(&self, callback: impl Fn(Option) + 'static) { - let state = self.state(); - self.gobject.connect_activate(move |_, _| callback(state)); + self.gobject.connect_activate(move |this, _| { + let state = this + .state() + .expect("State value required") + .get::() + .expect("Parameter type does not match `i32`"); + + callback(if state == DEFAULT_STATE { + None + } else { + Some(state) + }) + }); } // Getters - pub fn state(&self) -> Option { - let state = self - .gobject - .state() - .expect("State value required") - .get::() - .expect("Parameter type does not match `i32`"); - - if state != DEFAULT_STATE { - Some(state) - } else { - None - } - } - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject pub fn gobject(&self) -> &SimpleAction { &self.gobject diff --git a/src/app/browser/window/action/history_forward.rs b/src/app/browser/window/action/history_forward.rs index d1bc3a00..9f6c99c0 100644 --- a/src/app/browser/window/action/history_forward.rs +++ b/src/app/browser/window/action/history_forward.rs @@ -52,27 +52,23 @@ impl HistoryForward { /// Define callback function for /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal pub fn connect_activate(&self, callback: impl Fn(Option) + 'static) { - let state = self.state(); - self.gobject.connect_activate(move |_, _| callback(state)); + self.gobject.connect_activate(move |this, _| { + let state = this + .state() + .expect("State value required") + .get::() + .expect("Parameter type does not match `i32`"); + + callback(if state == DEFAULT_STATE { + None + } else { + Some(state) + }) + }); } // Getters - pub fn state(&self) -> Option { - let state = self - .gobject - .state() - .expect("State value required") - .get::() - .expect("Parameter type does not match `i32`"); - - if state != DEFAULT_STATE { - Some(state) - } else { - None - } - } - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject pub fn gobject(&self) -> &SimpleAction { &self.gobject diff --git a/src/app/browser/window/action/home.rs b/src/app/browser/window/action/home.rs index 536616a8..8c51520b 100644 --- a/src/app/browser/window/action/home.rs +++ b/src/app/browser/window/action/home.rs @@ -52,27 +52,23 @@ impl Home { /// Define callback function for /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal pub fn connect_activate(&self, callback: impl Fn(Option) + 'static) { - let state = self.state(); - self.gobject.connect_activate(move |_, _| callback(state)); + self.gobject.connect_activate(move |this, _| { + let state = this + .state() + .expect("State value required") + .get::() + .expect("Parameter type does not match `i32`"); + + callback(if state == DEFAULT_STATE { + None + } else { + Some(state) + }) + }); } // Getters - pub fn state(&self) -> Option { - let state = self - .gobject - .state() - .expect("State value required") - .get::() - .expect("Parameter type does not match `i32`"); - - if state != DEFAULT_STATE { - Some(state) - } else { - None - } - } - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject pub fn gobject(&self) -> &SimpleAction { &self.gobject diff --git a/src/app/browser/window/action/pin.rs b/src/app/browser/window/action/pin.rs index 7de6de1b..8ec61303 100644 --- a/src/app/browser/window/action/pin.rs +++ b/src/app/browser/window/action/pin.rs @@ -47,27 +47,23 @@ impl Pin { /// Define callback function for /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal pub fn connect_activate(&self, callback: impl Fn(Option) + 'static) { - let state = self.state(); - self.gobject.connect_activate(move |_, _| callback(state)); + self.gobject.connect_activate(move |this, _| { + let state = this + .state() + .expect("State value required") + .get::() + .expect("Parameter type does not match `i32`"); + + callback(if state == DEFAULT_STATE { + None + } else { + Some(state) + }) + }); } // Getters - pub fn state(&self) -> Option { - let state = self - .gobject - .state() - .expect("State value required") - .get::() - .expect("Parameter type does not match `i32`"); - - if state != DEFAULT_STATE { - Some(state) - } else { - None - } - } - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject pub fn gobject(&self) -> &SimpleAction { &self.gobject diff --git a/src/app/browser/window/action/reload.rs b/src/app/browser/window/action/reload.rs index 4cf58b02..a1edce11 100644 --- a/src/app/browser/window/action/reload.rs +++ b/src/app/browser/window/action/reload.rs @@ -52,27 +52,23 @@ impl Reload { /// Define callback function for /// [SimpleAction::activate](https://docs.gtk.org/gio/signal.SimpleAction.activate.html) signal pub fn connect_activate(&self, callback: impl Fn(Option) + 'static) { - let state = self.state(); - self.gobject.connect_activate(move |_, _| callback(state)); + self.gobject.connect_activate(move |this, _| { + let state = this + .state() + .expect("State value required") + .get::() + .expect("Parameter type does not match `i32`"); + + callback(if state == DEFAULT_STATE { + None + } else { + Some(state) + }) + }); } // Getters - pub fn state(&self) -> Option { - let state = self - .gobject - .state() - .expect("State value required") - .get::() - .expect("Parameter type does not match `i32`"); - - if state != DEFAULT_STATE { - Some(state) - } else { - None - } - } - /// Get reference to [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html) GObject pub fn gobject(&self) -> &SimpleAction { &self.gobject