[nautilus/wip/antoniof/new-list-view-continuation: 1/32] view-model: Always notify selection changes




commit 0e6d54b56fe3a12430444aff415366d589df262d
Author: António Fernandes <antoniof gnome org>
Date:   Thu Feb 10 12:47:32 2022 +0000

    view-model: Always notify selection changes
    
    Sometimes selection changes are not notified, which causes regressions:
    
      * `nautilus --select /path/to/file` fails to select file
      * going to parent folder fails to select child folder we came from
    
    As we implement GtkSelectionModel ourselves, we can and should notify
    these changes even if the internal GtkMultiSelection doesn't.

 src/nautilus-view-model.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-view-model.c b/src/nautilus-view-model.c
index 925e6208c..4c5d15011 100644
--- a/src/nautilus-view-model.c
+++ b/src/nautilus-view-model.c
@@ -82,8 +82,20 @@ nautilus_view_model_set_selection (GtkSelectionModel *model,
 {
     NautilusViewModel *self = NAUTILUS_VIEW_MODEL (model);
     GtkSelectionModel *selection_model = GTK_SELECTION_MODEL (self->selection_model);
+    gboolean res;
 
-    return gtk_selection_model_set_selection (selection_model, selected, mask);
+    res = gtk_selection_model_set_selection (selection_model, selected, mask);
+    if (res)
+    {
+        guint min = gtk_bitset_get_minimum (mask);
+        guint max = gtk_bitset_get_maximum (mask);
+
+        if (min <= max)
+        {
+            gtk_selection_model_selection_changed (selection_model, min, max - min + 1);
+        }
+    }
+    return res;
 }
 
 


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