diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-browser.c | 1 | ||||
-rw-r--r-- | mail/e-mail-display.c | 5 | ||||
-rw-r--r-- | mail/e-mail-paned-view.c | 11 | ||||
-rw-r--r-- | mail/em-format-html.c | 152 | ||||
-rw-r--r-- | mail/em-format-html.h | 12 | ||||
-rw-r--r-- | mail/evolution-mail.schemas.in | 18 |
6 files changed, 193 insertions, 6 deletions
diff --git a/mail/e-mail-browser.c b/mail/e-mail-browser.c index e1aeed0abf..6866913ff4 100644 --- a/mail/e-mail-browser.c +++ b/mail/e-mail-browser.c @@ -30,6 +30,7 @@ #include "e-util/gconf-bridge.h" #include "shell/e-shell.h" #include "shell/e-shell-utils.h" +#include "shell/e-shell-settings.h" #include "widgets/misc/e-alert-bar.h" #include "widgets/misc/e-popup-action.h" #include "widgets/misc/e-preview-pane.h" diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c index c0c96b5066..c3ca4d3f10 100644 --- a/mail/e-mail-display.c +++ b/mail/e-mail-display.c @@ -292,6 +292,11 @@ mail_display_link_clicked (GtkHTML *html, flags |= EM_FORMAT_HTML_HEADER_BCC; else flags &= ~EM_FORMAT_HTML_HEADER_BCC; + } else if (strcmp (uri, "##HEADERS##") == 0) { + if (em_format_html_get_headers_state (priv->formatter) == EM_FORMAT_HTML_HEADERS_STATE_COLLAPSED) + em_format_html_set_headers_state (priv->formatter, EM_FORMAT_HTML_HEADERS_STATE_EXPANDED); + else + em_format_html_set_headers_state (priv->formatter, EM_FORMAT_HTML_HEADERS_STATE_COLLAPSED); } priv->formatter->header_wrap_flags = flags; diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c index 20a0980949..c1e4cc415a 100644 --- a/mail/e-mail-paned-view.c +++ b/mail/e-mail-paned-view.c @@ -579,6 +579,8 @@ mail_paned_view_constructed (GObject *object) EShellBackend *shell_backend; EShellWindow *shell_window; EShellView *shell_view; + EShell *shell; + EShellSettings *shell_settings; ESearchBar *search_bar; EMailReader *reader; EMailView *view; @@ -594,6 +596,15 @@ mail_paned_view_constructed (GObject *object) shell_view = e_mail_view_get_shell_view (view); shell_window = e_shell_view_get_shell_window (shell_view); shell_backend = e_shell_view_get_shell_backend (shell_view); + shell = e_shell_window_get_shell (shell_window); + shell_settings = e_shell_get_shell_settings (shell); + + /* Make headers collapsable and store state of headers in config file */ + em_format_html_set_headers_collapsable (EM_FORMAT_HTML (priv->formatter), TRUE); + g_object_bind_property (shell_settings, "paned-view-headers-state", + EM_FORMAT_HTML (priv->formatter), "headers-state", + G_BINDING_BIDIRECTIONAL | + G_BINDING_SYNC_CREATE); web_view = em_format_html_get_web_view ( EM_FORMAT_HTML (priv->formatter)); diff --git a/mail/em-format-html.c b/mail/em-format-html.c index a5f485eef7..363be9afe7 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -92,6 +92,9 @@ struct _EMFormatHTMLPrivate { GdkColor colors[EM_FORMAT_HTML_NUM_COLOR_TYPES]; EMailImageLoadingPolicy image_loading_policy; + EMFormatHTMLHeadersState headers_state; + gboolean headers_collapsable; + guint load_images_now : 1; guint only_local_photos : 1; guint show_sender_photo : 1; @@ -111,7 +114,9 @@ enum { PROP_SHOW_SENDER_PHOTO, PROP_SHOW_REAL_DATE, PROP_TEXT_COLOR, - PROP_WEB_VIEW + PROP_WEB_VIEW, + PROP_HEADERS_STATE, + PROP_HEADERS_COLLAPSABLE }; static void efh_url_requested (GtkHTML *html, const gchar *url, GtkHTMLStream *handle, EMFormatHTML *efh); @@ -504,6 +509,15 @@ efh_set_property (GObject *object, EM_FORMAT_HTML_COLOR_TEXT, g_value_get_boxed (value)); return; + case PROP_HEADERS_STATE: + em_format_html_set_headers_state ( + EM_FORMAT_HTML (object), + g_value_get_int (value)); + return; + case PROP_HEADERS_COLLAPSABLE: + em_format_html_set_headers_collapsable ( + EM_FORMAT_HTML (object), + g_value_get_boolean (value)); } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -602,6 +616,15 @@ efh_get_property (GObject *object, value, em_format_html_get_web_view ( EM_FORMAT_HTML (object))); return; + case PROP_HEADERS_STATE: + g_value_set_int ( + value, em_format_html_get_headers_state ( + EM_FORMAT_HTML (object))); + return; + case PROP_HEADERS_COLLAPSABLE: + g_value_set_boolean ( + value, em_format_html_get_headers_collapsable ( + EM_FORMAT_HTML (object))); } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -922,6 +945,28 @@ efh_class_init (EMFormatHTMLClass *class) E_TYPE_WEB_VIEW, G_PARAM_READABLE)); + g_object_class_install_property ( + object_class, + PROP_HEADERS_STATE, + g_param_spec_int ( + "headers-state", + "Headers state", + NULL, + EM_FORMAT_HTML_HEADERS_STATE_EXPANDED, + EM_FORMAT_HTML_HEADERS_STATE_COLLAPSED, + EM_FORMAT_HTML_HEADERS_STATE_EXPANDED, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + object_class, + PROP_HEADERS_STATE, + g_param_spec_boolean ( + "headers-collapsable", + NULL, + NULL, + FALSE, + G_PARAM_READWRITE)); + /* cache expiry - 2 hour access, 1 day max */ user_cache_dir = e_get_user_cache_dir (); emfh_http_cache = camel_data_cache_new (user_cache_dir, NULL); @@ -1225,6 +1270,44 @@ em_format_html_set_show_real_date (EMFormatHTML *efh, g_object_notify (G_OBJECT (efh), "show-real-date"); } +EMFormatHTMLHeadersState +em_format_html_get_headers_state (EMFormatHTML *efh) +{ + g_return_val_if_fail (EM_IS_FORMAT_HTML (efh), EM_FORMAT_HTML_HEADERS_STATE_EXPANDED); + + return efh->priv->headers_state; +} + +void +em_format_html_set_headers_state (EMFormatHTML *efh, + EMFormatHTMLHeadersState state) +{ + g_return_if_fail (EM_IS_FORMAT_HTML (efh)); + + efh->priv->headers_state = state; + + g_object_notify (G_OBJECT (efh), "headers-state"); +} + +gboolean +em_format_html_get_headers_collapsable (EMFormatHTML *efh) +{ + g_return_val_if_fail (EM_IS_FORMAT_HTML (efh), FALSE); + + return efh->priv->headers_collapsable; +} + +void +em_format_html_set_headers_collapsable (EMFormatHTML *efh, + gboolean collapsable) +{ + g_return_if_fail (EM_IS_FORMAT_HTML (efh)); + + efh->priv->headers_collapsable = collapsable; + + g_object_notify (G_OBJECT (efh), "headers-collapsable"); +} + CamelMimePart * em_format_html_file_part (EMFormatHTML *efh, const gchar *mime_type, @@ -2692,6 +2775,7 @@ efh_format_headers (EMFormatHTML *efh, gchar *header_sender = NULL, *header_from = NULL, *name; gboolean mail_from_delegate = FALSE; const gchar *hdr_charset; + gchar *evolution_imagesdir; if (!part) return; @@ -2709,6 +2793,52 @@ efh_format_headers (EMFormatHTML *efh, EM_FORMAT_HTML_COLOR_HEADER])); hdr_charset = emf->charset ? emf->charset : emf->default_charset; + evolution_imagesdir = g_filename_to_uri (EVOLUTION_IMAGESDIR, NULL, NULL); + + /* If the header is collapsed, display just subject and sender in one row and leave */ + if (efh->priv->headers_state == EM_FORMAT_HTML_HEADERS_STATE_COLLAPSED && efh->priv->headers_collapsable) { + gchar *subject; + struct _camel_header_address *addrs = NULL; + GString *from = g_string_new (""); + + header = ((CamelMimePart *)part)->headers; + while (header) { + if (!g_ascii_strcasecmp (header->name, "From")) { + GString *tmp; + if (!(addrs = camel_header_address_decode (header->value, hdr_charset))) { + header = header->next; + continue; + } + tmp = g_string_new (""); + efh_format_address (efh, tmp, addrs, header->name); + + if (tmp->len) + g_string_printf (from, _("From: %s"), tmp->str); + g_string_free (tmp, TRUE); + } else if (!g_ascii_strcasecmp (header->name, "Subject")) { + gchar *buf = NULL; + buf = camel_header_unfold (header->value); + subject = camel_header_decode_string (buf, hdr_charset); + g_free (buf); + } + header = header->next; + } + + camel_stream_printf (stream, "<tr><td width=\"20\" valign=\"top\"><a href=\"##HEADERS##\"><img src=\"%s/plus.png\"></a></td><td><strong>%s</strong> %s%s%s</td></tr>", + evolution_imagesdir, subject, from->len ? "(" : "", from->str, from->len ? ")" : ""); + + g_free (subject); + g_free (header); + if (addrs) + camel_header_address_list_clear (&addrs); + g_string_free (from, TRUE); + + camel_stream_printf (stream, "</table>"); + + g_free (evolution_imagesdir); + + return; + } header = ((CamelMimePart *)part)->headers; while (header) { @@ -2769,10 +2899,22 @@ efh_format_headers (EMFormatHTML *efh, g_free (header_sender); g_free (header_from); - if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) - camel_stream_printf (stream, "<tr><td><table width=\"100%%\" border=0 cellpadding=\"0\">\n"); - else - camel_stream_printf (stream, "<tr><td><table border=0 cellpadding=\"0\">\n"); + if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) { + if (efh->priv->headers_collapsable) + camel_stream_printf (stream, "<tr><td valign=\"top\" width=\"20\"><a href=\"##HEADERS##\"><img src=\"%s/minus.png\"></a></td><td><table width=\"100%%\" border=0 cellpadding=\"0\">\n", + evolution_imagesdir); + else + camel_stream_printf (stream, "<tr><td><table width=\"100%%\" border=0 cellpadding=\"0\">\n"); + + } else { + if (efh->priv->headers_collapsable) + camel_stream_printf (stream, "<tr><td valign=\"top\" width=\"20\"><a href=\"##HEADERS##\"><img src=\"%s/minus.png\"></a></td><td><table border=0 cellpadding=\"0\">\n", + evolution_imagesdir); + else + camel_stream_printf (stream, "<tr><td><table border=0 cellpadding=\"0\">\n"); + } + + g_free (evolution_imagesdir); /* dump selected headers */ if (emf->mode == EM_FORMAT_MODE_ALLHEADERS) { diff --git a/mail/em-format-html.h b/mail/em-format-html.h index 01d7b02435..4e62cb7e37 100644 --- a/mail/em-format-html.h +++ b/mail/em-format-html.h @@ -70,6 +70,11 @@ typedef enum { } EMFormatHTMLState; typedef enum { + EM_FORMAT_HTML_HEADERS_STATE_EXPANDED = 0, /* Default value */ + EM_FORMAT_HTML_HEADERS_STATE_COLLAPSED +} EMFormatHTMLHeadersState; + +typedef enum { EM_FORMAT_HTML_COLOR_BODY, /* header area background */ EM_FORMAT_HTML_COLOR_CITATION, /* citation font color */ EM_FORMAT_HTML_COLOR_CONTENT, /* message area background */ @@ -277,6 +282,13 @@ void em_format_html_job_queue (EMFormatHTML *efh, gboolean em_format_html_get_show_real_date (EMFormatHTML *efh); void em_format_html_set_show_real_date (EMFormatHTML *efh, gboolean show_real_date); +EMFormatHTMLHeadersState + em_format_html_get_headers_state (EMFormatHTML *efh); +void em_format_html_set_headers_state (EMFormatHTML *efh, + EMFormatHTMLHeadersState state); +gboolean em_format_html_get_headers_collapsable (EMFormatHTML *efh); +void em_format_html_set_headers_collapsable (EMFormatHTML *efh, + gboolean collapsable); gchar * em_format_html_format_cert_infos (CamelCipherCertInfo *first_cinfo); diff --git a/mail/evolution-mail.schemas.in b/mail/evolution-mail.schemas.in index 993fa406a8..cb697b5aff 100644 --- a/mail/evolution-mail.schemas.in +++ b/mail/evolution-mail.schemas.in @@ -882,7 +882,23 @@ </long> </locale> </schema> - + + <schema> + <key>/schemas/apps/evolution/mail/display/paned_view_headers_state</key> + <applyto>/apps/evolution/mail/display/paned_view_headers_state</applyto> + <owner>evolution-mail</owner> + <type>int</type> + <default>0</default> + <locale name="C"> + <short>State of message headers in paned view</short> + <long> + Describes wheter message headers in paned view should be collapsed or expanded by default. + "0" = expanded + "1" = collapsed + </long> + </locale> + </schema> + <!-- Mail Browser --> <schema> |