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 e1654eba..a2715ec7 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 @@ -17,9 +17,9 @@ impl Form { // Constructors /// Create new `Self` - pub fn new(list_options: Vec<(Option, String, bool)>) -> Self { + pub fn new(items: Vec<(Option, String, bool)>) -> Self { // Init components - let list = List::new(&list_options); + let list = List::new(); let name = Name::new(); // Init main container @@ -28,17 +28,6 @@ impl Form { gobject.append(list.gobject()); gobject.append(name.gobject()); - // Init events - list.gobject().connect_selected_notify(move |this| { - // Get selection ID from vector @TODO use GObject storage instead - // https://gtk-rs.org/gtk4-rs/stable/latest/book/list_widgets.html - match list_options.get(this.selected() as usize) { - // Hide name entry on existing identity selected - Some((id, _, _)) => name.gobject().set_visible(id.is_none()), - None => todo!(), - } - }); - // Return activated `Self` Self { gobject } } 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 78cc8f15..7cadebbc 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,35 +1,63 @@ -use gtk::{DropDown, StringList}; +use gtk::{gio::ListStore, prelude::ObjectExt, DropDown, Label}; + +const PROPERTY_KEY_NAME: &str = "key"; // Store item key as GTK property +const PROPERTY_KEY_NONE_VALUE: i64 = -1; // C-type conversion for `None` values pub struct List { gobject: DropDown, + model: ListStore, } impl List { // Constructors /// Create new `Self` - pub fn new(list_options: &Vec<(Option, String, bool)>) -> Self { - // Init empty list model - let model = StringList::new(&[]); - - // Init `GObject` + pub fn new() -> Self { + let model = ListStore::new::