[gtk+] widget-factory: add entry progress modes



commit cbbc5d474a77db1ba73cc37472bcf6e53db40e7b
Author: William Jon McCann <william jon mccann gmail com>
Date:   Wed Feb 26 11:16:06 2014 -0500

    widget-factory: add entry progress modes

 demos/widget-factory/widget-factory.c  |   43 ++++++++++++++++++++++++++++++++
 demos/widget-factory/widget-factory.ui |    4 ++-
 2 files changed, 46 insertions(+), 1 deletions(-)
---
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index ee0e59c..19380a3 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -163,6 +163,47 @@ update_pulse_time (GtkAdjustment *adjustment, GtkWidget *widget)
     }
 }
 
+static guint pulse_entry_id = 0;
+
+static gboolean
+pulse_entry (GtkEntry *entry)
+{
+  gtk_entry_progress_pulse (entry);
+
+  pulse_entry_id = g_timeout_add (100, (GSourceFunc)pulse_entry, entry);
+
+  return G_SOURCE_REMOVE;
+}
+
+static void
+on_entry_icon_release (GtkEntry            *entry,
+                       GtkEntryIconPosition icon_pos,
+                       GdkEvent            *event,
+                       gpointer             user_data)
+{
+  static int num = 0;
+
+  if (icon_pos != GTK_ENTRY_ICON_SECONDARY)
+    return;
+
+  num++;
+
+  if (num % 3 == 0)
+    {
+      if (pulse_entry_id > 0)
+        g_source_remove (pulse_entry_id);
+      gtk_entry_set_progress_fraction (entry, 0);
+    }
+  else if (num % 3 == 1)
+    gtk_entry_set_progress_fraction (entry, 0.25);
+  else if (num % 3 == 2)
+    {
+      gtk_entry_set_progress_pulse_step (entry, 0.1);
+      pulse_entry (entry);
+    }
+
+}
+
 static void
 startup (GApplication *app)
 {
@@ -192,6 +233,8 @@ activate (GApplication *app)
 
   builder = gtk_builder_new ();
   gtk_builder_add_from_resource (builder, "/ui/widget-factory.ui", NULL);
+  gtk_builder_add_callback_symbol (builder, "on_entry_icon_release", (GCallback)on_entry_icon_release);
+  gtk_builder_connect_signals (builder, NULL);
 
   window = (GtkWindow *)gtk_builder_get_object (builder, "window");
   gtk_application_add_window (GTK_APPLICATION (app), window);
diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui
index 17a9008..cb6b0c8 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -206,7 +206,9 @@ Suspendisse feugiat quam quis dolor accumsan cursus. </property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="invisible_char">•</property>
-                            <property name="text" translatable="yes">entry</property>
+                            <property name="placeholder-text" translatable="yes">Click icon to change 
mode</property>
+                            <property name="secondary_icon_name">view-refresh-symbolic</property>
+                            <signal name="icon-release" handler="on_entry_icon_release" swapped="no"/>
                           </object>
                           <packing>
                             <property name="expand">False</property>


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