Compare commits

...

1 Commits

Author SHA1 Message Date
Matthias Clasen
b76b7e5cac Add a getter for the number of children
Having this api will let us optimize things later.
For now, just iterate over the children.
2017-08-22 14:18:15 -04:00
3 changed files with 25 additions and 0 deletions

View File

@@ -4631,6 +4631,7 @@ gtk_widget_get_next_sibling
gtk_widget_get_prev_sibling
gtk_widget_get_first_child
gtk_widget_get_last_child
gtk_widget_get_n_children
gtk_widget_insert_before
gtk_widget_insert_after

View File

@@ -15306,6 +15306,28 @@ gtk_widget_get_last_child (GtkWidget *widget)
return widget->priv->last_child;
}
/**
* gtk_widget_get_n_children:
* @widget: a #GtkWidget
*
* Returns: the number of children
*
* Since: 3.92
*/
guint
gtk_widget_get_n_children (GtkWidget *widget)
{
guint n = 0;
GtkWidget *child;
for (child = gtk_widget_get_first_child (widget);
child != NULL;
child = gtk-widget_get_next_sibling (child))
n++;
return n;
}
/**
* gtk_widget_get_next_sibling:
* @widget: a #GtkWidget

View File

@@ -1170,6 +1170,8 @@ GDK_AVAILABLE_IN_3_90
GtkWidget * gtk_widget_get_first_child (GtkWidget *widget);
GDK_AVAILABLE_IN_3_90
GtkWidget * gtk_widget_get_last_child (GtkWidget *widget);
GDK_AVAILABLE_IN_3_92
guint gtk_widget_get_n_children (GtkWidget *widget);
GDK_AVAILABLE_IN_3_90
GtkWidget * gtk_widget_get_next_sibling (GtkWidget *widget);
GDK_AVAILABLE_IN_3_90