mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
implement separated mod for file chooser form components
This commit is contained in:
parent
afedeb81f0
commit
a8f3e4fe2e
2 changed files with 29 additions and 8 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue