mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-03 01:55:27 +00:00
rename constructors
This commit is contained in:
parent
941b1cc283
commit
edb385f903
36 changed files with 266 additions and 180 deletions
|
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue