[Goodies-commits] r4995 - in xfce4-datetime-plugin/trunk: . panel-plugin
Diego Ongaro
ongardie at xfce.org
Wed Jun 25 21:52:32 CEST 2008
Author: ongardie
Date: 2008-06-25 19:52:32 +0000 (Wed, 25 Jun 2008)
New Revision: 4995
Modified:
xfce4-datetime-plugin/trunk/ChangeLog
xfce4-datetime-plugin/trunk/panel-plugin/datetime.c
Log:
Update tooltip at the top of the second (fixes Bug #4145).
Pulling code from Steve Tyler's Attachment #1697 in Bug #4145.
Modified: xfce4-datetime-plugin/trunk/ChangeLog
===================================================================
--- xfce4-datetime-plugin/trunk/ChangeLog 2008-06-25 19:52:27 UTC (rev 4994)
+++ xfce4-datetime-plugin/trunk/ChangeLog 2008-06-25 19:52:32 UTC (rev 4995)
@@ -2,6 +2,7 @@
* panel-plugin/datetime.c: Pulling code from Steve Tyler's
Attachment #1697 in Bug #4145.
+ - Update tooltip at the top of the second (fixes Bug #4145).
- Only gsource_remove valid timeouts, add pre-processor if to the
tooltips timeout.
- Fix Bug #4157 - updates occur once a second when datetime plugin
Modified: xfce4-datetime-plugin/trunk/panel-plugin/datetime.c
===================================================================
--- xfce4-datetime-plugin/trunk/panel-plugin/datetime.c 2008-06-25 19:52:27 UTC (rev 4994)
+++ xfce4-datetime-plugin/trunk/panel-plugin/datetime.c 2008-06-25 19:52:32 UTC (rev 4995)
@@ -51,6 +51,21 @@
}
/*
+ * Compute the wake interval,
+ * which is the time remaining from the current time
+ * to the next larger integral multiple of the update interval.
+ * Setting a timer to this value schedules the next update
+ * to occur on the next second or minute
+ * when the given update interval is 1000 or 60000 milliseconds, respectively.
+ */
+static inline guint datetime_wake_interval(const GTimeVal current_time,
+ const guint update_interval_ms)
+{
+ return update_interval_ms - (datetime_gtimeval_to_ms(current_time) %
+ update_interval_ms);
+}
+
+/*
* Get date/time string
*/
gchar * datetime_do_utf8strftime(const char *format, const struct tm *tm)
@@ -145,15 +160,8 @@
g_free(utf8str);
}
- /*
- * Compute the time to the next update and start the timer.
- * The wake interval is the time remaining
- * to the next larger integral multiple of the update interval.
- * Setting the timer to this value schedules the next update
- * to occur on the next second or minute
- * when the update interval is 1 or 60 seconds, respectively.
- */
- wake_interval = datetime->update_interval - datetime_gtimeval_to_ms(timeval) % datetime->update_interval;
+ /* Compute the time to the next update and start the timer. */
+ wake_interval = datetime_wake_interval(timeval, datetime->update_interval);
datetime->timeout_id = g_timeout_add(wake_interval, (GSourceFunc) datetime_update, datetime);
return TRUE;
@@ -188,6 +196,7 @@
struct tm *current;
gchar *utf8str;
gchar *format = NULL;
+ guint wake_interval; /* milliseconds to next update */
switch(datetime->layout)
{
@@ -218,7 +227,8 @@
* I think we can afford to inefficiently poll every
* second while the user keeps the mouse here.
*/
- datetime->tooltip_timeout_id = g_timeout_add(1000,
+ wake_interval = datetime_wake_interval(timeval, 1000);
+ datetime->tooltip_timeout_id = g_timeout_add(wake_interval,
(GSourceFunc) datetime_tooltip_timer, datetime);
}
More information about the Goodies-commits
mailing list