app: set keyboard focus to selected item in GimpContainerTreeView.

When the selection changes, the focus must be on one of the selected items. Not
doing this was creating a very annoying behavior where you would select an item
in the tree view with the pointer first, but then when moving up/down with the
keyboard arrow, the move originated from the previously set item. This was
because the arrow move used the "cursor path", i.e. the keyboard focus, and not
the item selection as origin.

In our case, let's make sure these match (i.e. the cursor path is the path of at
least one of the selected items, which is the most expected behavior for mixed
pointer/keyboard interactions).

See code in gtk_tree_view_move_cursor_up_down() from GTK code.
This commit is contained in:
Jehan 2023-10-04 15:12:21 +02:00
parent 68aadf4a27
commit 98f0c44881

View file

@ -934,6 +934,7 @@ gimp_container_tree_view_select_items (GimpContainerView *view,
/* Add to the selection. */
gtk_tree_selection_select_path (tree_view->priv->selection, path->data);
gtk_tree_view_set_cursor (tree_view->view, path->data, NULL, FALSE);
}
g_signal_handlers_unblock_by_func (tree_view->priv->selection,
gimp_container_tree_view_selection_changed,