[nautilus/wip/antoniof/new-list-view-without-expanders: 16/17] files-view-model: Focus selection when setting it
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/new-list-view-without-expanders: 16/17] files-view-model: Focus selection when setting it
- Date: Fri, 3 Jun 2022 17:03:27 +0000 (UTC)
commit 19b4dc0dfd9e4520d2b31c4f0a66b6d0839f18db
Author: António Fernandes <antoniof gnome org>
Date: Fri Jun 3 10:53:13 2022 +0100
files-view-model: Focus selection when setting it
In all cases when we set selection, we also want to set focus.
Otherwise, moving the focus is going to disrupt user workflow.
Solution based on Corey Berla's review suggestion.
Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2087
src/nautilus-files-model-view.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
---
diff --git a/src/nautilus-files-model-view.c b/src/nautilus-files-model-view.c
index 2da90855d..73b2b033b 100644
--- a/src/nautilus-files-model-view.c
+++ b/src/nautilus-files-model-view.c
@@ -376,6 +376,18 @@ real_set_selection (NautilusFilesView *files_view,
nautilus_view_model_get_index (priv->model, l->data));
}
+ /* Set focus on the first selected item. */
+ if (!g_queue_is_empty (selection_item_models))
+ {
+ NautilusViewItemModel *item = g_queue_peek_head (selection_item_models);
+ GtkWidget *parent = gtk_widget_get_parent (nautilus_view_item_model_get_item_ui (item));
+
+ while (!gtk_widget_grab_focus (parent))
+ {
+ parent = gtk_widget_get_parent (parent);
+ }
+ }
+
gtk_bitset_union (update_set, selection_set);
gtk_selection_model_set_selection (GTK_SELECTION_MODEL (priv->model),
selection_set,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]