[nautilus/wip/antoniof/new-view-event-bugfixes: 3/3] list-base: Fix extending seletion after going to parent




commit 13f5eb18cd1c31d23afd746ef65a8ff2ca0d7329
Author: António Fernandes <antoniof gnome org>
Date:   Wed Jun 22 11:23:46 2022 +0100

    list-base: Fix extending seletion after going to parent
    
    When going to parent, the previous location is selected and focused,
    but using Shift + arrow keys to extend selection has unexpected
    results: it assumes the last item is the start of the selection
    range.
    
    There is probably a GtkListBase bug underneath, but let's add a hack
    to fix the symptom for the time being.
    
    Closes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2294

 src/nautilus-list-base.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-list-base.c b/src/nautilus-list-base.c
index fa2707470..f05a1f1f0 100644
--- a/src/nautilus-list-base.c
+++ b/src/nautilus-list-base.c
@@ -682,13 +682,23 @@ real_set_selection (NautilusFilesView *files_view,
     if (!g_queue_is_empty (selection_items))
     {
         NautilusViewItem *item = g_queue_peek_head (selection_items);
-        GtkWidget *parent = gtk_widget_get_parent (nautilus_view_item_get_item_ui (item));
+        GtkWidget *item_widget = nautilus_view_item_get_item_ui (item);
+        GtkWidget *parent = gtk_widget_get_parent (item_widget);
 
         if (!gtk_widget_grab_focus (parent))
         {
             /* In GtkColumnView, the parent is a cell; its parent is the row. */
             gtk_widget_grab_focus (gtk_widget_get_parent (parent));
         }
+
+        /* HACK: Grabbing focus is not enough for the listbase item tracker to
+         * acknowledge it. So, poke the internal actions to fix the bug reported
+         * in https://gitlab.gnome.org/GNOME/nautilus/-/issues/2294 */
+        gtk_widget_activate_action (item_widget,
+                                    "list.select-item",
+                                    "(ubb)",
+                                    nautilus_view_model_get_index (priv->model, item),
+                                    FALSE, FALSE);
     }
 
     gtk_bitset_union (update_set, selection_set);


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