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 8b2b1de1..3accb16c 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 @@ -1,6 +1,8 @@ +mod file; pub mod list; mod name; +use file::File; use list::{item::value::Value, List}; use name::Name; @@ -10,6 +12,7 @@ use std::rc::Rc; pub struct Form { // pub action: Rc, + pub file: Rc, pub list: Rc, pub name: Rc, pub gobject: Box, @@ -23,15 +26,18 @@ impl Form { // Init components let list = Rc::new(List::new()); let name = Rc::new(Name::new(action.clone())); + let file = Rc::new(File::new(action.clone())); // Init main container let gobject = Box::builder().orientation(Orientation::Vertical).build(); gobject.append(&list.gobject); gobject.append(&name.gobject); + gobject.append(&file.gobject); // Connect events list.on_select({ + let file = file.clone(); let name = name.clone(); let update = action.update.clone(); move |key| { @@ -41,6 +47,12 @@ impl Form { _ => false, }); + // Change name entry visibility + file.show(match key { + Value::IMPORT_PEM => true, + _ => false, + }); + // Update widget update.activate(); } @@ -50,6 +62,7 @@ impl Form { Self { // action, gobject, + file, list, name, } diff --git a/src/app/browser/window/tab/item/identity/gemini/widget/form/file.rs b/src/app/browser/window/tab/item/identity/gemini/widget/form/file.rs new file mode 100644 index 00000000..9e950a67 --- /dev/null +++ b/src/app/browser/window/tab/item/identity/gemini/widget/form/file.rs @@ -0,0 +1,41 @@ +use super::Action; +use gtk::{ + prelude::{ButtonExt, WidgetExt}, + Button, +}; + +use std::rc::Rc; + +const LABEL: &str = "Select file.."; +const MARGIN: i32 = 8; + +pub struct File { + pub gobject: Button, +} + +impl File { + // Constructors + + /// Create new `Self` + pub fn new(action: Rc) -> Self { + // Init `GObject` + let gobject = Button::builder().label(LABEL).margin_top(MARGIN).build(); + + // Init events + gobject.connect_clicked(move |_| todo!()); + + // Return activated `Self` + Self { gobject } + } + + // Actions + + /// Change visibility status + /// * grab focus on `is_visible` + pub fn show(&self, is_visible: bool) { + self.gobject.set_visible(is_visible); + if is_visible { + self.gobject.grab_focus(); + } + } +}