[gtk+] switch: allow the user to toggle the switch by clicking on the handle



commit 0c6251d0d2b52cd49d63d7dcb61491f5c810ff33
Author: Thomas Wood <thos gnome org>
Date:   Tue Jan 11 11:34:23 2011 +0000

    switch: allow the user to toggle the switch by clicking on the handle

 gtk/gtkswitch.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c
index 28a5d8d..6b9866e 100644
--- a/gtk/gtkswitch.c
+++ b/gtk/gtkswitch.c
@@ -202,6 +202,15 @@ gtk_switch_button_release (GtkWidget      *widget,
       return TRUE;
     }
 
+  /* toggle the switch if the handle was clicked but a drag had not been
+   * initiated */
+  if (!priv->is_dragging && !priv->in_press)
+    {
+      gtk_switch_set_active (GTK_SWITCH (widget), !priv->is_active);
+
+      return TRUE;
+    }
+
   /* dragged toggle */
   if (priv->is_dragging)
     {



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