Skip to content
Commit 7700c17b authored by António Fernandes's avatar António Fernandes
Browse files

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
parent 47ee9eaf
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment