mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
update home button status detection
This commit is contained in:
parent
c5fad47a20
commit
5943ea622a
3 changed files with 27 additions and 23 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue