mod counter;
mod send;
use counter::Counter;
use gtk::{Align, Box, Button, Label, Orientation, prelude::BoxExt};
use send::Send;
const SPACING: i32 = 8;
pub struct Control {
pub counter: Label,
pub send: Button,
pub g_box: Box,
}
impl Control {
pub fn build() -> Self {
let counter = Label::counter();
let send = Button::send();
let g_box = Box::builder()
.halign(Align::End)
.orientation(Orientation::Horizontal)
.spacing(SPACING)
.build();
g_box.append(&counter);
g_box.append(&send);
Self {
counter,
send,
g_box,
}
}
pub fn update(&self, is_empty: bool, bytes_left: Option<isize>) {
self.counter.update(is_empty, bytes_left);
self.send.update(match bytes_left {
Some(left) => !is_empty && left >= 0,
None => false,
});
}
}