mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-09-05 19:31:57 +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 control;
|
||||||
|
mod form;
|
||||||
|
|
||||||
use super::Header;
|
use super::Header;
|
||||||
use gtk::Box;
|
use gtk::Box;
|
||||||
@ -10,6 +11,8 @@ pub trait File {
|
|||||||
impl File for Box {
|
impl File for Box {
|
||||||
fn file() -> Self {
|
fn file() -> Self {
|
||||||
use control::Control;
|
use control::Control;
|
||||||
|
use form::Form;
|
||||||
|
use gtk::Button;
|
||||||
use std::{cell::Cell, rc::Rc};
|
use std::{cell::Cell, rc::Rc};
|
||||||
|
|
||||||
// Init components
|
// Init components
|
||||||
@ -18,14 +21,7 @@ impl File for Box {
|
|||||||
token: None,
|
token: None,
|
||||||
}));
|
}));
|
||||||
let control = Box::control(&header);
|
let control = Box::control(&header);
|
||||||
let form = {
|
let form = Button::form();
|
||||||
const MARGIN: i32 = 8;
|
|
||||||
gtk::Button::builder()
|
|
||||||
.label("Choose a file..")
|
|
||||||
.margin_bottom(MARGIN)
|
|
||||||
.margin_top(MARGIN)
|
|
||||||
.build()
|
|
||||||
};
|
|
||||||
|
|
||||||
// Init main widget
|
// 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