aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
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
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')
-rw-r--r--e-util/e-activity-bar.c2
-rw-r--r--e-util/e-activity-proxy.c2
-rw-r--r--e-util/e-buffer-tagger.c2
-rw-r--r--e-util/e-category-completion.c11
-rw-r--r--e-util/e-misc-utils.c65
-rw-r--r--e-util/e-misc-utils.h3
-rw-r--r--e-util/e-table-group-leaf.c6
-rw-r--r--e-util/e-table-group-leaf.h2
-rw-r--r--e-util/e-tree.c4
9 files changed, 86 insertions, 11 deletions
diff --git a/e-util/e-activity-bar.c b/e-util/e-activity-bar.c
index f90e51df94..795ece505c 100644
--- a/e-util/e-activity-bar.c
+++ b/e-util/e-activity-bar.c
@@ -389,7 +389,7 @@ e_activity_bar_set_activity (EActivityBar *bar,
G_OBJECT (activity), (GWeakNotify)
activity_bar_weak_notify_cb, bar);
- e_signal_connect_notify_swapped (
+ g_signal_connect_swapped (
activity, "notify::state",
G_CALLBACK (activity_bar_feedback), bar);
diff --git a/e-util/e-activity-proxy.c b/e-util/e-activity-proxy.c
index bb21a5bc8a..f3a452b5af 100644
--- a/e-util/e-activity-proxy.c
+++ b/e-util/e-activity-proxy.c
@@ -362,7 +362,7 @@ e_activity_proxy_set_activity (EActivityProxy *proxy,
G_OBJECT (activity), (GWeakNotify)
activity_proxy_weak_notify_cb, proxy);
- e_signal_connect_notify_swapped (
+ g_signal_connect_swapped (
activity, "notify::state",
G_CALLBACK (activity_proxy_feedback), proxy);
diff --git a/e-util/e-buffer-tagger.c b/e-util/e-buffer-tagger.c
index ccd23dc158..c3c923aa7b 100644
--- a/e-util/e-buffer-tagger.c
+++ b/e-util/e-buffer-tagger.c
@@ -609,7 +609,7 @@ e_buffer_tagger_connect (GtkTextView *textview)
g_signal_connect (
buffer, "delete-range",
G_CALLBACK (buffer_delete_range), NULL);
- e_signal_connect_notify (
+ g_signal_connect (
buffer, "notify::cursor-position",
G_CALLBACK (buffer_cursor_position), NULL);
diff --git a/e-util/e-category-completion.c b/e-util/e-category-completion.c
index 39e26e2edf..8210f72f60 100644
--- a/e-util/e-category-completion.c
+++ b/e-util/e-category-completion.c
@@ -35,6 +35,9 @@ struct _ECategoryCompletionPrivate {
GtkWidget *last_known_entry;
gchar *create;
gchar *prefix;
+
+ gulong notify_cursor_position_id;
+ gulong notify_text_id;
};
enum {
@@ -346,6 +349,8 @@ category_completion_track_entry (GtkEntryCompletion *completion)
g_signal_handlers_disconnect_matched (
priv->last_known_entry, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, completion);
+ e_signal_disconnect_notify_handler (priv->last_known_entry, &priv->notify_cursor_position_id);
+ e_signal_disconnect_notify_handler (priv->last_known_entry, &priv->notify_text_id);
g_object_unref (priv->last_known_entry);
}
@@ -358,11 +363,11 @@ category_completion_track_entry (GtkEntryCompletion *completion)
g_object_ref (priv->last_known_entry);
- e_signal_connect_notify_swapped (
+ priv->notify_cursor_position_id = e_signal_connect_notify_swapped (
priv->last_known_entry, "notify::cursor-position",
G_CALLBACK (category_completion_update_prefix), completion);
- e_signal_connect_notify_swapped (
+ priv->notify_text_id = e_signal_connect_notify_swapped (
priv->last_known_entry, "notify::text",
G_CALLBACK (category_completion_update_prefix), completion);
@@ -417,6 +422,8 @@ category_completion_dispose (GObject *object)
g_signal_handlers_disconnect_matched (
priv->last_known_entry, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, object);
+ e_signal_disconnect_notify_handler (priv->last_known_entry, &priv->notify_cursor_position_id);
+ e_signal_disconnect_notify_handler (priv->last_known_entry, &priv->notify_text_id);
g_object_unref (priv->last_known_entry);
priv->last_known_entry = NULL;
}
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;
+}
diff --git a/e-util/e-misc-utils.h b/e-util/e-misc-utils.h
index 06de228899..ebc860b91e 100644
--- a/e-util/e-misc-utils.h
+++ b/e-util/e-misc-utils.h
@@ -228,6 +228,9 @@ gulong e_signal_connect_notify_object (gpointer instance,
GCallback c_handler,
gpointer gobject,
GConnectFlags connect_flags);
+void e_signal_disconnect_notify_handler
+ (gpointer instance,
+ gulong *handler_id);
G_END_DECLS
diff --git a/e-util/e-table-group-leaf.c b/e-util/e-table-group-leaf.c
index 88ea6b0e8d..ffdb8b94bc 100644
--- a/e-util/e-table-group-leaf.c
+++ b/e-util/e-table-group-leaf.c
@@ -108,9 +108,7 @@ etgl_dispose (GObject *object)
etgl->item,
etgl->etgl_start_drag_id);
- g_signal_handlers_disconnect_by_func (
- etgl->item,
- etgl_item_is_editing_changed_cb, etgl);
+ e_signal_disconnect_notify_handler (etgl->item, &etgl->notify_is_editing_id);
etgl->etgl_cursor_change_id = 0;
etgl->etgl_cursor_activated_id = 0;
@@ -368,7 +366,7 @@ etgl_realize (GnomeCanvasItem *item)
etgl->item, "start_drag",
G_CALLBACK (etgl_start_drag), etgl);
- e_signal_connect_notify (
+ etgl->notify_is_editing_id = e_signal_connect_notify (
etgl->item, "notify::is-editing",
G_CALLBACK (etgl_item_is_editing_changed_cb), etgl);
diff --git a/e-util/e-table-group-leaf.h b/e-util/e-table-group-leaf.h
index e4fcbedee8..c911890829 100644
--- a/e-util/e-table-group-leaf.h
+++ b/e-util/e-table-group-leaf.h
@@ -90,6 +90,8 @@ struct _ETableGroupLeaf {
gint etgl_start_drag_id;
ESelectionModel *selection_model;
+
+ gulong notify_is_editing_id;
};
struct _ETableGroupLeafClass {
diff --git a/e-util/e-tree.c b/e-util/e-tree.c
index 30d20fc4c8..697e88c800 100644
--- a/e-util/e-tree.c
+++ b/e-util/e-tree.c
@@ -1283,7 +1283,7 @@ et_setup_table_canvas_vadjustment (ETree *tree)
if (vadjustment) {
tree->priv->table_canvas_vadjustment = g_object_ref (vadjustment);
- e_signal_connect_notify (
+ g_signal_connect (
vadjustment, "notify::value",
G_CALLBACK (e_tree_table_canvas_scrolled_cb), tree);
}
@@ -1336,7 +1336,7 @@ e_tree_setup_table (ETree *tree)
G_CALLBACK (tree_canvas_reflow), tree);
et_setup_table_canvas_vadjustment (tree);
- e_signal_connect_notify_swapped (
+ g_signal_connect_swapped (
tree->priv->table_canvas, "notify::vadjustment",
G_CALLBACK (et_setup_table_canvas_vadjustment), tree);