diff options
author | Javier Jardón <javier.jardon@codethink.co.uk> | 2011-08-16 15:18:37 +0100 |
---|---|---|
committer | Javier Jardón <javier.jardon@codethink.co.uk> | 2011-08-16 15:18:37 +0100 |
commit | 8d74e5b47c5134f906fcd728b836047b8a4ad81f (patch) | |
tree | 4e08199574a89d79af741f4889a0143f2941063e /src/indicator-datetime.c | |
parent | 535f3a157ed42ea19e74f1f2ed194500b29b150e (diff) | |
download | ayatana-indicator-datetime-8d74e5b47c5134f906fcd728b836047b8a4ad81f.tar.gz ayatana-indicator-datetime-8d74e5b47c5134f906fcd728b836047b8a4ad81f.tar.bz2 ayatana-indicator-datetime-8d74e5b47c5134f906fcd728b836047b8a4ad81f.zip |
Use the new GDateTime glib API to deal with time
Diffstat (limited to 'src/indicator-datetime.c')
-rw-r--r-- | src/indicator-datetime.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 163804b..5da4a37 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -270,6 +270,9 @@ static void menu_visible_notfy_cb(GtkWidget * menu, G_GNUC_UNUSED GParamSpec *pspec, gpointer user_data) { IndicatorDatetime * self = INDICATOR_DATETIME(user_data); + GDateTime *datetime; + gint y, m, d; + g_debug("notify visible signal received"); // we should only react if we're currently visible @@ -277,18 +280,14 @@ menu_visible_notfy_cb(GtkWidget * menu, G_GNUC_UNUSED GParamSpec *pspec, gpointe g_object_get(G_OBJECT(menu), "visible", &visible, NULL); if (visible) return; g_debug("notify visible menu hidden, resetting date"); - - time_t curtime; - - time(&curtime); - struct tm *today = localtime(&curtime); - int y = today->tm_year; - int m = today->tm_mon; - int d = today->tm_mday; - + + datetime = g_date_time_new_now_local (); + g_date_time_get_ymd (datetime, &y, &m, &d); + g_date_time_unref (datetime); + // Set the calendar to todays date - ido_calendar_menu_item_set_date (self->priv->ido_calendar, y+1900, m, d); - + ido_calendar_menu_item_set_date (self->priv->ido_calendar, y, m, d); + // Make sure the day-selected signal is sent so the menu updates - may duplicate /*GVariant *variant = g_variant_new_uint32((guint)curtime); guint timestamp = (guint)time(NULL); |