[libadwaita/wip/exalm/demo-cleanups: 4/21] demo: Split welcome page into a separate class




commit 5db320d9f93c0dd50a7ea94db49e72330d3736df
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Thu Dec 9 15:13:23 2021 +0500

    demo: Split welcome page into a separate class

 demo/adw-demo-window.c                      |  3 +++
 demo/adw-demo-window.ui                     |  7 +------
 demo/adwaita-demo.gresources.xml            |  1 +
 demo/meson.build                            |  3 +++
 demo/pages/welcome/adw-demo-page-welcome.c  | 24 ++++++++++++++++++++++++
 demo/pages/welcome/adw-demo-page-welcome.h  | 11 +++++++++++
 demo/pages/welcome/adw-demo-page-welcome.ui | 14 ++++++++++++++
 7 files changed, 57 insertions(+), 6 deletions(-)
---
diff --git a/demo/adw-demo-window.c b/demo/adw-demo-window.c
index 6089e515..19eff01e 100644
--- a/demo/adw-demo-window.c
+++ b/demo/adw-demo-window.c
@@ -1,6 +1,7 @@
 #include "adw-demo-window.h"
 
 #include <glib/gi18n.h>
+#include "pages/welcome/adw-demo-page-welcome.h"
 #include "adw-flap-demo-window.h"
 #include "adw-style-demo-window.h"
 #include "adw-tab-view-demo-window.h"
@@ -954,6 +955,8 @@ adw_demo_window_init (AdwDemoWindow *self)
 {
   AdwStyleManager *manager = adw_style_manager_get_default ();
 
+  g_type_ensure (ADW_TYPE_DEMO_PAGE_WELCOME);
+
   gtk_widget_init_template (GTK_WIDGET (self));
 
   g_signal_connect_object (manager,
diff --git a/demo/adw-demo-window.ui b/demo/adw-demo-window.ui
index 7ea32ded..9a95834f 100644
--- a/demo/adw-demo-window.ui
+++ b/demo/adw-demo-window.ui
@@ -122,14 +122,9 @@
                         <signal name="notify::visible-child" handler="notify_visible_child_cb" after="yes" 
swapped="no"/>
                         <child>
                           <object class="GtkStackPage">
-                            <property name="name">welcome</property>
                             <property name="title" translatable="yes">Welcome</property>
                             <property name="child">
-                              <object class="AdwStatusPage">
-                                <property name="icon-name">org.gnome.Adwaita1.Demo-symbolic</property>
-                                <property name="title" translatable="yes">Welcome to Adwaita Demo</property>
-                                <property name="description" translatable="yes">This is a tour of the 
features the library has to offer.</property>
-                              </object>
+                              <object class="AdwDemoPageWelcome"/>
                             </property>
                           </object>
                         </child>
diff --git a/demo/adwaita-demo.gresources.xml b/demo/adwaita-demo.gresources.xml
index 524c9f68..62730f1e 100644
--- a/demo/adwaita-demo.gresources.xml
+++ b/demo/adwaita-demo.gresources.xml
@@ -41,6 +41,7 @@
     <file compressed="true">style-dark.css</file>
   </gresource>
   <gresource prefix="/org/gnome/Adwaita1/Demo/ui">
+    <file preprocess="xml-stripblanks">pages/welcome/adw-demo-page-welcome.ui</file>
     <file preprocess="xml-stripblanks">adw-demo-preferences-window.ui</file>
     <file preprocess="xml-stripblanks">adw-demo-window.ui</file>
     <file preprocess="xml-stripblanks">adw-flap-demo-window.ui</file>
diff --git a/demo/meson.build b/demo/meson.build
index 90e07d3a..e6d89269 100644
--- a/demo/meson.build
+++ b/demo/meson.build
@@ -11,6 +11,9 @@ adwaita_demo_resources = gnome.compile_resources(
 
 adwaita_demo_sources = [
   adwaita_demo_resources,
+
+  'pages/welcome/adw-demo-page-welcome.c',
+
   'adwaita-demo.c',
   'adw-demo-preferences-window.c',
   'adw-demo-window.c',
diff --git a/demo/pages/welcome/adw-demo-page-welcome.c b/demo/pages/welcome/adw-demo-page-welcome.c
new file mode 100644
index 00000000..91d74332
--- /dev/null
+++ b/demo/pages/welcome/adw-demo-page-welcome.c
@@ -0,0 +1,24 @@
+#include "adw-demo-page-welcome.h"
+
+#include <glib/gi18n.h>
+
+struct _AdwDemoPageWelcome
+{
+  AdwBin parent_instance;
+};
+
+G_DEFINE_TYPE (AdwDemoPageWelcome, adw_demo_page_welcome, ADW_TYPE_BIN)
+
+static void
+adw_demo_page_welcome_class_init (AdwDemoPageWelcomeClass *klass)
+{
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/Adwaita1/Demo/ui/pages/welcome/adw-demo-page-welcome.ui");
+}
+
+static void
+adw_demo_page_welcome_init (AdwDemoPageWelcome *self)
+{
+  gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/demo/pages/welcome/adw-demo-page-welcome.h b/demo/pages/welcome/adw-demo-page-welcome.h
new file mode 100644
index 00000000..63944866
--- /dev/null
+++ b/demo/pages/welcome/adw-demo-page-welcome.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#include <adwaita.h>
+
+G_BEGIN_DECLS
+
+#define ADW_TYPE_DEMO_PAGE_WELCOME (adw_demo_page_welcome_get_type())
+
+G_DECLARE_FINAL_TYPE (AdwDemoPageWelcome, adw_demo_page_welcome, ADW, DEMO_PAGE_WELCOME, AdwBin)
+
+G_END_DECLS
diff --git a/demo/pages/welcome/adw-demo-page-welcome.ui b/demo/pages/welcome/adw-demo-page-welcome.ui
new file mode 100644
index 00000000..c73f052a
--- /dev/null
+++ b/demo/pages/welcome/adw-demo-page-welcome.ui
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk" version="4.0"/>
+  <requires lib="libadwaita" version="1.0"/>
+  <template class="AdwDemoPageWelcome" parent="AdwBin">
+    <property name="child">
+      <object class="AdwStatusPage">
+        <property name="icon-name">org.gnome.Adwaita1.Demo-symbolic</property>
+        <property name="title" translatable="yes">Welcome to Adwaita Demo</property>
+        <property name="description" translatable="yes">This is a tour of the features the library has to 
offer.</property>
+      </object>
+    </property>
+  </template>
+</interface>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]