[evolution] I#813 - Improve styling of cited text in HTML mails



commit c99f8d23787575ef0926d36e37bc3597fdad7725
Author: Milan Crha <mcrha redhat com>
Date:   Thu Feb 27 15:02:23 2020 +0100

    I#813 - Improve styling of cited text in HTML mails
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/813

 data/webkit/e-web-view.js | 12 +++++++++---
 src/e-util/e-web-view.c   |  5 +++++
 src/mail/e-mail-display.c | 19 ++++++++++++++++++-
 3 files changed, 32 insertions(+), 4 deletions(-)
---
diff --git a/data/webkit/e-web-view.js b/data/webkit/e-web-view.js
index 5847b7ec39..e84fd7eb95 100644
--- a/data/webkit/e-web-view.js
+++ b/data/webkit/e-web-view.js
@@ -6,7 +6,8 @@
 var Evo = {
        hasSelection : false,
        blockquoteStyle : "margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex",
-       magicSpacebarState: -1
+       magicSpacebarState: -1,
+       markCitationColor : null
 };
 
 /* The 'traversar_obj' is an object, which implements a callback function:
@@ -993,8 +994,10 @@ Evo.unsetHTMLColors = function(doc)
        }
 }
 
-Evo.MailDisplayBindDOM = function(iframe_id)
+Evo.MailDisplayBindDOM = function(iframe_id, markCitationColor)
 {
+       Evo.markCitationColor = markCitationColor != "" ? markCitationColor : null;
+
        var traversar = {
                unstyleBlockquotes : function(doc) {
                        var ii, elems;
@@ -1015,6 +1018,9 @@ Evo.MailDisplayBindDOM = function(iframe_id)
                                    elem.getAttribute("style") == Evo.blockquoteStyle) {
                                        elem.removeAttribute("style");
                                }
+
+                               if (Evo.markCitationColor && elem.hasAttribute("type") && 
elem.getAttribute("type").toLowerCase() == "cite")
+                                       elem.style.color = Evo.markCitationColor;
                        }
                },
                textRequiresWrap : function(text) {
@@ -1142,7 +1148,7 @@ Evo.MailDisplayShowAttachment = function(element_id, show)
 
                        if (iframe) {
                                Evo.initializeAndPostContentLoaded(iframe);
-                               Evo.MailDisplayBindDOM(iframe.id);
+                               Evo.MailDisplayBindDOM(iframe.id, Evo.markCitationColor);
                        }
 
                        var iframe_id = "";
diff --git a/src/e-util/e-web-view.c b/src/e-util/e-web-view.c
index 7d223f100d..1c8ea78dc2 100644
--- a/src/e-util/e-web-view.c
+++ b/src/e-util/e-web-view.c
@@ -3501,6 +3501,7 @@ e_web_view_update_fonts_settings (GSettings *font_settings,
                        "blockquote[type=cite]:not(.-x-evo-plaintext-quoted) "
                        "{\n"
                        "  border-color: %s;\n"
+                       "  margin: 0 0 6px 0;\n"
                        "}\n",
                        e_web_view_get_citation_color_for_level (1));
 
@@ -3510,6 +3511,7 @@ e_web_view_update_fonts_settings (GSettings *font_settings,
                        "blockquote[type=cite]:not(.-x-evo-plaintext-quoted) "
                        "{\n"
                        "  border-color: %s;\n"
+                       "  margin: 0ch;\n"
                        "}\n",
                        e_web_view_get_citation_color_for_level (2));
 
@@ -3520,6 +3522,7 @@ e_web_view_update_fonts_settings (GSettings *font_settings,
                        "blockquote[type=cite]:not(.-x-evo-plaintext-quoted) "
                        "{\n"
                        "  border-color: %s;\n"
+                       "  margin: 0ch;\n"
                        "}\n",
                        e_web_view_get_citation_color_for_level (3));
 
@@ -3531,6 +3534,7 @@ e_web_view_update_fonts_settings (GSettings *font_settings,
                        "blockquote[type=cite]:not(.-x-evo-plaintext-quoted) "
                        "{\n"
                        "  border-color: %s;\n"
+                       "  margin: 0ch;\n"
                        "}\n",
                        e_web_view_get_citation_color_for_level (4));
 
@@ -3543,6 +3547,7 @@ e_web_view_update_fonts_settings (GSettings *font_settings,
                        "blockquote[type=cite]:not(.-x-evo-plaintext-quoted) "
                        "{\n"
                        "  border-color: %s;\n"
+                       "  margin: 0ch;\n"
                        "}\n",
                        e_web_view_get_citation_color_for_level (5));
 
diff --git a/src/mail/e-mail-display.c b/src/mail/e-mail-display.c
index 7b9ba10dc9..4ae60f7929 100644
--- a/src/mail/e-mail-display.c
+++ b/src/mail/e-mail-display.c
@@ -1264,6 +1264,7 @@ mail_display_content_loaded_cb (EWebView *web_view,
                                gpointer user_data)
 {
        EMailDisplay *mail_display;
+       gchar *citation_color = NULL;
 
        g_return_if_fail (E_IS_MAIL_DISPLAY (web_view));
 
@@ -1280,8 +1281,24 @@ mail_display_content_loaded_cb (EWebView *web_view,
                        mail_display_remote_content_clicked_cb, NULL);
        }
 
+       if (g_settings_get_boolean (mail_display->priv->settings, "mark-citations")) {
+               GdkRGBA rgba;
+
+               citation_color = g_settings_get_string (mail_display->priv->settings, "citation-color");
+
+               if (!citation_color || !gdk_rgba_parse (&rgba, citation_color)) {
+                       g_free (citation_color);
+                       citation_color = NULL;
+               } else {
+                       g_free (citation_color);
+                       citation_color = g_strdup_printf ("#%06x", e_rgba_to_value (&rgba));
+               }
+       }
+
        e_web_view_jsc_run_script (WEBKIT_WEB_VIEW (web_view), e_web_view_get_cancellable (web_view),
-               "Evo.MailDisplayBindDOM(%s);", iframe_id);
+               "Evo.MailDisplayBindDOM(%s, %s);", iframe_id, citation_color);
+
+       g_free (citation_color);
 
        if (mail_display->priv->part_list) {
                if (!iframe_id || !*iframe_id) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]