mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
fix bookmark update action
This commit is contained in:
parent
d0a7c3079d
commit
feca899c5b
@ -70,7 +70,7 @@ impl Navigation {
|
||||
let request = self.request.widget().gobject().text();
|
||||
|
||||
self.bookmark
|
||||
.update(!self.profile.bookmark.has_request(&request, true));
|
||||
.update(self.profile.bookmark.has_request(&request, true));
|
||||
self.history.update();
|
||||
self.home.update(self.request.uri());
|
||||
self.reload.update(!request.is_empty());
|
||||
|
@ -6,7 +6,6 @@ use crate::app::browser::window::action::Action as WindowAction;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Bookmark {
|
||||
action: Rc<WindowAction>,
|
||||
widget: Rc<Widget>,
|
||||
}
|
||||
|
||||
@ -15,17 +14,12 @@ impl Bookmark {
|
||||
pub fn new(action: Rc<WindowAction>) -> Self {
|
||||
Self {
|
||||
widget: Rc::new(Widget::new(action.clone())),
|
||||
action,
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn update(&self, is_enabled: bool) {
|
||||
// Update actions
|
||||
self.action.bookmark().gobject().set_enabled(is_enabled);
|
||||
|
||||
// Update child components
|
||||
self.widget.update(is_enabled);
|
||||
pub fn update(&self, has_bookmark: bool) {
|
||||
self.widget.update(has_bookmark);
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
@ -1,11 +1,11 @@
|
||||
use gtk::{
|
||||
prelude::{ButtonExt, WidgetExt},
|
||||
Button,
|
||||
};
|
||||
use gtk::{prelude::ButtonExt, Button};
|
||||
|
||||
use crate::app::browser::window::action::Action as WindowAction;
|
||||
use std::rc::Rc;
|
||||
|
||||
const ICON_YES: &str = "starred-symbolic";
|
||||
const ICON_NON: &str = "non-starred-symbolic";
|
||||
|
||||
pub struct Widget {
|
||||
gobject: Button,
|
||||
}
|
||||
@ -16,13 +16,12 @@ impl Widget {
|
||||
pub fn new(action: Rc<WindowAction>) -> Self {
|
||||
// Init gobject
|
||||
let gobject = Button::builder()
|
||||
.icon_name("starred-symbolic")
|
||||
.icon_name(ICON_NON)
|
||||
.tooltip_text("Bookmark")
|
||||
.sensitive(false)
|
||||
.build();
|
||||
|
||||
// Init events
|
||||
gobject.connect_clicked(move |_| action.home().activate());
|
||||
gobject.connect_clicked(move |_| action.bookmark().activate());
|
||||
|
||||
// Return activated `Self`
|
||||
Self { gobject }
|
||||
@ -30,8 +29,9 @@ impl Widget {
|
||||
|
||||
// Actions
|
||||
|
||||
pub fn update(&self, is_sensitive: bool) {
|
||||
self.gobject.set_sensitive(is_sensitive);
|
||||
pub fn update(&self, has_bookmark: bool) {
|
||||
self.gobject
|
||||
.set_icon_name(if has_bookmark { ICON_YES } else { ICON_NON });
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
Loading…
x
Reference in New Issue
Block a user