Compare commits

...

2 Commits

Author SHA1 Message Date
Christopher Davis
022491762c 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.
2021-09-29 16:24:56 -07:00
Christopher Davis
c3b7ca6dcb 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.
2021-09-29 16:22:31 -07:00
4 changed files with 41 additions and 4 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);

View File

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

View File

@@ -178,6 +178,9 @@ void gtk_list_box_insert (GtkListBox
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