update home button status detection

This commit is contained in:
yggverse 2025-01-23 14:34:46 +02:00
parent c5fad47a20
commit 5943ea622a
3 changed files with 27 additions and 23 deletions

View file

@ -1,4 +1,4 @@
use super::{Request, WindowAction};
use super::WindowAction;
use gtk::{
prelude::{ButtonExt, WidgetExt},
Button,
@ -7,13 +7,12 @@ use std::rc::Rc;
pub struct Home {
action: Rc<WindowAction>,
request: Rc<Request>,
pub button: Button,
}
impl Home {
// Construct
pub fn build(action: &Rc<WindowAction>, request: &Rc<Request>) -> Self {
pub fn build(action: &Rc<WindowAction>) -> Self {
// Init gobject
let button = Button::builder()
.icon_name("go-home-symbolic")
@ -30,14 +29,12 @@ impl Home {
// Return activated `Self`
Self {
action: action.clone(),
request: request.clone(),
button,
}
}
// Actions
pub fn update(&self) {
let has_home = self.request.home().is_some();
pub fn update(&self, has_home: bool) {
self.action.home.simple_action.set_enabled(has_home);
self.button.set_sensitive(has_home);
}