diff options
author | Ted Gould <ted@gould.cx> | 2010-03-31 14:15:36 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-03-31 14:15:36 -0500 |
commit | abd4bb02f717e6d27b77c903877a98d1a5a534b7 (patch) | |
tree | 901f7518f5da2db2a90075706bf0c18b5320f0c5 /libdbusmenu-glib/client.c | |
parent | 85a76718ac641b83bb3a283d5819a3272fdd134c (diff) | |
parent | 1f308a47c578baec7ba7bfebb880e0ecf0a17688 (diff) | |
download | libdbusmenu-abd4bb02f717e6d27b77c903877a98d1a5a534b7.tar.gz libdbusmenu-abd4bb02f717e6d27b77c903877a98d1a5a534b7.tar.bz2 libdbusmenu-abd4bb02f717e6d27b77c903877a98d1a5a534b7.zip |
* Upstream merge
* Supporting AboutToShow in event callbacks to catch up
with QT implementation.
Diffstat (limited to 'libdbusmenu-glib/client.c')
-rw-r--r-- | libdbusmenu-glib/client.c | 54 |
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 * |