toggle action status

This commit is contained in:
yggverse 2024-09-28 00:21:19 +03:00
parent 98f88c5464
commit 832b90d37d

View file

@ -7,22 +7,25 @@ pub struct Base {
impl Base { impl Base {
// Construct // Construct
pub fn new() -> Self { pub fn new() -> Self {
Self { let widget = Button::builder()
widget: Button::builder() .action_name("win.tab_page_base")
.action_name("win.tab_page_base") .icon_name("go-home-symbolic")
.icon_name("go-home-symbolic") .tooltip_text("Base")
.tooltip_text("Base") .sensitive(false)
.sensitive(false) .build();
.build(),
} Self { widget }
} }
// Actions // Actions
pub fn update(&self, uri: Option<Uri>) { pub fn update(&self, uri: Option<Uri>) {
self.widget.set_sensitive(match uri { let status = match uri {
Some(uri) => "/" != uri.path(), Some(uri) => "/" != uri.path(),
None => false, None => false,
}); };
self.widget.action_set_enabled("win.tab_page_base", status);
self.widget.set_sensitive(status);
} }
// Getters // Getters