From 46a25306e1ae3f3bd3528a13db19480110828402 Mon Sep 17 00:00:00 2001 From: yggverse Date: Mon, 18 Nov 2024 22:16:20 +0200 Subject: [PATCH] replace hashmap index with custom gobject properties impl --- .../window/tab/item/identity/gemini.rs | 3 +- .../item/identity/gemini/widget/form/list.rs | 65 ++++++++++++------- .../identity/gemini/widget/form/list/item.rs | 38 +++++++++++ .../gemini/widget/form/list/item/imp.rs | 34 ++++++++++ 4 files changed, 114 insertions(+), 26 deletions(-) create mode 100644 src/app/browser/window/tab/item/identity/gemini/widget/form/list/item.rs create mode 100644 src/app/browser/window/tab/item/identity/gemini/widget/form/list/item/imp.rs diff --git a/src/app/browser/window/tab/item/identity/gemini.rs b/src/app/browser/window/tab/item/identity/gemini.rs index c10fb7a5..0d2668b1 100644 --- a/src/app/browser/window/tab/item/identity/gemini.rs +++ b/src/app/browser/window/tab/item/identity/gemini.rs @@ -23,7 +23,7 @@ impl Gemini { let widget = Rc::new(Widget::new()); // Add new identity option - widget.form.list.append(None, "Create new.."); + widget.form.list.append(None, "Create new..", true); // Collect additional options from database match profile.identity.gemini.database.records() { @@ -49,6 +49,7 @@ impl Gemini { Some(name) => format!("{name} ({expires})"), None => format!("{expires}"), }, + true, ); } } 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 8aa166e7..a0c0fc50 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 @@ -1,10 +1,12 @@ -use gtk::{gio::ListStore, DropDown, Label}; -use std::{cell::RefCell, collections::HashMap, rc::Rc}; +mod item; +use item::Item; + +use gio::prelude::{Cast, CastNone}; +use gtk::{gio::ListStore, prelude::ListItemExt, DropDown, Label, ListItem, SignalListItemFactory}; pub struct List { pub gobject: DropDown, model: ListStore, - index: Rc>>>, } impl List { @@ -12,31 +14,40 @@ impl List { /// Create new `Self` pub fn new() -> Self { - let index = Rc::new(RefCell::new(HashMap::new())); - let model = ListStore::new::