summaryrefslogtreecommitdiff
path: root/schist_gtk4_gui/src/window.rs
blob: b3cea357611899f7cb3b38fdc4b392b99911a43d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use gtk::{
    gio,
    glib::{
        self,
        object::IsA,
        subclass::{
            object::{ObjectImpl, ObjectImplExt},
            types::ObjectSubclass,
            InitializingObject,
        },
    },
    subclass::{
        application_window::ApplicationWindowImpl,
        widget::{
            CompositeTemplateClass, CompositeTemplateInitializingExt, WidgetClassExt, WidgetImpl,
        },
        window::WindowImpl,
    },
    TemplateChild,
};

use crate::{
    balances_view::SchistBalancesView, categories_view::SchistCategoriesView,
    category_transfers_view::SchistCategoryTransfersView,
    transactions_view::SchistTransactionsView,
};

gtk::glib::wrapper! {
    pub struct SchistWindow(ObjectSubclass<SchistWindowSubclass>)
        @extends gtk::ApplicationWindow, gtk::Window, gtk::Widget,
        @implements gio::ActionGroup, gio::ActionMap, gtk::Accessible, gtk::Buildable,
            gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager;
}

impl SchistWindow {
    pub fn new<A: IsA<gtk::Application>>(app: &A) -> Self {
        glib::Object::builder().property("application", app).build()
    }
}

#[derive(gtk::CompositeTemplate, Default)]
#[template(resource = "/net/joeac/schist/ui/window.ui")]
pub struct SchistWindowSubclass {
    #[template_child]
    pub balances_view: TemplateChild<SchistBalancesView>,

    #[template_child]
    pub categories_view: TemplateChild<SchistCategoriesView>,

    #[template_child]
    pub category_transfers_view: TemplateChild<SchistCategoryTransfersView>,

    #[template_child]
    pub transactions_view: TemplateChild<SchistTransactionsView>,
}

#[glib::object_subclass]
impl ObjectSubclass for SchistWindowSubclass {
    const NAME: &'static str = "SchistWindow";
    type Type = SchistWindow;
    type ParentType = gtk::ApplicationWindow;

    fn class_init(klass: &mut Self::Class) {
        klass.bind_template();
    }

    fn instance_init(obj: &InitializingObject<Self>) {
        obj.init_template();
    }
}

impl ObjectImpl for SchistWindowSubclass {
    fn constructed(&self) {
        self.parent_constructed();
    }
}

impl WidgetImpl for SchistWindowSubclass {}

impl WindowImpl for SchistWindowSubclass {}

impl ApplicationWindowImpl for SchistWindowSubclass {}