Yoda/src/app/browser/action.rs

70 lines
1.5 KiB
Rust
Raw Normal View History

2024-11-10 07:09:55 +02:00
mod about;
mod close;
mod debug;
mod profile;
mod update;
2024-11-10 07:09:55 +02:00
use about::About;
use close::Close;
use debug::Debug;
use profile::Profile;
use update::Update;
use gtk::{
gio::SimpleActionGroup,
glib::{uuid_string_random, GString},
prelude::ActionMapExt,
};
use std::rc::Rc;
/// [SimpleActionGroup](https://docs.gtk.org/gio/class.SimpleActionGroup.html) wrapper for `Browser` actions
pub struct Action {
2024-11-10 07:09:55 +02:00
// Actions
2024-11-28 01:35:48 +02:00
pub about: Rc<About>,
pub close: Rc<Close>,
pub debug: Rc<Debug>,
pub profile: Rc<Profile>,
pub update: Rc<Update>,
2024-11-10 07:09:55 +02:00
// Group
2024-11-28 01:35:48 +02:00
pub id: GString,
pub gobject: SimpleActionGroup,
}
impl Action {
// Constructors
2024-11-10 07:09:55 +02:00
/// Create new `Self`
pub fn new() -> Self {
2024-11-10 07:09:55 +02:00
// Init actions
let about = Rc::new(About::new());
let close = Rc::new(Close::new());
let debug = Rc::new(Debug::new());
let profile = Rc::new(Profile::new());
let update = Rc::new(Update::new());
// Generate unique group ID
let id = uuid_string_random();
// Init group
let gobject = SimpleActionGroup::new();
// Add action to given group
2024-11-28 01:35:48 +02:00
gobject.add_action(&about.gobject);
gobject.add_action(&close.gobject);
gobject.add_action(&debug.gobject);
gobject.add_action(&profile.gobject);
gobject.add_action(&update.gobject);
2024-11-10 07:09:55 +02:00
// Done
Self {
2024-11-10 07:09:55 +02:00
about,
close,
debug,
profile,
update,
id,
gobject,
}
}
}