[libadwaita/wip/exalm/demo-cleanups: 6/21] demo: Split clamp page into a separate class
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/demo-cleanups: 6/21] demo: Split clamp page into a separate class
- Date: Thu, 9 Dec 2021 21:44:33 +0000 (UTC)
commit b4da3cca034926614d83b8fe91321f54d7b39c4e
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Thu Dec 9 15:58:04 2021 +0500
demo: Split clamp page into a separate class
demo/adw-demo-window.c | 2 ++
demo/adw-demo-window.ui | 53 +---------------------------
demo/adwaita-demo.gresources.xml | 1 +
demo/meson.build | 1 +
demo/pages/clamp/adw-demo-page-clamp.c | 24 +++++++++++++
demo/pages/clamp/adw-demo-page-clamp.h | 11 ++++++
demo/pages/clamp/adw-demo-page-clamp.ui | 62 +++++++++++++++++++++++++++++++++
7 files changed, 102 insertions(+), 52 deletions(-)
---
diff --git a/demo/adw-demo-window.c b/demo/adw-demo-window.c
index f33def5d..fc121f23 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/clamp/adw-demo-page-clamp.h"
#include "pages/leaflet/adw-demo-page-leaflet.h"
#include "pages/welcome/adw-demo-page-welcome.h"
#include "adw-flap-demo-window.h"
@@ -921,6 +922,7 @@ adw_demo_window_init (AdwDemoWindow *self)
{
AdwStyleManager *manager = adw_style_manager_get_default ();
+ g_type_ensure (ADW_TYPE_DEMO_PAGE_CLAMP);
g_type_ensure (ADW_TYPE_DEMO_PAGE_LEAFLET);
g_type_ensure (ADW_TYPE_DEMO_PAGE_WELCOME);
diff --git a/demo/adw-demo-window.ui b/demo/adw-demo-window.ui
index 59c11b0b..0c0f9f7a 100644
--- a/demo/adw-demo-window.ui
+++ b/demo/adw-demo-window.ui
@@ -141,46 +141,9 @@
</child>
<child>
<object class="GtkStackPage">
- <property name="name">clamp</property>
<property name="title" translatable="yes">Clamp</property>
<property name="child">
- <object class="AdwStatusPage">
- <property name="icon-name">widget-clamp-symbolic</property>
- <property name="title" translatable="yes">Clamp</property>
- <property name="description" translatable="yes">This page is clamped to
smoothly grow up to a maximum width.</property>
- <property name="child">
- <object class="AdwClamp">
- <property name="maximum-size"
bind-source="clamp_maximum_size_adjustment" bind-property="value" bind-flags="sync-create"/>
- <property name="tightening-threshold"
bind-source="clamp_tightening_threshold_adjustment" bind-property="value" bind-flags="sync-create"/>
- <property name="child">
- <object class="AdwPreferencesGroup">
- <child>
- <object class="AdwActionRow">
- <property name="title" translatable="yes">Maximum
Width</property>
- <child>
- <object class="GtkSpinButton">
- <property
name="adjustment">clamp_maximum_size_adjustment</property>
- <property name="valign">center</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="AdwActionRow">
- <property name="title" translatable="yes">Tightening
Threshold</property>
- <child>
- <object class="GtkSpinButton">
- <property
name="adjustment">clamp_tightening_threshold_adjustment</property>
- <property name="valign">center</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </property>
- </object>
- </property>
- </object>
+ <object class="AdwDemoPageClamp"/>
</property>
</object>
</child>
@@ -1386,20 +1349,6 @@
</object>
</child>
</template>
- <object class="GtkAdjustment" id="clamp_maximum_size_adjustment">
- <property name="lower">0</property>
- <property name="upper">10000</property>
- <property name="value">600</property>
- <property name="page-increment">100</property>
- <property name="step-increment">10</property>
- </object>
- <object class="GtkAdjustment" id="clamp_tightening_threshold_adjustment">
- <property name="lower">0</property>
- <property name="upper">10000</property>
- <property name="value">500</property>
- <property name="page-increment">100</property>
- <property name="step-increment">10</property>
- </object>
<object class="GtkSizeGroup">
<property name="mode">both</property>
<widgets>
diff --git a/demo/adwaita-demo.gresources.xml b/demo/adwaita-demo.gresources.xml
index a0eec955..c3f5d793 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/clamp/adw-demo-page-clamp.ui</file>
<file preprocess="xml-stripblanks">pages/leaflet/adw-demo-page-leaflet.ui</file>
<file preprocess="xml-stripblanks">pages/welcome/adw-demo-page-welcome.ui</file>
<file preprocess="xml-stripblanks">adw-demo-preferences-window.ui</file>
diff --git a/demo/meson.build b/demo/meson.build
index 99475e99..3e05af16 100644
--- a/demo/meson.build
+++ b/demo/meson.build
@@ -12,6 +12,7 @@ adwaita_demo_resources = gnome.compile_resources(
adwaita_demo_sources = [
adwaita_demo_resources,
+ 'pages/clamp/adw-demo-page-clamp.c',
'pages/leaflet/adw-demo-page-leaflet.c',
'pages/welcome/adw-demo-page-welcome.c',
diff --git a/demo/pages/clamp/adw-demo-page-clamp.c b/demo/pages/clamp/adw-demo-page-clamp.c
new file mode 100644
index 00000000..7d9802ba
--- /dev/null
+++ b/demo/pages/clamp/adw-demo-page-clamp.c
@@ -0,0 +1,24 @@
+#include "adw-demo-page-clamp.h"
+
+#include <glib/gi18n.h>
+
+struct _AdwDemoPageClamp
+{
+ AdwBin parent_instance;
+};
+
+G_DEFINE_TYPE (AdwDemoPageClamp, adw_demo_page_clamp, ADW_TYPE_BIN)
+
+static void
+adw_demo_page_clamp_class_init (AdwDemoPageClampClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Adwaita1/Demo/ui/pages/clamp/adw-demo-page-clamp.ui");
+}
+
+static void
+adw_demo_page_clamp_init (AdwDemoPageClamp *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/demo/pages/clamp/adw-demo-page-clamp.h b/demo/pages/clamp/adw-demo-page-clamp.h
new file mode 100644
index 00000000..89e3b20c
--- /dev/null
+++ b/demo/pages/clamp/adw-demo-page-clamp.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#include <adwaita.h>
+
+G_BEGIN_DECLS
+
+#define ADW_TYPE_DEMO_PAGE_CLAMP (adw_demo_page_clamp_get_type())
+
+G_DECLARE_FINAL_TYPE (AdwDemoPageClamp, adw_demo_page_clamp, ADW, DEMO_PAGE_CLAMP, AdwBin)
+
+G_END_DECLS
diff --git a/demo/pages/clamp/adw-demo-page-clamp.ui b/demo/pages/clamp/adw-demo-page-clamp.ui
new file mode 100644
index 00000000..e8f02f4b
--- /dev/null
+++ b/demo/pages/clamp/adw-demo-page-clamp.ui
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk" version="4.0"/>
+ <requires lib="libadwaita" version="1.0"/>
+ <template class="AdwDemoPageClamp" parent="AdwBin">
+ <property name="child">
+ <object class="AdwStatusPage">
+ <property name="icon-name">widget-clamp-symbolic</property>
+ <property name="title" translatable="yes">Clamp</property>
+ <property name="description" translatable="yes">This page is clamped to smoothly grow up to a
maximum width.</property>
+ <property name="child">
+ <object class="AdwClamp">
+ <property name="maximum-size" bind-source="maximum_size_adjustment" bind-property="value"
bind-flags="sync-create"/>
+ <property name="tightening-threshold" bind-source="tightening_threshold_adjustment"
bind-property="value" bind-flags="sync-create"/>
+ <property name="child">
+ <object class="AdwPreferencesGroup">
+ <child>
+ <object class="AdwActionRow">
+ <property name="title" translatable="yes">Maximum Width</property>
+ <child>
+ <object class="GtkSpinButton">
+ <property name="valign">center</property>
+ <property name="adjustment">
+ <object class="GtkAdjustment" id="maximum_size_adjustment">
+ <property name="lower">0</property>
+ <property name="upper">10000</property>
+ <property name="value">600</property>
+ <property name="page-increment">100</property>
+ <property name="step-increment">10</property>
+ </object>
+ </property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwActionRow">
+ <property name="title" translatable="yes">Tightening Threshold</property>
+ <child>
+ <object class="GtkSpinButton">
+ <property name="valign">center</property>
+ <property name="adjustment">
+ <object class="GtkAdjustment" id="tightening_threshold_adjustment">
+ <property name="lower">0</property>
+ <property name="upper">10000</property>
+ <property name="value">500</property>
+ <property name="page-increment">100</property>
+ <property name="step-increment">10</property>
+ </object>
+ </property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </property>
+ </object>
+ </property>
+ </object>
+ </property>
+ </template>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]