X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-datetime-formatter.c;h=8ce371a109c12a80c03a23a750e31896eb4253ee;hp=c4a3cebc6750e04a260261a248fb7a64298db73e;hb=11d0b1ecfdd84c1711e11ed3384536a3aa0c9edf;hpb=cd21a6efcbb4ed487d3968324b1ae68e80ae10bd diff --git a/src/modest-datetime-formatter.c b/src/modest-datetime-formatter.c index c4a3ceb..8ce371a 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,10 +170,13 @@ clock_format_changed (GConfClient *gconf, #endif #ifdef MODEST_USE_LIBTIME -static void +static void time_changed_cb (gpointer userdata) { - time_get_synced (); + if (global_self) { + time_get_synced (); + g_signal_emit (global_self, signals[FORMAT_CHANGED_SIGNAL], 0); + } } #endif @@ -199,9 +210,11 @@ 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 } @@ -226,6 +239,13 @@ modest_datetime_formatter_finalize (GObject *obj) priv->gconf_handler = 0; gconf_client_remove_dir (gconf, HILDON2_GCONF_FORMAT_DIR, NULL); + + /* Disconnect notification */ +#ifdef MODEST_USE_LIBTIME + 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); }