mod counter;
mod send;
mod widget;
use counter::Counter;
use send::Send;
use widget::Widget;
use gtk::gio::SimpleAction;
use std::rc::Rc;
pub struct Control {
pub counter: Rc<Counter>,
pub send: Rc<Send>,
pub widget: Rc<Widget>,
}
impl Control {
pub fn new(action_send: SimpleAction) -> Self {
let counter = Rc::new(Counter::new());
let send = Rc::new(Send::new(action_send));
let widget = Rc::new(Widget::new(&counter.widget.label, &send.widget.button));
Self {
counter,
send,
widget,
}
}
pub fn update(&self, chars_left: Option<i32>) {
self.counter.update(chars_left);
self.send.update(match chars_left {
Some(left) => left > 0,
None => false,
});
}
}