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>
Mon, 3 Oct 2022 19:26:24 +0000 (20:26 +0100)
commit4fc429892086e8bc1c9be94d5184e7eeff518f9c
treef1b86462a8dac8444228f3a2e6e3360e7e781271
parent1b4ed005091c0c0fd3ca387f9f12890b72e1893c
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.
gtk/gtklistbase.c