Yoda 0.9.0

Browser for Gemini Protocol
mod counter;
mod send;
mod widget;

use counter::Counter;
use send::Send;
use widget::Widget;

use gtk::{gio::SimpleAction, Box};
use std::rc::Rc;

pub struct Control {
    counter: Rc<Counter>,
    send: Rc<Send>,
    widget: Rc<Widget>,
}

impl Control {
    // Construct
    pub fn new(action_send: SimpleAction) -> Self {
        // Init components
        let counter = Rc::new(Counter::new());
        let send = Rc::new(Send::new(action_send));

        // Init widget
        let widget = Rc::new(Widget::new(counter.gobject(), send.gobject()));

        // Return activated struct
        Self {
            counter,
            send,
            widget,
        }
    }

    // Actions
    pub fn update(&self, chars_left: Option<i32>) {
        // Update children components
        self.counter.update(chars_left);
        self.send.update(match chars_left {
            Some(left) => left > 0,
            None => false,
        });
    }

    // Getters
    pub fn gobject(&self) -> &Box {
        self.widget.gobject()
    }
}