mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
create separated wrapper for home action
This commit is contained in:
parent
b4dee17768
commit
4afa2c204c
15 changed files with 136 additions and 62 deletions
|
|
@ -60,7 +60,6 @@ impl Page {
|
|||
browser_action: Rc<BrowserAction>,
|
||||
window_action: Rc<WindowAction>,
|
||||
tab_action: Rc<TabAction>,
|
||||
action_page_home: SimpleAction,
|
||||
action_page_history_back: SimpleAction,
|
||||
action_page_history_forward: SimpleAction,
|
||||
) -> Rc<Self> {
|
||||
|
|
@ -75,7 +74,6 @@ impl Page {
|
|||
let navigation = Navigation::new_rc(
|
||||
browser_action.clone(),
|
||||
window_action.clone(),
|
||||
action_page_home.clone(),
|
||||
action_page_history_back.clone(),
|
||||
action_page_history_forward.clone(),
|
||||
action_page_open.clone(),
|
||||
|
|
|
|||
|
|
@ -33,13 +33,12 @@ impl Navigation {
|
|||
pub fn new_rc(
|
||||
browser_action: Rc<BrowserAction>,
|
||||
window_action: Rc<WindowAction>,
|
||||
action_page_home: SimpleAction,
|
||||
action_page_history_back: SimpleAction,
|
||||
action_page_history_forward: SimpleAction,
|
||||
action_page_open: SimpleAction,
|
||||
) -> Rc<Self> {
|
||||
// Init components
|
||||
let home = Home::new_rc(action_page_home);
|
||||
let home = Home::new_rc(window_action.clone());
|
||||
let history = History::new_rc(action_page_history_back, action_page_history_forward);
|
||||
let reload = Reload::new_rc(window_action);
|
||||
let request = Request::new_rc(browser_action, action_page_open.clone());
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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_home: SimpleAction) -> Rc<Self> {
|
||||
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||
// Init gobject
|
||||
let gobject = Button::builder()
|
||||
.icon_name("go-home-symbolic")
|
||||
|
|
@ -20,12 +20,7 @@ impl Widget {
|
|||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked({
|
||||
let action_page_home = action_page_home.clone();
|
||||
move |_| {
|
||||
action_page_home.activate(None);
|
||||
}
|
||||
});
|
||||
gobject.connect_clicked(move |_| window_action.home().activate());
|
||||
|
||||
// Return activated struct
|
||||
Rc::new(Self { gobject })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue