mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-03 01:55:27 +00:00
fix bookmark update action
This commit is contained in:
parent
d0a7c3079d
commit
feca899c5b
3 changed files with 12 additions and 18 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue