mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
implement recent bookmarks menu item
This commit is contained in:
parent
c335207b28
commit
9e86e9b29f
13 changed files with 155 additions and 60 deletions
44
src/app/browser/window/action/open.rs
Normal file
44
src/app/browser/window/action/open.rs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
// Defaults
|
||||
|
||||
use gtk::{
|
||||
gio::SimpleAction,
|
||||
glib::{uuid_string_random, SignalHandlerId},
|
||||
prelude::StaticVariantType,
|
||||
};
|
||||
|
||||
/// Open [SimpleAction](https://docs.gtk.org/gio/class.SimpleAction.html)
|
||||
pub struct Open {
|
||||
pub simple_action: SimpleAction,
|
||||
}
|
||||
|
||||
impl Open {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self`
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
simple_action: SimpleAction::new(
|
||||
&uuid_string_random(),
|
||||
Some(&String::static_variant_type()),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
||||
/// Formatted action connector for external implementation
|
||||
pub fn on_activate(
|
||||
&self,
|
||||
callback: impl Fn(&SimpleAction, String) + 'static,
|
||||
) -> SignalHandlerId {
|
||||
self.simple_action.connect_activate(move |this, message| {
|
||||
callback(
|
||||
this,
|
||||
message
|
||||
.expect("Variant required to call this action")
|
||||
.get::<String>()
|
||||
.expect("Parameter does not match `String` type"),
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue