use gtk::{
gio::SimpleAction,
glib::{gformat, uuid_string_random, GString, VariantTy},
prelude::ActionExt,
};
pub struct Action {
group: GString,
simple: SimpleAction,
}
impl Action {
pub fn new(group: &str, is_enabled: bool, parameter_type: Option<&VariantTy>) -> Self {
let simple = SimpleAction::new(&uuid_string_random(), parameter_type);
simple.set_enabled(is_enabled);
let group = GString::from(group);
Self { group, simple }
}
pub fn detailed_name(&self) -> GString {
gformat!("{}.{}", self.group, self.simple.name()) }
pub fn simple(&self) -> SimpleAction {
self.simple.clone()
}
}