create separated wrapper for home action

This commit is contained in:
yggverse 2024-11-10 10:46:46 +02:00
parent b4dee17768
commit 4afa2c204c
15 changed files with 136 additions and 62 deletions

View file

@ -2,26 +2,26 @@ mod widget;
use widget::Widget;
use crate::app::browser::window::action::Action as WindowAction;
use gtk::{
gio::SimpleAction,
glib::{gformat, GString, Uri},
Button,
};
use std::{cell::RefCell, rc::Rc};
pub struct Home {
action_page_home: SimpleAction,
window_action: Rc<WindowAction>,
uri: RefCell<Option<Uri>>,
widget: Rc<Widget>,
}
impl Home {
// Construct
pub fn new_rc(action_page_home: SimpleAction) -> Rc<Self> {
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
Rc::new(Self {
action_page_home: action_page_home.clone(),
window_action: window_action.clone(),
uri: RefCell::new(None),
widget: Widget::new_rc(action_page_home),
widget: Widget::new_rc(window_action),
})
}
@ -37,7 +37,7 @@ impl Home {
self.uri.replace(uri);
// Update action status
self.action_page_home.set_enabled(status);
self.window_action.home().gobject().set_enabled(status);
// Update child components
self.widget.update(status);