mod counter;
mod options;
mod upload;
use counter::Counter;
use gtk::{
Align, Box, Button, Label, Orientation,
prelude::{BoxExt, WidgetExt},
};
use options::Options;
pub use upload::Upload;
pub struct Control {
pub counter: Label,
pub options: Button,
pub upload: Button,
pub g_box: Box,
}
impl Control {
pub fn build() -> Self {
let counter = Label::counter();
let options = Button::options();
let upload = Button::upload();
let g_box = {
const MARGIN: i32 = 8;
Box::builder()
.halign(Align::End)
.margin_bottom(MARGIN / 2)
.orientation(Orientation::Horizontal)
.spacing(MARGIN)
.build()
};
g_box.append(&counter);
g_box.append(&options);
g_box.append(&upload);
Self {
counter,
options,
upload,
g_box,
}
}
pub fn update(&self, bytes_total: Option<usize>, chars_count: Option<i32>) {
self.counter.update(bytes_total, chars_count);
self.upload
.set_sensitive(bytes_total.is_some_and(|this| this > 0));
}
}