aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-07-16 16:46:56 -0500
committerTed Gould <ted@gould.cx>2010-07-16 16:46:56 -0500
commite4773774abeb21f9b04c1d7a0ff8dee395719f0b (patch)
tree1e8853fdffab81d633ad6e117f1bc4d393d2759d
parent98978e04d0b663af6db11271172d9ea62c1f0f1f (diff)
downloadayatana-indicator-datetime-e4773774abeb21f9b04c1d7a0ff8dee395719f0b.tar.gz
ayatana-indicator-datetime-e4773774abeb21f9b04c1d7a0ff8dee395719f0b.tar.bz2
ayatana-indicator-datetime-e4773774abeb21f9b04c1d7a0ff8dee395719f0b.zip
Starting to smartly choose when to update the time.
-rw-r--r--src/indicator-datetime.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c
index 7f8b58d..c351e3d 100644
--- a/src/indicator-datetime.c
+++ b/src/indicator-datetime.c
@@ -558,8 +558,20 @@ setup_timer (IndicatorDatetime * self)
g_source_remove(self->priv->timer);
self->priv->timer = 0;
}
+
+ if (self->priv->show_seconds) {
+ self->priv->timer = g_timeout_add_seconds(1, timer_func, self);
+ } else {
+ time_t t;
+ struct tm *ltime;
+
+ t = time(NULL);
+ ltime = localtime(&t);
+
+ /* Plus 2 so we're just after the minute, don't want to be early. */
+ self->priv->timer = g_timeout_add_seconds(60 - ltime->tm_sec + 2, timer_func, self);
+ }
- self->priv->timer = g_timeout_add_seconds(60, timer_func, self);
return;
}