diff options
author | Christopher Davis <christopherdavis@gnome.org> | 2021-09-29 14:26:49 -0700 |
---|---|---|
committer | Christopher Davis <christopherdavis@gnome.org> | 2021-09-29 16:22:31 -0700 |
commit | c3b7ca6dcb93c16c998153a7bca2459d00bc18ef (patch) | |
tree | 55a742d249dd072580ba369609b81166c8838f85 | |
parent | 502b3ceaa29663f70801920077bceaf4138b56d3 (diff) | |
download | gtk+-c3b7ca6dcb93c16c998153a7bca2459d00bc18ef.tar.gz |
gtklistbox: Add remove_all()
Adds a function to remove all children from
a GtkListBox. This way app developers don't need to
implement this themselves.
-rw-r--r-- | gtk/gtklistbox.c | 22 | ||||
-rw-r--r-- | gtk/gtklistbox.h | 3 |
2 files changed, 21 insertions, 4 deletions
diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c index 95120f8cef..5013f2210c 100644 --- a/gtk/gtklistbox.c +++ b/gtk/gtklistbox.c @@ -431,10 +431,7 @@ gtk_list_box_set_property (GObject *obj, static void gtk_list_box_dispose (GObject *object) { - GtkWidget *child; - - while ((child = gtk_widget_get_first_child (GTK_WIDGET (object)))) - gtk_list_box_remove (GTK_LIST_BOX (object), child); + gtk_list_box_remove_all (GTK_LIST_BOX (object)); G_OBJECT_CLASS (gtk_list_box_parent_class)->dispose (object); } @@ -2428,6 +2425,23 @@ gtk_list_box_remove (GtkListBox *box, } } +/** + * gtk_list_box_remove_all: + * @box: a `GtkListBox` + * + * Removes all rows from @box. + */ +void +gtk_list_box_remove_all (GtkListBox *box) +{ + GtkWidget *child; + + g_return_if_fail (GTK_IS_LIST_BOX (box)); + + while ((child = gtk_widget_get_first_child (GTK_WIDGET (box)))) + gtk_list_box_remove (box, child); +} + static void gtk_list_box_compute_expand (GtkWidget *widget, gboolean *hexpand_p, diff --git a/gtk/gtklistbox.h b/gtk/gtklistbox.h index 0e41498bda..f14a30fbe3 100644 --- a/gtk/gtklistbox.h +++ b/gtk/gtklistbox.h @@ -179,6 +179,9 @@ GDK_AVAILABLE_IN_ALL void gtk_list_box_remove (GtkListBox *box, GtkWidget *child); GDK_AVAILABLE_IN_ALL +void gtk_list_box_remove_all (GtkListBox *box); + +GDK_AVAILABLE_IN_ALL GtkListBoxRow* gtk_list_box_get_selected_row (GtkListBox *box); GDK_AVAILABLE_IN_ALL GtkListBoxRow* gtk_list_box_get_row_at_index (GtkListBox *box, |