mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
begin global actions config implementation
This commit is contained in:
parent
f803d89f52
commit
9e481f78ce
9 changed files with 58 additions and 68 deletions
|
|
@ -6,7 +6,6 @@ use debug::Debug;
|
|||
|
||||
use gtk::{
|
||||
gio::SimpleActionGroup,
|
||||
glib::{gformat, uuid_string_random, GString},
|
||||
prelude::{IsA, WidgetExt},
|
||||
Window,
|
||||
};
|
||||
|
|
@ -17,7 +16,6 @@ pub struct Action {
|
|||
debug: Debug,
|
||||
// Group
|
||||
gobject: SimpleActionGroup,
|
||||
name: GString,
|
||||
}
|
||||
|
||||
impl Action {
|
||||
|
|
@ -31,11 +29,10 @@ impl Action {
|
|||
/// * children actions implemented as wrapper also, that extend default [Variant](https://docs.gtk.org/glib/struct.Variant.html) features, etc
|
||||
pub fn new_for(window: &(impl IsA<Window> + WidgetExt)) -> Self {
|
||||
// Init group
|
||||
let name = uuid_string_random();
|
||||
let gobject = SimpleActionGroup::new();
|
||||
|
||||
// Add group to window
|
||||
window.insert_action_group(&name, Some(&gobject));
|
||||
window.insert_action_group(crate::action::APP_BROWSER_WIDGET, Some(&gobject));
|
||||
|
||||
// Init actions
|
||||
let close = Close::new_for(&gobject, window.clone());
|
||||
|
|
@ -45,23 +42,6 @@ impl Action {
|
|||
close,
|
||||
debug,
|
||||
gobject,
|
||||
name,
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn debug(&self) -> GString {
|
||||
self.detailed_name(self.debug.name())
|
||||
}
|
||||
|
||||
pub fn close(&self) -> GString {
|
||||
self.detailed_name(self.close.name())
|
||||
}
|
||||
|
||||
// Helpers
|
||||
|
||||
fn detailed_name(&self, action_name: GString) -> GString {
|
||||
gformat!("{}.{}", self.name, action_name)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue