#include <modest-datetime-formatter.h>
#ifdef MODEST_TOOLKIT_HILDON2
#include <gconf/gconf-client.h>
-#include <glib/gi18n.h>
-#include <modest-text-utils.h>
#include <gtk/gtkmarshal.h>
#endif
+#include <glib/gi18n.h>
+#include "modest-text-utils.h"
typedef enum {
DATETIME_FORMAT_12H,
DATETIME_FORMAT_LOCALE,
} DatetimeFormat;
-#define HILDON2_GCONF_FORMAT_KEY "/apps/clock/time-format"
+#define HILDON2_GCONF_FORMAT_DIR "/apps/clock"
+#define HILDON2_GCONF_FORMAT_KEY HILDON2_GCONF_FORMAT_DIR "/time-format"
/* 'private'/'protected' functions */
static void modest_datetime_formatter_class_init (ModestDatetimeFormatterClass *klass);
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (ModestDatetimeFormatterClass, format_changed),
NULL, NULL,
- gtk_marshal_VOID__VOID,
+ g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
update_format (ModestDatetimeFormatter *obj)
{
GConfClient *gconf;
- GError *error = NULL;
+ GError *err = NULL;
gboolean gconf_value;
ModestDatetimeFormatterPrivate *priv;
gconf = gconf_client_get_default ();
gconf_value = gconf_client_get_bool (gconf, HILDON2_GCONF_FORMAT_KEY,
- &error);
+ &err);
- if (error != NULL) {
- g_warning ("Error reading time format in gconf %s", error->message);
- g_error_free (error);
+ if (err != NULL) {
+ g_warning ("Error reading time format in gconf %s", err->message);
+ g_error_free (err);
} else {
priv->current_format = gconf_value?DATETIME_FORMAT_24H:DATETIME_FORMAT_12H;
}
#ifdef MODEST_TOOLKIT_HILDON2
GConfClient *gconf;
- GError *error = NULL;
+ GError *err = NULL;
gconf = gconf_client_get_default ();
+ gconf_client_add_dir (gconf, HILDON2_GCONF_FORMAT_DIR,
+ GCONF_CLIENT_PRELOAD_ONELEVEL,
+ &err);
priv->gconf_handler = gconf_client_notify_add (gconf, HILDON2_GCONF_FORMAT_KEY,
clock_format_changed, (gpointer) obj,
- NULL, &error);
+ NULL, &err);
- if (error != NULL) {
- g_warning ("Error listening to time format in gconf %s", error->message);
- g_error_free (error);
+ if (err != NULL) {
+ g_warning ("Error listening to time format in gconf %s", err->message);
+ g_error_free (err);
}
update_format (obj);
#endif
{
#ifdef MODEST_TOOLKIT_HILDON2
ModestDatetimeFormatterPrivate *priv;
+ GConfClient *gconf;
priv = MODEST_DATETIME_FORMATTER_GET_PRIVATE (obj);
- gconf_client_notify_remove (gconf_client_get_default (),
+ gconf = gconf_client_get_default ();
+ gconf_client_notify_remove (gconf,
priv->gconf_handler);
priv->gconf_handler = 0;
+ gconf_client_remove_dir (gconf, HILDON2_GCONF_FORMAT_DIR,
+ NULL);
#endif
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
switch (priv->current_format) {
case DATETIME_FORMAT_12H:
- format_string = is_pm?_HL("wdgt_12h_time_pm"):_HL("wdgt_12h_time_am");
+ format_string = is_pm?_HL("wdgt_va_12h_time_pm"):_HL("wdgt_va_12h_time_am");
break;
case DATETIME_FORMAT_24H:
format_string = _HL("wdgt_va_24h_time");
}
const gchar *
+modest_datetime_formatter_display_long_datetime (ModestDatetimeFormatter *self,
+ time_t date)
+{
+
+#define DATE_BUF_DOUBLE_SIZE 128
+
+ static gchar date_buf[DATE_BUF_DOUBLE_SIZE];
+
+ snprintf (date_buf, DATE_BUF_DOUBLE_SIZE,
+ "%s %s", modest_datetime_formatter_format_date (self, date),
+ modest_datetime_formatter_format_time (self, date));
+
+ return date_buf;
+}
+
+const gchar *
modest_datetime_formatter_display_datetime (ModestDatetimeFormatter *self,
time_t date)
{