[Xfce4-commits] <xfce4-panel:xfce-4.6> Use g_timeout_add_seconds when available for the clock timeout.
Nick Schermer
noreply at xfce.org
Fri Oct 16 14:30:06 CEST 2009
Updating branch refs/heads/xfce-4.6
to f95283cb37df8ab067a7c1a8ba26a4064e639605 (commit)
from 5da0f55f9638e270db87a825eccc44c032ae84bd (commit)
commit f95283cb37df8ab067a7c1a8ba26a4064e639605
Author: Nick Schermer <nick at xfce.org>
Date: Tue Oct 6 11:12:52 2009 +0200
Use g_timeout_add_seconds when available for the clock timeout.
These functions tend to stay better in sync with the system clock
and thus resulting in less rescheduling.
plugins/clock/clock.c | 46 ++++++++++++++++++++++++++++++----------------
1 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/plugins/clock/clock.c b/plugins/clock/clock.c
index b2a1988..f62c57f 100644
--- a/plugins/clock/clock.c
+++ b/plugins/clock/clock.c
@@ -35,6 +35,18 @@
#define USE_DEBUG_TIME (0)
+#if GLIB_CHECK_VERSION (2, 14, 0)
+#define clock_timeout_add_seconds(interval,function,data) \
+ g_timeout_add_seconds (interval,function,data)
+#define clock_timeout_add_seconds_full(priority,interval,function,data,notify) \
+ g_timeout_add_seconds_full (priority,interval,function,data,notify)
+#else
+#define clock_timeout_add_seconds(interval,function,data) \
+ g_timeout_add ((interval) * 1000,function,data)
+#define clock_timeout_add_seconds_full(priority,interval,function,data,notify) \
+ g_timeout_add_full (priority,(interval) * 1000,function,data,notify)
+#endif
+
/** prototypes **/
@@ -273,9 +285,10 @@ xfce_clock_tooltip_sync_timeout (gpointer user_data)
ClockPlugin *plugin = (ClockPlugin *) user_data;
/* start the tooltip update interval */
- plugin->tooltip_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, plugin->tooltip_interval * 1000,
- xfce_clock_tooltip_timeout, plugin,
- xfce_clock_tooltip_timeout_destroyed);
+ plugin->tooltip_timeout_id = clock_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE,
+ plugin->tooltip_interval,
+ xfce_clock_tooltip_timeout, plugin,
+ xfce_clock_tooltip_timeout_destroyed);
/* manual update for this timeout */
xfce_clock_tooltip_update (plugin);
@@ -307,14 +320,15 @@ xfce_clock_tooltip_sync (ClockPlugin *plugin)
if (interval > 0 && plugin->tooltip_interval != CLOCK_INTERVAL_SECOND)
{
/* start the sync timeout */
- plugin->tooltip_timeout_id = g_timeout_add (interval * 1000, xfce_clock_tooltip_sync_timeout, plugin);
+ plugin->tooltip_timeout_id = clock_timeout_add_seconds (interval, xfce_clock_tooltip_sync_timeout, plugin);
}
else
{
/* start the real timeout */
- plugin->tooltip_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, plugin->tooltip_interval * 1000,
- xfce_clock_tooltip_timeout, plugin,
- xfce_clock_tooltip_timeout_destroyed);
+ plugin->tooltip_timeout_id = clock_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE,
+ plugin->tooltip_interval,
+ xfce_clock_tooltip_timeout, plugin,
+ xfce_clock_tooltip_timeout_destroyed);
}
/* update the tooltip */
@@ -369,9 +383,10 @@ xfce_clock_widget_sync_timeout (gpointer user_data)
if (G_LIKELY (plugin->widget))
{
/* start the clock update timeout */
- plugin->clock_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, plugin->interval * 1000,
- xfce_clock_widget_timeout, plugin,
- xfce_clock_widget_timeout_destroyed);
+ plugin->clock_timeout_id = clock_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE,
+ plugin->interval,
+ xfce_clock_widget_timeout, plugin,
+ xfce_clock_widget_timeout_destroyed);
/* manual update for this interval */
(plugin->update) (plugin->widget);
@@ -408,17 +423,16 @@ xfce_clock_widget_sync (ClockPlugin *plugin)
if (interval > 0 && plugin->interval != CLOCK_INTERVAL_SECOND)
{
/* start the sync timeout */
- plugin->clock_timeout_id = g_timeout_add (interval * 1000, xfce_clock_widget_sync_timeout, plugin);
+ plugin->clock_timeout_id = clock_timeout_add_seconds (interval, xfce_clock_widget_sync_timeout, plugin);
}
else
{
/* start the real timeout */
- plugin->clock_timeout_id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, plugin->interval * 1000,
- xfce_clock_widget_timeout, plugin,
- xfce_clock_widget_timeout_destroyed);
+ plugin->clock_timeout_id = clock_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE,
+ plugin->interval,
+ xfce_clock_widget_timeout, plugin,
+ xfce_clock_widget_timeout_destroyed);
}
-
-
}
}
More information about the Xfce4-commits
mailing list