aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-01-26 14:15:02 -0600
committerTed Gould <ted@gould.cx>2012-01-26 14:15:02 -0600
commit95e56adc0d86cfbbc67f04582a230076721276d1 (patch)
tree9c31a8bc3f6884a043f0b5b38151d91f1264b623 /libdbusmenu-glib
parent5bf87433bf05327d57a3816435de4eaa29b4648d (diff)
parentad1f0f82c67b3b17e829ff5f5b8b353f125ace10 (diff)
downloadlibdbusmenu-95e56adc0d86cfbbc67f04582a230076721276d1.tar.gz
libdbusmenu-95e56adc0d86cfbbc67f04582a230076721276d1.tar.bz2
libdbusmenu-95e56adc0d86cfbbc67f04582a230076721276d1.zip
Add a way for newcomers to the bus to find out who's there
Diffstat (limited to 'libdbusmenu-glib')
-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