Commit 626d7733 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

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
parent 97f35aff
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<gresources> <gresources>
<gresource prefix="/org/gnome/Tour/"> <gresource prefix="/org/gnome/Tour/">
<file compressed="true" alias="style.css">resources/style.css</file> <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="welcome.svg">resources/assets/welcome.svg</file>
<file compressed="true" alias="overview.svg">resources/assets/overview.svg</file> <file compressed="true" alias="overview.svg">resources/assets/overview.svg</file>
<file compressed="true" alias="search.svg">resources/assets/search.svg</file> <file compressed="true" alias="search.svg">resources/assets/search.svg</file>
......
<?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>
...@@ -12,9 +12,11 @@ mod imp { ...@@ -12,9 +12,11 @@ mod imp {
use crate::config; use crate::config;
use adw::subclass::prelude::*; use adw::subclass::prelude::*;
#[derive(Debug, Default)] #[derive(Debug, Default, gtk::CompositeTemplate)]
#[template(resource = "/org/gnome/Tour/ui/window.ui")]
pub struct Window { pub struct Window {
pub(super) paginator: PaginatorWidget, #[template_child]
pub(super) paginator: TemplateChild<PaginatorWidget>,
} }
#[glib::object_subclass] #[glib::object_subclass]
...@@ -22,11 +24,18 @@ mod imp { ...@@ -22,11 +24,18 @@ mod imp {
const NAME: &'static str = "Window"; const NAME: &'static str = "Window";
type Type = super::Window; type Type = super::Window;
type ParentType = adw::ApplicationWindow; 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 { impl ObjectImpl for Window {
fn constructed(&self, widget: &Self::Type) { fn constructed(&self, widget: &Self::Type) {
widget.set_default_size(960, 720);
widget.set_icon_name(Some(config::APP_ID)); widget.set_icon_name(Some(config::APP_ID));
// Devel Profile // Devel Profile
...@@ -73,7 +82,6 @@ mod imp { ...@@ -73,7 +82,6 @@ mod imp {
last_page.add_css_class("last-page"); last_page.add_css_class("last-page");
self.paginator.add_page(last_page); self.paginator.add_page(last_page);
widget.set_content(Some(&self.paginator));
self.parent_constructed(widget); self.parent_constructed(widget);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment