mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
init context menu for page tabs
This commit is contained in:
parent
51f543143d
commit
b443d1c58e
6 changed files with 93 additions and 27 deletions
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use gtk::{
|
||||
gio::SimpleAction,
|
||||
glib::{gformat, uuid_string_random, GString, VariantTy},
|
||||
glib::{gformat, uuid_string_random, GString, Variant, VariantTy},
|
||||
prelude::ActionExt,
|
||||
};
|
||||
|
||||
|
|
@ -27,6 +27,23 @@ impl Action {
|
|||
Self { group, simple }
|
||||
}
|
||||
|
||||
pub fn new_stateful(
|
||||
group: &str,
|
||||
is_enabled: bool,
|
||||
parameter_type: Option<&VariantTy>,
|
||||
state: &Variant,
|
||||
) -> Self {
|
||||
// Create random action name as no static values should be in use
|
||||
let simple = SimpleAction::new_stateful(&uuid_string_random(), parameter_type, state);
|
||||
simple.set_enabled(is_enabled);
|
||||
|
||||
// Assign action to the group
|
||||
let group = GString::from(group);
|
||||
|
||||
// Return new Action
|
||||
Self { group, simple }
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn detailed_name(&self) -> GString {
|
||||
gformat!("{}.{}", self.group, self.simple.name()) // @TODO find the way to ident parent group
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue