Add option to unset colors provided in HTML mails for preview into Preferences

It's located in Edit->Preferences->Mail Preferences->HTML Messages->Unset
colors provided in HTML mails in message preview.

Related to https://gitlab.gnome.org/GNOME/evolution/issues/695
This commit is contained in:
Milan Crha 2022-02-01 11:23:40 +01:00
parent a56da82fef
commit ed36776c40
4 changed files with 59 additions and 10 deletions

View File

@ -1069,10 +1069,10 @@ Evo.unsetHTMLColors = function(doc)
continue;
if (rule.style.color)
rule.style.color = "inherit";
rule.style.removeProperty("color");
if (rule.style.backgroundColor)
rule.style.backgroundColor = "inherit";
rule.style.removeProperty("background-color");
}
}
@ -1086,10 +1086,13 @@ Evo.unsetHTMLColors = function(doc)
if (elem.tagName != "HTML" && elem.tagName != "IFRAME" && elem.tagName != "INPUT" && elem.tagName != "BUTTON" && elem.tagName != "IMG") {
if (elem.style) {
if (elem.style.color)
elem.style.color = "inherit";
elem.style.removeProperty("color");
if (elem.style.backgroundColor)
elem.style.backgroundColor = "inherit";
elem.style.removeProperty("background-color");
if (!elem.style.length)
elem.removeAttribute("style");
}
elem.removeAttribute("color");

View File

@ -2108,12 +2108,13 @@ mail_display_drag_data_get (GtkWidget *widget,
g_free (uri);
}
static void
e_mail_display_test_change_and_update_fonts_cb (EMailDisplay *mail_display,
const gchar *key,
GSettings *settings)
static gboolean
e_mail_display_test_key_changed (EMailDisplay *mail_display,
const gchar *key,
GSettings *settings)
{
GVariant *new_value, *old_value;
gboolean changed = FALSE;
new_value = g_settings_get_value (settings, key);
old_value = g_hash_table_lookup (mail_display->priv->old_settings, key);
@ -2124,10 +2125,30 @@ e_mail_display_test_change_and_update_fonts_cb (EMailDisplay *mail_display,
else
g_hash_table_remove (mail_display->priv->old_settings, key);
e_web_view_update_fonts (E_WEB_VIEW (mail_display));
changed = TRUE;
} else if (new_value) {
g_variant_unref (new_value);
}
return changed;
}
static void
e_mail_display_test_change_and_update_fonts_cb (EMailDisplay *mail_display,
const gchar *key,
GSettings *settings)
{
if (e_mail_display_test_key_changed (mail_display, key, settings))
e_web_view_update_fonts (E_WEB_VIEW (mail_display));
}
static void
e_mail_display_test_change_and_reload_cb (EMailDisplay *mail_display,
const gchar *key,
GSettings *settings)
{
if (e_mail_display_test_key_changed (mail_display, key, settings))
e_mail_display_reload (mail_display);
}
static void
@ -2408,6 +2429,9 @@ e_mail_display_init (EMailDisplay *display)
g_signal_connect_swapped (
display->priv->settings , "changed::use-custom-font",
G_CALLBACK (e_mail_display_test_change_and_update_fonts_cb), display);
g_signal_connect_swapped (
display->priv->settings , "changed::preview-unset-html-colors",
G_CALLBACK (e_mail_display_test_change_and_reload_cb), display);
g_signal_connect (
display, "load-changed",

View File

@ -2407,6 +2407,22 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="chkUnsetHTMLColors">
<property name="label" translatable="yes">Unset colors provided in HTML mails in message previe_w</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0.5</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="chkPromptWantHTML">
<property name="label" translatable="yes">_Prompt on sending HTML mail to contacts that do not want them</property>
@ -2420,7 +2436,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
</object>

View File

@ -1786,6 +1786,12 @@ em_mailer_prefs_construct (EMMailerPrefs *prefs,
widget, "active",
G_SETTINGS_BIND_DEFAULT);
widget = e_builder_get_widget (prefs->priv->builder, "chkUnsetHTMLColors");
g_settings_bind (
settings, "preview-unset-html-colors",
widget, "active",
G_SETTINGS_BIND_DEFAULT);
widget = e_builder_get_widget (prefs->priv->builder, "chkPromptWantHTML");
g_settings_bind (
settings, "prompt-on-unwanted-html",