[nautilus/wip/antoniof/flowbox-to-gridview] view-icon-controller: Prevent spontaneous scrolling when loading



commit 7e960ab84cc61d15b3443ed25b6a30bae8b4a666
Author: António Fernandes <antoniof gnome org>
Date:   Wed Feb 2 19:31:00 2022 +0000

    view-icon-controller: Prevent spontaneous scrolling when loading
    
    When loading a directory with many files, GtkGridView keeps scrolling
    down spontaneously.
    
    This happens because GtkListBase anchoring doesn't cope well with our
    lazy loading.
    
    Use a hacky workaround to prevent scrolling while we are at the top.

 src/nautilus-view-icon-controller.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index c96193fa5..a170f5e27 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -1107,6 +1107,14 @@ real_add_files (NautilusFilesView *files_view,
     files_queue = convert_glist_to_queue (files);
     item_models = convert_files_to_item_models (self, files_queue);
     nautilus_view_model_add_items (self->model, item_models);
+
+    /* GtkListBase anchoring doesn't cope well with our lazy loading.
+     * Assuming that GtkListBase|list.scroll-to-item resets the anchor to 0, use
+     * that as a workaround to prevent scrolling while we are at the top. */
+    if (gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (self->view_ui))) == 0)
+    {
+        gtk_widget_activate_action (GTK_WIDGET (self->view_ui), "list.scroll-to-item", "u", 0);
+    }
 }
 
 


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