[Galago-commits] r2991 - in trunk/notification-daemon: . src/daemon

galago-commits at freedesktop.org galago-commits at freedesktop.org
Sat Aug 25 18:56:46 PDT 2007


Author: chipx86
Date: 2007-08-25 18:56:45 -0700 (Sat, 25 Aug 2007)
New Revision: 2991

Modified:
   trunk/notification-daemon/ChangeLog
   trunk/notification-daemon/src/daemon/daemon.c
   trunk/notification-daemon/src/daemon/daemon.h
Log:
- Send the reason the notification closed when emitting the NotificationClosed signal, as per the spec.
- Bump spec compliance to 1.0.


Modified: trunk/notification-daemon/ChangeLog
===================================================================
--- trunk/notification-daemon/ChangeLog	2007-08-26 01:26:29 UTC (rev 2990)
+++ trunk/notification-daemon/ChangeLog	2007-08-26 01:56:45 UTC (rev 2991)
@@ -1,3 +1,11 @@
+Sat Aug 25 18:55:34 PDT 2007  Christian Hammond <chipx86 at chipx86.com>
+
+	* src/daemon/daemon.c:
+	* src/daemon/daemon.h:
+	  - Send the reason the notification closed when emitting
+	    the NotificationClosed signal, as per the spec.
+	  - Bump spec compliance to 1.0.
+
 Sat Aug 25 18:15:02 PDT 2007  Christian Hammond <chipx86 at chipx86.com>
 
 	A po/ar.po:

Modified: trunk/notification-daemon/src/daemon/daemon.c
===================================================================
--- trunk/notification-daemon/src/daemon/daemon.c	2007-08-26 01:26:29 UTC (rev 2990)
+++ trunk/notification-daemon/src/daemon/daemon.c	2007-08-26 01:56:45 UTC (rev 2991)
@@ -116,8 +116,9 @@
 
 static void notify_daemon_finalize(GObject *object);
 static void _close_notification(NotifyDaemon *daemon, guint id,
-								gboolean hide_notification);
-static void _emit_closed_signal(GtkWindow *nw);
+								gboolean hide_notification,
+								NotifydClosedReason reason);
+static void _emit_closed_signal(GtkWindow *nw, NotifydClosedReason reason);
 static void _action_invoked_cb(GtkWindow *nw, const char *key);
 static NotifyStackLocation get_stack_location_from_string(const char *slocation);
 
@@ -249,31 +250,32 @@
 	dbus_connection_send(dbus_conn, message, NULL);
 	dbus_message_unref(message);
 
-	_close_notification(daemon, id, TRUE);
+	_close_notification(daemon, id, TRUE, NOTIFYD_CLOSED_USER);
 }
 
 static void
-_emit_closed_signal(GtkWindow *nw)
+_emit_closed_signal(GtkWindow *nw, NotifydClosedReason reason)
 {
 	DBusMessage *message = create_signal(nw, "NotificationClosed");
+	dbus_message_append_args(message,
+							 DBUS_TYPE_UINT32, &reason,
+							 DBUS_TYPE_INVALID);
 	dbus_connection_send(dbus_conn, message, NULL);
 	dbus_message_unref(message);
 }
 
 static void
-_close_notification(NotifyDaemon *daemon, guint id, gboolean hide_notification)
+_close_notification(NotifyDaemon *daemon, guint id,
+					gboolean hide_notification, NotifydClosedReason reason)
 {
 	NotifyDaemonPrivate *priv = daemon->priv;
 	NotifyTimeout *nt;
 
-	printf("Closing notification %d (%d)\n", id, hide_notification);
-
 	nt = (NotifyTimeout *)g_hash_table_lookup(priv->notification_hash, &id);
 
 	if (nt != NULL)
 	{
-		printf("Found.\n");
-		_emit_closed_signal(nt->nw);
+		_emit_closed_signal(nt->nw, reason);
 
 		if (hide_notification)
 			theme_hide_notification(nt->nw);
@@ -285,7 +287,12 @@
 static void
 _notification_destroyed_cb(GtkWindow *nw, NotifyDaemon *daemon)
 {
-	_close_notification(daemon, NW_GET_NOTIFY_ID(nw), FALSE);
+	/*
+	 * This usually won't happen, but can if notification-daemon dies before
+	 * all notifications are closed. Mark them as expired.
+	 */
+	_close_notification(daemon, NW_GET_NOTIFY_ID(nw), FALSE,
+						NOTIFYD_CLOSED_EXPIRED);
 }
 
 static void
@@ -353,7 +360,7 @@
 	if (now_time > expiration_time)
 	{
 		theme_notification_tick(nt->nw, 0);
-		_emit_closed_signal(nt->nw);
+		_emit_closed_signal(nt->nw, NOTIFYD_CLOSED_EXPIRED);
 		return TRUE;
 	}
 	else if (nt->paused)
@@ -656,7 +663,8 @@
 	}
 
 	_action_invoked_cb(nw, "default");
-	_close_notification(daemon, NW_GET_NOTIFY_ID(nw), TRUE);
+	_close_notification(daemon, NW_GET_NOTIFY_ID(nw), TRUE,
+						NOTIFYD_CLOSED_USER);
 }
 
 static void
@@ -1101,7 +1109,7 @@
 					_("%u is not a valid notification ID"), id);
 		return FALSE;
 	} else {
-		_close_notification(daemon, id, TRUE);
+		_close_notification(daemon, id, TRUE, NOTIFYD_CLOSED_API);
 		return TRUE;
 	}
 }
@@ -1131,7 +1139,7 @@
 	*out_name     = g_strdup("Notification Daemon");
 	*out_vendor   = g_strdup("Galago Project");
 	*out_version  = g_strdup(VERSION);
-	*out_spec_ver = g_strdup("0.9");
+	*out_spec_ver = g_strdup("1.0");
 
 	return TRUE;
 }

Modified: trunk/notification-daemon/src/daemon/daemon.h
===================================================================
--- trunk/notification-daemon/src/daemon/daemon.h	2007-08-26 01:26:29 UTC (rev 2990)
+++ trunk/notification-daemon/src/daemon/daemon.h	2007-08-26 01:56:45 UTC (rev 2991)
@@ -49,12 +49,22 @@
 
 #define NOTIFY_DAEMON_DEFAULT_TIMEOUT 7000
 
-enum {
+enum
+{
 	URGENCY_LOW,
 	URGENCY_NORMAL,
 	URGENCY_CRITICAL
 };
 
+typedef enum
+{
+	NOTIFYD_CLOSED_EXPIRED = 1,
+	NOTIFYD_CLOSED_USER = 2,
+	NOTIFYD_CLOSED_API = 3,
+	NOTIFYD_CLOSED_RESERVED = 4
+
+} NotifydClosedReason;
+
 typedef struct _NotifyDaemon        NotifyDaemon;
 typedef struct _NotifyDaemonClass   NotifyDaemonClass;
 typedef struct _NotifyDaemonPrivate NotifyDaemonPrivate;



More information about the galago-commits mailing list