[gtk/wip/cdavis/remove-all-funcs] gtkflowbox: Add remove_all()
- From: Christopher Davis <christopherdavis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/cdavis/remove-all-funcs] gtkflowbox: Add remove_all()
- Date: Wed, 29 Sep 2021 23:20:30 +0000 (UTC)
commit da17c8e07f6875a178832a845e818ab4e1836717
Author: Christopher Davis <christopherdavis gnome org>
Date: Wed Sep 29 15:20:37 2021 -0700
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.
gtk/gtkflowbox.c | 18 ++++++++++++++++++
gtk/gtkflowbox.h | 3 +++
2 files changed, 21 insertions(+)
---
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index 188b76c562..bdde833ccc 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -3073,6 +3073,7 @@ gtk_flow_box_remove (GtkFlowBox *box,
if (child == priv->active_child)
priv->active_child = NULL;
if (child == priv->selected_child)
+ GtkWidget *child;
priv->selected_child = NULL;
g_sequence_remove (CHILD_PRIV (child)->iter);
@@ -3085,6 +3086,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
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]