[gtk/stack-fixes] stack switcher: Stop connecting to GtkStack::destroy
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/stack-fixes] stack switcher: Stop connecting to GtkStack::destroy
- Date: Sun, 10 Feb 2019 00:10:47 +0000 (UTC)
commit 3c60c9237b0b48e60e1540a55bf4ba254a0fb5ce
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Feb 9 19:03:18 2019 -0500
stack switcher: Stop connecting to GtkStack::destroy
No need for this, the model gets emptied, we can just
listen for that.
Also, avoid notification when unsetting the stack in
dispose.
gtk/gtkstackswitcher.c | 53 +++++++++++++++++++++++++++++++-------------------
1 file changed, 33 insertions(+), 20 deletions(-)
---
diff --git a/gtk/gtkstackswitcher.c b/gtk/gtkstackswitcher.c
index 57b4d2725f..e7e8e8353e 100644
--- a/gtk/gtkstackswitcher.c
+++ b/gtk/gtkstackswitcher.c
@@ -410,7 +410,6 @@ disconnect_stack_signals (GtkStackSwitcher *switcher)
g_signal_handlers_disconnect_by_func (priv->pages, items_changed_cb, switcher);
g_signal_handlers_disconnect_by_func (priv->pages, selection_changed_cb, switcher);
- g_signal_handlers_disconnect_by_func (priv->stack, disconnect_stack_signals, switcher);
}
static void
@@ -420,7 +419,35 @@ connect_stack_signals (GtkStackSwitcher *switcher)
g_signal_connect (priv->pages, "items-changed", G_CALLBACK (items_changed_cb), switcher);
g_signal_connect (priv->pages, "selection-changed", G_CALLBACK (selection_changed_cb), switcher);
- g_signal_connect_swapped (priv->stack, "destroy", G_CALLBACK (disconnect_stack_signals), switcher);
+}
+
+static void
+set_stack (GtkStackSwitcher *switcher,
+ GtkStack *stack)
+{
+ GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
+
+ if (stack)
+ {
+ priv->stack = g_object_ref (stack);
+ priv->pages = gtk_stack_get_pages (stack);
+ populate_switcher (switcher);
+ connect_stack_signals (switcher);
+ }
+}
+
+static void
+unset_stack (GtkStackSwitcher *switcher)
+{
+ GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
+
+ if (priv->stack)
+ {
+ disconnect_stack_signals (switcher);
+ clear_switcher (switcher);
+ g_clear_object (&priv->stack);
+ g_clear_object (&priv->pages);
+ }
}
/**
@@ -434,30 +461,16 @@ void
gtk_stack_switcher_set_stack (GtkStackSwitcher *switcher,
GtkStack *stack)
{
- GtkStackSwitcherPrivate *priv;
+ GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
g_return_if_fail (GTK_IS_STACK_SWITCHER (switcher));
g_return_if_fail (GTK_IS_STACK (stack) || stack == NULL);
- priv = gtk_stack_switcher_get_instance_private (switcher);
-
if (priv->stack == stack)
return;
- if (priv->stack)
- {
- disconnect_stack_signals (switcher);
- clear_switcher (switcher);
- g_clear_object (&priv->stack);
- g_clear_object (&priv->pages);
- }
- if (stack)
- {
- priv->stack = g_object_ref (stack);
- priv->pages = gtk_stack_get_pages (stack);
- populate_switcher (switcher);
- connect_stack_signals (switcher);
- }
+ unset_stack (switcher);
+ set_stack (switcher, stack);
gtk_widget_queue_resize (GTK_WIDGET (switcher));
@@ -532,7 +545,7 @@ gtk_stack_switcher_dispose (GObject *object)
GtkStackSwitcher *switcher = GTK_STACK_SWITCHER (object);
remove_switch_timer (switcher);
- gtk_stack_switcher_set_stack (switcher, NULL);
+ unset_stack (switcher);
G_OBJECT_CLASS (gtk_stack_switcher_parent_class)->dispose (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]