From 648b7cc189f25359c124161e61536a121f7bc9a9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Jul 2010 16:38:50 -0500 Subject: Adding a level of indirection to encapsulate the setting up of the timer func --- src/indicator-datetime.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src') 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; -- cgit v1.2.3