aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-05-09 02:13:06 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-05-09 02:39:21 +0800
commit26ca1f2c563d5b4b2f3d3adcf427b8c3db62f4c4 (patch)
tree5f6ff61eb4ac0eb243a4619ae393a2ac4810e46d
parente403abb2e4eaace12e23749e4d8cf6ddf07950fe (diff)
downloadgsoc2013-evolution-26ca1f2c563d5b4b2f3d3adcf427b8c3db62f4c4.tar
gsoc2013-evolution-26ca1f2c563d5b4b2f3d3adcf427b8c3db62f4c4.tar.gz
gsoc2013-evolution-26ca1f2c563d5b4b2f3d3adcf427b8c3db62f4c4.tar.bz2
gsoc2013-evolution-26ca1f2c563d5b4b2f3d3adcf427b8c3db62f4c4.tar.lz
gsoc2013-evolution-26ca1f2c563d5b4b2f3d3adcf427b8c3db62f4c4.tar.xz
gsoc2013-evolution-26ca1f2c563d5b4b2f3d3adcf427b8c3db62f4c4.tar.zst
gsoc2013-evolution-26ca1f2c563d5b4b2f3d3adcf427b8c3db62f4c4.zip
EMailFormatterHeaders cleanups.
-rw-r--r--em-format/e-mail-formatter-headers.c88
-rw-r--r--em-format/e-mail-formatter.h13
2 files changed, 59 insertions, 42 deletions
diff --git a/em-format/e-mail-formatter-headers.c b/em-format/e-mail-formatter-headers.c
index ab22e1a353..89ac5f677a 100644
--- a/em-format/e-mail-formatter-headers.c
+++ b/em-format/e-mail-formatter-headers.c
@@ -116,17 +116,29 @@ format_short_headers (EMailFormatter *formatter,
is_rtl = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL;
if (is_rtl) {
- g_string_append_printf (
- buffer,
- "<tr><td width=\"100%%\" align=\"right\">%s%s%s <strong>%s</strong></td></tr>",
- from->len ? "(" : "", from->str, from->len ? ")" : "",
- subject ? subject : _("(no subject)"));
+ g_string_append (
+ buffer, "<tr><td width=\"100%%\" align=\"right\">");
+ if (from->len > 0)
+ g_string_append_printf (buffer, "(%s) ", from->str);
+ g_string_append (buffer, "<strong>");
+ if (subject != NULL && *subject != '\0')
+ g_string_append (buffer, subject);
+ else
+ g_string_append (buffer, _("(no subject)"));
+ g_string_append (buffer, "</strong>");
+ g_string_append (buffer, "</td></tr>");
} else {
- g_string_append_printf (
- buffer,
- "<tr><td><strong>%s</strong> %s%s%s</td></tr>",
- subject ? subject : _("(no subject)"),
- from->len ? "(" : "", from->str, from->len ? ")" : "");
+ g_string_append (
+ buffer, "<tr><td width=\"100%%\" align=\"left\">");
+ g_string_append (buffer, "<strong>");
+ if (subject != NULL && *subject != '\0')
+ g_string_append (buffer, subject);
+ else
+ g_string_append (buffer, _("(no subject)"));
+ g_string_append (buffer, "</strong>");
+ if (from->len > 0)
+ g_string_append_printf (buffer, " (%s)", from->str);
+ g_string_append (buffer, "</td></tr>");
}
g_string_append (buffer, "</table>");
@@ -265,7 +277,7 @@ format_full_headers (EMailFormatter *formatter,
flags & E_MAIL_FORMATTER_HEADER_FLAG_COLLAPSED ? "none" : "block");
header = ((CamelMimePart *) part)->headers;
- while (header) {
+ while (header != NULL) {
if (!g_ascii_strcasecmp (header->name, "Sender")) {
struct _camel_header_address *addrs;
GString *html;
@@ -275,14 +287,15 @@ format_full_headers (EMailFormatter *formatter,
html = g_string_new ("");
name = e_mail_formatter_format_address (
- formatter, html, addrs, header->name, FALSE,
- ~(flags & E_MAIL_FORMATTER_HEADER_FLAG_NOELIPSIZE));
+ formatter, html, addrs, header->name, FALSE,
+ ~(flags & E_MAIL_FORMATTER_HEADER_FLAG_NOELIPSIZE));
header_sender = html->str;
camel_header_address_list_clear (&addrs);
g_string_free (html, FALSE);
g_free (name);
+
} else if (!g_ascii_strcasecmp (header->name, "From")) {
struct _camel_header_address *addrs;
GString *html;
@@ -292,14 +305,15 @@ format_full_headers (EMailFormatter *formatter,
html = g_string_new ("");
name = e_mail_formatter_format_address (
- formatter, html, addrs, header->name, FALSE,
- !(flags & E_MAIL_FORMATTER_HEADER_FLAG_NOELIPSIZE));
+ formatter, html, addrs, header->name, FALSE,
+ !(flags & E_MAIL_FORMATTER_HEADER_FLAG_NOELIPSIZE));
header_from = html->str;
camel_header_address_list_clear (&addrs);
g_string_free (html, FALSE);
g_free (name);
+
} else if (!g_ascii_strcasecmp (header->name, "X-Evolution-Mail-From-Delegate")) {
mail_from_delegate = TRUE;
}
@@ -349,7 +363,7 @@ format_full_headers (EMailFormatter *formatter,
/* dump selected headers */
if (mode & E_MAIL_FORMATTER_MODE_ALL_HEADERS) {
header = ((CamelMimePart *) part)->headers;
- while (header) {
+ while (header != NULL) {
e_mail_formatter_format_header (
formatter, buffer, part, header,
E_MAIL_FORMATTER_HEADER_FLAG_NOCOLUMNS, charset);
@@ -371,7 +385,7 @@ format_full_headers (EMailFormatter *formatter,
mailer = !g_ascii_strcasecmp (h->name, "X-Evolution-Mailer");
face = !g_ascii_strcasecmp (h->name, "Face");
- while (header) {
+ while (header != NULL) {
if (e_mail_formatter_get_show_sender_photo (formatter) &&
!photo_name && !g_ascii_strcasecmp (header->name, "From"))
photo_name = header->value;
@@ -505,7 +519,9 @@ emfe_headers_format (EMailFormatterExtension *extension,
GCancellable *cancellable)
{
GString *buffer;
- gint bg_color;
+ const GdkRGBA white = { 1.0, 1.0, 1.0, 1.0 };
+ const GdkRGBA *body_rgba = &white;
+ const GdkRGBA *header_rgba;
if (g_cancellable_is_cancelled (cancellable))
return FALSE;
@@ -515,26 +531,21 @@ emfe_headers_format (EMailFormatterExtension *extension,
buffer = g_string_new ("");
- if (context->mode == E_MAIL_FORMATTER_MODE_PRINTING) {
- GdkRGBA white = { 1.0, 1.0, 1.0, 1.0};
- bg_color = e_rgba_to_value (&white);
- } else {
- bg_color = e_rgba_to_value (
- e_mail_formatter_get_color (
- formatter, E_MAIL_FORMATTER_COLOR_BODY));
- }
+ if (context->mode != E_MAIL_FORMATTER_MODE_PRINTING)
+ body_rgba = e_mail_formatter_get_color (
+ formatter, E_MAIL_FORMATTER_COLOR_BODY);
+
+ header_rgba = e_mail_formatter_get_color (
+ formatter, E_MAIL_FORMATTER_COLOR_HEADER);
g_string_append_printf (
buffer,
"<div class=\"headers\" style=\"background: #%06x;\" id=\"%s\">"
"<table border=\"0\" width=\"100%%\" style=\"color: #%06x;\">\n"
"<tr><td valign=\"top\" width=\"16\">\n",
- bg_color,
+ e_rgba_to_value (body_rgba),
part->id,
- e_rgba_to_value (
- e_mail_formatter_get_color (
- formatter,
- E_MAIL_FORMATTER_COLOR_HEADER)));
+ e_rgba_to_value (header_rgba));
if (context->flags & E_MAIL_FORMATTER_HEADER_FLAG_COLLAPSABLE) {
g_string_append_printf (
@@ -546,12 +557,19 @@ emfe_headers_format (EMailFormatterExtension *extension,
(context->flags & E_MAIL_FORMATTER_HEADER_FLAG_COLLAPSED) ?
"plus.png" : "minus.png");
- format_short_headers (formatter, buffer,
- (CamelMedium *) part->part, context->flags, cancellable);
+ format_short_headers (
+ formatter, buffer,
+ CAMEL_MEDIUM (part->part),
+ context->flags,
+ cancellable);
}
- format_full_headers (formatter, buffer,
- (CamelMedium *) part->part, context->mode, context->flags, cancellable);
+ format_full_headers (
+ formatter, buffer,
+ CAMEL_MEDIUM (part->part),
+ context->mode,
+ context->flags,
+ cancellable);
g_string_append (buffer, "</td></tr></table></div>");
diff --git a/em-format/e-mail-formatter.h b/em-format/e-mail-formatter.h
index 2c7b144359..c2cebfa6a2 100644
--- a/em-format/e-mail-formatter.h
+++ b/em-format/e-mail-formatter.h
@@ -174,8 +174,7 @@ CamelMimeFilterToHTMLFlags
e_mail_formatter_get_text_format_flags
(EMailFormatter *formatter);
-const GdkRGBA *
- e_mail_formatter_get_color (EMailFormatter *formatter,
+const GdkRGBA * e_mail_formatter_get_color (EMailFormatter *formatter,
EMailFormatterColorType type);
void e_mail_formatter_set_color (EMailFormatter *efh,
EMailFormatterColorType type,
@@ -202,11 +201,11 @@ void e_mail_formatter_set_show_sender_photo
(EMailFormatter *formatter,
gboolean show_sender_photo);
-gboolean e_mail_formatter_get_animate_images
- (EMailFormatter *formatter);
-void e_mail_formatter_set_animate_images
- (EMailFormatter *formatter,
- gboolean animate_images);
+gboolean e_mail_formatter_get_animate_images
+ (EMailFormatter *formatter);
+void e_mail_formatter_set_animate_images
+ (EMailFormatter *formatter,
+ gboolean animate_images);
gboolean e_mail_formatter_get_show_real_date
(EMailFormatter *formatter);