ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #03758
[Merge] lp:~jjardon/indicator-datetime/use_gdatetime into lp:indicator-datetime
Javier Jardón has proposed merging lp:~jjardon/indicator-datetime/use_gdatetime into lp:indicator-datetime.
Requested reviews:
Indicator Applet Developers (indicator-applet-developers)
For more details, see:
https://code.launchpad.net/~jjardon/indicator-datetime/use_gdatetime/+merge/71705
--
https://code.launchpad.net/~jjardon/indicator-datetime/use_gdatetime/+merge/71705
Your team ayatana-commits is subscribed to branch lp:indicator-datetime.
=== modified file 'src/datetime-service.c'
--- src/datetime-service.c 2011-08-03 17:38:26 +0000
+++ src/datetime-service.c 2011-08-16 14:37:44 +0000
@@ -299,25 +299,25 @@
static gboolean
update_datetime (gpointer user_data)
{
+ GDateTime *datetime;
+ gchar *utf8;
+
g_debug("Updating Date/Time");
- gchar longstr[128];
- time_t t;
- struct tm *ltime;
-
- t = time(NULL);
- ltime = localtime(&t);
- if (ltime == NULL) {
+ datetime = g_date_time_new_now_local ();
+ if (datetime == NULL) {
g_warning("Error getting local time");
dbusmenu_menuitem_property_set(date, DBUSMENU_MENUITEM_PROP_LABEL, _("Error getting time"));
+ g_date_time_unref (datetime);
return FALSE;
}
- /* Translators: strftime(3) style date format on top of the menu when you click on the clock */
- strftime(longstr, 128, _("%A, %e %B %Y"), ltime);
-
- gchar * utf8 = g_locale_to_utf8(longstr, -1, NULL, NULL, NULL);
+ /* eranslators: strftime(3) style date format on top of the menu when you click on the clock */
+ utf8 = g_date_time_format (datetime, _("%A, %e %B %Y"));
+
dbusmenu_menuitem_property_set(date, DBUSMENU_MENUITEM_PROP_LABEL, utf8);
+
+ g_date_time_unref (datetime);
g_free(utf8);
return FALSE;
@@ -701,7 +701,7 @@
// Get today & work out query times
time(&curtime);
- struct tm *today = localtime(&curtime);
+ struct tm *today = localtime(&curtime);
const int mday = today->tm_mday;
const int mon = today->tm_mon;
const int year = today->tm_year;
=== modified file 'src/indicator-datetime.c'
--- src/indicator-datetime.c 2011-07-14 14:26:01 +0000
+++ src/indicator-datetime.c 2011-08-16 14:37:44 +0000
@@ -270,6 +270,9 @@
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 @@
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);
Follow ups