aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib/client.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-03-31 13:58:29 -0500
committerTed Gould <ted@gould.cx>2010-03-31 13:58:29 -0500
commit1f308a47c578baec7ba7bfebb880e0ecf0a17688 (patch)
treee6aaa5fd904fbb136625714c1643381b5baa26ce /libdbusmenu-glib/client.c
parent04ad3cb433ac8ed581998ea6ce69bd0e7d1dbb68 (diff)
parent0bec1d5af5d3d61ffc24913e0257f724765e5563 (diff)
downloadlibdbusmenu-1f308a47c578baec7ba7bfebb880e0ecf0a17688.tar.gz
libdbusmenu-1f308a47c578baec7ba7bfebb880e0ecf0a17688.tar.bz2
libdbusmenu-1f308a47c578baec7ba7bfebb880e0ecf0a17688.zip
Merging in support for sending AboutToShow events.
Diffstat (limited to 'libdbusmenu-glib/client.c')
-rw-r--r--libdbusmenu-glib/client.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index fb2a2bc..09a663a 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -668,6 +668,8 @@ menuitem_call_cb (DBusGProxy * proxy, GError * error, gpointer userdata)
return;
}
+/* Sends the event over DBus to the server on the other side
+ of the bus. */
void
dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name, const GValue * value, guint timestamp)
{
@@ -676,6 +678,58 @@ dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name
return;
}
+typedef struct _about_to_show_t about_to_show_t;
+struct _about_to_show_t {
+ DbusmenuClient * client;
+ void (*cb) (gpointer data);
+ gpointer cb_data;
+};
+
+/* Reports errors and responds to update request that were a result
+ of sending the about to show signal. */
+static void
+about_to_show_cb (DBusGProxy * proxy, gboolean need_update, GError * error, gpointer userdata)
+{
+ about_to_show_t * data = (about_to_show_t *)userdata;
+
+ if (error != NULL) {
+ g_warning("Unable to send about_to_show: %s", error->message);
+ /* Note: we're just ensuring only the callback gets called */
+ need_update = FALSE;
+ }
+
+ /* If we need to update, do that first. */
+ if (need_update) {
+ update_layout(data->client);
+ }
+
+ if (data->cb != NULL) {
+ data->cb(data->cb_data);
+ }
+
+ g_object_unref(data->client);
+ g_free(data);
+
+ return;
+}
+
+/* Sends the about to show signal for a given id to the
+ server on the other side of DBus */
+void
+dbusmenu_client_send_about_to_show(DbusmenuClient * client, gint id, void (*cb)(gpointer data), gpointer cb_data)
+{
+ DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
+
+ about_to_show_t * data = g_new0(about_to_show_t, 1);
+ data->client = client;
+ data->cb = cb;
+ data->cb_data = cb_data;
+ g_object_ref(client);
+
+ org_ayatana_dbusmenu_about_to_show_async (priv->menuproxy, id, about_to_show_cb, data);
+ return;
+}
+
/* Parse recursively through the XML and make it into
objects as need be */
static DbusmenuMenuitem *