[gtk/popover-menu-custom-child: 108/108] widget-factory: Add a scale to the gear menu
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/popover-menu-custom-child: 108/108] widget-factory: Add a scale to the gear menu
- Date: Tue, 27 Oct 2020 02:44:22 +0000 (UTC)
commit 0faadef36f5bbc62013327dea8264ec82ade8f34
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Oct 26 12:58:23 2020 -0400
widget-factory: Add a scale to the gear menu
This tests the custom menuitem support, and lets you
control the transition duration for the main stack.
demos/widget-factory/widget-factory.c | 11 +++++++++++
demos/widget-factory/widget-factory.ui | 26 ++++++++++++++++++++++++--
2 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 021b69e640..1d81031a8e 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -91,6 +91,16 @@ change_theme_state (GSimpleAction *action,
static GtkWidget *page_stack;
+static void
+transition_speed_changed (GtkRange *range,
+ gpointer data)
+{
+ double value;
+
+ value = gtk_range_get_value (range);
+ gtk_stack_set_transition_duration (GTK_STACK (page_stack), (int)value);
+}
+
static void
change_transition_state (GSimpleAction *action,
GVariant *state,
@@ -2022,6 +2032,7 @@ activate (GApplication *app)
"validate_more_details", (GCallback)validate_more_details,
"mode_switch_state_set", (GCallback)mode_switch_state_set,
"level_scale_value_changed", (GCallback)level_scale_value_changed,
+ "transition_speed_changed", (GCallback)transition_speed_changed,
NULL);
gtk_builder_set_scope (builder, scope);
g_object_unref (scope);
diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui
index 0b383655ee..36bee582cf 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <menu id="gear_menu">
+ <menu id="gear_menu_model">
<section>
<item>
<attribute name="label" translatable="yes">Get Busy</attribute>
@@ -40,6 +40,9 @@
<attribute name="label" translatable="yes">Transition Pages</attribute>
<attribute name="action">win.transition</attribute>
</item>
+ <item>
+ <attribute name="custom">transition-speed</attribute>
+ </item>
</section>
<section>
<item>
@@ -444,7 +447,26 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child type="end">
<object class="GtkMenuButton" id="gear_menu_button">
<property name="valign">center</property>
- <property name="menu-model">gear_menu</property>
+ <property name="popover">
+ <object class="GtkPopoverMenu" id="gear_menu">
+ <property name="menu-model">gear_menu_model</property>
+ <child type="transition-speed">
+ <object class="GtkScale">
+ <property name="adjustment">
+ <object class="GtkAdjustment">
+ <property name="lower">0</property>
+ <property name="upper">1000</property>
+ <property name="value">250</property>
+ <property name="step-increment">50</property>
+ <property name="page-increment">50</property>
+ <property name="page-size">0</property>
+ </object>
+ </property>
+ <signal name="value-changed" handler="transition_speed_changed"/>
+ </object>
+ </child>
+ </object>
+ </property>
<property name="icon-name">open-menu-symbolic</property>
</object>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]