mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
implement is_history record argument for load action
This commit is contained in:
parent
60d4a94ff3
commit
47b2be986b
7 changed files with 49 additions and 34 deletions
|
|
@ -15,7 +15,10 @@ impl Load {
|
|||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: SimpleAction::new(&uuid_string_random(), Some(&String::static_variant_type())),
|
||||
gobject: SimpleAction::new(
|
||||
&uuid_string_random(),
|
||||
Some(&<(String, bool)>::static_variant_type()),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -23,13 +26,16 @@ 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>) {
|
||||
pub fn activate(&self, request: Option<&str>, is_history: bool) {
|
||||
self.gobject.activate(Some(
|
||||
&match request {
|
||||
Some(value) => String::from(value),
|
||||
None => String::new(),
|
||||
}
|
||||
.to_variant(),
|
||||
&(
|
||||
match request {
|
||||
Some(value) => String::from(value),
|
||||
None => String::new(),
|
||||
},
|
||||
is_history,
|
||||
)
|
||||
.to_variant(),
|
||||
));
|
||||
}
|
||||
|
||||
|
|
@ -37,17 +43,20 @@ impl Load {
|
|||
|
||||
/// 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>) + 'static) {
|
||||
self.gobject.connect_activate(move |_, variant| {
|
||||
let request = variant
|
||||
.expect("Parameter value required")
|
||||
.get::<String>()
|
||||
.expect("Parameter type does not match `String`");
|
||||
pub fn connect_activate(&self, callback: impl Fn(Option<GString>, bool) + 'static) {
|
||||
self.gobject.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()),
|
||||
})
|
||||
callback(
|
||||
match request.is_empty() {
|
||||
true => None,
|
||||
false => Some(request.into()),
|
||||
},
|
||||
is_history,
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue