mycitadel/view/about/
component.rs1use gladis::Gladis;
13use gtk::Dialog;
14use relm::{Relm, Update, Widget};
15
16use super::{Msg, ViewModel, Widgets};
17
18pub struct Component {
19 model: ViewModel,
20 widgets: Widgets,
21}
22
23impl Component {}
24
25impl Update for Component {
26 type Model = ViewModel;
28 type ModelParam = ();
30 type Msg = Msg;
32
33 fn model(_relm: &Relm<Self>, _param: Self::ModelParam) -> Self::Model { ViewModel::default() }
34
35 fn update(&mut self, event: Msg) {
36 match event {
37 Msg::Show => {
38 self.widgets.init_ui(&self.model);
39 self.widgets.show();
40 }
41 Msg::Response(_) => {
42 self.widgets.hide();
43 }
44 }
45 }
46}
47
48impl Widget for Component {
49 type Root = Dialog;
51
52 fn root(&self) -> Self::Root { self.widgets.to_root() }
54
55 fn view(relm: &Relm<Self>, model: Self::Model) -> Self {
56 let glade_src = include_str!("about.glade");
57 let widgets = Widgets::from_string(glade_src).expect("glade file broken");
58
59 widgets.connect(relm);
60 widgets.init_ui(&model);
61 widgets.show();
62
63 Component { model, widgets }
64 }
65}