diff options
author | Christopher Davis <christopherdavis@gnome.org> | 2021-09-29 15:20:37 -0700 |
---|---|---|
committer | Christopher Davis <christopherdavis@gnome.org> | 2021-09-29 16:24:56 -0700 |
commit | 022491762c726180407e97447fdec4d0dd66143b (patch) | |
tree | 4e9353ea5343d8ef06921bb33cce4049884403ad | |
parent | c3b7ca6dcb93c16c998153a7bca2459d00bc18ef (diff) | |
download | gtk+-wip/cdavis/remove-all-funcs.tar.gz |
gtkflowbox: Add remove_all()wip/cdavis/remove-all-funcs
Removing all items from containers is a common use case.
Without this applications needed to implement this manually.
It makes senses to handle it here.
-rw-r--r-- | gtk/gtkflowbox.c | 17 | ||||
-rw-r--r-- | gtk/gtkflowbox.h | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c index 188b76c562..8b281b860c 100644 --- a/gtk/gtkflowbox.c +++ b/gtk/gtkflowbox.c @@ -3085,6 +3085,23 @@ gtk_flow_box_remove (GtkFlowBox *box, g_signal_emit (box, signals[SELECTED_CHILDREN_CHANGED], 0); } +/** + * gtk_flow_box_remove_all: + * @box: a `GtkFlowBox` + * + * Removes all children from @box. + */ +void +gtk_flow_box_remove_all (GtkFlowBox *box) +{ + GtkWidget *child; + + g_return_if_fail (GTK_IS_FLOW_BOX (box)); + + while ((child = gtk_widget_get_first_child (GTK_WIDGET (box)))) + gtk_flow_box_remove (box, child); +} + /* Keynav {{{2 */ static gboolean diff --git a/gtk/gtkflowbox.h b/gtk/gtkflowbox.h index 3625d18ddf..2283138206 100644 --- a/gtk/gtkflowbox.h +++ b/gtk/gtkflowbox.h @@ -155,6 +155,9 @@ GDK_AVAILABLE_IN_ALL void gtk_flow_box_remove (GtkFlowBox *box, GtkWidget *widget); GDK_AVAILABLE_IN_ALL +void gtk_flow_box_remove_all (GtkFlowBox *box); + +GDK_AVAILABLE_IN_ALL GtkFlowBoxChild *gtk_flow_box_get_child_at_index (GtkFlowBox *box, int idx); |