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

@ -60,8 +60,6 @@ impl Page {
browser_action: Rc<BrowserAction>,
window_action: Rc<WindowAction>,
tab_action: Rc<TabAction>,
action_page_history_back: SimpleAction,
action_page_history_forward: SimpleAction,
) -> Rc<Self> {
// Init local actions
let action_page_load = SimpleAction::new(&uuid_string_random(), None);
@ -74,8 +72,6 @@ impl Page {
let navigation = Navigation::new_rc(
browser_action.clone(),
window_action.clone(),
action_page_history_back.clone(),
action_page_history_forward.clone(),
action_page_open.clone(),
);

View file

@ -33,13 +33,11 @@ impl Navigation {
pub fn new_rc(
browser_action: Rc<BrowserAction>,
window_action: Rc<WindowAction>,
action_page_history_back: SimpleAction,
action_page_history_forward: SimpleAction,
action_page_open: SimpleAction,
) -> Rc<Self> {
// Init components
let home = Home::new_rc(window_action.clone());
let history = History::new_rc(action_page_history_back, action_page_history_forward);
let history = History::new_rc(window_action.clone());
let reload = Reload::new_rc(window_action);
let request = Request::new_rc(browser_action, action_page_open.clone());
let bookmark = Bookmark::new_rc();

View file

@ -6,7 +6,8 @@ use back::Back;
use forward::Forward;
use widget::Widget;
use gtk::{gio::SimpleAction, glib::GString, Box};
use crate::app::browser::window::action::Action as WindowAction;
use gtk::{glib::GString, Box};
use std::{cell::RefCell, rc::Rc};
struct Memory {
@ -27,13 +28,10 @@ pub struct History {
impl History {
// Construct
pub fn new_rc(
action_page_history_back: SimpleAction,
action_page_history_forward: SimpleAction,
) -> Rc<Self> {
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
// init components
let back = Back::new_rc(action_page_history_back);
let forward = Forward::new_rc(action_page_history_forward);
let back = Back::new_rc(window_action.clone());
let forward = Forward::new_rc(window_action);
// Init widget
let widget = Widget::new_rc(back.gobject(), forward.gobject());

View file

@ -2,28 +2,32 @@ mod widget;
use widget::Widget;
use gtk::{gio::SimpleAction, Button};
use crate::app::browser::window::action::Action as WindowAction;
use gtk::Button;
use std::rc::Rc;
pub struct Back {
action_page_history_back: SimpleAction,
window_action: Rc<WindowAction>,
widget: Rc<Widget>,
}
impl Back {
// Construct
pub fn new_rc(action_page_history_back: SimpleAction) -> Rc<Self> {
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
// Return activated struct
Rc::new(Self {
action_page_history_back: action_page_history_back.clone(),
widget: Widget::new_rc(action_page_history_back),
window_action: window_action.clone(),
widget: Widget::new_rc(window_action),
})
}
// Actions
pub fn update(&self, status: bool) {
// Update actions
self.action_page_history_back.set_enabled(status);
self.window_action
.history_back()
.gobject()
.set_enabled(status);
// Update child components
self.widget.update(status);

View file

@ -1,6 +1,6 @@
use crate::app::browser::window::action::Action as WindowAction;
use gtk::{
gio::SimpleAction,
prelude::{ActionExt, ButtonExt, WidgetExt},
prelude::{ButtonExt, WidgetExt},
Button,
};
use std::rc::Rc;
@ -11,7 +11,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_rc(action_page_history_back: SimpleAction) -> Rc<Self> {
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
// Init gobject
let gobject = Button::builder()
.icon_name("go-previous-symbolic")
@ -21,9 +21,9 @@ impl Widget {
// Init events
gobject.connect_clicked({
let action_page_history_back = action_page_history_back.clone();
let window_action = window_action.clone();
move |_| {
action_page_history_back.activate(None);
window_action.history_back().activate();
}
});

View file

@ -2,28 +2,32 @@ mod widget;
use widget::Widget;
use gtk::{gio::SimpleAction, Button};
use crate::app::browser::window::action::Action as WindowAction;
use gtk::Button;
use std::rc::Rc;
pub struct Forward {
action_page_history_forward: SimpleAction,
window_action: Rc<WindowAction>,
widget: Rc<Widget>,
}
impl Forward {
// Construct
pub fn new_rc(action_page_history_forward: SimpleAction) -> Rc<Self> {
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
// Return activated struct
Rc::new(Self {
action_page_history_forward: action_page_history_forward.clone(),
widget: Widget::new_rc(action_page_history_forward),
window_action: window_action.clone(),
widget: Widget::new_rc(window_action),
})
}
// Actions
pub fn update(&self, status: bool) {
// Update actions
self.action_page_history_forward.set_enabled(status);
self.window_action
.history_forward()
.gobject()
.set_enabled(status);
// Update child components
self.widget.update(status);

View file

@ -1,6 +1,6 @@
use crate::app::browser::window::action::Action as WindowAction;
use gtk::{
gio::SimpleAction,
prelude::{ActionExt, ButtonExt, WidgetExt},
prelude::{ButtonExt, WidgetExt},
Button,
};
use std::rc::Rc;
@ -11,7 +11,7 @@ pub struct Widget {
impl Widget {
// Construct
pub fn new_rc(action_page_history_forward: SimpleAction) -> Rc<Self> {
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
// Init gobject
let gobject = Button::builder()
.icon_name("go-next-symbolic")
@ -21,9 +21,9 @@ impl Widget {
// Init events
gobject.connect_clicked({
let action_page_history_forward = action_page_history_forward.clone();
let window_action = window_action.clone();
move |_| {
action_page_history_forward.activate(None);
window_action.history_forward().activate();
}
});