summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2024-12-22 19:30:35 +0000
committerJoe Carstairs <me@joeac.net>2024-12-22 19:30:35 +0000
commit10759bb88331141b1586c9e6fa6cf6ce1683b964 (patch)
tree06aaa25a3d1b154d08bb49ed2771ff969271a138
parentf3d73f9d88e65a3729086dc4de433bed2f03a396 (diff)
Histogram
-rw-r--r--schist_gtk4_gui/resources/resources.gresource.xml1
-rw-r--r--schist_gtk4_gui/resources/ui/balances_histogram.ui28
-rw-r--r--schist_gtk4_gui/resources/ui/balances_view.ui6
-rw-r--r--schist_gtk4_gui/src/balances_histogram.rs59
-rw-r--r--schist_gtk4_gui/src/balances_view.rs12
-rw-r--r--schist_gtk4_gui/src/lib.rs1
6 files changed, 100 insertions, 7 deletions
diff --git a/schist_gtk4_gui/resources/resources.gresource.xml b/schist_gtk4_gui/resources/resources.gresource.xml
index 350a77d..c4b9e10 100644
--- a/schist_gtk4_gui/resources/resources.gresource.xml
+++ b/schist_gtk4_gui/resources/resources.gresource.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/net/joeac/schist/">
+ <file compressed="true" preprocess="xml-stripblanks">ui/balances_histogram.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/balances_view.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/categories_view.ui</file>
<file compressed="true" preprocess="xml-stripblanks">ui/category_transfers_view.ui</file>
diff --git a/schist_gtk4_gui/resources/ui/balances_histogram.ui b/schist_gtk4_gui/resources/ui/balances_histogram.ui
new file mode 100644
index 0000000..b6306b9
--- /dev/null
+++ b/schist_gtk4_gui/resources/ui/balances_histogram.ui
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<interface>
+ <template class="SchistBalancesHistogram" parent="GtkBox">
+ <child>
+ <object class="GtkListBox" id="balances_list">
+ <child>
+ <object class="GtkListBoxRow">
+ <child>
+ <object class="GtkLabel">
+ <property name="label">I am a balance</property>
+ </object>
+ </child>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkListBoxRow">
+ <child>
+ <object class="GtkLabel">
+ <property name="label">I am another balance</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/schist_gtk4_gui/resources/ui/balances_view.ui b/schist_gtk4_gui/resources/ui/balances_view.ui
index 7c329f7..a8f7d7e 100644
--- a/schist_gtk4_gui/resources/ui/balances_view.ui
+++ b/schist_gtk4_gui/resources/ui/balances_view.ui
@@ -18,11 +18,7 @@
<property name="name">overview</property>
<property name="title">Overview</property>
<property name="child">
- <object class="GtkLabel">
- <property name="label">
- Hello, balances overview!
- </property>
- </object>
+ <object class="SchistBalancesHistogram" id="balances_histogram" />
</property>
</object>
</child>
diff --git a/schist_gtk4_gui/src/balances_histogram.rs b/schist_gtk4_gui/src/balances_histogram.rs
new file mode 100644
index 0000000..d258ae4
--- /dev/null
+++ b/schist_gtk4_gui/src/balances_histogram.rs
@@ -0,0 +1,59 @@
+use gtk::{
+ glib::{
+ self,
+ subclass::{
+ object::{ObjectImpl, ObjectImplExt},
+ types::ObjectSubclass,
+ InitializingObject,
+ },
+ Object,
+ },
+ subclass::{box_::BoxImpl, widget::{
+ CompositeTemplateClass, CompositeTemplateInitializingExt, WidgetClassExt, WidgetImpl,
+ }},
+ TemplateChild,
+};
+
+glib::wrapper! {
+ pub struct SchistBalancesHistogram(ObjectSubclass<SchistBalancesHistogramImpl>)
+ @extends gtk::Box, gtk::Widget,
+ @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
+}
+
+impl SchistBalancesHistogram {
+ pub fn new() -> Self {
+ Object::builder().build()
+ }
+}
+
+#[derive(gtk::CompositeTemplate, Default)]
+#[template(resource = "/net/joeac/schist/ui/balances_histogram.ui")]
+pub struct SchistBalancesHistogramImpl {
+ #[template_child]
+ balances_list: TemplateChild<gtk::ListBox>,
+}
+
+#[glib::object_subclass]
+impl ObjectSubclass for SchistBalancesHistogramImpl {
+ const NAME: &'static str = "SchistBalancesHistogram";
+ type Type = SchistBalancesHistogram;
+ type ParentType = gtk::Box;
+
+ fn class_init(klass: &mut Self::Class) {
+ klass.bind_template();
+ }
+
+ fn instance_init(obj: &InitializingObject<Self>) {
+ obj.init_template();
+ }
+}
+
+impl ObjectImpl for SchistBalancesHistogramImpl {
+ fn constructed(&self) {
+ self.parent_constructed();
+ }
+}
+
+impl WidgetImpl for SchistBalancesHistogramImpl {}
+
+impl BoxImpl for SchistBalancesHistogramImpl {}
diff --git a/schist_gtk4_gui/src/balances_view.rs b/schist_gtk4_gui/src/balances_view.rs
index 5afb192..28dfba1 100644
--- a/schist_gtk4_gui/src/balances_view.rs
+++ b/schist_gtk4_gui/src/balances_view.rs
@@ -10,10 +10,15 @@ use gtk::{
},
subclass::{
box_::BoxImpl,
- widget::{CompositeTemplateClass, CompositeTemplateInitializingExt, WidgetImpl},
+ widget::{
+ CompositeTemplateClass, CompositeTemplateInitializingExt, WidgetClassExt, WidgetImpl,
+ },
},
+ TemplateChild,
};
+use crate::balances_histogram::SchistBalancesHistogram;
+
glib::wrapper! {
pub struct SchistBalancesView(ObjectSubclass<SchistBalancesViewImpl>)
@extends gtk::Box, gtk::Widget,
@@ -28,7 +33,10 @@ impl SchistBalancesView {
#[derive(gtk::CompositeTemplate, Default)]
#[template(resource = "/net/joeac/schist/ui/balances_view.ui")]
-pub struct SchistBalancesViewImpl {}
+pub struct SchistBalancesViewImpl {
+ #[template_child]
+ balances_histogram: TemplateChild<SchistBalancesHistogram>,
+}
#[glib::object_subclass]
impl ObjectSubclass for SchistBalancesViewImpl {
diff --git a/schist_gtk4_gui/src/lib.rs b/schist_gtk4_gui/src/lib.rs
index 10240b0..d418ba0 100644
--- a/schist_gtk4_gui/src/lib.rs
+++ b/schist_gtk4_gui/src/lib.rs
@@ -1,3 +1,4 @@
+mod balances_histogram;
mod balances_view;
mod categories_view;
mod category_transfers_view;