highlight ident button on active auth session, disable on auth unsupported

This commit is contained in:
yggverse 2024-11-21 10:22:04 +02:00
parent 3064b530ea
commit 5d01786596
4 changed files with 32 additions and 9 deletions

View file

@ -5,6 +5,7 @@ use crate::app::browser::window::tab::item::Action;
use std::rc::Rc;
pub struct Identity {
action: Rc<Action>,
widget: Rc<Widget>,
}
@ -12,13 +13,18 @@ impl Identity {
// Construct
pub fn new(action: Rc<Action>) -> Self {
Self {
widget: Rc::new(Widget::new(action.clone())),
action: action.clone(),
widget: Rc::new(Widget::new(action)),
}
}
// Actions
pub fn update(&self) {
self.widget.update(false) // @TODO
pub fn update(&self, is_auth: bool, is_enabled: bool) {
// Update action status
self.action.ident().gobject().set_enabled(is_enabled);
// Update widget
self.widget.update(is_auth, is_enabled)
}
// Getters

View file

@ -27,8 +27,10 @@ impl Widget {
}
// Actions
pub fn update(&self, is_sensitive: bool) {
//self.gobject.set_sensitive(is_sensitive);
pub fn update(&self, is_auth: bool, is_enabled: bool) {
self.gobject.set_sensitive(is_enabled);
self.gobject
.set_css_classes(if is_auth { &["success"] } else { &[] });
}
// Getters