[gnome-tour/bilelmoussaoui/fixes] move Window to composite templates
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-tour/bilelmoussaoui/fixes] move Window to composite templates
- Date: Mon, 3 Jan 2022 16:21:32 +0000 (UTC)
commit 626d77332b54a283295bf8ea7ef74c8045ba00c1
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Sat Jan 1 10:37:56 2022 +0100
move Window to composite templates
it doesn't make much sense now, but it will do once we port the rest of widgets as well
data/resources.gresource.xml | 1 +
data/resources/ui/window.ui | 10 ++++++++++
src/widgets/window.rs | 16 ++++++++++++----
3 files changed, 23 insertions(+), 4 deletions(-)
---
diff --git a/data/resources.gresource.xml b/data/resources.gresource.xml
index 4f542c2..ea29d68 100644
--- a/data/resources.gresource.xml
+++ b/data/resources.gresource.xml
@@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/org/gnome/Tour/">
<file compressed="true" alias="style.css">resources/style.css</file>
+ <file compressed="true" preprocess="xml-stripblanks" alias="ui/window.ui">resources/ui/window.ui</file>
<file compressed="true" alias="welcome.svg">resources/assets/welcome.svg</file>
<file compressed="true" alias="overview.svg">resources/assets/overview.svg</file>
<file compressed="true" alias="search.svg">resources/assets/search.svg</file>
diff --git a/data/resources/ui/window.ui b/data/resources/ui/window.ui
new file mode 100644
index 0000000..64f52de
--- /dev/null
+++ b/data/resources/ui/window.ui
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="Window" parent="AdwApplicationWindow">
+ <property name="default-width">960</property>
+ <property name="default-height">720</property>
+ <property name="content">
+ <object class="PaginatorWidget" id="paginator" />
+ </property>
+ </template>
+</interface>
diff --git a/src/widgets/window.rs b/src/widgets/window.rs
index 6255754..1766ec8 100644
--- a/src/widgets/window.rs
+++ b/src/widgets/window.rs
@@ -12,9 +12,11 @@ mod imp {
use crate::config;
use adw::subclass::prelude::*;
- #[derive(Debug, Default)]
+ #[derive(Debug, Default, gtk::CompositeTemplate)]
+ #[template(resource = "/org/gnome/Tour/ui/window.ui")]
pub struct Window {
- pub(super) paginator: PaginatorWidget,
+ #[template_child]
+ pub(super) paginator: TemplateChild<PaginatorWidget>,
}
#[glib::object_subclass]
@@ -22,11 +24,18 @@ mod imp {
const NAME: &'static str = "Window";
type Type = super::Window;
type ParentType = adw::ApplicationWindow;
+
+ fn class_init(klass: &mut Self::Class) {
+ Self::bind_template(klass);
+ }
+
+ fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
+ obj.init_template();
+ }
}
impl ObjectImpl for Window {
fn constructed(&self, widget: &Self::Type) {
- widget.set_default_size(960, 720);
widget.set_icon_name(Some(config::APP_ID));
// Devel Profile
@@ -73,7 +82,6 @@ mod imp {
last_page.add_css_class("last-page");
self.paginator.add_page(last_page);
- widget.set_content(Some(&self.paginator));
self.parent_constructed(widget);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]