diff options
author | Ted Gould <ted@gould.cx> | 2010-01-05 15:41:53 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-01-05 15:41:53 -0600 |
commit | a324b57d5d79f7a081fc4d8ad0fa2f9d36e72beb (patch) | |
tree | ee8384812b99fc4be9eea5507f3d35dfe14103b7 | |
parent | e154d9e960566730478182bae00405c8f00d4f32 (diff) | |
download | ayatana-indicator-datetime-a324b57d5d79f7a081fc4d8ad0fa2f9d36e72beb.tar.gz ayatana-indicator-datetime-a324b57d5d79f7a081fc4d8ad0fa2f9d36e72beb.tar.bz2 ayatana-indicator-datetime-a324b57d5d79f7a081fc4d8ad0fa2f9d36e72beb.zip |
Adding in a timer to update
-rw-r--r-- | src/indicator-datetime.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 1112536..1dbd6ce 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -34,6 +34,7 @@ struct _IndicatorDatetime { struct _IndicatorDatetimePrivate { GtkLabel * label; + guint timer; }; #define INDICATOR_DATETIME_GET_PRIVATE(o) \ @@ -121,6 +122,23 @@ update_label (GtkLabel * label) return; } +/* Runs every minute and updates the time */ +gboolean +minute_timer_func (gpointer user_data) +{ + IndicatorDatetime * self = INDICATOR_DATETIME(user_data); + + if (self->priv->label != NULL) { + update_label(self->priv->label); + return TRUE; + } else { + self->priv->timer = 0; + return FALSE; + } + + return FALSE; +} + /* Grabs the label. Creates it if it doesn't exist already */ static GtkLabel * @@ -135,6 +153,10 @@ get_label (IndicatorObject * io) update_label(self->priv->label); gtk_widget_show(GTK_WIDGET(self->priv->label)); } + + if (self->priv->timer == 0) { + self->priv->timer = g_timeout_add_seconds(60, minute_timer_func, self); + } return self->priv->label; } |