[gtk+] Bug 592883 - Spin cell rendererer problem with double click



commit de1c79c72100ea8d630ec15034dca37d9857213b
Author: Kristian Rietveld <kris gtk org>
Date:   Thu Aug 27 16:22:11 2009 +0200

    Bug 592883 - Spin cell rendererer problem with double click
    
    Block 2BUTTON and 3BUTTON press events using a button press event
    handler in GtkCellRendererSpin, so that they won't be eaten and
    processed by tree view.

 gtk/gtkcellrendererspin.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcellrendererspin.c b/gtk/gtkcellrendererspin.c
index 92b6692..ebd08e2 100644
--- a/gtk/gtkcellrendererspin.c
+++ b/gtk/gtkcellrendererspin.c
@@ -271,6 +271,21 @@ gtk_cell_renderer_spin_key_press_event (GtkWidget   *widget,
   return FALSE;
 }
 
+static gboolean
+gtk_cell_renderer_spin_button_press_event (GtkWidget      *widget,
+                                           GdkEventButton *event,
+                                           gpointer        user_data)
+{
+  /* Block 2BUTTON and 3BUTTON here, so that they won't be eaten
+   * by tree view.
+   */
+  if (event->type == GDK_2BUTTON_PRESS
+      || event->type == GDK_3BUTTON_PRESS)
+    return TRUE;
+
+  return FALSE;
+}
+
 static GtkCellEditable *
 gtk_cell_renderer_spin_start_editing (GtkCellRenderer     *cell,
 				      GdkEvent            *event,
@@ -296,6 +311,10 @@ gtk_cell_renderer_spin_start_editing (GtkCellRenderer     *cell,
   spin = gtk_spin_button_new (priv->adjustment,
 			      priv->climb_rate, priv->digits);
 
+  g_signal_connect (spin, "button-press-event",
+                    G_CALLBACK (gtk_cell_renderer_spin_button_press_event),
+                    NULL);
+
   if (cell_text->text)
     gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin),
 			       g_ascii_strtod (cell_text->text, NULL));



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