forked from AuroraMiddleware/gtk
a11y: Don't allocate a list just for counting widgets in GtkContainerAccessible
It's more straightforward if counting through gtk_container_foreach().
This commit is contained in:
parent
faa6db8485
commit
89c4ef5873
@ -28,21 +28,24 @@ struct _GtkContainerAccessiblePrivate
|
|||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkContainerAccessible, gtk_container_accessible, GTK_TYPE_WIDGET_ACCESSIBLE)
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkContainerAccessible, gtk_container_accessible, GTK_TYPE_WIDGET_ACCESSIBLE)
|
||||||
|
|
||||||
|
static void
|
||||||
|
count_widget (GtkWidget *widget,
|
||||||
|
gint *count)
|
||||||
|
{
|
||||||
|
(*count)++;
|
||||||
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
gtk_container_accessible_get_n_children (AtkObject* obj)
|
gtk_container_accessible_get_n_children (AtkObject* obj)
|
||||||
{
|
{
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GList *children;
|
|
||||||
gint count = 0;
|
gint count = 0;
|
||||||
|
|
||||||
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
|
||||||
if (widget == NULL)
|
if (widget == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
children = gtk_container_get_children (GTK_CONTAINER (widget));
|
gtk_container_foreach (GTK_CONTAINER (widget), (GtkCallback) count_widget, &count);
|
||||||
count = g_list_length (children);
|
|
||||||
g_list_free (children);
|
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user