summaryrefslogtreecommitdiff
path: root/schist_gtk4_gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'schist_gtk4_gui/src')
-rw-r--r--schist_gtk4_gui/src/categories_view.rs56
-rw-r--r--schist_gtk4_gui/src/lib.rs1
-rw-r--r--schist_gtk4_gui/src/window.rs14
3 files changed, 68 insertions, 3 deletions
diff --git a/schist_gtk4_gui/src/categories_view.rs b/schist_gtk4_gui/src/categories_view.rs
new file mode 100644
index 0000000..efad621
--- /dev/null
+++ b/schist_gtk4_gui/src/categories_view.rs
@@ -0,0 +1,56 @@
+use gtk::{
+ glib::{
+ self,
+ subclass::{
+ object::{ObjectImpl, ObjectImplExt},
+ types::ObjectSubclass,
+ InitializingObject,
+ },
+ Object,
+ },
+ subclass::{
+ box_::BoxImpl,
+ widget::{CompositeTemplateClass, CompositeTemplateInitializingExt, WidgetImpl},
+ },
+};
+
+glib::wrapper! {
+ pub struct SchistCategoriesView(ObjectSubclass<SchistCategoriesViewImpl>)
+ @extends gtk::Box, gtk::Widget,
+ @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
+}
+
+impl SchistCategoriesView {
+ pub fn new() -> Self {
+ Object::builder().build()
+ }
+}
+
+#[derive(gtk::CompositeTemplate, Default)]
+#[template(resource = "/net/joeac/schist/ui/categories_view.ui")]
+pub struct SchistCategoriesViewImpl {}
+
+#[glib::object_subclass]
+impl ObjectSubclass for SchistCategoriesViewImpl {
+ const NAME: &'static str = "SchistCategoriesView";
+ type Type = SchistCategoriesView;
+ 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 SchistCategoriesViewImpl {
+ fn constructed(&self) {
+ self.parent_constructed();
+ }
+}
+
+impl WidgetImpl for SchistCategoriesViewImpl {}
+
+impl BoxImpl for SchistCategoriesViewImpl {}
diff --git a/schist_gtk4_gui/src/lib.rs b/schist_gtk4_gui/src/lib.rs
index 1430f4c..7455d83 100644
--- a/schist_gtk4_gui/src/lib.rs
+++ b/schist_gtk4_gui/src/lib.rs
@@ -1,3 +1,4 @@
+mod categories_view;
mod window;
use gtk::{gdk::Display, gio, glib, prelude::*, Application, CssProvider};
diff --git a/schist_gtk4_gui/src/window.rs b/schist_gtk4_gui/src/window.rs
index b1ca9f6..b612e92 100644
--- a/schist_gtk4_gui/src/window.rs
+++ b/schist_gtk4_gui/src/window.rs
@@ -11,11 +11,16 @@ use gtk::{
},
subclass::{
application_window::ApplicationWindowImpl,
- widget::{CompositeTemplateClass, CompositeTemplateInitializingExt, WidgetImpl},
+ widget::{
+ CompositeTemplateClass, CompositeTemplateInitializingExt, WidgetClassExt, WidgetImpl,
+ },
window::WindowImpl,
},
+ TemplateChild,
};
+use crate::categories_view::SchistCategoriesView;
+
gtk::glib::wrapper! {
pub struct SchistWindow(ObjectSubclass<SchistWindowSubclass>)
@extends gtk::ApplicationWindow, gtk::Window, gtk::Widget,
@@ -30,8 +35,11 @@ impl SchistWindow {
}
#[derive(gtk::CompositeTemplate, Default)]
-#[template(resource = "/net/joeac/schist/window.ui")]
-pub struct SchistWindowSubclass {}
+#[template(resource = "/net/joeac/schist/ui/window.ui")]
+pub struct SchistWindowSubclass {
+ #[template_child]
+ pub categories_view: TemplateChild<SchistCategoriesView>,
+}
#[glib::object_subclass]
impl ObjectSubclass for SchistWindowSubclass {