X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-datetime-formatter.c;h=b04ec34010b8b1dbfc1c16df12fcb4cdda76e82e;hp=db50dc1c280fbca8d6dbf7dcd8e8a93d2dcf9c55;hb=f0d738c2f55101eca82723d61289d2eb9c3b67fa;hpb=f5dacc075b7a68afc0ed0aa4a4c8f6e8cc2d6e33 diff --git a/src/modest-datetime-formatter.c b/src/modest-datetime-formatter.c index db50dc1..b04ec34 100644 --- a/src/modest-datetime-formatter.c +++ b/src/modest-datetime-formatter.c @@ -63,6 +63,14 @@ struct _ModestDatetimeFormatterPrivate { #endif }; +/* We need this very nasty stuff because the call to + osso_time_set_notification_cb cannot be reverted and thus the + handler will be called always even though we try to set another + one */ +#ifdef MODEST_USE_LIBTIME +static ModestDatetimeFormatter *global_self = NULL; +#endif + #define MODEST_DATETIME_FORMATTER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ MODEST_TYPE_DATETIME_FORMATTER, \ ModestDatetimeFormatterPrivate)) @@ -162,11 +170,13 @@ clock_format_changed (GConfClient *gconf, #endif #ifdef MODEST_USE_LIBTIME -static void +static void time_changed_cb (gpointer userdata) { - time_get_synced (); - g_signal_emit (G_OBJECT (userdata), signals[FORMAT_CHANGED_SIGNAL], 0); + if (global_self) { + time_get_synced (); + g_signal_emit (global_self, signals[FORMAT_CHANGED_SIGNAL], 0); + } } #endif @@ -200,9 +210,10 @@ init_format (ModestDatetimeFormatter *obj) #endif #ifdef MODEST_USE_LIBTIME - osso_time_set_notification_cb (modest_platform_get_osso_context (), - time_changed_cb, - obj); + if (OSSO_OK == osso_time_set_notification_cb (modest_platform_get_osso_context (), + time_changed_cb, + NULL)) + global_self = obj; time_get_synced (); #endif @@ -231,7 +242,9 @@ modest_datetime_formatter_finalize (GObject *obj) /* Disconnect notification */ #ifdef MODEST_USE_LIBTIME - osso_time_set_notification_cb (modest_platform_get_osso_context (), NULL, NULL); + if (OSSO_OK != osso_time_set_notification_cb (modest_platform_get_osso_context (), + NULL, NULL)) + global_self = NULL; #endif #endif G_OBJECT_CLASS (parent_class)->finalize (obj); @@ -259,7 +272,7 @@ modest_datetime_formatter_format_date (ModestDatetimeFormatter *self, switch (priv->current_format) { case DATETIME_FORMAT_12H: case DATETIME_FORMAT_24H: - format_string = _HL("wdgt_va_date"); + format_string = _HL_DATE; break; case DATETIME_FORMAT_LOCALE: format_string = "%x"; @@ -295,10 +308,10 @@ modest_datetime_formatter_format_time (ModestDatetimeFormatter *self, switch (priv->current_format) { case DATETIME_FORMAT_12H: - format_string = is_pm?_HL("wdgt_va_12h_time_pm"):_HL("wdgt_va_12h_time_am"); + format_string = is_pm?_HL_12H_TIME_PM:_HL_12H_TIME_AM; break; case DATETIME_FORMAT_24H: - format_string = _HL("wdgt_va_24h_time"); + format_string = _HL_24H_TIME; break; case DATETIME_FORMAT_LOCALE: format_string = "%X";