From 50302d03b3ce145b165db2ddef4e92ad190cbef9 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 4 Aug 2009 15:04:02 +0200 Subject: Bug #205137 - Configurable date formats in components --- mail/em-format-html-display.c | 29 +- mail/em-format-html.c | 34 +- mail/mail-config.glade | 1963 +++++++++++++++++++++++++++-------------- mail/message-list.c | 8 +- 4 files changed, 1315 insertions(+), 719 deletions(-) (limited to 'mail') diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index a15b0d671f..70b8547972 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -63,6 +63,7 @@ #include #include +#include "e-util/e-datetime-format.h" #include #include @@ -81,16 +82,6 @@ #include "widgets/misc/e-attachment-button.h" #include "widgets/misc/e-attachment-view.h" -#ifdef G_OS_WIN32 -/* Undefine the similar macro from ,it doesn't check if - * localtime() returns NULL. - */ -#undef localtime_r - -/* The localtime() in Microsoft's C library is MT-safe */ -#define localtime_r(tp,tmp) (localtime(tp)?(*(tmp)=*localtime(tp),(tmp)):0) -#endif - #define d(x) #define EM_FORMAT_HTML_DISPLAY_GET_PRIVATE(obj) \ @@ -768,9 +759,7 @@ efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMF { const gchar *flag, *comp, *due; time_t date; - gchar due_date[128]; - struct tm due_tm; - gchar *iconpath; + gchar *iconpath, *due_date_str; if (emf->folder == NULL || emf->uid == NULL || (flag = camel_folder_get_message_user_tag(emf->folder, emf->uid, "follow-up")) == NULL @@ -801,10 +790,10 @@ efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMF camel_stream_printf(stream, ""); if (comp && comp[0]) { - date = camel_header_decode_date(comp, NULL); - localtime_r(&date, &due_tm); - e_utf8_strftime_fix_am_pm(due_date, sizeof (due_date), _("Completed on %B %d, %Y, %l:%M %p"), &due_tm); - camel_stream_printf(stream, "%s, %s", flag, due_date); + date = camel_header_decode_date (comp, NULL); + due_date_str = e_datetime_format_format ("mail", "header", DTFormatKindDateTime, date); + camel_stream_printf (stream, "%s, %s %s", flag, _("Completed on"), due_date_str ? due_date_str : "???"); + g_free (due_date_str); } else if ((due = camel_folder_get_message_user_tag(emf->folder, emf->uid, "due-by")) != NULL && due[0]) { time_t now; @@ -813,9 +802,9 @@ efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePart *part, EMF if (now > date) camel_stream_printf(stream, "%s ", _("Overdue:")); - localtime_r(&date, &due_tm); - e_utf8_strftime_fix_am_pm(due_date, sizeof (due_date), _("by %B %d, %Y, %l:%M %p"), &due_tm); - camel_stream_printf(stream, "%s %s", flag, due_date); + due_date_str = e_datetime_format_format ("mail", "header", DTFormatKindDateTime, date); + /* To Translators: the "by" is part of the string, like "Follow-up by Tuesday, January 13, 2009" */ + camel_stream_printf (stream, "%s %s %s", flag, _("by"), due_date_str ? due_date_str : "???"); } else { camel_stream_printf(stream, "%s", flag); } diff --git a/mail/em-format-html.c b/mail/em-format-html.c index fa713282c1..b9657a1fd9 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -43,6 +43,7 @@ #include /* for e_utf8_strftime, what about e_time_format_time? */ #include +#include "e-util/e-datetime-format.h" #include "e-util/e-icon-factory.h" #include "e-util/e-util-private.h" #include "e-util/e-util.h" @@ -2321,14 +2322,16 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct gint msg_offset, local_tz; time_t msg_date; struct tm local; + gchar *date_str; txt = header->value; while (*txt == ' ' || *txt == '\t') txt++; - /* Show the local timezone equivalent in brackets if the sender is remote */ msg_date = camel_header_decode_date(txt, &msg_offset); - e_localtime_with_offset(msg_date, &local, &local_tz); + e_localtime_with_offset (msg_date, &local, &local_tz); + + date_str = e_datetime_format_format ("mail", "header", DTFormatKindDateTime, msg_date); /* Convert message offset to minutes (e.g. -0400 --> -240) */ msg_offset = ((msg_offset / 100) * 60) + (msg_offset % 100); @@ -2336,25 +2339,18 @@ efh_format_header(EMFormat *emf, CamelStream *stream, CamelMedium *part, struct msg_offset -= local_tz / 60; if (msg_offset) { - gchar buf[256], *html; - - msg_offset += (local.tm_hour * 60) + local.tm_min; - if (msg_offset >= (24 * 60) || msg_offset < 0) { - /* translators: strftime format for local time equivalent in Date header display, with day */ - gchar *msg = g_strdup_printf("%s", _(" (%a, %R %Z)")); - e_utf8_strftime(buf, sizeof(buf), msg, &local); - g_free(msg); - } else { - /* translators: strftime format for local time equivalent in Date header display, without day */ - gchar *msg = g_strdup_printf("%s", _(" (%R %Z)")); - e_utf8_strftime(buf, sizeof(buf), msg, &local); - g_free(msg); - } + gchar *html; + + html = camel_text_to_html (txt, efh->text_html_flags, 0); + txt = value = g_strdup_printf ("%s (%s)", date_str, html); + + g_free (html); + g_free (date_str); - html = camel_text_to_html(txt, efh->text_html_flags, 0); - txt = value = g_strdup_printf("%s %s", html, buf); - g_free(html); flags |= EM_FORMAT_HTML_HEADER_HTML; + } else { + /* date_str will be freed at the end */ + txt = value = date_str; } flags |= EM_FORMAT_HEADER_BOLD; diff --git a/mail/mail-config.glade b/mail/mail-config.glade index b6e61b87f7..a0b61bf6bd 100644 --- a/mail/mail-config.glade +++ b/mail/mail-config.glade @@ -3215,685 +3215,1290 @@ For example: "Work" or "Personal" True a b - - - False - False - 1 - - - - - 0 - - - - - Confirm _when expunging a folder - True - True - False - True - True - - - False - False - 1 - - - - - - - 1 - - - - - 1 - - - - - False - False - 2 - - - - - - - True - General - True - center - - - False - tab - - - - - True - 12 - 12 - - - True - 0 - <span weight="bold">General</span> - True - - - False - False - 0 - - - - - True - 12 - - - True - - - False - False - 0 - - - - - True - 6 - - - _Show image animations - True - True - False - True - True - - - False - False - 0 - - - - - _Prompt on sending HTML mail to contacts that do not want them - True - True - False - True - True - - - False - False - 1 - - - - - False - False - 1 - - - - - False - False - 1 - - - - - True - 6 - - - True - 0 - <span weight="bold">Loading Images</span> - True - - - False - False - 0 - - - - - True - 12 - - - True - - - False - False - 0 - - - - - True - 6 - - - _Never load images from the Internet - True - True - False - True - True - - - False - False - 0 - - - - - _Load images in messages from contacts - True - True - False - True - True - radImagesNever - - - False - False - 1 - - - - - _Always load images from the Internet - True - True - False - True - True - radImagesNever - - - False - False - 2 - - - - - False - False - 1 - - - - - False - False - 1 - - - - - False - False - 2 - - - - - 1 - - - - - True - HTML Messages - True - center - - - 1 - False - tab - - - - - True - 12 - 6 - - - True - 0 - <span weight="bold">Labels</span> - True - - - False - False - 0 - - - - - True - 12 - - - - - - 1 - - - - - 2 - - - - - True - Labels - True - center - - - 2 - False - tab - - - - - True - 12 - 6 - - - True - 3 - - - True - - - True - <b>Sender Photograph</b> - True - - - False - False - 0 - - - - - False - False - 0 - - - - - True - - - True - - - _Show the photograph of sender in the message preview - True - True - False - True - True - - - False - False - 10 - 0 - - - - - False - False - 0 - - - - - True - - - S_earch for sender photograph only in local address books - True - True - False - True - True - - - False - False - 10 - 0 - - - - - False - False - 1 - - - - - False - False - 1 - - - - - False - False - 0 - - - - - True - 0 - <span weight="bold">Displayed Message _Headers</span> - True - True - txtHeaders - - - False - False - 1 - - - - - True - 12 - - - True - - - False - False - 0 - - - - - True - 12 - - - True - True - - - False - False - 0 - - - - - True - True - automatic - automatic - in - - - True - True - False - - Mail Headers Table - - - - - - 1 - - - - - 1 - - - - - True - 6 - - - gtk-add - True - False - True - False - True - - - False - False - 0 - - - - - gtk-remove - True - True - False - True - - - False - False - 1 - - - - - False - False - 2 - - - - - 2 - - - - - 3 - - - - - True - Headers - True - - - 3 - False - tab - - - - - True - 12 - 6 - - - True - - - True - 0 - <span weight="bold">General</span> - True - - - False - False - 0 - - - - - True - 12 - 9 - 3 - - - True - 6 - - - True - _Default junk plugin: - True - default_junk_plugin - - - False - False - 6 - 0 - - - - - True - create_combo_text_widget - - - False - False - 1 - - - - - 7 - 8 - GTK_FILL - - - - - Check incoming _messages for junk - True - True - False - Checks incoming mail messages to be Junk - True - True - - - GTK_FILL - - 4 - - - - - True - 3 - - - True - gtk-info - 4 - - - False - False - 0 - - - - - True - True - - - False - False - 1 - - - - - 8 - 9 - GTK_FILL - 15 - - - - - True - 4 - - - Delete junk messages on e_xit - True - True - False - True - True - - - False - False - 0 - - - - - True - a + False + True + + + 0 + False + False + + + + + 0 + True + True + + + + + + True + True + Confirm _when expunging a folder + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + 0 + 1 + 0 + 1 + + + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + False + False + + + + + False + True + + + + + + True + General + True + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + + 12 + True + False + 12 + + + + True + <span weight="bold">General</span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 12 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 6 + + + + True + True + _Show image animations + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + _Prompt on sending HTML mail to contacts that do not want them + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 6 + + + + True + <span weight="bold">Loading Images</span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 12 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 6 + + + + True + True + _Never load images from the Internet + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + _Load images in messages from contacts + True + GTK_RELIEF_NORMAL + True + False + False + True + radImagesNever + + + 0 + False + False + + + + + + True + True + _Always load images from the Internet + True + GTK_RELIEF_NORMAL + True + False + False + True + radImagesNever + + + 0 + False + False + + + + + 0 + False + False + + + + + 0 + False + False + + + + + 0 + False + False + + + + + False + True + + + + + + True + HTML Messages + True + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + + 12 + True + False + 6 + + + + True + <span weight="bold">Labels</span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 12 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 0 + + + + True + False + 0 + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + False + False + False + + + + + 0 + True + True + + + + + + True + Note: Underscore in the label name is used as mnemonic identifier in menu. + False + False + GTK_JUSTIFY_CENTER + True + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 10 + False + False + + + + + 0 + True + True + + + + + + True + False + 2 + + + + True + True + gtk-add + True + GTK_RELIEF_NORMAL + False + + + 0 + False + False + + + + + + True + True + gtk-edit + True + GTK_RELIEF_NORMAL + True + + + 0 + False + False + + + + + + True + True + gtk-remove + True + GTK_RELIEF_NORMAL + True + + + 0 + False + False + + + + + + + + + 6 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + False + True + + + + + + True + Labels + True + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + + 12 + True + False + 6 + + + + True + False + 3 + + + + True + False + 0 + + + + True + <b>Sender Photograph</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 0 + + + + True + False + 0 + + + + True + True + _Show the photograph of sender in the message preview + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 10 + False + False + + + + + 0 + False + False + + + + + + True + False + 0 + + + + True + True + S_earch for sender photograph only in local address books + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 10 + False + False + + + + + 0 + False + False + + + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + <span weight="bold">Displayed Message _Headers</span> + True + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + txtHeaders + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 12 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 12 + + + + True + True + True + True + 0 + + True + * + False + + + 0 + False + False + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + False + True + False + False + False + + Mail Headers Table + + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + True + False + 6 + + + + True + False + True + gtk-add + True + GTK_RELIEF_NORMAL + True + + + 0 + False + False + + + + + + True + True + gtk-remove + True + GTK_RELIEF_NORMAL + True + + + 0 + False + False + + + + + 0 + False + False + + + + + 0 + True + True + + + + + + True + False + 0 + + + + True + <span weight="bold">Date/Time Format</span> + True + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + txtHeaders + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + False + 0 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 6 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + 1 + 3 + False + 0 + 0 + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + False + True + + + + + False + True + + + + + + True + Headers + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + + + + + 12 + True + False + 6 + + + + True + False + 0 + + + + True + <span weight="bold">General</span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + 12 + True + 9 + 1 + False + 3 + 0 + + + + True + False + 6 + + + + True + _Default junk plugin: + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + default_junk_plugin + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 6 + False + False + + + + + + True + create_combo_text_widget + 0 + 0 + Fri, 23 Mar 2007 09:28:55 GMT + + + 0 + False + False + + + + + 0 + 1 + 7 + 8 + fill + + + + + + True + Checks incoming mail messages to be Junk + True + Check incoming _messages for junk + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 1 + 0 + 1 + 4 + fill + + + + + + + True + False + 3 + + + + True + 4 + gtk-info + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + 0 + 1 + 8 + 9 + 15 + fill + + + + + + True + False + 4 + + + + True + True + Delete junk messages on e_xit + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + a b diff --git a/mail/message-list.c b/mail/message-list.c index b80431d5ff..7e0fb9b4c2 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -1811,7 +1811,8 @@ static ECell * create_composite_cell (gint col) images [i] = states_pixmaps [i + 6].pixbuf; cell_attach = e_cell_toggle_new (0, 2, images); - cell_date = e_cell_date_new(NULL, GTK_JUSTIFY_RIGHT); + cell_date = e_cell_date_new (NULL, GTK_JUSTIFY_RIGHT); + e_cell_date_set_format_component (E_CELL_DATE (cell_date), "mail"); g_object_set (G_OBJECT (cell_date), "bold_column", COL_UNREAD, "color_column", COL_COLOUR, @@ -1894,6 +1895,7 @@ message_list_create_extras (void) /* date cell */ cell = e_cell_date_new (NULL, GTK_JUSTIFY_LEFT); + e_cell_date_set_format_component (E_CELL_DATE (cell), "mail"); g_object_set (G_OBJECT (cell), "bold_column", COL_UNREAD, "color_column", COL_COLOUR, @@ -1927,6 +1929,10 @@ message_list_create_extras (void) cell = create_composite_cell (COL_TO); e_table_extras_add_cell (extras, "render_composite_to", cell); + /* set proper format component for a default 'date' cell renderer */ + cell = e_table_extras_get_cell (extras, "date"); + e_cell_date_set_format_component (E_CELL_DATE (cell), "mail"); + return extras; } -- cgit v1.2.3