diff --git a/src/app/browser/window/tab/item/page/input/titan/file.rs b/src/app/browser/window/tab/item/page/input/titan/file.rs index 23d29b7d..313c8c90 100644 --- a/src/app/browser/window/tab/item/page/input/titan/file.rs +++ b/src/app/browser/window/tab/item/page/input/titan/file.rs @@ -1,4 +1,5 @@ mod control; +mod form; use super::Header; use gtk::Box; @@ -10,6 +11,8 @@ pub trait File { impl File for Box { fn file() -> Self { use control::Control; + use form::Form; + use gtk::Button; use std::{cell::Cell, rc::Rc}; // Init components @@ -18,14 +21,7 @@ impl File for Box { token: None, })); let control = Box::control(&header); - let form = { - const MARGIN: i32 = 8; - gtk::Button::builder() - .label("Choose a file..") - .margin_bottom(MARGIN) - .margin_top(MARGIN) - .build() - }; + let form = Button::form(); // Init main widget { diff --git a/src/app/browser/window/tab/item/page/input/titan/file/form.rs b/src/app/browser/window/tab/item/page/input/titan/file/form.rs new file mode 100644 index 00000000..40a11fed --- /dev/null +++ b/src/app/browser/window/tab/item/page/input/titan/file/form.rs @@ -0,0 +1,25 @@ +use gtk::Button; + +pub trait Form { + fn form() -> Self; +} + +impl Form for Button { + fn form() -> Self { + use gtk::prelude::{ButtonExt, WidgetExt}; + + const MARGIN: i32 = 8; + + let button = Button::builder() + .label("Choose a file..") + .margin_bottom(MARGIN) + .margin_top(MARGIN) + .build(); + + button.connect_clicked(|this| { + this.set_sensitive(false); // lock + }); + + button + } +}