Skip to content
Snippets Groups Projects
Commit c5bf27d4 authored by Alexander Mikhaylenko's avatar Alexander Mikhaylenko
Browse files

header-group: Ref itself instead of header bars

When adding a header bar, ref the header group and connect to 'destroy'
signal of the header bar. When a header bar is destroyed or
hdy_header_group_remove_header_bar() is called, unref the header bar and
remove it from the list.

This way, a non-empty header group is only destroyed after every header
bar it contains has been removed from the group or destroyed.

Fixes #56
parent 14e5fc7b
No related branches found
No related tags found
1 merge request!174header-group: Ref itself instead of header bars
......@@ -127,6 +127,19 @@ update_decoration_layouts (HdyHeaderGroup *self)
gtk_header_bar_set_decoration_layout (end_headerbar, end_layout);
}
static void
header_bar_destroyed (HdyHeaderGroup *self, GtkHeaderBar *header_bar)
{
HdyHeaderGroupPrivate *priv;
g_return_if_fail (HDY_IS_HEADER_GROUP (self));
priv = hdy_header_group_get_instance_private (self);
priv->header_bars = g_slist_remove (priv->header_bars, header_bar);
g_object_unref (self);
}
HdyHeaderGroup *
hdy_header_group_new (void)
{
......@@ -161,7 +174,11 @@ hdy_header_group_add_header_bar (HdyHeaderGroup *self,
g_signal_connect_swapped (header_bar, "map", G_CALLBACK (update_decoration_layouts), self);
g_signal_connect_swapped (header_bar, "unmap", G_CALLBACK (update_decoration_layouts), self);
priv->header_bars = g_slist_prepend (priv->header_bars, g_object_ref_sink (header_bar));
priv->header_bars = g_slist_prepend (priv->header_bars, header_bar);
g_object_ref (self);
g_signal_connect_swapped (header_bar, "destroy", G_CALLBACK (header_bar_destroyed), self);
update_decoration_layouts (self);
}
......@@ -190,7 +207,9 @@ hdy_header_group_remove_header_bar (HdyHeaderGroup *self,
if (priv->focus == header_bar)
hdy_header_group_set_focus (self, NULL);
g_object_unref (header_bar);
g_signal_handlers_disconnect_by_data (header_bar, self);
g_object_unref (self);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment