mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-09-03 10:22:21 +00:00
implement separated mod for file chooser form components
This commit is contained in:
parent
afedeb81f0
commit
a8f3e4fe2e
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user