init context menu for page tabs

This commit is contained in:
yggverse 2024-11-04 04:52:33 +02:00
parent 51f543143d
commit b443d1c58e
6 changed files with 93 additions and 27 deletions

View file

@ -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