aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-02-09 23:12:22 -0600
committerTed Gould <ted@gould.cx>2010-02-09 23:12:22 -0600
commit8b2d9eb519c695b71ca08fd4afb71b086160d8b4 (patch)
treebc0514c7cbd6601e32369316c788b3cc48316171
parentfb1e4ab223f5fd203ac5330a040b8a222bc96ca8 (diff)
downloadlibdbusmenu-8b2d9eb519c695b71ca08fd4afb71b086160d8b4.tar.gz
libdbusmenu-8b2d9eb519c695b71ca08fd4afb71b086160d8b4.tar.bz2
libdbusmenu-8b2d9eb519c695b71ca08fd4afb71b086160d8b4.zip
Storing the handler IDs so that we can easily disconnect the signals later.
-rw-r--r--libdbusmenu-glib/menuitem-proxy.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/libdbusmenu-glib/menuitem-proxy.c b/libdbusmenu-glib/menuitem-proxy.c
index 3bd2684..22d2d61 100644
--- a/libdbusmenu-glib/menuitem-proxy.c
+++ b/libdbusmenu-glib/menuitem-proxy.c
@@ -35,6 +35,10 @@ License version 3 and version 2.1 along with this program. If not, see
typedef struct _DbusmenuMenuitemProxyPrivate DbusmenuMenuitemProxyPrivate;
struct _DbusmenuMenuitemProxyPrivate {
DbusmenuMenuitem * mi;
+ gulong sig_property_changed;
+ gulong sig_child_added;
+ gulong sig_child_removed;
+ gulong sig_child_moved;
};
/* Properties */
@@ -92,6 +96,11 @@ dbusmenu_menuitem_proxy_init (DbusmenuMenuitemProxy *self)
priv->mi = NULL;
+ priv->sig_property_changed = 0;
+ priv->sig_child_added = 0;
+ priv->sig_child_removed = 0;
+ priv->sig_child_moved = 0;
+
return;
}
@@ -213,10 +222,10 @@ add_menuitem (DbusmenuMenuitemProxy * pmi, DbusmenuMenuitem * mi)
g_object_ref(G_OBJECT(priv->mi));
/* Attach signals */
- g_signal_connect(G_OBJECT(priv->mi), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(proxy_item_property_changed), pmi);
- g_signal_connect(G_OBJECT(priv->mi), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(proxy_item_child_added), pmi);
- g_signal_connect(G_OBJECT(priv->mi), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(proxy_item_child_removed), pmi);
- g_signal_connect(G_OBJECT(priv->mi), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(proxy_item_child_moved), pmi);
+ priv->sig_property_changed = g_signal_connect(G_OBJECT(priv->mi), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(proxy_item_property_changed), pmi);
+ priv->sig_child_added = g_signal_connect(G_OBJECT(priv->mi), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(proxy_item_child_added), pmi);
+ priv->sig_child_removed = g_signal_connect(G_OBJECT(priv->mi), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(proxy_item_child_removed), pmi);
+ priv->sig_child_moved = g_signal_connect(G_OBJECT(priv->mi), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(proxy_item_child_moved), pmi);
/* Grab (cache) Properties */
@@ -236,6 +245,18 @@ remove_menuitem (DbusmenuMenuitemProxy * pmi)
}
/* Remove signals */
+ if (priv->sig_property_changed != 0) {
+ g_signal_handler_disconnect(G_OBJECT(priv->mi), priv->sig_property_changed);
+ }
+ if (priv->sig_child_added != 0) {
+ g_signal_handler_disconnect(G_OBJECT(priv->mi), priv->sig_child_added);
+ }
+ if (priv->sig_child_removed != 0) {
+ g_signal_handler_disconnect(G_OBJECT(priv->mi), priv->sig_child_removed);
+ }
+ if (priv->sig_child_moved != 0) {
+ g_signal_handler_disconnect(G_OBJECT(priv->mi), priv->sig_child_moved);
+ }
/* Unref */
g_object_unref(G_OBJECT(priv->mi));