[glade] GladeEditable: Automatically disconnect to signals when an editor is destroyed.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] GladeEditable: Automatically disconnect to signals when an editor is destroyed.
- Date: Sun, 28 Apr 2013 10:13:58 +0000 (UTC)
commit 6626d36433bd9504879b74f606ff1b04f3166014
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Sun Apr 28 18:46:20 2013 +0900
GladeEditable: Automatically disconnect to signals when an editor is destroyed.
gladeui/glade-editable.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/gladeui/glade-editable.c b/gladeui/glade-editable.c
index d205c39..605b141 100644
--- a/gladeui/glade-editable.c
+++ b/gladeui/glade-editable.c
@@ -39,6 +39,7 @@ G_DEFINE_INTERFACE (GladeEditable, glade_editable, GTK_TYPE_WIDGET);
static GQuark glade_editable_project_quark = 0;
static GQuark glade_editable_widget_quark = 0;
static GQuark glade_editable_loading_quark = 0;
+static GQuark glade_editable_destroy_quark = 0;
static void
project_changed (GladeProject *project,
@@ -61,6 +62,12 @@ project_closed (GladeProject *project,
}
static void
+editable_destroyed (GladeEditable *editable)
+{
+ glade_editable_load (editable, NULL);
+}
+
+static void
glade_editable_load_default (GladeEditable *editable,
GladeWidget *widget)
{
@@ -102,6 +109,7 @@ glade_editable_default_init (GladeEditableIface *iface)
glade_editable_project_quark = g_quark_from_static_string ("glade-editable-project-quark");
glade_editable_widget_quark = g_quark_from_static_string ("glade-editable-widget-quark");
glade_editable_loading_quark = g_quark_from_static_string ("glade-editable-loading-quark");
+ glade_editable_destroy_quark = g_quark_from_static_string ("glade-editable-destroy-quark");
iface->load = glade_editable_load_default;
}
@@ -122,6 +130,15 @@ glade_editable_load (GladeEditable *editable, GladeWidget *widget)
g_return_if_fail (GLADE_IS_EDITABLE (editable));
g_return_if_fail (widget == NULL || GLADE_IS_WIDGET (widget));
+ /* Connect to the destroy signal once, make sure we unload the widget and disconnect
+ * to any signals when destroying
+ */
+ if (!GPOINTER_TO_INT (g_object_get_qdata (G_OBJECT (editable), glade_editable_destroy_quark)))
+ {
+ g_signal_connect (editable, "destroy", G_CALLBACK (editable_destroyed), NULL);
+ g_object_set_qdata (G_OBJECT (editable), glade_editable_destroy_quark, GINT_TO_POINTER (TRUE));
+ }
+
iface = GLADE_EDITABLE_GET_IFACE (editable);
g_object_set_qdata (G_OBJECT (editable), glade_editable_loading_quark, GINT_TO_POINTER (TRUE));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]