aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-10-04 17:59:10 +0100
committerTed Gould <ted@gould.cx>2011-10-04 17:59:10 +0100
commit1da8653f7745fd81acd89ab6422160235264be81 (patch)
treeea2d9893540f1b87ee34dced355e020b7382c411
parent1e2a29f24c3f28fd4d7e22ee6f0e873fbcf47e4a (diff)
downloadlibdbusmenu-1da8653f7745fd81acd89ab6422160235264be81.tar.gz
libdbusmenu-1da8653f7745fd81acd89ab6422160235264be81.tar.bz2
libdbusmenu-1da8653f7745fd81acd89ab6422160235264be81.zip
Respond to the 'FindServers' signal
-rw-r--r--libdbusmenu-glib/server.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c
index 9c085f7..4890d37 100644
--- a/libdbusmenu-glib/server.c
+++ b/libdbusmenu-glib/server.c
@@ -54,6 +54,7 @@ struct _DbusmenuServerPrivate
guint layout_idle;
GDBusConnection * bus;
+ guint find_server_signal;
GCancellable * bus_lookup;
guint dbus_registration;
@@ -191,6 +192,14 @@ static void bus_event (DbusmenuServer * server,
static void bus_about_to_show (DbusmenuServer * server,
GVariant * params,
GDBusMethodInvocation * invocation);
+static void find_servers_cb (GDBusConnection * connection,
+ const gchar * sender,
+ const gchar * path,
+ const gchar * interface,
+ const gchar * signal,
+ GVariant * params,
+ gpointer user_data);
+static gboolean layout_update_idle (gpointer user_data);
/* Globals */
static GDBusNodeInfo * dbusmenu_node_info = NULL;
@@ -366,6 +375,7 @@ dbusmenu_server_init (DbusmenuServer *self)
priv->layout_idle = 0;
priv->bus = NULL;
priv->bus_lookup = NULL;
+ priv->find_server_signal = 0;
priv->dbus_registration = 0;
default_text_direction(self);
@@ -405,6 +415,11 @@ dbusmenu_server_dispose (GObject *object)
priv->dbus_registration = 0;
}
+ if (priv->find_server_signal != 0) {
+ g_dbus_connection_signal_unsubscribe(priv->bus, priv->find_server_signal);
+ priv->find_server_signal = 0;
+ }
+
if (priv->bus != NULL) {
g_object_unref(priv->bus);
priv->bus = NULL;
@@ -706,12 +721,32 @@ bus_got_cb (GObject * obj, GAsyncResult * result, gpointer user_data)
DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(user_data);
priv->bus = bus;
+ priv->find_server_signal = g_dbus_connection_signal_subscribe(priv->bus,
+ NULL, /* sender */
+ "com.canonical.dbusmenu", /* interface */
+ "FindServers", /* member */
+ NULL, /* object path */
+ NULL, /* arg0 */
+ G_DBUS_SIGNAL_FLAGS_NONE, /* flags */
+ find_servers_cb, /* cb */
+ user_data, /* data */
+ NULL); /* free func */
+
register_object(DBUSMENU_SERVER(user_data));
g_object_unref(G_OBJECT(user_data));
return;
}
+/* Respond to the find servers signal by sending an update
+ to the bus */
+static void
+find_servers_cb (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * signal, GVariant * params, gpointer user_data)
+{
+ layout_update_idle(user_data);
+ return;
+}
+
/* Function for the GDBus vtable to handle all method calls and dish
them out the appropriate functions */
static void