gtkflowbox: Add remove_all()

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.
This commit is contained in:
Christopher Davis
2021-09-29 15:20:37 -07:00
parent c3b7ca6dcb
commit 022491762c
2 changed files with 20 additions and 0 deletions

View File

@@ -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

View File

@@ -154,6 +154,9 @@ void gtk_flow_box_insert (GtkFlowBox
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);