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

@ -30,4 +30,10 @@ impl Ident {
pub fn connect_activate(&self, callback: impl Fn() + 'static) { pub fn connect_activate(&self, callback: impl Fn() + 'static) {
self.gobject.connect_activate(move |_, _| callback()); self.gobject.connect_activate(move |_, _| callback());
} }
// Getters
pub fn gobject(&self) -> &SimpleAction {
&self.gobject
}
} }

View File

@ -73,14 +73,23 @@ impl Navigation {
// Actions // Actions
pub fn update(&self, progress_fraction: Option<f64>) { pub fn update(&self, progress_fraction: Option<f64>) {
let request = self.request.widget().gobject().text(); let request_text = self.request.widget().gobject().text();
self.identity.update(); self.identity.update(
self.profile
.identity
.gemini
.auth
.memory
.match_priority(&request_text)
.is_some(),
!request_text.is_empty() && request_text.starts_with("gemini"),
);
self.bookmark self.bookmark
.update(self.profile.bookmark.get(&request).is_ok()); .update(self.profile.bookmark.get(&request_text).is_ok());
self.history.update(); self.history.update();
self.home.update(self.request.uri()); self.home.update(self.request.uri());
self.reload.update(!request.is_empty()); self.reload.update(!request_text.is_empty());
self.request.update(progress_fraction); self.request.update(progress_fraction);
} }

View File

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

View File

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