mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
connect actions directly, use trait implementation for navigation buttons
This commit is contained in:
parent
10c73f4e3d
commit
5145a53bfa
9 changed files with 87 additions and 266 deletions
|
|
@ -1,33 +1,21 @@
|
|||
mod widget;
|
||||
|
||||
use widget::Widget;
|
||||
|
||||
use super::WindowAction;
|
||||
use gtk::{prelude::ActionExt, Button};
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Reload {
|
||||
action: Rc<WindowAction>,
|
||||
pub widget: Rc<Widget>,
|
||||
pub trait Reload {
|
||||
fn reload(action: &Rc<WindowAction>) -> Self;
|
||||
}
|
||||
|
||||
impl Reload {
|
||||
// Constructors
|
||||
|
||||
/// Build new `Self`
|
||||
pub fn build(action: &Rc<WindowAction>) -> Self {
|
||||
Self {
|
||||
action: action.clone(),
|
||||
widget: Rc::new(Widget::build(action)),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
||||
pub fn update(&self, is_enabled: bool) {
|
||||
// Update actions
|
||||
self.action.reload.simple_action.set_enabled(is_enabled);
|
||||
|
||||
// Update child components
|
||||
self.widget.update(is_enabled);
|
||||
impl Reload for Button {
|
||||
fn reload(action: &Rc<WindowAction>) -> Self {
|
||||
Button::builder()
|
||||
.action_name(format!(
|
||||
"{}.{}",
|
||||
action.id,
|
||||
action.reload.simple_action.name()
|
||||
)) // @TODO
|
||||
.icon_name("view-refresh-symbolic")
|
||||
.tooltip_text("Reload")
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue