delegate history_snap action to protocol driver implementation

This commit is contained in:
yggverse 2025-03-12 11:00:16 +02:00
parent 68b3119bb1
commit 33d5d414ac
16 changed files with 124 additions and 147 deletions

View file

@ -32,30 +32,25 @@ impl Load {
/// 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, request: Option<&str>, is_history: bool) {
self.simple_action.activate(Some(
&(request.unwrap_or_default(), is_history).to_variant(),
));
pub fn activate(&self, request: Option<&str>) {
self.simple_action
.activate(Some(&(request.unwrap_or_default()).to_variant()));
}
// Events
/// 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<GString>, bool) + 'static) {
pub fn connect_activate(&self, callback: impl Fn(Option<GString>) + 'static) {
self.simple_action.connect_activate(move |_, this| {
let (request, is_history) = this
.expect("Expected (`request`,`is_history`) variant")
.get::<(String, bool)>()
.expect("Parameter type does not match (`String`,`bool`) tuple");
callback(
match request.is_empty() {
true => None,
false => Some(request.into()),
},
is_history,
)
let request = this
.expect("Expected `request` variant")
.get::<String>()
.expect("Parameter type does not match `String`");
callback(match request.is_empty() {
true => None,
false => Some(request.into()),
})
});
}
}