mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
connect navigation widget to bookmark action
This commit is contained in:
parent
ad89d08f0f
commit
367b4d017b
@ -21,9 +21,9 @@ use sqlite::Transaction;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Navigation {
|
||||
home: Rc<Home>,
|
||||
bookmark: Rc<Bookmark>,
|
||||
history: Rc<History>,
|
||||
home: Rc<Home>,
|
||||
reload: Rc<Reload>,
|
||||
request: Rc<Request>,
|
||||
widget: Rc<Widget>,
|
||||
@ -38,9 +38,9 @@ impl Navigation {
|
||||
// Init components
|
||||
let home = Rc::new(Home::new(window_action.clone()));
|
||||
let history = Rc::new(History::new(window_action.clone()));
|
||||
let reload = Rc::new(Reload::new(window_action));
|
||||
let reload = Rc::new(Reload::new(window_action.clone()));
|
||||
let request = Rc::new(Request::new(browser_action, tab_action));
|
||||
let bookmark = Rc::new(Bookmark::new());
|
||||
let bookmark = Rc::new(Bookmark::new(window_action));
|
||||
|
||||
// Init widget
|
||||
let widget = Rc::new(Widget::new(
|
||||
@ -53,24 +53,24 @@ impl Navigation {
|
||||
|
||||
// Done
|
||||
Self {
|
||||
widget,
|
||||
home,
|
||||
bookmark,
|
||||
history,
|
||||
home,
|
||||
reload,
|
||||
request,
|
||||
bookmark,
|
||||
widget,
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
||||
pub fn update(&self, progress_fraction: Option<f64>) {
|
||||
self.home.update(self.request.uri());
|
||||
self.bookmark.update();
|
||||
self.history.update();
|
||||
self.home.update(self.request.uri());
|
||||
self.reload
|
||||
.update(!self.request.widget().gobject().text().is_empty());
|
||||
self.request.update(progress_fraction);
|
||||
self.bookmark.update();
|
||||
}
|
||||
|
||||
pub fn clean(
|
||||
|
@ -2,23 +2,35 @@ mod widget;
|
||||
|
||||
use widget::Widget;
|
||||
|
||||
use crate::app::browser::window::action::Action as WindowAction;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Bookmark {
|
||||
window_action: Rc<WindowAction>,
|
||||
widget: Rc<Widget>,
|
||||
}
|
||||
|
||||
impl Bookmark {
|
||||
// Construct
|
||||
pub fn new() -> Self {
|
||||
pub fn new(window_action: Rc<WindowAction>) -> Self {
|
||||
Self {
|
||||
widget: Rc::new(Widget::new()),
|
||||
widget: Rc::new(Widget::new(window_action.clone())),
|
||||
window_action,
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn update(&self) {
|
||||
// @TODO
|
||||
let is_enabled = false; // @TODO DB
|
||||
|
||||
// Update actions
|
||||
self.window_action
|
||||
.bookmark()
|
||||
.gobject()
|
||||
.set_enabled(is_enabled);
|
||||
|
||||
// Update child components
|
||||
self.widget.update(is_enabled);
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
@ -1,22 +1,41 @@
|
||||
use gtk::Button;
|
||||
use gtk::{
|
||||
prelude::{ButtonExt, WidgetExt},
|
||||
Button,
|
||||
};
|
||||
|
||||
use crate::app::browser::window::action::Action as WindowAction;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Widget {
|
||||
gobject: Button,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
gobject: Button::builder()
|
||||
// Constructors
|
||||
|
||||
pub fn new(window_action: Rc<WindowAction>) -> Self {
|
||||
// Init gobject
|
||||
let gobject = Button::builder()
|
||||
.icon_name("starred-symbolic")
|
||||
.tooltip_text("Bookmark")
|
||||
.sensitive(false)
|
||||
.build(),
|
||||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked(move |_| window_action.home().activate());
|
||||
|
||||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
||||
pub fn update(&self, is_sensitive: bool) {
|
||||
self.gobject.set_sensitive(is_sensitive);
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
pub fn gobject(&self) -> &Button {
|
||||
&self.gobject
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user