[gtk+] listbox: Listen to ::stopped on the press gesture



commit 4d0a57fe0b4f54edd1826f0abd02297e44f2c780
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Nov 19 14:47:24 2017 -0500

    listbox: Listen to ::stopped on the press gesture
    
    Otherwise, we end up interpreting grab notify's as
    button releases, which is not right. This matches
    what GtkFlowBox does.

 gtk/gtklistbox.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 103371c..c1f9d5a 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -243,6 +243,8 @@ static void gtk_list_box_multipress_gesture_released (GtkGestureMultiPress *gest
                                                       gdouble               x,
                                                       gdouble               y,
                                                       GtkListBox           *box);
+static void gtk_list_box_multipress_gesture_stopped  (GtkGestureMultiPress *gesture,
+                                                      GtkListBox           *box);
 
 static void gtk_list_box_update_row_styles (GtkListBox    *box);
 static void gtk_list_box_update_row_style  (GtkListBox    *box,
@@ -599,6 +601,8 @@ gtk_list_box_init (GtkListBox *box)
                     G_CALLBACK (gtk_list_box_multipress_gesture_pressed), box);
   g_signal_connect (priv->multipress_gesture, "released",
                     G_CALLBACK (gtk_list_box_multipress_gesture_released), box);
+  g_signal_connect (priv->multipress_gesture, "stopped",
+                    G_CALLBACK (gtk_list_box_multipress_gesture_stopped), box);
 
 
   g_signal_connect (box, "notify::parent", G_CALLBACK (gtk_list_box_parent_cb), NULL);
@@ -1783,6 +1787,7 @@ gtk_list_box_multipress_gesture_released (GtkGestureMultiPress *gesture,
    */
   g_object_ref (box);
 
+g_print ("released\n");
   if (priv->active_row != NULL &&
       priv->active_row == gtk_list_box_get_row_at_y (box, y))
     {
@@ -1816,8 +1821,7 @@ gtk_list_box_multipress_gesture_released (GtkGestureMultiPress *gesture,
 
   if (priv->active_row)
     {
-      gtk_widget_unset_state_flags (GTK_WIDGET (priv->active_row),
-                                    GTK_STATE_FLAG_ACTIVE);
+      gtk_widget_unset_state_flags (GTK_WIDGET (priv->active_row), GTK_STATE_FLAG_ACTIVE);
       priv->active_row = NULL;
     }
 
@@ -1825,6 +1829,21 @@ gtk_list_box_multipress_gesture_released (GtkGestureMultiPress *gesture,
 }
 
 static void
+gtk_list_box_multipress_gesture_stopped (GtkGestureMultiPress *gesture,
+                                         GtkListBox           *box)
+{
+  GtkListBoxPrivate *priv = BOX_PRIV (box);
+
+g_print ("stopped\n");
+  if (priv->active_row)
+    {
+      gtk_widget_unset_state_flags (GTK_WIDGET (priv->active_row), GTK_STATE_FLAG_ACTIVE);
+      priv->active_row = NULL;
+      gtk_widget_queue_draw (GTK_WIDGET (box));
+    }
+}
+
+static void
 gtk_list_box_show (GtkWidget *widget)
 {
   gtk_list_box_do_reseparate (GTK_LIST_BOX (widget));


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