aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-03-30 09:38:16 -0500
committerTed Gould <ted@gould.cx>2012-03-30 09:38:16 -0500
commitbc358d3583dc68af36648d09f74d39fa1665c647 (patch)
treeeb857f81cdf1e010c24b063ace91bcb6d85a92ec /libdbusmenu-glib
parent2372656fcf782c7ca28acb579eb70dbd2e47f35a (diff)
downloadlibdbusmenu-bc358d3583dc68af36648d09f74d39fa1665c647.tar.gz
libdbusmenu-bc358d3583dc68af36648d09f74d39fa1665c647.tar.bz2
libdbusmenu-bc358d3583dc68af36648d09f74d39fa1665c647.zip
Pulling the core event handling into its own function
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r--libdbusmenu-glib/server.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c
index e67ec58..04b9b68 100644
--- a/libdbusmenu-glib/server.c
+++ b/libdbusmenu-glib/server.c
@@ -1647,6 +1647,28 @@ event_local_handler (gpointer user_data)
return FALSE;
}
+/* The core menu finding and doing the work part of the two
+ event functions */
+static gboolean
+bus_event_core (DbusmenuServer * server, gint32 id, gchar * event_type, GVariant * data, guint32 timestamp)
+{
+ DbusmenuMenuitem * mi = lookup_menuitem_by_id(server, id);
+
+ if (mi == NULL) {
+ return FALSE;
+ }
+
+ idle_event_t * event_data = g_new0(idle_event_t, 1);
+ event_data->mi = g_object_ref(mi);
+ event_data->eventid = event_type; /* give away our allocation */
+ event_data->timestamp = timestamp;
+ event_data->variant = data; /* give away our reference */
+
+ g_timeout_add(0, event_local_handler, event_data);
+
+ return TRUE;
+}
+
/* Handles the events coming off of DBus */
static void
bus_event (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * invocation)
@@ -1668,9 +1690,7 @@ bus_event (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * i
g_variant_get(params, "(isvu)", &id, &etype, &data, &ts);
- DbusmenuMenuitem * mi = lookup_menuitem_by_id(server, id);
-
- if (mi == NULL) {
+ if (!bus_event_core(server, id, etype, data, ts)) {
g_dbus_method_invocation_return_error(invocation,
error_quark(),
INVALID_MENUITEM_ID,
@@ -1678,16 +1698,7 @@ bus_event (DbusmenuServer * server, GVariant * params, GDBusMethodInvocation * i
id);
g_free(etype);
g_variant_unref(data);
-
} else {
- idle_event_t * event_data = g_new0(idle_event_t, 1);
- event_data->mi = g_object_ref(mi);
- event_data->eventid = etype; /* give away our allocation */
- event_data->timestamp = ts;
- event_data->variant = data; /* give away our reference */
-
- g_timeout_add(0, event_local_handler, event_data);
-
if (~g_dbus_message_get_flags (g_dbus_method_invocation_get_message (invocation)) & G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED) {
g_dbus_method_invocation_return_value(invocation, NULL);
}