From 9e28aff1c045d7b31b6efb526a80b08048a23d99 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Mon, 16 Dec 2024 22:06:36 +0000 Subject: Moves window to window.rs --- schist_gtk4_gui/src/window.rs | 61 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 schist_gtk4_gui/src/window.rs (limited to 'schist_gtk4_gui/src/window.rs') diff --git a/schist_gtk4_gui/src/window.rs b/schist_gtk4_gui/src/window.rs new file mode 100644 index 0000000..b1ca9f6 --- /dev/null +++ b/schist_gtk4_gui/src/window.rs @@ -0,0 +1,61 @@ +use gtk::{ + gio, + glib::{ + self, + object::IsA, + subclass::{ + object::{ObjectImpl, ObjectImplExt}, + types::ObjectSubclass, + InitializingObject, + }, + }, + subclass::{ + application_window::ApplicationWindowImpl, + widget::{CompositeTemplateClass, CompositeTemplateInitializingExt, WidgetImpl}, + window::WindowImpl, + }, +}; + +gtk::glib::wrapper! { + pub struct SchistWindow(ObjectSubclass) + @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>(app: &A) -> Self { + glib::Object::builder().property("application", app).build() + } +} + +#[derive(gtk::CompositeTemplate, Default)] +#[template(resource = "/net/joeac/schist/window.ui")] +pub struct SchistWindowSubclass {} + +#[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) { + 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 {} -- cgit v1.2.3