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

galago-commits at freedesktop.org galago-commits at freedesktop.org
Fri Apr 21 16:34:46 PDT 2006


Author: chipx86
Date: 2006-04-21 16:34:43 -0700 (Fri, 21 Apr 2006)
New Revision: 2760

Modified:
   trunk/notification-daemon/ChangeLog
   trunk/notification-daemon/src/daemon.c
Log:
Fix notifications no longer expiring due to the fix for bug #22. The logic is now a bit smarter and more hacky. But it works. And really, if it didn't, would I be committing this? Yes, probably.


Modified: trunk/notification-daemon/ChangeLog
===================================================================
--- trunk/notification-daemon/ChangeLog	2006-04-21 22:56:01 UTC (rev 2759)
+++ trunk/notification-daemon/ChangeLog	2006-04-21 23:34:43 UTC (rev 2760)
@@ -1,3 +1,10 @@
+Fri Apr 21 16:33:56 PDT 2006  Christian Hammond <chipx86 at chipx86.com>
+
+	* src/daemon.c:
+	  - Fix notifications no longer expiring due to the fix for bug #22.
+	    The logic is now a bit smarter and more hacky. But it works. And
+	    really, if it didn't, would I be committing this? Yes, probably.
+
 Fri Apr 21 15:54:01 PDT 2006  Christian Hammond <chipx86 at chipx86.com>
 
 	* src/daemon.c:

Modified: trunk/notification-daemon/src/daemon.c
===================================================================
--- trunk/notification-daemon/src/daemon.c	2006-04-21 22:56:01 UTC (rev 2759)
+++ trunk/notification-daemon/src/daemon.c	2006-04-21 23:34:43 UTC (rev 2760)
@@ -270,7 +270,8 @@
 {
 	NotifyTimeout *nt = (NotifyTimeout *)value;
 	gboolean *phas_more_timeouts = (gboolean *)data;
-	gulong remaining;
+	time_t now_time;
+	time_t expiration_time;
 	GTimeVal now;
 
 	if (!nt->has_timeout)
@@ -278,17 +279,18 @@
 
 	g_get_current_time(&now);
 
-	remaining = ((nt->expiration.tv_sec * 1000) +
-				 (nt->expiration.tv_usec / 1000)) -
-	            ((now.tv_sec * 1000) + (now.tv_usec / 1000));
+	expiration_time = (nt->expiration.tv_sec * 1000) +
+	                  (nt->expiration.tv_usec / 1000);
+	now_time = (now.tv_sec * 1000) + (now.tv_usec / 1000);
 
-	theme_notification_tick(nt->nw, remaining);
-
-	if (remaining <= 0)
+	if (now_time > expiration_time)
 	{
+		theme_notification_tick(nt->nw, 0);
 		_emit_closed_signal(G_OBJECT(nt->nw));
 		return TRUE;
 	}
+	else
+		theme_notification_tick(nt->nw, expiration_time - now_time);
 
 	*phas_more_timeouts = TRUE;
 
@@ -317,7 +319,7 @@
 		nt->has_timeout = FALSE;
 	else
 	{
-		gulong usec;
+		glong usec;
 
 		nt->has_timeout = TRUE;
 
@@ -327,6 +329,15 @@
 		theme_set_notification_timeout(nt->nw, timeout);
 
 		usec = timeout * 1000;	/* convert from msec to usec */
+
+		/*
+		 * If it's less than 0, wrap around back to MAXLONG.
+		 * g_time_val_add() requires a glong, and anything larger than
+		 * MAXLONG will be treated as a negative value.
+		 */
+		if (usec < 0)
+			usec = G_MAXLONG;
+
 		g_get_current_time(&nt->expiration);
 		g_time_val_add(&nt->expiration, usec);
 



More information about the galago-commits mailing list