[libadwaita/wip/exalm/demo-cleanups: 12/20] demo: Split buttons page into a separate class
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/demo-cleanups: 12/20] demo: Split buttons page into a separate class
- Date: Thu, 9 Dec 2021 14:21:07 +0000 (UTC)
commit d07d99b8244448430c7ef997a629ad447d4e4775
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Thu Dec 9 18:29:33 2021 +0500
demo: Split buttons page into a separate class
demo/adw-demo-window.c | 2 +
demo/adw-demo-window.ui | 120 +-------------------------
demo/adwaita-demo.gresources.xml | 1 +
demo/meson.build | 1 +
demo/pages/buttons/adw-demo-page-buttons.c | 24 ++++++
demo/pages/buttons/adw-demo-page-buttons.h | 11 +++
demo/pages/buttons/adw-demo-page-buttons.ui | 127 ++++++++++++++++++++++++++++
7 files changed, 167 insertions(+), 119 deletions(-)
---
diff --git a/demo/adw-demo-window.c b/demo/adw-demo-window.c
index 71e38d48..7b8519da 100644
--- a/demo/adw-demo-window.c
+++ b/demo/adw-demo-window.c
@@ -2,6 +2,7 @@
#include <glib/gi18n.h>
#include "pages/avatar/adw-demo-page-avatar.h"
+#include "pages/buttons/adw-demo-page-buttons.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"
@@ -610,6 +611,7 @@ adw_demo_window_init (AdwDemoWindow *self)
AdwStyleManager *manager = adw_style_manager_get_default ();
g_type_ensure (ADW_TYPE_DEMO_PAGE_AVATAR);
+ g_type_ensure (ADW_TYPE_DEMO_PAGE_BUTTONS);
g_type_ensure (ADW_TYPE_DEMO_PAGE_CAROUSEL);
g_type_ensure (ADW_TYPE_DEMO_PAGE_CLAMP);
g_type_ensure (ADW_TYPE_DEMO_PAGE_FLAP);
diff --git a/demo/adw-demo-window.ui b/demo/adw-demo-window.ui
index 6851e3df..33edc4d5 100644
--- a/demo/adw-demo-window.ui
+++ b/demo/adw-demo-window.ui
@@ -21,19 +21,6 @@
</item>
</section>
</menu>
- <menu id="sample_menu">
- <section>
- <item>
- <attribute name="label" translatable="yes">Item 1</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Item 2</attribute>
- </item>
- <item>
- <attribute name="label" translatable="yes">Item 3</attribute>
- </item>
- </section>
- </menu>
<template class="AdwDemoWindow" parent="AdwApplicationWindow">
<property name="title" translatable="yes">Adwaita Demo</property>
<property name="default_width">800</property>
@@ -197,114 +184,9 @@
</child>
<child>
<object class="GtkStackPage">
- <property name="name">buttons</property>
<property name="title" translatable="yes">Buttons</property>
<property name="child">
- <object class="AdwStatusPage">
- <property name="title" translatable="yes">Buttons</property>
- <property name="description" translatable="yes">Button helper
widgets.</property>
- <property name="child">
- <object class="AdwClamp">
- <property name="maximum-size">400</property>
- <property name="tightening-threshold">300</property>
- <property name="child">
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkGrid">
- <property name="halign">center</property>
- <property name="column-spacing">12</property>
- <property name="row-spacing">12</property>
- <child>
- <object class="AdwSplitButton">
- <property name="icon-name">document-open-symbolic</property>
- <property name="menu-model">sample_menu</property>
- <layout>
- <property name="column">0</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
- <child>
- <object class="AdwSplitButton">
- <property name="icon-name">document-open-symbolic</property>
- <property name="menu-model">sample_menu</property>
- <style>
- <class name="flat"/>
- </style>
- <layout>
- <property name="column">0</property>
- <property name="row">1</property>
- </layout>
- </object>
- </child>
- <child>
- <object class="AdwSplitButton">
- <property name="label" translatable="yes">_Open</property>
- <property name="use-underline">True</property>
- <property name="menu-model">sample_menu</property>
- <layout>
- <property name="column">1</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
- <child>
- <object class="AdwSplitButton">
- <property name="label" translatable="yes">_Open</property>
- <property name="use-underline">True</property>
- <property name="menu-model">sample_menu</property>
- <style>
- <class name="flat"/>
- </style>
- <layout>
- <property name="column">1</property>
- <property name="row">1</property>
- </layout>
- </object>
- </child>
- <child>
- <object class="AdwSplitButton">
- <property name="child">
- <object class="AdwButtonContent">
- <property
name="icon-name">document-open-symbolic</property>
- <property name="label"
translatable="yes">_Open</property>
- <property name="use-underline">True</property>
- </object>
- </property>
- <property name="menu-model">sample_menu</property>
- <layout>
- <property name="column">2</property>
- <property name="row">0</property>
- </layout>
- </object>
- </child>
- <child>
- <object class="AdwSplitButton">
- <property name="child">
- <object class="AdwButtonContent">
- <property
name="icon-name">document-open-symbolic</property>
- <property name="label"
translatable="yes">_Open</property>
- <property name="use-underline">True</property>
- </object>
- </property>
- <property name="menu-model">sample_menu</property>
- <style>
- <class name="flat"/>
- </style>
- <layout>
- <property name="column">2</property>
- <property name="row">1</property>
- </layout>
- </object>
- </child>
- </object>
- </child>
- </object>
- </property>
- </object>
- </property>
- </object>
+ <object class="AdwDemoPageButtons"/>
</property>
</object>
</child>
diff --git a/demo/adwaita-demo.gresources.xml b/demo/adwaita-demo.gresources.xml
index ebce2f10..2b264c68 100644
--- a/demo/adwaita-demo.gresources.xml
+++ b/demo/adwaita-demo.gresources.xml
@@ -42,6 +42,7 @@
</gresource>
<gresource prefix="/org/gnome/Adwaita1/Demo/ui">
<file preprocess="xml-stripblanks">pages/avatar/adw-demo-page-avatar.ui</file>
+ <file preprocess="xml-stripblanks">pages/buttons/adw-demo-page-buttons.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>
diff --git a/demo/meson.build b/demo/meson.build
index e4901611..0b30056a 100644
--- a/demo/meson.build
+++ b/demo/meson.build
@@ -13,6 +13,7 @@ adwaita_demo_sources = [
adwaita_demo_resources,
'pages/avatar/adw-demo-page-avatar.c',
+ 'pages/buttons/adw-demo-page-buttons.c',
'pages/carousel/adw-demo-page-carousel.c',
'pages/clamp/adw-demo-page-clamp.c',
'pages/flap/adw-demo-page-flap.c',
diff --git a/demo/pages/buttons/adw-demo-page-buttons.c b/demo/pages/buttons/adw-demo-page-buttons.c
new file mode 100644
index 00000000..f5868717
--- /dev/null
+++ b/demo/pages/buttons/adw-demo-page-buttons.c
@@ -0,0 +1,24 @@
+#include "adw-demo-page-buttons.h"
+
+#include <glib/gi18n.h>
+
+struct _AdwDemoPageButtons
+{
+ AdwBin parent_instance;
+};
+
+G_DEFINE_TYPE (AdwDemoPageButtons, adw_demo_page_buttons, ADW_TYPE_BIN)
+
+static void
+adw_demo_page_buttons_class_init (AdwDemoPageButtonsClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Adwaita1/Demo/ui/pages/buttons/adw-demo-page-buttons.ui");
+}
+
+static void
+adw_demo_page_buttons_init (AdwDemoPageButtons *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/demo/pages/buttons/adw-demo-page-buttons.h b/demo/pages/buttons/adw-demo-page-buttons.h
new file mode 100644
index 00000000..8a90ffc6
--- /dev/null
+++ b/demo/pages/buttons/adw-demo-page-buttons.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#include <adwaita.h>
+
+G_BEGIN_DECLS
+
+#define ADW_TYPE_DEMO_PAGE_BUTTONS (adw_demo_page_buttons_get_type())
+
+G_DECLARE_FINAL_TYPE (AdwDemoPageButtons, adw_demo_page_buttons, ADW, DEMO_PAGE_BUTTONS, AdwBin)
+
+G_END_DECLS
diff --git a/demo/pages/buttons/adw-demo-page-buttons.ui b/demo/pages/buttons/adw-demo-page-buttons.ui
new file mode 100644
index 00000000..c8ecd4a7
--- /dev/null
+++ b/demo/pages/buttons/adw-demo-page-buttons.ui
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk" version="4.0"/>
+ <requires lib="libadwaita" version="1.0"/>
+ <menu id="sample_menu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Item 1</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Item 2</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Item 3</attribute>
+ </item>
+ </section>
+ </menu>
+ <template class="AdwDemoPageButtons" parent="AdwBin">
+ <property name="child">
+ <object class="AdwStatusPage">
+ <property name="title" translatable="yes">Buttons</property>
+ <property name="description" translatable="yes">Button helper widgets.</property>
+ <property name="child">
+ <object class="AdwClamp">
+ <property name="maximum-size">400</property>
+ <property name="tightening-threshold">300</property>
+ <property name="child">
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="halign">center</property>
+ <property name="column-spacing">12</property>
+ <property name="row-spacing">12</property>
+ <child>
+ <object class="AdwSplitButton">
+ <property name="icon-name">document-open-symbolic</property>
+ <property name="menu-model">sample_menu</property>
+ <layout>
+ <property name="column">0</property>
+ <property name="row">0</property>
+ </layout>
+ </object>
+ </child>
+ <child>
+ <object class="AdwSplitButton">
+ <property name="icon-name">document-open-symbolic</property>
+ <property name="menu-model">sample_menu</property>
+ <style>
+ <class name="flat"/>
+ </style>
+ <layout>
+ <property name="column">0</property>
+ <property name="row">1</property>
+ </layout>
+ </object>
+ </child>
+ <child>
+ <object class="AdwSplitButton">
+ <property name="label" translatable="yes">_Open</property>
+ <property name="use-underline">True</property>
+ <property name="menu-model">sample_menu</property>
+ <layout>
+ <property name="column">1</property>
+ <property name="row">0</property>
+ </layout>
+ </object>
+ </child>
+ <child>
+ <object class="AdwSplitButton">
+ <property name="label" translatable="yes">_Open</property>
+ <property name="use-underline">True</property>
+ <property name="menu-model">sample_menu</property>
+ <style>
+ <class name="flat"/>
+ </style>
+ <layout>
+ <property name="column">1</property>
+ <property name="row">1</property>
+ </layout>
+ </object>
+ </child>
+ <child>
+ <object class="AdwSplitButton">
+ <property name="child">
+ <object class="AdwButtonContent">
+ <property name="icon-name">document-open-symbolic</property>
+ <property name="label" translatable="yes">_Open</property>
+ <property name="use-underline">True</property>
+ </object>
+ </property>
+ <property name="menu-model">sample_menu</property>
+ <layout>
+ <property name="column">2</property>
+ <property name="row">0</property>
+ </layout>
+ </object>
+ </child>
+ <child>
+ <object class="AdwSplitButton">
+ <property name="child">
+ <object class="AdwButtonContent">
+ <property name="icon-name">document-open-symbolic</property>
+ <property name="label" translatable="yes">_Open</property>
+ <property name="use-underline">True</property>
+ </object>
+ </property>
+ <property name="menu-model">sample_menu</property>
+ <style>
+ <class name="flat"/>
+ </style>
+ <layout>
+ <property name="column">2</property>
+ <property name="row">1</property>
+ </layout>
+ </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]