[nautilus/wip/corey/select_first: 32/32] list-base: Set selection directly in select_first
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/corey/select_first: 32/32] list-base: Set selection directly in select_first
- Date: Sat, 17 Sep 2022 08:45:50 +0000 (UTC)
commit b145063343aebfaf98b07735c49c199cf7c6d37a
Author: Corey Berla <corey berla me>
Date: Wed Sep 14 13:53:13 2022 -0700
list-base: Set selection directly in select_first
We used to select the first search result as soon as it arives,
in order to allow keyboard shortcuts to take effect on it. This
makes search more efficient to use with keyboard.
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 f4673b9d3..c1f85e6d1 100644
--- a/src/nautilus-list-base.c
+++ b/src/nautilus-list-base.c
@@ -1506,18 +1506,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]