listbase: Grab focus on items instead of container
authorAntónio Fernandes <antoniof@gnome.org>
Thu, 15 Sep 2022 00:52:22 +0000 (01:52 +0100)
committerAntónio Fernandes <antoniof@gnome.org>
Fri, 21 Oct 2022 08:03:14 +0000 (08:03 +0000)
commitb86c91de1d2562209093250ddf43f17f7265d539
tree547c774df1e59e87f133e00e2fb13bde98faa9a0
parente87801f7e60ce0543487ebd700640d745f727fdb
listbase: Grab focus on items instead of container

The container view itself being focusable makes keyboard navigation
slower by adding a useless focus step.

It also means if an item gets removed, the focus jumps back to the view,
instead of jumping to the next item, as seen in nautilus bug report:
https://gitlab.gnome.org/GNOME/nautilus/-/issues/2489

Instead of making the GtkListBase container itself focusable, override
the .grab_focus() vfunc. This way, calling gtk_widget_grab_focus() on
the view container keeps working sucessfully, but focuses the focus
item directly instead.

This is particularly useful to have because applicaiton authors do
not have direct acess to this class's children, so they can't call
gtk_widget_grab_focus() on them directly.

(cherry picked from commit 4fc429892086e8bc1c9be94d5184e7eeff518f9c)
gtk/gtklistbase.c