[gtk+] listbox: Add missing ::row-selected emissions



commit 6f857f87dcd98c3c6f002c143267cfb5cbe9f7fd
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu May 8 11:42:56 2014 +0200

    listbox: Add missing ::row-selected emissions
    
    Rows are not necessarily selected via select_row_internal(), add
    the missing signal emissions there. Also the signal should be emitted
    when removing the selection altogether.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=729809

 gtk/gtklistbox.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c
index 29449e9..56ffc34 100644
--- a/gtk/gtklistbox.c
+++ b/gtk/gtklistbox.c
@@ -693,13 +693,21 @@ void
 gtk_list_box_select_row (GtkListBox    *box,
                          GtkListBoxRow *row)
 {
+  gboolean dirty = FALSE;
+
   g_return_if_fail (GTK_IS_LIST_BOX (box));
   g_return_if_fail (row == NULL || GTK_IS_LIST_BOX_ROW (row));
 
   if (row)
     gtk_list_box_select_row_internal (box, row);
   else
-    gtk_list_box_unselect_all_internal (box);
+    dirty = gtk_list_box_unselect_all_internal (box);
+
+  if (dirty)
+    {
+      g_signal_emit (box, signals[ROW_SELECTED], 0, NULL);
+      g_signal_emit (box, signals[SELECTED_ROWS_CHANGED], 0);
+    }
 }
 
 /**   
@@ -765,7 +773,10 @@ gtk_list_box_unselect_all (GtkListBox *box)
   dirty = gtk_list_box_unselect_all_internal (box);
 
   if (dirty)
-    g_signal_emit (box, signals[SELECTED_ROWS_CHANGED], 0);
+    {
+      g_signal_emit (box, signals[ROW_SELECTED], 0, NULL);
+      g_signal_emit (box, signals[SELECTED_ROWS_CHANGED], 0);
+    }
 }
 
 static void
@@ -1449,6 +1460,7 @@ gtk_list_box_unselect_row_internal (GtkListBox    *box,
   else
     gtk_list_box_row_set_selected (row, FALSE);
 
+  g_signal_emit (box, signals[ROW_SELECTED], 0, NULL);
   g_signal_emit (box, signals[SELECTED_ROWS_CHANGED], 0);
 }
 
@@ -1540,6 +1552,7 @@ gtk_list_box_update_selection (GtkListBox    *box,
     {
       gtk_list_box_unselect_all_internal (box);
       gtk_list_box_row_set_selected (row, TRUE);
+      g_signal_emit (box, signals[ROW_SELECTED], 0, row);
       priv->selected_row = row;
     }
   else if (priv->selection_mode == GTK_SELECTION_SINGLE)
@@ -1550,6 +1563,7 @@ gtk_list_box_update_selection (GtkListBox    *box,
       gtk_list_box_unselect_all_internal (box);
       gtk_list_box_row_set_selected (row, modify ? !was_selected : TRUE);
       priv->selected_row = ROW_PRIV (row)->selected ? row : NULL;
+      g_signal_emit (box, signals[ROW_SELECTED], 0, priv->selected_row);
     }
   else /* GTK_SELECTION_MULTIPLE */
     {
@@ -1560,6 +1574,7 @@ gtk_list_box_update_selection (GtkListBox    *box,
             {
               gtk_list_box_row_set_selected (row, TRUE);
               priv->selected_row = row;
+              g_signal_emit (box, signals[ROW_SELECTED], 0, row);
             }
           else
             gtk_list_box_select_all_between (box, priv->selected_row, row, FALSE);
@@ -1569,12 +1584,15 @@ gtk_list_box_update_selection (GtkListBox    *box,
           if (modify)
             {
               gtk_list_box_row_set_selected (row, !ROW_PRIV (row)->selected);
+              g_signal_emit (box, signals[ROW_SELECTED], 0, ROW_PRIV (row)->selected ? row
+                                                                                     : NULL);
             }
           else
             {
               gtk_list_box_unselect_all_internal (box);
               gtk_list_box_row_set_selected (row, !ROW_PRIV (row)->selected);
               priv->selected_row = row;
+              g_signal_emit (box, signals[ROW_SELECTED], 0, row);
             }
         }
     }


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