summaryrefslogtreecommitdiff
path: root/src/nautilus-files-view.c
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2022-09-02 17:15:28 +0100
committerAntónio Fernandes <antoniof@gnome.org>2022-09-02 17:15:28 +0100
commit7700c17bb373c284603c0c4289b95428dc0bba2d (patch)
treeac1858ab17b3ba0bf1241f272d5c3a5faacbe33c /src/nautilus-files-view.c
parent47ee9eaf5404162e517f37d096f16eee077c7d3d (diff)
downloadnautilus-7700c17bb373c284603c0c4289b95428dc0bba2d.tar.gz
files-view: Add files in right order
When populating a GList in a loop, we should use prepend() for best performance, then flip it around once with reverse(). The list of pending additions to files view lacks the second part. This used to be compensated for by the old views: * NautilusCanvasView, through NautilusCanvasContainer, would iterate this list to populate its own list with prepend(), effectively reversing the order, as was necessary. * NautilusListView, through NautilusListModel, would iterate this list to populate its own list with insert_sorted(), once again fixing the loading order. The new view don't do that, and have no reason to because they don't have their own GLists (instead, they manage GListModels). But this means that the item which should be added last actually is added first. GtkListBase treats the first added item as the initial focus and as scroll anchor. The end result is that the view always scrolls to the bottom and, on keyboard focus, the last item is selected first. The first issue (view always scrolls to the bottom) has been worked around with a hack, but the second one persists. Therefore, lets just reverse the list right after it is built. This way, the first added item is the one actual first item. It gets initial keyboard focus and anchors the view to the top (allowing to remove the workaround). Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2353
Diffstat (limited to 'src/nautilus-files-view.c')
-rw-r--r--src/nautilus-files-view.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index f0d38b4ea..f19fab712 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -4342,6 +4342,7 @@ process_old_files (NautilusFilesView *view)
GUINT_TO_POINTER (TRUE));
}
}
+ pending_additions = g_list_reverse (pending_additions);
if (files_added != NULL)
{