diff --git a/src/app/browser/window/tab/item/page/navigation.rs b/src/app/browser/window/tab/item/page/navigation.rs index 829bb753..f312003e 100644 --- a/src/app/browser/window/tab/item/page/navigation.rs +++ b/src/app/browser/window/tab/item/page/navigation.rs @@ -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()); diff --git a/src/app/browser/window/tab/item/page/navigation/bookmark.rs b/src/app/browser/window/tab/item/page/navigation/bookmark.rs index 27b17b4a..adac4a18 100644 --- a/src/app/browser/window/tab/item/page/navigation/bookmark.rs +++ b/src/app/browser/window/tab/item/page/navigation/bookmark.rs @@ -6,7 +6,6 @@ use crate::app::browser::window::action::Action as WindowAction; use std::rc::Rc; pub struct Bookmark { - action: Rc, widget: Rc, } @@ -15,17 +14,12 @@ impl Bookmark { pub fn new(action: Rc) -> 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 diff --git a/src/app/browser/window/tab/item/page/navigation/bookmark/widget.rs b/src/app/browser/window/tab/item/page/navigation/bookmark/widget.rs index 57dbaaea..e6ac853d 100644 --- a/src/app/browser/window/tab/item/page/navigation/bookmark/widget.rs +++ b/src/app/browser/window/tab/item/page/navigation/bookmark/widget.rs @@ -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) -> 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