create separated wrappers for history, close action group

This commit is contained in:
yggverse 2024-11-10 11:53:43 +02:00
parent 4afa2c204c
commit 8113022cd4
22 changed files with 557 additions and 335 deletions

View file

@ -1,9 +1,17 @@
mod append;
mod close;
mod close_all;
mod history_back;
mod history_forward;
mod home;
mod pin;
mod reload;
use append::Append;
use close::Close;
use close_all::CloseAll;
use history_back::HistoryBack;
use history_forward::HistoryForward;
use home::Home;
use pin::Pin;
use reload::Reload;
@ -19,6 +27,10 @@ use std::rc::Rc;
pub struct Action {
// Actions
append: Rc<Append>,
close_all: Rc<CloseAll>,
close: Rc<Close>,
history_back: Rc<HistoryBack>,
history_forward: Rc<HistoryForward>,
home: Rc<Home>,
pin: Rc<Pin>,
reload: Rc<Reload>,
@ -34,6 +46,10 @@ impl Action {
pub fn new() -> Self {
// Init actions
let append = Rc::new(Append::new());
let close = Rc::new(Close::new());
let close_all = Rc::new(CloseAll::new());
let history_back = Rc::new(HistoryBack::new());
let history_forward = Rc::new(HistoryForward::new());
let home = Rc::new(Home::new());
let pin = Rc::new(Pin::new());
let reload = Rc::new(Reload::new());
@ -46,6 +62,10 @@ impl Action {
// Add action to given group
gobject.add_action(append.gobject());
gobject.add_action(close_all.gobject());
gobject.add_action(close.gobject());
gobject.add_action(history_back.gobject());
gobject.add_action(history_forward.gobject());
gobject.add_action(home.gobject());
gobject.add_action(pin.gobject());
gobject.add_action(reload.gobject());
@ -53,6 +73,10 @@ impl Action {
// Done
Self {
append,
close_all,
close,
history_back,
history_forward,
home,
pin,
reload,
@ -68,6 +92,26 @@ impl Action {
&self.append
}
/// Get reference `CloseAll` action
pub fn close_all(&self) -> &Rc<CloseAll> {
&self.close_all
}
/// Get reference `Close` action
pub fn close(&self) -> &Rc<Close> {
&self.close
}
/// Get reference `HistoryBack` action
pub fn history_back(&self) -> &Rc<HistoryBack> {
&self.history_back
}
/// Get reference `HistoryForward` action
pub fn history_forward(&self) -> &Rc<HistoryForward> {
&self.history_forward
}
/// Get reference `Home` action
pub fn home(&self) -> &Rc<Home> {
&self.home