Merge branch 'wip/antoniof/backport-list-focus' into 'gtk-4-8'

Backport MR !5023 to 4.8

See merge request GNOME/gtk!5157
This commit is contained in:
Matthias Clasen 2022-10-21 17:34:35 +00:00
commit 070926a4cc
2 changed files with 17 additions and 1 deletions

View File

@ -659,6 +659,8 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gpointer iface;
widget_class->focus = gtk_widget_focus_child;
widget_class->grab_focus = gtk_widget_grab_focus_child;
widget_class->measure = gtk_column_view_measure;
widget_class->size_allocate = gtk_column_view_allocate;
@ -1314,7 +1316,6 @@ gtk_column_view_init (GtkColumnView *self)
g_quark_from_static_string (I_("view")));
gtk_widget_set_overflow (GTK_WIDGET (self), GTK_OVERFLOW_HIDDEN);
gtk_widget_set_focusable (GTK_WIDGET (self), TRUE);
self->reorderable = TRUE;
}

View File

@ -569,6 +569,20 @@ gtk_list_base_focus (GtkWidget *widget,
return gtk_widget_child_focus (item->widget, direction);
}
static gboolean
gtk_list_base_grab_focus (GtkWidget *widget)
{
GtkListBase *self = GTK_LIST_BASE (widget);
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
guint pos;
pos = gtk_list_item_tracker_get_position (priv->item_manager, priv->focus);
if (gtk_list_base_grab_focus_on_item (self, pos, FALSE, FALSE, FALSE))
return TRUE;
return GTK_WIDGET_CLASS (gtk_list_base_parent_class)->grab_focus (widget);
}
static void
gtk_list_base_dispose (GObject *object)
{
@ -1120,6 +1134,7 @@ gtk_list_base_class_init (GtkListBaseClass *klass)
gpointer iface;
widget_class->focus = gtk_list_base_focus;
widget_class->grab_focus = gtk_list_base_grab_focus;
gobject_class->dispose = gtk_list_base_dispose;
gobject_class->get_property = gtk_list_base_get_property;