aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-07-16 16:38:50 -0500
committerTed Gould <ted@gould.cx>2010-07-16 16:38:50 -0500
commit648b7cc189f25359c124161e61536a121f7bc9a9 (patch)
tree5af140054730fe41b7215fb25a124049a45b0f78
parentf5de0401fe3757957c033043d0cfcab6457cce3f (diff)
downloadayatana-indicator-datetime-648b7cc189f25359c124161e61536a121f7bc9a9.tar.gz
ayatana-indicator-datetime-648b7cc189f25359c124161e61536a121f7bc9a9.tar.bz2
ayatana-indicator-datetime-648b7cc189f25359c124161e61536a121f7bc9a9.zip
Adding a level of indirection to encapsulate the setting up of the timer func
-rw-r--r--src/indicator-datetime.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c
index bef53b4..983a76f 100644
--- a/src/indicator-datetime.c
+++ b/src/indicator-datetime.c
@@ -134,6 +134,7 @@ static gboolean bind_enum_get (GValue * value, GVariant * variant, g
static gchar * generate_format_string (IndicatorDatetime * self);
static void update_label (IndicatorDatetime * io);
static void guess_label_size (IndicatorDatetime * self);
+static void setup_timer (IndicatorDatetime * self);
/* Indicator Module Config */
INDICATOR_SET_VERSION
@@ -533,21 +534,28 @@ update_label (IndicatorDatetime * io)
/* Runs every minute and updates the time */
gboolean
-minute_timer_func (gpointer user_data)
+timer_func (gpointer user_data)
{
IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
+ self->priv->timer = 0;
+ setup_timer(self);
if (self->priv->label != NULL) {
update_label(self);
- return TRUE;
- } else {
- self->priv->timer = 0;
return FALSE;
}
return FALSE;
}
+/* Configure the timer to run the next time through */
+static void
+setup_timer (IndicatorDatetime * self)
+{
+ self->priv->timer = g_timeout_add_seconds(60, timer_func, self);
+ return;
+}
+
/* Does a quick meausre of how big the string is in
pixels with a Pango layout */
static gint
@@ -878,7 +886,7 @@ get_label (IndicatorObject * io)
}
if (self->priv->timer == 0) {
- self->priv->timer = g_timeout_add_seconds(60, minute_timer_func, self);
+ setup_timer(self);
}
return self->priv->label;