create separated wrapper for pin action

This commit is contained in:
yggverse 2024-11-10 10:07:16 +02:00
parent e47c22ac92
commit 33b22ca30a
11 changed files with 152 additions and 54 deletions

View file

@ -1,6 +1,8 @@
mod append;
mod pin;
use append::Append;
use pin::Pin;
use gtk::{
gio::SimpleActionGroup,
@ -13,6 +15,7 @@ use std::rc::Rc;
pub struct Action {
// Actions
append: Rc<Append>,
pin: Rc<Pin>,
// Group
id: GString,
gobject: SimpleActionGroup,
@ -25,6 +28,7 @@ impl Action {
pub fn new() -> Self {
// Init actions
let append = Rc::new(Append::new());
let pin = Rc::new(Pin::new());
// Generate unique group ID
let id = uuid_string_random();
@ -34,10 +38,12 @@ impl Action {
// Add action to given group
gobject.add_action(append.gobject());
gobject.add_action(pin.gobject());
// Done
Self {
append,
pin,
id,
gobject,
}
@ -50,6 +56,11 @@ impl Action {
&self.append
}
/// Get reference `Pin` action
pub fn pin(&self) -> &Rc<Pin> {
&self.pin
}
/// Get auto-generated name for action group
/// * useful for manual relationship with GObjects or as the `detailed_name`
/// for [Accels](https://docs.gtk.org/gtk4/method.Application.set_accels_for_action.html) or