Index: libnotify/notification.c =================================================================== --- libnotify/notification.c (révision 2973) +++ libnotify/notification.c (copie de travail) @@ -31,6 +31,7 @@ # define HAVE_STATUS_ICON # include #endif +#include #define CHECK_DBUS_VERSION(major, minor) \ (DBUS_MAJOR_VER > (major) || \ @@ -46,7 +47,7 @@ static void notify_notification_class_init(NotifyNotificationClass *klass); static void notify_notification_init(NotifyNotification *sp); static void notify_notification_finalize(GObject *object); -static void _close_signal_handler(DBusGProxy *proxy, guint32 id, +static void _close_signal_handler(DBusGProxy *proxy, guint32 id, guint32 reason, NotifyNotification *notification); static void _action_signal_handler(DBusGProxy *proxy, guint32 id, @@ -89,6 +90,8 @@ struct _NotifyNotificationPrivate gboolean has_nondefault_actions; gboolean updates_pending; gboolean signals_registered; + + gint closed_reason; }; enum @@ -100,11 +103,13 @@ enum enum { PROP_0, + PROP_ID, PROP_SUMMARY, PROP_BODY, PROP_ICON_NAME, PROP_ATTACH_WIDGET, - PROP_STATUS_ICON + PROP_STATUS_ICON, + PROP_CLOSED_REASON }; static void notify_notification_set_property(GObject *object, guint prop_id, @@ -156,6 +161,18 @@ notify_notification_class_init(NotifyNot NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_object_class_install_property(object_class, PROP_ID, + g_param_spec_int("id", "ID", + "The notification ID", + 0, + G_MAXINT32, + 0, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); + g_object_class_install_property(object_class, PROP_SUMMARY, g_param_spec_string("summary", "Summary", "The summary text", @@ -210,6 +227,17 @@ notify_notification_class_init(NotifyNot G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); #endif /* HAVE_STATUS_ICON */ + + g_object_class_install_property(object_class, PROP_CLOSED_REASON, + g_param_spec_int("closed-reason", "Closed Reason", + "The reason code for why the notification was closed", + -1, + G_MAXINT32, + -1, + G_PARAM_READABLE | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); } static void @@ -223,6 +251,10 @@ notify_notification_set_property(GObject switch (prop_id) { + case PROP_ID: + priv->id = g_value_get_int(value); + break; + case PROP_SUMMARY: notify_notification_update(notification, g_value_get_string(value), priv->body, priv->icon_name); @@ -268,6 +300,10 @@ notify_notification_get_property(GObject switch (prop_id) { + case PROP_ID: + g_value_set_int(value, priv->id); + break; + case PROP_SUMMARY: g_value_set_string(value, priv->summary); break; @@ -290,6 +326,10 @@ notify_notification_get_property(GObject break; #endif + case PROP_CLOSED_REASON: + g_value_set_int(value, priv->closed_reason); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -317,6 +357,7 @@ notify_notification_init(NotifyNotificat { obj->priv = g_new0(NotifyNotificationPrivate, 1); obj->priv->timeout = NOTIFY_EXPIRES_DEFAULT; + obj->priv->closed_reason = -1; obj->priv->hints = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GFreeFunc)_g_value_free); @@ -375,6 +416,13 @@ notify_notification_finalize(GObject *ob G_OBJECT_CLASS(parent_class)->finalize(object); } +static GtkWidget * +get_internal_tray_icon (GtkStatusIcon *status) +{ + /* This function is a temporary hack */ + return GTK_WIDGET (*((GtkWidget**)(status->priv))); +} + static void _notify_notification_update_applet_hints(NotifyNotification *n) { @@ -386,6 +434,18 @@ _notify_notification_update_applet_hints if (priv->status_icon != NULL) { GdkRectangle rect; + GtkWidget *internal_tray = get_internal_tray_icon (priv->status_icon); + GdkWindow *window; + + // TODO: this is sort of a hack, but we need a window ID to send along + gtk_widget_realize (internal_tray); + window = internal_tray->window; + + if (window != NULL) + { + guint32 xid = GDK_WINDOW_XID (window); + notify_notification_set_hint_uint32(n, "window-xid", xid); + } if (!gtk_status_icon_get_geometry(priv->status_icon, &screen, &rect, NULL)) @@ -670,12 +730,13 @@ notify_notification_set_geometry_hints(N } static void -_close_signal_handler(DBusGProxy *proxy, guint32 id, +_close_signal_handler(DBusGProxy *proxy, guint32 id, guint32 reason, NotifyNotification *notification) { if (id == notification->priv->id) { g_object_ref(G_OBJECT(notification)); + notification->priv->closed_reason = reason; g_signal_emit(notification, signals[SIGNAL_CLOSED], 0); notification->priv->id = 0; g_object_unref(G_OBJECT(notification)); @@ -982,6 +1043,32 @@ notify_notification_set_hint_int32(Notif g_strdup(key), hint_value); } + +/** + * notify_notification_set_hint_uint32: + * @notification: The notification. + * @key: The hint. + * @value: The hint's value. + * + * Sets a hint with an unsigned 32-bit integer value. + */ +void +notify_notification_set_hint_uint32(NotifyNotification *notification, + const gchar *key, guint value) +{ + GValue *hint_value; + + g_return_if_fail(notification != NULL); + g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification)); + g_return_if_fail(key != NULL && *key != '\0'); + + hint_value = g_new0(GValue, 1); + g_value_init(hint_value, G_TYPE_UINT); + g_value_set_uint(hint_value, value); + g_hash_table_insert(notification->priv->hints, + g_strdup(key), hint_value); +} + /** * notify_notification_set_hint_double: * @notification: The notification. @@ -1232,3 +1319,21 @@ notify_notification_close(NotifyNotifica return TRUE; } + +/** + * notify_notification_get_closed_reason: + * @notification: The notification. + * + * Returns the closed reason code for the notification. This is valid only + * after the "closed" signal is emitted. + * + * Returns: The closed reason code. + */ +gint +notify_notification_get_closed_reason(const NotifyNotification *notification) +{ + g_return_val_if_fail(notification != NULL, -1); + g_return_val_if_fail(NOTIFY_IS_NOTIFICATION(notification), -1); + + return notification->priv->closed_reason; +} Index: libnotify/notify-marshal.list =================================================================== --- libnotify/notify-marshal.list (révision 2973) +++ libnotify/notify-marshal.list (copie de travail) @@ -1 +1,2 @@ +VOID:UINT,UINT VOID:UINT,STRING Index: libnotify/notify.c =================================================================== --- libnotify/notify.c (révision 2973) +++ libnotify/notify.c (copie de travail) @@ -72,13 +72,19 @@ notify_init(const char *app_name) NOTIFY_DBUS_CORE_INTERFACE); dbus_g_connection_unref(bus); + dbus_g_object_register_marshaller(notify_marshal_VOID__UINT_UINT, + G_TYPE_NONE, + G_TYPE_UINT, + G_TYPE_UINT, G_TYPE_INVALID); + dbus_g_object_register_marshaller(notify_marshal_VOID__UINT_STRING, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_add_signal(_proxy, "NotificationClosed", - G_TYPE_UINT, G_TYPE_INVALID); + G_TYPE_UINT, G_TYPE_UINT, + G_TYPE_INVALID); dbus_g_proxy_add_signal(_proxy, "ActionInvoked", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID); Index: libnotify/notification.h =================================================================== --- libnotify/notification.h (révision 2973) +++ libnotify/notification.h (copie de travail) @@ -25,7 +25,6 @@ #include #include #include -#include G_BEGIN_DECLS @@ -77,7 +76,9 @@ typedef enum } NotifyUrgency; -typedef void (*NotifyActionCallback)(NotifyNotification *, gchar *, gpointer); +typedef void (*NotifyActionCallback)(NotifyNotification *notification, + gchar *action, + gpointer user_data); #define NOTIFY_ACTION_CALLBACK(func) ((NotifyActionCallback)(func)) @@ -128,6 +129,8 @@ void notify_notification_set_icon_from_p void notify_notification_set_hint_int32(NotifyNotification *notification, const gchar *key, gint value); +void notify_notification_set_hint_uint32(NotifyNotification *notification, + const gchar *key, guint value); void notify_notification_set_hint_double(NotifyNotification *notification, const gchar *key, gdouble value); @@ -154,6 +157,9 @@ void notify_notification_clear_actions(N gboolean notify_notification_close(NotifyNotification *notification, GError **error); +gint notify_notification_get_closed_reason( + const NotifyNotification *notification); + G_END_DECLS #endif /* NOTIFY_NOTIFICATION_H */ Index: tools/notify-send.c =================================================================== --- tools/notify-send.c (révision 2973) +++ tools/notify-send.c (copie de travail) @@ -3,20 +3,20 @@ * * Copyright (C) 2004 Christian Hammond. * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, + * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the Free - * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #include Index: AUTHORS =================================================================== --- AUTHORS (révision 2973) +++ AUTHORS (copie de travail) @@ -14,3 +14,4 @@ Patch Writers: M.S. mderezynski Ed Catmur + Lucas Rocha Index: ChangeLog =================================================================== --- ChangeLog (révision 2973) +++ ChangeLog (copie de travail) @@ -1,3 +1,48 @@ +Thu Sep 25 18:45:41 PDT 2008 Christian Hammond + + * libnotify/notification.c: + * libnotify/notification.h: + - Prevent a backwards-compatibility breakage introduced where the + "reason" code was added to the "closed" signal. This meant that + existing signal handlers that passed extra data would break. We now + require that you call notify_notification_get_closed_reason() to get + this data. + +Thu Sep 25 18:05:38 PDT 2008 Christian Hammond + + * libnotify/notification.h: + * NEWS: + - Fixed a breakage where we were including gtkversion.h directly. + Reported by Richard Hughes. + +Tue Mar 18 21:51:32 PDT 2008 Christian Hammond + + * libnotify/notification.c: + * libnotify/notification.h: + * libnotify/notify.c: + * libnotify/notify-marshal.list: + * NEWS: + - Add support for sending the closed reason in the signal handler. + Closes ticket #139. + +Sat Aug 25 18:08:01 PDT 2007 Christian Hammond + + * tools/notify-send.c: + - Relicense notify-send under the LGPL in order to keep licensing + simple and to allow reuse in more projects. Fixes bug #124. + +Sun Apr 29 02:45:20 PDT 2007 Christian Hammond + + * configure.ac: + - Bump to version 0.4.4.90. + +Sun Apr 29 00:39:32 PDT 2007 Christian Hammond + + * docs/reference/tmpl/notification.sgml: + * libnotify/notification.c: + - Patch by Lucas Rocha to add GObject property accessors for + notification IDs. + ========================= 0.4.4 ========================= Tue Feb 27 21:11:36 PST 2007 Christian Hammond Index: docs/ChangeLog =================================================================== --- docs/ChangeLog (révision 2973) +++ docs/ChangeLog (copie de travail) @@ -1,3 +1,9 @@ +Sat Aug 25 18:25:02 PDT 2007 Christian Hammond + + * notification-spec.xml: + - Add a spec_version return value for GetServerInformation. + - Bump to version 1.0. It's about time, and things are pretty solid now. + Wed Jan 25 23:45:11 PST 2006 Christian Hammond * notification-spec.xml: Index: docs/notification-spec.xml =================================================================== --- docs/notification-spec.xml (révision 2973) +++ docs/notification-spec.xml (copie de travail) @@ -3,8 +3,8 @@
Desktop Notifications Specification - Version 0.9 - 15 January 2006 + Version 1.0 + 25 August 2007 Mike @@ -27,6 +27,15 @@ + 1.0 + 25 August 2007 + cdh + + Added spec_version to the GetServerInformation return values. + Mark this specification as a 1.0. + + + 0.9 15 January 2006 cdh @@ -1049,6 +1058,7 @@ out STRING name out STRING vendor out STRING version + out STRING spec_version @@ -1084,6 +1094,11 @@ STRING The server's version number. + + spec_version + STRING + The specification version the server is compliant with. + Index: docs/reference/tmpl/notification.sgml =================================================================== --- docs/reference/tmpl/notification.sgml (révision 2973) +++ docs/reference/tmpl/notification.sgml (copie de travail) @@ -66,6 +66,11 @@ not be used directly. Use the accessor f + + + + + Index: NEWS =================================================================== --- NEWS (révision 2973) +++ NEWS (copie de travail) @@ -1,3 +1,13 @@ +version 0.4.5: + * Added GObject property accessors for notification IDs. Patch by Lucas + Rocha. + * Added support for sending the closed reason in the "closed" signal + handler. (Ticket #139) + * Added support for sending the status icon XID to the notification + daemon. This will allow better position tracking for context + notifications. Patch by Colin Walters. + * Fixed a breakage where we were including gtkversion.h directly. + version 0.4.4 (27-February-2007): * Fixed a bug where a notification's ID could be reset when a different notification was closed. Patch by jylefort. (Bug #94)