[gtk+] widget-factory: Add a reset button to the notification



commit a397824e9b38acc9dfb7a81c8872ae6dfa89a42b
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Aug 11 23:14:34 2014 +0200

    widget-factory: Add a reset button to the notification
    
    Change the initial value to something that is not a multiple of 3, so
    that dismissing the notification on reset makes sense. Let's use 50
    because that is already being used elsewhere.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=734614

 demos/widget-factory/widget-factory.c  |   11 +++++++++++
 demos/widget-factory/widget-factory.ui |    9 ++++++++-
 2 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index e9f7cfb..efc3c9b 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -144,6 +144,13 @@ dismiss (GtkWidget *button)
   gtk_revealer_set_reveal_child (GTK_REVEALER (w), FALSE);
 }
 
+static void
+spin_value_reset (GtkWidget *button, GtkAdjustment *adjustment)
+{
+  gtk_adjustment_set_value (adjustment, 50.0);
+  dismiss (button);
+}
+
 static gint pulse_time = 250;
 static gint pulse_entry_mode = 0;
 
@@ -626,6 +633,10 @@ activate (GApplication *app)
   g_signal_connect (adj, "value-changed", G_CALLBACK (update_pulse_time), widget);
   update_pulse_time (adj, widget);
 
+  widget = (GtkWidget *)gtk_builder_get_object (builder, "page2reset");
+  adj = (GtkAdjustment *) gtk_builder_get_object (builder, "adjustment2");
+  g_signal_connect (widget, "clicked", G_CALLBACK (spin_value_reset), adj);
+
   widget = (GtkWidget *)gtk_builder_get_object (builder, "page2dismiss");
   g_signal_connect (widget, "clicked", G_CALLBACK (dismiss), NULL);
 
diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui
index a57e255..426b812 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -89,7 +89,7 @@
   <object class="GtkAdjustment" id="adjustment2">
     <property name="upper">1000</property>
     <property name="lower">1</property>
-    <property name="value">42</property>
+    <property name="value">50</property>
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
@@ -1986,6 +1986,13 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
                               </object>
                             </child>
                             <child>
+                              <object class="GtkButton" id="page2reset">
+                                <property name="visible">True</property>
+                                <property name="valign">center</property>
+                                <property name="label" translatable="yes">Reset</property>
+                              </object>
+                            </child>
+                            <child>
                               <object class="GtkButton" id="page2dismiss">
                                 <property name="visible">True</property>
                                 <property name="focus-on-click">False</property>


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