headerbar: Add gtk_header_bar_remove

This is a replacement for gtk_container_remove.
This commit is contained in:
Matthias Clasen 2020-05-08 09:19:21 -04:00
parent 3d100abea8
commit d59d9d4bd5
3 changed files with 21 additions and 10 deletions

View File

@ -5597,6 +5597,7 @@ gtk_header_bar_set_title_widget
gtk_header_bar_get_title_widget
gtk_header_bar_pack_start
gtk_header_bar_pack_end
gtk_header_bar_remove
gtk_header_bar_set_show_title_buttons
gtk_header_bar_get_show_title_buttons
gtk_header_bar_set_decoration_layout

View File

@ -495,31 +495,38 @@ gtk_header_bar_add (GtkContainer *container,
gtk_header_bar_pack (GTK_HEADER_BAR (container), child, GTK_PACK_START);
}
static void
gtk_header_bar_remove (GtkContainer *container,
GtkWidget *widget)
/**
* gtk_header_bar_remove:
* @bar: a #GtkHeaderBar
* @child: the child to remove
*
* Removes a child from @bar, after it has been added
* with gtk_header_bar_pack_start(), gtk_header_bar_pack_end()
* or gtk_header_bar_set_title_widget().
*/
void
gtk_header_bar_remove (GtkHeaderBar *bar,
GtkWidget *child)
{
GtkHeaderBar *bar = GTK_HEADER_BAR (container);
GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
GtkWidget *parent;
gboolean removed = FALSE;
parent = gtk_widget_get_parent (widget);
parent = gtk_widget_get_parent (child);
if (parent == priv->start_box)
{
gtk_container_remove (GTK_CONTAINER (priv->start_box), widget);
gtk_container_remove (GTK_CONTAINER (priv->start_box), child);
removed = TRUE;
}
else if (parent == priv->end_box)
{
gtk_container_remove (GTK_CONTAINER (priv->end_box), widget);
gtk_container_remove (GTK_CONTAINER (priv->end_box), child);
removed = TRUE;
}
else if (parent == GTK_WIDGET (container) &&
gtk_center_box_get_center_widget (GTK_CENTER_BOX (priv->center_box)) == widget)
else if (parent == priv->center_box)
{
gtk_widget_unparent (widget);
gtk_center_box_set_center_widget (GTK_CENTER_BOX (priv->center_box), NULL);
removed = TRUE;
}

View File

@ -50,6 +50,9 @@ void gtk_header_bar_pack_start (GtkHeaderBar *bar,
GDK_AVAILABLE_IN_ALL
void gtk_header_bar_pack_end (GtkHeaderBar *bar,
GtkWidget *child);
GDK_AVAILABLE_IN_ALL
void gtk_header_bar_remove (GtkHeaderBar *bar,
GtkWidget *child);
GDK_AVAILABLE_IN_ALL
gboolean gtk_header_bar_get_show_title_buttons (GtkHeaderBar *bar);