aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-08-04 21:04:02 +0800
committerMilan Crha <mcrha@redhat.com>2009-08-04 21:04:02 +0800
commitb6313289303f2263649c70ea477e04aea4a994ec (patch)
tree36b4435a060aca6425e717b1b0ddd29efb8a0712 /mail
parentbc301a8c3784610a0c55c9fb5056ec63ca574f4d (diff)
downloadgsoc2013-evolution-b6313289303f2263649c70ea477e04aea4a994ec.tar
gsoc2013-evolution-b6313289303f2263649c70ea477e04aea4a994ec.tar.gz
gsoc2013-evolution-b6313289303f2263649c70ea477e04aea4a994ec.tar.bz2
gsoc2013-evolution-b6313289303f2263649c70ea477e04aea4a994ec.tar.lz
gsoc2013-evolution-b6313289303f2263649c70ea477e04aea4a994ec.tar.xz
gsoc2013-evolution-b6313289303f2263649c70ea477e04aea4a994ec.tar.zst
gsoc2013-evolution-b6313289303f2263649c70ea477e04aea4a994ec.zip
Bug #205137 - Configurable date formats in components
Diffstat (limited to 'mail')
-rw-r--r--mail/em-format-html-display.c29
-rw-r--r--mail/em-format-html.c34
-rw-r--r--mail/em-mailer-prefs.c8
-rw-r--r--mail/mail-config.glade93
-rw-r--r--mail/message-list.c8
5 files changed, 131 insertions, 41 deletions
diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c
index 312e5a1fb5..003eb37f8c 100644
--- a/mail/em-format-html-display.c
+++ b/mail/em-format-html-display.c
@@ -63,6 +63,7 @@
#include <e-util/e-util-private.h>
#include <libedataserver/e-msgport.h>
+#include "e-util/e-datetime-format.h"
#include <e-util/e-dialog-utils.h>
#include <e-util/e-icon-factory.h>
@@ -82,16 +83,6 @@
#include "widgets/misc/e-attachment-button.h"
#include "widgets/misc/e-attachment-view.h"
-#ifdef G_OS_WIN32
-/* Undefine the similar macro from <pthread.h>,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)
struct _EMFormatHTMLDisplayPrivate {
@@ -953,9 +944,7 @@ static void efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePar
{
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
@@ -986,10 +975,10 @@ static void efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePar
camel_stream_printf(stream, "<td align=\"left\" width=\"100%%\">");
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;
@@ -998,9 +987,9 @@ static void efhd_message_prefix(EMFormat *emf, CamelStream *stream, CamelMimePar
if (now > date)
camel_stream_printf(stream, "<b>%s</b>&nbsp;", _("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 ec3427c88d..038ca4b61b 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -43,6 +43,7 @@
#include <libedataserver/e-data-server-util.h> /* for e_utf8_strftime, what about e_time_format_time? */
#include <libedataserver/e-time-utils.h>
+#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"
@@ -1750,14 +1751,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);
@@ -1765,25 +1768,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("<I>%s</I>", _(" (%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("<I>%s</I>", _(" (%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 (<I>%s</I>)", 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/em-mailer-prefs.c b/mail/em-mailer-prefs.c
index 057b2d9210..7da40551a5 100644
--- a/mail/em-mailer-prefs.c
+++ b/mail/em-mailer-prefs.c
@@ -41,6 +41,7 @@
#include "libedataserverui/e-cell-renderer-color.h"
+#include "e-util/e-datetime-format.h"
#include "e-util/e-util-private.h"
#include "e-util/e-util-labels.h"
@@ -1147,7 +1148,7 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs)
{
GSList *header_config_list, *header_add_list, *p;
GHashTable *default_header_hash;
- GtkWidget *toplevel;
+ GtkWidget *toplevel, *table;
GtkTreeSelection *selection;
GtkCellRenderer *renderer;
GtkTreeIter iter;
@@ -1449,6 +1450,11 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs)
g_slist_free (header_add_list);
+ /* date/time format */
+ table = glade_xml_get_widget (gui, "datetime_format_table");
+ e_datetime_format_add_setup_widget (table, 0, "mail", "header", DTFormatKindDateTime, _("Date header:"));
+ e_datetime_format_add_setup_widget (table, 1, "mail", "table", DTFormatKindDateTime, _("Table column:"));
+
/* Junk prefs */
prefs->check_incoming = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkCheckIncomingMail"));
toggle_button_init (prefs, prefs->check_incoming, FALSE,
diff --git a/mail/mail-config.glade b/mail/mail-config.glade
index 586dc854b1..a97fbb8ab2 100644
--- a/mail/mail-config.glade
+++ b/mail/mail-config.glade
@@ -6583,6 +6583,99 @@ b</property>
<property name="fill">True</property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox210">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkLabel" id="label591">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;span weight=&quot;bold&quot;&gt;Date/Time Format&lt;/span&gt;</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">txtHeaders</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox245">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkLabel" id="label592">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">6</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkTable" id="datetime_format_table">
+ <property name="visible">True</property>
+ <property name="n_rows">1</property>
+ <property name="n_columns">3</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">0</property>
+ <property name="column_spacing">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="tab_expand">False</property>
diff --git a/mail/message-list.c b/mail/message-list.c
index 07143ca0e5..92c740bb9d 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -1728,7 +1728,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,
@@ -1811,6 +1812,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,
@@ -1844,6 +1846,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;
}