[libadwaita/wip/exalm/demo-cleanups: 10/20] demo: Split flap page into a separate class
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/demo-cleanups: 10/20] demo: Split flap page into a separate class
- Date: Thu, 9 Dec 2021 14:21:07 +0000 (UTC)
commit b65cfd74d908b86c2021f779952b68c3ab0da567
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Thu Dec 9 18:17:33 2021 +0500
demo: Split flap page into a separate class
demo/adw-demo-window.c | 14 ++--------
demo/adw-demo-window.ui | 17 +-----------
demo/adwaita-demo.gresources.xml | 3 ++-
demo/meson.build | 3 ++-
demo/pages/flap/adw-demo-page-flap.c | 38 +++++++++++++++++++++++++++
demo/pages/flap/adw-demo-page-flap.h | 11 ++++++++
demo/pages/flap/adw-demo-page-flap.ui | 24 +++++++++++++++++
demo/{ => pages/flap}/adw-flap-demo-window.c | 2 +-
demo/{ => pages/flap}/adw-flap-demo-window.h | 0
demo/{ => pages/flap}/adw-flap-demo-window.ui | 0
10 files changed, 81 insertions(+), 31 deletions(-)
---
diff --git a/demo/adw-demo-window.c b/demo/adw-demo-window.c
index 853ef285..6d6604db 100644
--- a/demo/adw-demo-window.c
+++ b/demo/adw-demo-window.c
@@ -4,11 +4,11 @@
#include "pages/avatar/adw-demo-page-avatar.h"
#include "pages/carousel/adw-demo-page-carousel.h"
#include "pages/clamp/adw-demo-page-clamp.h"
+#include "pages/flap/adw-demo-page-flap.h"
#include "pages/leaflet/adw-demo-page-leaflet.h"
#include "pages/lists/adw-demo-page-lists.h"
#include "pages/view-switcher/adw-demo-page-view-switcher.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"
@@ -162,16 +162,6 @@ adw_demo_window_new (GtkApplication *application)
return g_object_new (ADW_TYPE_DEMO_WINDOW, "application", application, NULL);
}
-static void
-flap_demo_clicked_cb (GtkButton *btn,
- AdwDemoWindow *self)
-{
- AdwFlapDemoWindow *window = adw_flap_demo_window_new ();
-
- gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (self));
- gtk_window_present (GTK_WINDOW (window));
-}
-
static void
tab_view_demo_clicked_cb (GtkButton *btn,
AdwDemoWindow *self)
@@ -533,7 +523,6 @@ adw_demo_window_class_init (AdwDemoWindowClass *klass)
gtk_widget_class_bind_template_callback (widget_class, leaflet_next_page_cb);
gtk_widget_class_bind_template_callback (widget_class, get_color_scheme_icon_name);
gtk_widget_class_bind_template_callback (widget_class, color_scheme_button_clicked_cb);
- gtk_widget_class_bind_template_callback (widget_class, flap_demo_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, tab_view_demo_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, style_classes_demo_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, add_toast_cb);
@@ -635,6 +624,7 @@ adw_demo_window_init (AdwDemoWindow *self)
g_type_ensure (ADW_TYPE_DEMO_PAGE_AVATAR);
g_type_ensure (ADW_TYPE_DEMO_PAGE_CAROUSEL);
g_type_ensure (ADW_TYPE_DEMO_PAGE_CLAMP);
+ g_type_ensure (ADW_TYPE_DEMO_PAGE_FLAP);
g_type_ensure (ADW_TYPE_DEMO_PAGE_LEAFLET);
g_type_ensure (ADW_TYPE_DEMO_PAGE_LISTS);
g_type_ensure (ADW_TYPE_DEMO_PAGE_VIEW_SWITCHER);
diff --git a/demo/adw-demo-window.ui b/demo/adw-demo-window.ui
index 0715b24a..74df32e3 100644
--- a/demo/adw-demo-window.ui
+++ b/demo/adw-demo-window.ui
@@ -181,24 +181,9 @@
</child>
<child>
<object class="GtkStackPage">
- <property name="name">flap</property>
<property name="title" translatable="yes">Flap</property>
<property name="child">
- <object class="AdwStatusPage">
- <property name="icon-name">widget-flap-symbolic</property>
- <property name="title" translatable="yes">Flap</property>
- <property name="description" translatable="yes">A widget showing a flap next
to or above the content.</property>
- <property name="child">
- <object class="GtkButton">
- <property name="label" translatable="yes">Run the Demo</property>
- <property name="halign">center</property>
- <signal name="clicked" handler="flap_demo_clicked_cb" swapped="no"/>
- <style>
- <class name="pill"/>
- </style>
- </object>
- </property>
- </object>
+ <object class="AdwDemoPageFlap"/>
</property>
</object>
</child>
diff --git a/demo/adwaita-demo.gresources.xml b/demo/adwaita-demo.gresources.xml
index 178dbf5c..6450b442 100644
--- a/demo/adwaita-demo.gresources.xml
+++ b/demo/adwaita-demo.gresources.xml
@@ -44,6 +44,8 @@
<file preprocess="xml-stripblanks">pages/avatar/adw-demo-page-avatar.ui</file>
<file preprocess="xml-stripblanks">pages/carousel/adw-demo-page-carousel.ui</file>
<file preprocess="xml-stripblanks">pages/clamp/adw-demo-page-clamp.ui</file>
+ <file preprocess="xml-stripblanks">pages/flap/adw-demo-page-flap.ui</file>
+ <file preprocess="xml-stripblanks">pages/flap/adw-flap-demo-window.ui</file>
<file preprocess="xml-stripblanks">pages/leaflet/adw-demo-page-leaflet.ui</file>
<file preprocess="xml-stripblanks">pages/lists/adw-demo-page-lists.ui</file>
<file preprocess="xml-stripblanks">pages/view-switcher/adw-demo-page-view-switcher.ui</file>
@@ -51,7 +53,6 @@
<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>
<file preprocess="xml-stripblanks">adw-style-demo-window.ui</file>
<file preprocess="xml-stripblanks">adw-tab-view-demo-window.ui</file>
</gresource>
diff --git a/demo/meson.build b/demo/meson.build
index 4c8b7e56..3f6e1bcd 100644
--- a/demo/meson.build
+++ b/demo/meson.build
@@ -15,6 +15,8 @@ adwaita_demo_sources = [
'pages/avatar/adw-demo-page-avatar.c',
'pages/carousel/adw-demo-page-carousel.c',
'pages/clamp/adw-demo-page-clamp.c',
+ 'pages/flap/adw-demo-page-flap.c',
+ 'pages/flap/adw-flap-demo-window.c',
'pages/leaflet/adw-demo-page-leaflet.c',
'pages/lists/adw-demo-page-lists.c',
'pages/view-switcher/adw-demo-page-view-switcher.c',
@@ -24,7 +26,6 @@ adwaita_demo_sources = [
'adwaita-demo.c',
'adw-demo-preferences-window.c',
'adw-demo-window.c',
- 'adw-flap-demo-window.c',
'adw-style-demo-window.c',
'adw-tab-view-demo-window.c',
libadwaita_generated_headers,
diff --git a/demo/pages/flap/adw-demo-page-flap.c b/demo/pages/flap/adw-demo-page-flap.c
new file mode 100644
index 00000000..807bb292
--- /dev/null
+++ b/demo/pages/flap/adw-demo-page-flap.c
@@ -0,0 +1,38 @@
+#include "adw-demo-page-flap.h"
+
+#include <glib/gi18n.h>
+
+#include "adw-flap-demo-window.h"
+
+struct _AdwDemoPageFlap
+{
+ AdwBin parent_instance;
+};
+
+G_DEFINE_TYPE (AdwDemoPageFlap, adw_demo_page_flap, ADW_TYPE_BIN)
+
+static void
+demo_run_cb (AdwDemoPageFlap *self)
+{
+ AdwFlapDemoWindow *window = adw_flap_demo_window_new ();
+ GtkRoot *root = gtk_widget_get_root (GTK_WIDGET (self));
+
+ gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (root));
+ gtk_window_present (GTK_WINDOW (window));
+}
+
+static void
+adw_demo_page_flap_class_init (AdwDemoPageFlapClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Adwaita1/Demo/ui/pages/flap/adw-demo-page-flap.ui");
+
+ gtk_widget_class_install_action (widget_class, "demo.run", NULL, (GtkWidgetActionActivateFunc)
demo_run_cb);
+}
+
+static void
+adw_demo_page_flap_init (AdwDemoPageFlap *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/demo/pages/flap/adw-demo-page-flap.h b/demo/pages/flap/adw-demo-page-flap.h
new file mode 100644
index 00000000..02121edd
--- /dev/null
+++ b/demo/pages/flap/adw-demo-page-flap.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#include <adwaita.h>
+
+G_BEGIN_DECLS
+
+#define ADW_TYPE_DEMO_PAGE_FLAP (adw_demo_page_flap_get_type())
+
+G_DECLARE_FINAL_TYPE (AdwDemoPageFlap, adw_demo_page_flap, ADW, DEMO_PAGE_FLAP, AdwBin)
+
+G_END_DECLS
diff --git a/demo/pages/flap/adw-demo-page-flap.ui b/demo/pages/flap/adw-demo-page-flap.ui
new file mode 100644
index 00000000..ff16c6b8
--- /dev/null
+++ b/demo/pages/flap/adw-demo-page-flap.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk" version="4.0"/>
+ <requires lib="libadwaita" version="1.0"/>
+ <template class="AdwDemoPageFlap" parent="AdwBin">
+ <property name="child">
+ <object class="AdwStatusPage">
+ <property name="icon-name">widget-flap-symbolic</property>
+ <property name="title" translatable="yes">Flap</property>
+ <property name="description" translatable="yes">A widget showing a flap next to or above the
content.</property>
+ <property name="child">
+ <object class="GtkButton">
+ <property name="label" translatable="yes">Run the Demo</property>
+ <property name="halign">center</property>
+ <property name="action-name">demo.run</property>
+ <style>
+ <class name="pill"/>
+ </style>
+ </object>
+ </property>
+ </object>
+ </property>
+ </template>
+</interface>
diff --git a/demo/adw-flap-demo-window.c b/demo/pages/flap/adw-flap-demo-window.c
similarity index 97%
rename from demo/adw-flap-demo-window.c
rename to demo/pages/flap/adw-flap-demo-window.c
index f43e802f..47ddcb64 100644
--- a/demo/adw-flap-demo-window.c
+++ b/demo/pages/flap/adw-flap-demo-window.c
@@ -72,7 +72,7 @@ adw_flap_demo_window_class_init (AdwFlapDemoWindowClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Adwaita1/Demo/ui/adw-flap-demo-window.ui");
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Adwaita1/Demo/ui/pages/flap/adw-flap-demo-window.ui");
gtk_widget_class_bind_template_child (widget_class, AdwFlapDemoWindow, flap);
gtk_widget_class_bind_template_child (widget_class, AdwFlapDemoWindow, reveal_btn_start);
gtk_widget_class_bind_template_child (widget_class, AdwFlapDemoWindow, reveal_btn_end);
diff --git a/demo/adw-flap-demo-window.h b/demo/pages/flap/adw-flap-demo-window.h
similarity index 100%
rename from demo/adw-flap-demo-window.h
rename to demo/pages/flap/adw-flap-demo-window.h
diff --git a/demo/adw-flap-demo-window.ui b/demo/pages/flap/adw-flap-demo-window.ui
similarity index 100%
rename from demo/adw-flap-demo-window.ui
rename to demo/pages/flap/adw-flap-demo-window.ui
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]