aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2009-11-05 21:53:05 +0800
committerMilan Crha <mcrha@redhat.com>2009-11-05 21:53:05 +0800
commitc79efd6590bfabecd3a31c2a30d1ddb9a55349e4 (patch)
tree0eed30a3489a4689428a590d5759d44a0f81fd76 /mail
parentdf1f9b3b33de886c5b9a63b0ee6e722bfea4b2e0 (diff)
downloadgsoc2013-evolution-c79efd6590bfabecd3a31c2a30d1ddb9a55349e4.tar.gz
gsoc2013-evolution-c79efd6590bfabecd3a31c2a30d1ddb9a55349e4.tar.zst
gsoc2013-evolution-c79efd6590bfabecd3a31c2a30d1ddb9a55349e4.zip
Bug #597582 - Original Date: header should be given precedence
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-reader.c4
-rw-r--r--mail/em-format-html.c83
-rw-r--r--mail/em-format-html.h3
-rw-r--r--mail/evolution-mail.schemas.in15
4 files changed, 90 insertions, 15 deletions
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index f6a3f99a26..d77fafc448 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -2516,6 +2516,10 @@ e_mail_reader_init (EMailReader *reader)
shell_settings, "mail-show-sender-photo",
html_display, "show-sender-photo");
+ e_binding_new (
+ shell_settings, "mail-show-real-date",
+ html_display, "show-real-date");
+
action_name = "mail-caret-mode";
action = e_mail_reader_get_action (reader, action_name);
diff --git a/mail/em-format-html.c b/mail/em-format-html.c
index 53d10e8f12..47213dc5d5 100644
--- a/mail/em-format-html.c
+++ b/mail/em-format-html.c
@@ -112,6 +112,7 @@ struct _EMFormatHTMLPrivate {
guint load_images_now : 1;
guint only_local_photos : 1;
guint show_sender_photo : 1;
+ guint show_real_date : 1;
};
enum {
@@ -125,6 +126,7 @@ enum {
PROP_MARK_CITATIONS,
PROP_ONLY_LOCAL_PHOTOS,
PROP_SHOW_SENDER_PHOTO,
+ PROP_SHOW_REAL_DATE,
PROP_TEXT_COLOR
};
@@ -485,6 +487,12 @@ efh_set_property (GObject *object,
g_value_get_boolean (value));
return;
+ case PROP_SHOW_REAL_DATE:
+ em_format_html_set_show_real_date (
+ EM_FORMAT_HTML (object),
+ g_value_get_boolean (value));
+ return;
+
case PROP_TEXT_COLOR:
em_format_html_set_color (
EM_FORMAT_HTML (object),
@@ -570,6 +578,12 @@ efh_get_property (GObject *object,
EM_FORMAT_HTML (object)));
return;
+ case PROP_SHOW_REAL_DATE:
+ g_value_set_boolean (
+ value, em_format_html_get_show_real_date (
+ EM_FORMAT_HTML (object)));
+ return;
+
case PROP_TEXT_COLOR:
em_format_html_get_color (
EM_FORMAT_HTML (object),
@@ -863,6 +877,17 @@ efh_class_init (EMFormatHTMLClass *class)
g_object_class_install_property (
object_class,
+ PROP_SHOW_REAL_DATE,
+ g_param_spec_boolean (
+ "show-real-date",
+ "Show real Date header value",
+ NULL,
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
PROP_TEXT_COLOR,
g_param_spec_boxed (
"text-color",
@@ -1135,6 +1160,25 @@ em_format_html_set_show_sender_photo (EMFormatHTML *efh,
g_object_notify (G_OBJECT (efh), "show-sender-photo");
}
+gboolean
+em_format_html_get_show_real_date (EMFormatHTML *efh)
+{
+ g_return_val_if_fail (EM_IS_FORMAT_HTML (efh), FALSE);
+
+ return efh->priv->show_real_date;
+}
+
+void
+em_format_html_set_show_real_date (EMFormatHTML *efh,
+ gboolean show_real_date)
+{
+ g_return_if_fail (EM_IS_FORMAT_HTML (efh));
+
+ efh->priv->show_real_date = show_real_date;
+
+ g_object_notify (G_OBJECT (efh), "show-real-date");
+}
+
CamelMimePart *
em_format_html_file_part(EMFormatHTML *efh, const gchar *mime_type, const gchar *filename)
{
@@ -2370,38 +2414,47 @@ 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;
+ gchar *html;
+ gboolean hide_real_date;
+
+ hide_real_date = !em_format_html_get_show_real_date (efh);
txt = header->value;
while (*txt == ' ' || *txt == '\t')
txt++;
+ html = camel_text_to_html (txt, efh->text_html_flags, 0);
+
msg_date = camel_header_decode_date(txt, &msg_offset);
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);
/* Turn into offset from localtime, not UTC */
msg_offset -= local_tz / 60;
- if (msg_offset) {
- gchar *html;
+ /* value will be freed at the end */
+ if (!hide_real_date && !msg_offset) {
+ /* No timezone difference; just show the real Date: header */
+ txt = value = html;
+ } else {
+ gchar *date_str;
- html = camel_text_to_html (txt, efh->text_html_flags, 0);
- txt = value = g_strdup_printf ("%s (<I>%s</I>)", date_str, html);
+ date_str = e_datetime_format_format ("mail", "header",
+ DTFormatKindDateTime, msg_date);
+ if (hide_real_date) {
+ /* Show only the local-formatted date, losing all timezone
+ information like Outlook does. Should we attempt to show
+ it somehow? */
+ txt = value = date_str;
+ } else {
+ txt = value = g_strdup_printf ("%s (<I>%s</I>)", html, date_str);
+ g_free (date_str);
+ }
g_free (html);
- g_free (date_str);
-
- flags |= EM_FORMAT_HTML_HEADER_HTML;
- } else {
- /* date_str will be freed at the end */
- txt = value = date_str;
}
-
- flags |= EM_FORMAT_HEADER_BOLD;
+ flags |= EM_FORMAT_HTML_HEADER_HTML | EM_FORMAT_HEADER_BOLD;
} else if (!strcmp(name, "Newsgroups")) {
struct _camel_header_newsgroup *ng, *scan;
GString *html;
diff --git a/mail/em-format-html.h b/mail/em-format-html.h
index a76ae9cfb7..9d96c4056c 100644
--- a/mail/em-format-html.h
+++ b/mail/em-format-html.h
@@ -278,6 +278,9 @@ EMFormatHTMLJob *
gpointer data);
void em_format_html_job_queue (EMFormatHTML *efh,
EMFormatHTMLJob *job);
+gboolean em_format_html_get_show_real_date(EMFormatHTML *efh);
+void em_format_html_set_show_real_date(EMFormatHTML *efh,
+ gboolean show_real_date);
G_END_DECLS
diff --git a/mail/evolution-mail.schemas.in b/mail/evolution-mail.schemas.in
index 418e57d371..6039c31cef 100644
--- a/mail/evolution-mail.schemas.in
+++ b/mail/evolution-mail.schemas.in
@@ -1136,6 +1136,21 @@
</locale>
</schema>
+ <schema>
+ <key>/schemas/apps/evolution/mail/display/show_real_date</key>
+ <applyto>/apps/evolution/mail/display/show_real_date</applyto>
+ <owner>evolution-mail</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short>Show original "Date" header value.</short>
+ <long>
+ Show the original "Date" header (with a local time only if the time zone differs).
+ Otherwise always show "Date" header value in a user preferred format and local time zone.
+ </long>
+ </locale>
+ </schema>
+
<!-- Labels and Colours -->