From 29de19e1acf32b35bed5f0a88b461d0ed0896a51 Mon Sep 17 00:00:00 2001 From: Christian Hammond Date: Mon, 28 Jun 2004 04:40:04 +0000 Subject: [PATCH] Added support for the NotificationClosed and RequestClosed signals, along with request callbacks. I wonder if any of this works. --- ChangeLog | 6 ++++++ libnotify/notify.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f843edf..9e1baf2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Jun 27 21:39:13 PDT 2004 Christian Hammond + + * libnotify/notify.c: + - Added support for the NotificationClosed and RequestClosed signals, + along with request callbacks. I wonder if any of this works. + Sun Jun 27 20:23:00 PDT 2004 Christian Hammond * libnotify/notify.c: diff --git a/libnotify/notify.c b/libnotify/notify.c index 34a9c70..9d1f14f 100644 --- a/libnotify/notify.c +++ b/libnotify/notify.c @@ -117,7 +117,49 @@ _notify_dbus_message_iter_append_app_info(DBusMessageIter *iter) static DBusHandlerResult _filter_func(DBusConnection *dbus_conn, DBusMessage *message, void *user_data) { - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + DBusMessageIter iter; + + if (dbus_message_is_signal(message, NOTIFY_DBUS_CORE_INTERFACE, + "NotificationClosed")) + { + /* We can ignore this, pretty much. */ + } + else if (dbus_message_is_signal(message, NOTIFY_DBUS_CORE_INTERFACE, + "RequestClosed")) + { + guint32 id, button; + NotifyRequestData *request_data; + + dbus_message_iter_init(message, &iter); + + id = dbus_message_iter_get_uint32(&iter); + dbus_message_iter_next(&iter); + + button = dbus_message_iter_get_uint32(&iter); + + request_data = g_hash_table_lookup(_request_ids, GINT_TO_POINTER(id)); + + if (request_data != NULL) + { + if (button >= request_data->num_buttons) + { + fprintf(stderr, + "Returned request button ID is greater than " + "the maximum number of buttons!\n"); + } + else if (request_data->cbs[button] != NULL) + { + (request_data->cbs[button])(id, button, + request_data->user_data); + } + + g_hash_table_remove(_request_ids, GINT_TO_POINTER(id)); + } + } + else + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + return DBUS_HANDLER_RESULT_HANDLED; } static gboolean