[Goodies-commits] r4993 - in xfce4-datetime-plugin/trunk: . panel-plugin

Diego Ongaro ongardie at xfce.org
Wed Jun 25 21:52:21 CEST 2008


Author: ongardie
Date: 2008-06-25 19:52:21 +0000 (Wed, 25 Jun 2008)
New Revision: 4993

Modified:
   xfce4-datetime-plugin/trunk/ChangeLog
   xfce4-datetime-plugin/trunk/panel-plugin/datetime.c
Log:
Fix Bug #4157.

Bug #4157: Updates occur once a second when datetime plugin shows date
only.
Used code from Steve Tyler's Attachment #1697 in Bug #4145.


Modified: xfce4-datetime-plugin/trunk/ChangeLog
===================================================================
--- xfce4-datetime-plugin/trunk/ChangeLog	2008-06-25 01:35:32 UTC (rev 4992)
+++ xfce4-datetime-plugin/trunk/ChangeLog	2008-06-25 19:52:21 UTC (rev 4993)
@@ -1,5 +1,8 @@
 2008-06-21	Diego Ongaro <ongardie at gmail.com>
 
+	* panel-plugin/datetime.c: Fix Bug #4157 - updates occur once a second
+	when datetime plugin shows date only. Used code from Steve Tyler's
+	Attachment #1697 in Bug #4145.
 	* panel-plugin/datetime-dialog.c, panel-plugin/datetime.h: Change
 	order of layout dropdown (Bug #4158)
 

Modified: xfce4-datetime-plugin/trunk/panel-plugin/datetime.c
===================================================================
--- xfce4-datetime-plugin/trunk/panel-plugin/datetime.c	2008-06-25 01:35:32 UTC (rev 4992)
+++ xfce4-datetime-plugin/trunk/panel-plugin/datetime.c	2008-06-25 19:52:21 UTC (rev 4993)
@@ -118,6 +118,8 @@
   struct tm *current;
   guint wake_interval;  /* milliseconds to next update */
 
+  DBG("wake");
+
   /* stop timer */
   if (datetime->timeout_id)
   {
@@ -160,6 +162,7 @@
 #if USE_GTK_TOOLTIP_API
 static gboolean datetime_tooltip_timer(t_datetime *datetime)
 {
+  DBG("wake");
 
   /* flag to datetime_query_tooltip that there is no longer an active timeout */
   datetime->tooltip_timeout_id = 0;
@@ -510,6 +513,31 @@
   }
 }
 
+static void datetime_set_update_interval(t_datetime *datetime)
+{
+  /* a custom date format could specify seconds */
+  gboolean date_has_seconds = datetime_format_has_seconds(datetime->date_format);
+  gboolean time_has_seconds = datetime_format_has_seconds(datetime->time_format);
+  gboolean has_seconds;
+
+  /* set update interval for the date/time displayed in the panel */
+  switch(datetime->layout)
+  {
+    case LAYOUT_DATE:
+      has_seconds = date_has_seconds;
+      break;
+    case LAYOUT_TIME:
+      has_seconds = time_has_seconds;
+      break;
+    default:
+      has_seconds = date_has_seconds || time_has_seconds;
+      break;
+  }
+
+  /* 1000 ms in 1 second */
+  datetime->update_interval = 1000 * (has_seconds ? 1 : 60);
+}
+
 /*
  * set the date and time format
  */
@@ -532,15 +560,7 @@
     datetime->time_format = g_strdup(time_format);
   }
 
-  if (datetime_format_has_seconds(datetime->date_format) ||
-      datetime_format_has_seconds(datetime->time_format))
-  {
-    datetime->update_interval = 1000; /* 1 second */
-  }
-  else
-  {
-    datetime->update_interval = 60000; /* 1 minute */
-  }
+  datetime_set_update_interval(datetime);
 }
 
 /*




More information about the Goodies-commits mailing list