rename constructors

This commit is contained in:
yggverse 2025-01-15 00:25:33 +02:00
parent 941b1cc283
commit edb385f903
36 changed files with 266 additions and 180 deletions

View file

@ -1,36 +1,40 @@
use gtk::{prelude::ButtonExt, Button};
use crate::app::browser::window::Action;
use super::WindowAction;
use std::rc::Rc;
const ICON_YES: &str = "starred-symbolic";
const ICON_NON: &str = "non-starred-symbolic";
pub struct Widget {
pub gobject: Button,
pub button: Button,
}
impl Widget {
// Constructors
pub fn new(action: Rc<Action>) -> Self {
/// Build new `Self`
pub fn build(action: &Rc<WindowAction>) -> Self {
// Init gobject
let gobject = Button::builder()
let button = Button::builder()
.icon_name(ICON_NON)
.tooltip_text("Bookmark")
.build();
// Init events
gobject.connect_clicked(move |_| action.bookmark.activate());
button.connect_clicked({
let action = action.clone();
move |_| action.bookmark.activate()
});
// Return activated `Self`
Self { gobject }
Self { button }
}
// Actions
pub fn update(&self, has_bookmark: bool) {
self.gobject
self.button
.set_icon_name(if has_bookmark { ICON_YES } else { ICON_NON });
}
}