From 8908c1aea152fb62db1d7cf492c0e31eda9a438e Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 14 Dec 2024 02:50:00 +0200 Subject: [PATCH] deactivate apply button on guest item selected, use accent color for active items --- .../tab/item/identity/gemini/widget/form.rs | 3 +-- .../item/identity/gemini/widget/form/list.rs | 26 ++++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/app/browser/window/tab/item/identity/gemini/widget/form.rs b/src/app/browser/window/tab/item/identity/gemini/widget/form.rs index 91865d03..103ea5b9 100644 --- a/src/app/browser/window/tab/item/identity/gemini/widget/form.rs +++ b/src/app/browser/window/tab/item/identity/gemini/widget/form.rs @@ -91,8 +91,7 @@ impl Form { match self.list.selected().value_enum() { Value::GeneratePem => self.name.is_valid(), Value::ImportPem => self.file.is_valid(), - Value::ProfileIdentityGeminiId(_) => !self.list.selected().is_active(), - _ => true, + _ => !self.list.selected().is_active(), } } diff --git a/src/app/browser/window/tab/item/identity/gemini/widget/form/list.rs b/src/app/browser/window/tab/item/identity/gemini/widget/form/list.rs index f338c207..2dcfea51 100644 --- a/src/app/browser/window/tab/item/identity/gemini/widget/form/list.rs +++ b/src/app/browser/window/tab/item/identity/gemini/widget/form/list.rs @@ -26,25 +26,39 @@ impl List { /// Create new `Self` pub fn new(widget_action: Rc, profile: Rc, auth_uri: Uri) -> Self { + // Init dropdown items + let guest_session = Item::new_guest_session(); + let generate_pem = Item::new_generate_pem(); + let import_pem = Item::new_import_pem(); + // Init model let list_store = ListStore::new::(); - list_store.append(&Item::new_guest_session()); - list_store.append(&Item::new_generate_pem()); - list_store.append(&Item::new_import_pem()); + list_store.append(&guest_session); + list_store.append(&generate_pem); + list_store.append(&import_pem); match profile.identity.gemini.database.records() { Ok(identities) => { + let mut is_guest_session = true; for identity in identities { match Item::new_profile_identity_gemini_id( &profile, identity.id, &auth_uri.to_string(), ) { - Ok(item) => list_store.append(&item), + Ok(item) => { + if item.is_active() { + is_guest_session = false; + } + list_store.append(&item) + } Err(_) => todo!(), } } + if is_guest_session { + guest_session.set_is_active(true); + } } Err(_) => todo!(), } @@ -98,12 +112,12 @@ impl List { match child.first_child().and_downcast::