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