listbase: Select via action
authorBenjamin Otte <otte@redhat.com>
Wed, 29 Mar 2023 04:01:26 +0000 (06:01 +0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 29 Mar 2023 08:42:49 +0000 (10:42 +0200)
Instead of directly calling select_item(), trigger the select-item
action of the focused child.

We do this convoluted calling into the widget because that way
GtkListItem::selectable gets respected, which is what one would expect.

Plus, this code is usually triggered via keybindings, and this way the
ListBase keybindings work identical to the ListItem keybindings.

gtk/gtklistbase.c

index 33161454842658f0ee31d8c8ccc8ee228570d72a..c0e24482791f7ddc8617bbffbab62b4a256f7790 100644 (file)
@@ -499,7 +499,15 @@ gtk_list_base_grab_focus_on_item (GtkListBase *self,
     return FALSE;
 
   if (select)
-    gtk_list_base_select_item (self, pos, modify, extend);
+    {
+      tile = gtk_list_item_manager_get_nth (priv->item_manager, pos, NULL);
+
+      /* We do this convoluted calling into the widget because that way
+       * GtkListItem::selectable gets respected, which is what one would expect.
+       */
+      g_assert (tile->widget);
+      gtk_widget_activate_action (tile->widget, "listitem.select", "(bb)", modify, extend);
+    }
 
   return TRUE;
 }