aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-misc-utils.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2014-06-05 17:47:13 +0800
committerMilan Crha <mcrha@redhat.com>2014-06-05 17:47:13 +0800
commit2e71c861438a25ceac5811d9d3aa528691e71410 (patch)
tree88acf6b67904de4caae1034cebb7c040f3fab804 /e-util/e-misc-utils.c
parent2f3fbdd6c6ff42a6c71ebe1d1d78108affe59d0f (diff)
downloadgsoc2013-evolution-2e71c861438a25ceac5811d9d3aa528691e71410.tar
gsoc2013-evolution-2e71c861438a25ceac5811d9d3aa528691e71410.tar.gz
gsoc2013-evolution-2e71c861438a25ceac5811d9d3aa528691e71410.tar.bz2
gsoc2013-evolution-2e71c861438a25ceac5811d9d3aa528691e71410.tar.lz
gsoc2013-evolution-2e71c861438a25ceac5811d9d3aa528691e71410.tar.xz
gsoc2013-evolution-2e71c861438a25ceac5811d9d3aa528691e71410.tar.zst
gsoc2013-evolution-2e71c861438a25ceac5811d9d3aa528691e71410.zip
Properly disconnect signal handlers added with e_signal_connect_notify*()
This is a follow-up for the previous commit, where e_signal_connect_notify*() functions had been added. Due to a different callback and user data being attached to the 'notify' signal, the g_signal_handlers_*() functions do not work properly, thus these e_signal_connect_notify*() functions need a different way for a signal handler disconnect. A side-change was done in e-settings-web-view-gtkhtml.c, checking for a real key change from GSettings.
Diffstat (limited to 'e-util/e-misc-utils.c')
-rw-r--r--e-util/e-misc-utils.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/e-util/e-misc-utils.c b/e-util/e-misc-utils.c
index f7be7af5ac..510dad39b2 100644
--- a/e-util/e-misc-utils.c
+++ b/e-util/e-misc-utils.c
@@ -2394,6 +2394,16 @@ e_signal_connect_notify_cb (gpointer instance,
}
}
+/**
+ * e_signal_connect_notify:
+ *
+ * This installs a special handler in front of @c_handler, which will
+ * call the @c_handler only if the property value changed since the last
+ * time it was checked. Due to this, these handlers cannot be disconnected
+ * by by any of the g_signal_handlers_* functions, but only with the returned
+ * handler ID. A convenient e_signal_disconnect_notify_handler() was added
+ * to make it easier.
+ **/
gulong
e_signal_connect_notify (gpointer instance,
const gchar *notify_name,
@@ -2414,6 +2424,16 @@ e_signal_connect_notify (gpointer instance,
0);
}
+/**
+ * e_signal_connect_notify_after:
+ *
+ * This installs a special handler in front of @c_handler, which will
+ * call the @c_handler only if the property value changed since the last
+ * time it was checked. Due to this, these handlers cannot be disconnected
+ * by by any of the g_signal_handlers_* functions, but only with the returned
+ * handler ID. A convenient e_signal_disconnect_notify_handler() was added
+ * to make it easier.
+ **/
gulong
e_signal_connect_notify_after (gpointer instance,
const gchar *notify_name,
@@ -2434,6 +2454,16 @@ e_signal_connect_notify_after (gpointer instance,
G_CONNECT_AFTER);
}
+/**
+ * e_signal_connect_notify_swapped:
+ *
+ * This installs a special handler in front of @c_handler, which will
+ * call the @c_handler only if the property value changed since the last
+ * time it was checked. Due to this, these handlers cannot be disconnected
+ * by by any of the g_signal_handlers_* functions, but only with the returned
+ * handler ID. A convenient e_signal_disconnect_notify_handler() was added
+ * to make it easier.
+ **/
gulong
e_signal_connect_notify_swapped (gpointer instance,
const gchar *notify_name,
@@ -2454,6 +2484,16 @@ e_signal_connect_notify_swapped (gpointer instance,
0);
}
+/**
+ * e_signal_connect_notify_object:
+ *
+ * This installs a special handler in front of @c_handler, which will
+ * call the @c_handler only if the property value changed since the last
+ * time it was checked. Due to this, these handlers cannot be disconnected
+ * by by any of the g_signal_handlers_* functions, but only with the returned
+ * handler ID. A convenient e_signal_disconnect_notify_handler() was added
+ * to make it easier.
+ **/
gulong
e_signal_connect_notify_object (gpointer instance,
const gchar *notify_name,
@@ -2492,3 +2532,28 @@ e_signal_connect_notify_object (gpointer instance,
closure,
connect_flags & G_CONNECT_AFTER);
}
+
+/**
+ * e_signal_disconnect_notify_handler:
+ *
+ * Convenient handler disconnect function to be used with
+ * returned handler IDs from:
+ * e_signal_connect_notify()
+ * e_signal_connect_notify_after()
+ * e_signal_connect_notify_swapped()
+ * e_signal_connect_notify_object()
+ * but not necessarily only with these functions.
+ **/
+void
+e_signal_disconnect_notify_handler (gpointer instance,
+ gulong *handler_id)
+{
+ g_return_if_fail (instance != NULL);
+ g_return_if_fail (handler_id != NULL);
+
+ if (!*handler_id)
+ return;
+
+ g_signal_handler_disconnect (instance, *handler_id);
+ *handler_id = 0;
+}