mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
connect navigation widget to bookmark action
This commit is contained in:
parent
ad89d08f0f
commit
367b4d017b
3 changed files with 52 additions and 21 deletions
|
|
@ -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()
|
||||
.icon_name("starred-symbolic")
|
||||
.tooltip_text("Bookmark")
|
||||
.sensitive(false)
|
||||
.build(),
|
||||
}
|
||||
// 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();
|
||||
|
||||
// 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…
Add table
Add a link
Reference in a new issue