[gtk/listitemmanager-selection] listitemmanager: Handle selection-changes properly



commit 71c29bfcff1f65b156250806e3b3520db8acabad
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 6 08:34:46 2020 -0400

    listitemmanager: Handle selection-changes properly
    
    The selection model will only emit one of items-changed
    or selection-changed, so when we handle an items-changed,
    we must assume that selection state may have changed for
    any of the newly added items.
    
    This fixes lingering selection state in the visible range
    if you change the sorting of the colors demo.
    
    Fixes: #2827

 gtk/gtklistitemmanager.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/gtk/gtklistitemmanager.c b/gtk/gtklistitemmanager.c
index ef0570d45a..e08592bca8 100644
--- a/gtk/gtklistitemmanager.c
+++ b/gtk/gtklistitemmanager.c
@@ -395,6 +395,7 @@ gtk_list_item_manager_add_items (GtkListItemManager *self,
 
   if (item == NULL || item->widget)
     item = gtk_rb_tree_insert_before (self->items, item);
+
   item->n_items += n_items;
   gtk_rb_tree_node_mark_dirty (item);
 
@@ -569,6 +570,12 @@ gtk_list_item_manager_ensure_items (GtkListItemManager *self,
     gtk_list_item_manager_release_list_item (self, NULL, widget);
 }
 
+static void
+gtk_list_item_manager_model_selection_changed_cb (GListModel         *model,
+                                                  guint               position,
+                                                  guint               n_items,
+                                                  GtkListItemManager *self);
+
 static void
 gtk_list_item_manager_model_items_changed_cb (GListModel         *model,
                                               guint               position,
@@ -735,6 +742,8 @@ gtk_list_item_manager_model_items_changed_cb (GListModel         *model,
 
   g_hash_table_unref (change);
 
+  gtk_list_item_manager_model_selection_changed_cb (model, position, added, self);
+
   gtk_widget_queue_resize (self->widget);
 }
 


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