toggle action status on update

This commit is contained in:
yggverse 2024-09-30 01:49:12 +03:00
parent 9a199dc32d
commit 49c912a094

View File

@ -6,6 +6,7 @@ use gtk::{
use std::sync::Arc; use std::sync::Arc;
pub struct Reload { pub struct Reload {
action_tab_page_reload: Arc<SimpleAction>,
widget: Button, widget: Button,
} }
@ -20,18 +21,24 @@ impl Reload {
.build(); .build();
// Init events // Init events
widget.connect_clicked(move |_| { widget.connect_clicked({
action_tab_page_reload.activate(None); let action_tab_page_reload = action_tab_page_reload.clone();
move |_| {
action_tab_page_reload.activate(None);
}
}); });
// Return activated struct // Return activated struct
Self { widget } Self {
action_tab_page_reload,
widget,
}
} }
// Actions // Actions
pub fn update(&self, is_enabled: bool) { pub fn update(&self, is_enabled: bool) {
self.action_tab_page_reload.set_enabled(is_enabled);
self.widget.set_sensitive(is_enabled); self.widget.set_sensitive(is_enabled);
// @TODO deactivate action
} }
// Getters // Getters