diff options
Diffstat (limited to 'schist_gtk4_gui/src')
| -rw-r--r-- | schist_gtk4_gui/src/lib.rs | 2 | ||||
| -rw-r--r-- | schist_gtk4_gui/src/window.rs | 61 | ||||
| -rw-r--r-- | schist_gtk4_gui/src/window/imp.rs | 50 | ||||
| -rw-r--r-- | schist_gtk4_gui/src/window/mod.rs | 21 |
4 files changed, 62 insertions, 72 deletions
diff --git a/schist_gtk4_gui/src/lib.rs b/schist_gtk4_gui/src/lib.rs index 99c090e..1430f4c 100644 --- a/schist_gtk4_gui/src/lib.rs +++ b/schist_gtk4_gui/src/lib.rs @@ -15,7 +15,7 @@ pub fn run() -> glib::ExitCode { } fn build_window(app: &Application) { - let window = window::Window::new(app); + let window = window::SchistWindow::new(app); window.present() } 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<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/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<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 {} diff --git a/schist_gtk4_gui/src/window/imp.rs b/schist_gtk4_gui/src/window/imp.rs deleted file mode 100644 index 82e14b0..0000000 --- a/schist_gtk4_gui/src/window/imp.rs +++ /dev/null @@ -1,50 +0,0 @@ -use gtk::{ - glib::{ - self, - subclass::{ - object::{ - ObjectImpl, - ObjectImplExt, - }, - types::ObjectSubclass, InitializingObject, - }, - }, - subclass::{application_window::ApplicationWindowImpl, widget::{ - CompositeTemplateClass, CompositeTemplateInitializingExt, WidgetImpl - }, window::WindowImpl}, -}; - -#[derive(gtk::CompositeTemplate, Default)] -#[template(resource = "/net/joeac/schist/window.ui")] -pub struct Window { -} - -#[glib::object_subclass] -impl ObjectSubclass for Window { - const NAME: &'static str = "SchistWindow"; - type Type = super::Window; - 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 Window { - fn constructed(&self) { - self.parent_constructed(); - } -} - -impl WidgetImpl for Window { -} - -impl WindowImpl for Window { -} - -impl ApplicationWindowImpl for Window { -} diff --git a/schist_gtk4_gui/src/window/mod.rs b/schist_gtk4_gui/src/window/mod.rs deleted file mode 100644 index dcbba04..0000000 --- a/schist_gtk4_gui/src/window/mod.rs +++ /dev/null @@ -1,21 +0,0 @@ -mod imp; - -use gtk::{ - gio, - glib::{self, object::IsA}, -}; - -gtk::glib::wrapper! { - pub struct Window(ObjectSubclass<imp::Window>) - @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 Window { - pub fn new<A: IsA<gtk::Application>>(app: &A) -> Self { - glib::Object::builder() - .property("application", app) - .build() - } -} |
