mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
create separated wrapper for reload action
This commit is contained in:
parent
baea14de95
commit
b4dee17768
16 changed files with 144 additions and 64 deletions
|
|
@ -13,6 +13,7 @@ use navigation::Navigation;
|
|||
use widget::Widget;
|
||||
|
||||
use crate::app::browser::action::Action as BrowserAction;
|
||||
use crate::app::browser::window::action::Action as WindowAction;
|
||||
use crate::app::browser::window::tab::action::Action as TabAction;
|
||||
use gtk::{
|
||||
gdk_pixbuf::Pixbuf,
|
||||
|
|
@ -37,6 +38,7 @@ pub struct Page {
|
|||
cancellable: RefCell<Cancellable>,
|
||||
// Actions
|
||||
browser_action: Rc<BrowserAction>,
|
||||
window_action: Rc<WindowAction>,
|
||||
tab_action: Rc<TabAction>,
|
||||
action_page_load: SimpleAction,
|
||||
// Components
|
||||
|
|
@ -56,11 +58,11 @@ impl Page {
|
|||
pub fn new_rc(
|
||||
id: GString,
|
||||
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,
|
||||
action_page_reload: SimpleAction,
|
||||
) -> Rc<Self> {
|
||||
// Init local actions
|
||||
let action_page_load = SimpleAction::new(&uuid_string_random(), None);
|
||||
|
|
@ -72,10 +74,10 @@ 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_reload.clone(),
|
||||
action_page_open.clone(),
|
||||
);
|
||||
|
||||
|
|
@ -97,6 +99,7 @@ impl Page {
|
|||
id,
|
||||
// Actions
|
||||
browser_action,
|
||||
window_action,
|
||||
tab_action,
|
||||
action_page_load: action_page_load.clone(),
|
||||
// Components
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use request::Request;
|
|||
use widget::Widget;
|
||||
|
||||
use crate::app::browser::action::Action as BrowserAction;
|
||||
use crate::app::browser::window::action::Action as WindowAction;
|
||||
use gtk::{gio::SimpleAction, glib::GString, prelude::WidgetExt, Box};
|
||||
use sqlite::Transaction;
|
||||
use std::rc::Rc;
|
||||
|
|
@ -31,16 +32,16 @@ pub struct Navigation {
|
|||
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_reload: SimpleAction,
|
||||
action_page_open: SimpleAction,
|
||||
) -> Rc<Self> {
|
||||
// Init components
|
||||
let home = Home::new_rc(action_page_home);
|
||||
let history = History::new_rc(action_page_history_back, action_page_history_forward);
|
||||
let reload = Reload::new_rc(action_page_reload.clone());
|
||||
let reload = Reload::new_rc(window_action);
|
||||
let request = Request::new_rc(browser_action, action_page_open.clone());
|
||||
let bookmark = Bookmark::new_rc();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,27 +2,31 @@ 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 Reload {
|
||||
action_page_reload: SimpleAction,
|
||||
window_action: Rc<WindowAction>,
|
||||
widget: Rc<Widget>,
|
||||
}
|
||||
|
||||
impl Reload {
|
||||
// Construct
|
||||
pub fn new_rc(action_page_reload: SimpleAction) -> Rc<Self> {
|
||||
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||
Rc::new(Self {
|
||||
action_page_reload: action_page_reload.clone(),
|
||||
widget: Widget::new_rc(action_page_reload),
|
||||
window_action: window_action.clone(),
|
||||
widget: Widget::new_rc(window_action),
|
||||
})
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn update(&self, is_enabled: bool) {
|
||||
// Update actions
|
||||
self.action_page_reload.set_enabled(is_enabled);
|
||||
self.window_action
|
||||
.reload()
|
||||
.gobject()
|
||||
.set_enabled(is_enabled);
|
||||
|
||||
// Update child components
|
||||
self.widget.update(is_enabled);
|
||||
|
|
|
|||
|
|
@ -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_reload: SimpleAction) -> Rc<Self> {
|
||||
pub fn new_rc(window_action: Rc<WindowAction>) -> Rc<Self> {
|
||||
// Init gobject
|
||||
let gobject = Button::builder()
|
||||
.icon_name("view-refresh-symbolic")
|
||||
|
|
@ -20,12 +20,7 @@ impl Widget {
|
|||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked({
|
||||
let action_page_reload = action_page_reload.clone();
|
||||
move |_| {
|
||||
action_page_reload.activate(None);
|
||||
}
|
||||
});
|
||||
gobject.connect_clicked(move |_| window_action.reload().activate());
|
||||
|
||||
// Return activated struct
|
||||
Rc::new(Self { gobject })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue