[nautilus/wip/corey/select_first] list-base: Set selection directly in select_first




commit 7930a7c77bb0db3091fddf877a5eb3fb12a909dd
Author: Corey Berla <corey berla me>
Date:   Wed Sep 14 13:53:13 2022 -0700

    list-base: Set selection directly in select_first
    
    Prior to the gtk4 port (and the introduction of list-base,
    canvas view and list view set the selection directly in `select_first`
    through `icon_set_selected` and `gtk_tree_selection_select_iter`.
    
    After the port to gtk4, list-base used the existing function
    `nautilus_view_set_selection` which seemed to work, except
    `nautilus_files_view_set_selection` only actually sets the selection
    when the view is not loading.  In the meantime, it puts the selection
    is a pending_selection to be set when the loading is complete.
    
    This causes problems for search because loading generally takes
    longer to complete in a search, and the user will have to wait
    until the search is complete for the item to be selected.
    As a matter of fact, the *only* time that select_first is used
    is during a search (which was the original intention of the function
    when introduced in 50711e28ba4d4c971a812a0bdef0c30516141f4e).
    
    There's no need to add further complexity, beyond what the
    GtkSelectionModel already provides.  Just as `real_select_all`
    simples calls `gtk_selection_model_select_all`, make
    `real_select_first` call `gtk_selection_model_select_item`.
    
    Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2481

 src/nautilus-list-base.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
---
diff --git a/src/nautilus-list-base.c b/src/nautilus-list-base.c
index af063e99b..d1ae0889c 100644
--- a/src/nautilus-list-base.c
+++ b/src/nautilus-list-base.c
@@ -1498,18 +1498,8 @@ real_select_first (NautilusFilesView *files_view)
 {
     NautilusListBase *self = NAUTILUS_LIST_BASE (files_view);
     NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
-    g_autoptr (NautilusViewItem) item = NULL;
-    NautilusFile *file;
-    g_autoptr (GList) selection = NULL;
 
-    item = get_view_item (G_LIST_MODEL (priv->model), 0);
-    if (item == NULL)
-    {
-        return;
-    }
-    file = nautilus_view_item_get_file (item);
-    selection = g_list_prepend (selection, file);
-    nautilus_view_set_selection (NAUTILUS_VIEW (files_view), selection);
+    gtk_selection_model_select_item (GTK_SELECTION_MODEL (priv->model), 0, TRUE);
 }
 
 static GdkRectangle *


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