summaryrefslogtreecommitdiff
path: root/gtk/a11y
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2014-03-10 15:15:37 +0100
committerCarlos Garnacho <carlosg@gnome.org>2014-03-10 23:02:41 +0100
commit89c4ef5873a8949a6986cc450d61fbaf707f7654 (patch)
tree331c3214a132c91695f1aa87e94bb03812ee3eb8 /gtk/a11y
parentfaa6db84850bfb11cf75b9c433a1a99740f390de (diff)
downloadgtk+-89c4ef5873a8949a6986cc450d61fbaf707f7654.tar.gz
a11y: Don't allocate a list just for counting widgets in GtkContainerAccessible
It's more straightforward if counting through gtk_container_foreach().
Diffstat (limited to 'gtk/a11y')
-rw-r--r--gtk/a11y/gtkcontaineraccessible.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/gtk/a11y/gtkcontaineraccessible.c b/gtk/a11y/gtkcontaineraccessible.c
index 3db0165b2b..98e5554319 100644
--- a/gtk/a11y/gtkcontaineraccessible.c
+++ b/gtk/a11y/gtkcontaineraccessible.c
@@ -28,21 +28,24 @@ struct _GtkContainerAccessiblePrivate
G_DEFINE_TYPE_WITH_PRIVATE (GtkContainerAccessible, gtk_container_accessible, GTK_TYPE_WIDGET_ACCESSIBLE)
+static void
+count_widget (GtkWidget *widget,
+ gint *count)
+{
+ (*count)++;
+}
+
static gint
gtk_container_accessible_get_n_children (AtkObject* obj)
{
GtkWidget *widget;
- GList *children;
gint count = 0;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
if (widget == NULL)
return 0;
- children = gtk_container_get_children (GTK_CONTAINER (widget));
- count = g_list_length (children);
- g_list_free (children);
-
+ gtk_container_foreach (GTK_CONTAINER (widget), (GtkCallback) count_widget, &count);
return count;
}