[evolution/wip/webkit2] [Incomplete] Bug 747510 - Add composer option "Inherit theme colors in HTML mode"
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] [Incomplete] Bug 747510 - Add composer option "Inherit theme colors in HTML mode"
- Date: Wed, 24 Feb 2016 16:33:12 +0000 (UTC)
commit 57420089b5f859afd50e47d8b4a42790ca0ff03d
Author: Tomas Popela <tpopela redhat com>
Date: Wed Feb 24 17:32:53 2016 +0100
[Incomplete] Bug 747510 - Add composer option "Inherit theme colors in HTML mode"
data/org.gnome.evolution.mail.gschema.xml.in | 5 +
e-util/e-html-editor-page-dialog.c | 90 +++++++++---
e-util/e-html-editor-view.c | 21 +---
mail/mail-config.ui | 24 +++-
modules/mail/em-composer-prefs.c | 6 +
.../composer/e-html-editor-undo-redo-manager.c | 6 +
.../composer/e-html-editor-view-dom-functions.c | 149 +++++++++++++++-----
.../composer/e-html-editor-view-dom-functions.h | 3 +
.../composer/e-html-editor-web-extension.c | 3 +
9 files changed, 225 insertions(+), 82 deletions(-)
---
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index 6e8f9c5..33103ab 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -595,6 +595,11 @@
<_summary>Allow expunge in virtual folders</_summary>
<_description>Enables Expunge in virtual folders, which means that the Folder->Expunge will be
callable in virtual folders, while the expunge itself will be done in all folders for all deleted messages
within the virtual folder, not only for deleted messages belonging to the virtual folder.</_description>
</key>
+ <key name="composer-inherit-theme-colors" type="b">
+ <default>false</default>
+ <_summary>Inherit theme colors in HTML mode</_summary>
+ <_description>When enabled the theme colors for background, text and links are sent in resulting HTML
formatted message.</_description>
+ </key>
<child name="browser-window" schema="org.gnome.evolution.window"/>
<child name="composer-window" schema="org.gnome.evolution.window"/>
<child name="filter-window" schema="org.gnome.evolution.window"/>
diff --git a/e-util/e-html-editor-page-dialog.c b/e-util/e-html-editor-page-dialog.c
index 269be51..10f7cb2 100644
--- a/e-util/e-html-editor-page-dialog.c
+++ b/e-util/e-html-editor-page-dialog.c
@@ -37,6 +37,7 @@
struct _EHTMLEditorPageDialogPrivate {
GtkWidget *text_color_picker;
GtkWidget *link_color_picker;
+ GtkWidget *visited_link_color_picker;
GtkWidget *background_color_picker;
GtkWidget *background_template_combo;
@@ -192,6 +193,32 @@ html_editor_page_dialog_set_link_color (EHTMLEditorPageDialog *dialog)
}
static void
+html_editor_page_dialog_set_visited_link_color (EHTMLEditorPageDialog *dialog)
+{
+ EHTMLEditor *editor;
+ EHTMLEditorView *view;
+ GDBusProxy *web_extension;
+ GdkRGBA rgba;
+ gchar *color;
+
+ editor = e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog));
+ view = e_html_editor_get_view (editor);
+ web_extension = e_html_editor_view_get_web_extension_proxy (view);
+ if (!web_extension)
+ return;
+
+ e_color_combo_get_current_color (
+ E_COLOR_COMBO (dialog->priv->visited_link_color_picker), &rgba);
+
+ color = g_strdup_printf ("#%06x", e_rgba_to_value (&rgba));
+
+ e_html_editor_view_set_element_attribute (
+ view, "body", "vlink", color);
+
+ g_free (color);
+}
+
+static void
html_editor_page_dialog_set_background_color (EHTMLEditorPageDialog *dialog)
{
EHTMLEditor *editor;
@@ -397,32 +424,34 @@ html_editor_page_dialog_show (GtkWidget *widget)
const gchar *value;
g_variant_get (result, "(&s)", &value);
- if (!value || !*value) {
- GdkColor *color = NULL;
- GtkStyleContext *context;
-
- context = gtk_widget_get_style_context (GTK_WIDGET (view));
- gtk_style_context_get_style (context, "link-color", &color, NULL);
-
- if (color == NULL) {
- rgba.alpha = 1;
- rgba.red = 0;
- rgba.green = 0;
- rgba.blue = 1;
- } else {
- rgba.alpha = 1;
- rgba.red = ((gdouble) color->red) / G_MAXUINT16;
- rgba.green = ((gdouble) color->green) / G_MAXUINT16;
- rgba.blue = ((gdouble) color->blue) / G_MAXUINT16;
- }
- } else {
- gdk_rgba_parse (&rgba, value);
+ if (!gdk_rgba_parse (&rgba, value)) {
+ rgba.alpha = 1;
+ rgba.red = 0;
+ rgba.green = 0;
+ rgba.blue = 1;
}
e_color_combo_set_current_color (
E_COLOR_COMBO (dialog->priv->link_color_picker), &rgba);
g_variant_unref (result);
}
+ result = e_html_editor_view_get_element_attribute (view, "body", "vlink");
+
+ if (result) {
+ const gchar *value;
+
+ g_variant_get (result, "(&s)", &value);
+ if (!gdk_rgba_parse (&rgba, value)) {
+ rgba.alpha = 1;
+ rgba.red = 1;
+ rgba.green = 0;
+ rgba.blue = 0;
+ }
+ e_color_combo_set_current_color (
+ E_COLOR_COMBO (dialog->priv->visited_link_color_picker), &rgba);
+ g_variant_unref (result);
+ }
+
result = e_html_editor_view_get_element_attribute (view, "body", "bgcolor");
if (result) {
@@ -526,20 +555,35 @@ e_html_editor_page_dialog_init (EHTMLEditorPageDialog *dialog)
GTK_LABEL (widget), dialog->priv->link_color_picker);
gtk_grid_attach (grid, widget, 0, 1, 1, 1);
+ /* Visited Link */
+ widget = e_color_combo_new ();
+ gtk_widget_set_hexpand (widget, TRUE);
+ g_signal_connect_swapped (
+ widget, "notify::current-color",
+ G_CALLBACK (html_editor_page_dialog_set_visited_link_color), dialog);
+ gtk_grid_attach (grid, widget, 1, 2, 1, 1);
+ dialog->priv->visited_link_color_picker = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("_Visited Link:"));
+ gtk_label_set_justify (GTK_LABEL (widget), GTK_JUSTIFY_RIGHT);
+ gtk_label_set_mnemonic_widget (
+ GTK_LABEL (widget), dialog->priv->visited_link_color_picker);
+ gtk_grid_attach (grid, widget, 0, 2, 1, 1);
+
/* Background */
widget = e_color_combo_new ();
gtk_widget_set_hexpand (widget, TRUE);
g_signal_connect_swapped (
widget, "notify::current-color",
G_CALLBACK (html_editor_page_dialog_set_background_color), dialog);
- gtk_grid_attach (grid, widget, 1, 2, 1, 1);
+ gtk_grid_attach (grid, widget, 1, 3, 1, 1);
dialog->priv->background_color_picker = widget;
widget = gtk_label_new_with_mnemonic (_("_Background:"));
gtk_label_set_justify (GTK_LABEL (widget), GTK_JUSTIFY_RIGHT);
gtk_label_set_mnemonic_widget (
GTK_LABEL (widget), dialog->priv->background_color_picker);
- gtk_grid_attach (grid, widget, 0, 2, 1, 1);
+ gtk_grid_attach (grid, widget, 0, 3, 1, 1);
/* == Background Image == */
widget = gtk_label_new ("");
@@ -550,7 +594,7 @@ e_html_editor_page_dialog_init (EHTMLEditorPageDialog *dialog)
grid = GTK_GRID (gtk_grid_new ());
gtk_grid_set_row_spacing (grid, 5);
gtk_grid_set_column_spacing (grid, 5);
- gtk_grid_attach (main_layout, GTK_WIDGET (grid), 0, 3, 1, 1);
+ gtk_grid_attach (main_layout, GTK_WIDGET (grid), 0, 4, 1, 1);
gtk_widget_set_margin_left (GTK_WIDGET (grid), 10);
/* Template */
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 5b4659c..fb74dc1 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -2393,12 +2393,10 @@ void
e_html_editor_view_update_fonts (EHTMLEditorView *view)
{
gboolean mark_citations, use_custom_font;
- GdkColor *visited = NULL;
gchar *font, *aa = NULL, *citation_color;
const gchar *styles[] = { "normal", "oblique", "italic" };
const gchar *smoothing = NULL;
GString *stylesheet;
- GtkStyleContext *context;
PangoFontDescription *ms, *vw;
WebKitSettings *settings;
WebKitUserContentManager *manager;
@@ -2486,22 +2484,6 @@ e_html_editor_view_update_fonts (EHTMLEditorView *view)
pango_font_description_get_weight (ms),
styles[pango_font_description_get_style (ms)]);
- context = gtk_widget_get_style_context (GTK_WIDGET (view));
- gtk_style_context_get_style (
- context, "visited-link-color", &visited, NULL);
-
- if (visited == NULL) {
- visited = g_slice_new0 (GdkColor);
- visited->red = G_MAXINT16;
- }
-
- g_string_append_printf (
- stylesheet,
- "a:visited {\n"
- " color: #%06x;\n"
- "}\n",
- e_color_to_value (visited));
-
/* See bug #689777 for details */
g_string_append (
stylesheet,
@@ -2779,8 +2761,6 @@ e_html_editor_view_update_fonts (EHTMLEditorView *view)
"}\n",
e_web_view_get_citation_color_for_level (5));
- gdk_color_free (visited);
-
settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (view));
g_object_set (
G_OBJECT (settings),
@@ -3347,6 +3327,7 @@ e_html_editor_view_save_selection (EHTMLEditorView *view)
e_html_editor_view_call_simple_extension_function (view, "DOMSaveSelection");
}
/* FIXME WK2
+ Finish also changes from commit 59e3bb0 Bug 747510 - Add composer option "Inherit theme colors in HTML
mode"
static void
set_link_color (EHTMLEditorView *view)
{
diff --git a/mail/mail-config.ui b/mail/mail-config.ui
index 98d2e34..a887abf 100644
--- a/mail/mail-config.ui
+++ b/mail/mail-config.ui
@@ -250,6 +250,22 @@
</packing>
</child>
<child>
+ <object class="GtkCheckButton" id="chkInheritThemeColors">
+ <property name="label" translatable="yes">Inherit theme colors in HTML
mode</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="chkAutoSmileys">
<property name="label" translatable="yes">Automatically insert _emoticons</property>
<property name="visible">True</property>
@@ -262,7 +278,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -278,7 +294,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
@@ -294,7 +310,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
@@ -310,7 +326,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">4</property>
+ <property name="position">5</property>
</packing>
</child>
<child>
diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c
index 09c0e05..c753784 100644
--- a/modules/mail/em-composer-prefs.c
+++ b/modules/mail/em-composer-prefs.c
@@ -1104,6 +1104,12 @@ em_composer_prefs_construct (EMComposerPrefs *prefs,
widget, "active",
G_SETTINGS_BIND_DEFAULT);
+ widget = e_builder_get_widget (prefs->builder, "chkInheritThemeColors");
+ g_settings_bind (
+ settings, "composer-inherit-theme-colors",
+ widget, "active",
+ G_SETTINGS_BIND_DEFAULT);
+
widget = e_builder_get_widget (prefs->builder, "chkPromptAccelSend");
g_settings_bind (
settings, "prompt-on-accel-send",
diff --git a/web-extensions/composer/e-html-editor-undo-redo-manager.c
b/web-extensions/composer/e-html-editor-undo-redo-manager.c
index 3b00f9e..1e20747 100644
--- a/web-extensions/composer/e-html-editor-undo-redo-manager.c
+++ b/web-extensions/composer/e-html-editor-undo-redo-manager.c
@@ -720,6 +720,12 @@ undo_redo_page_dialog (WebKitDOMDocument *document,
value = webkit_dom_node_get_node_value (attr_clone);
dom_set_link_color (document, value);
g_free (value);
+ } else if (g_strcmp0 (name, "vlink") == 0) {
+ gchar *value;
+
+ value = webkit_dom_node_get_node_value (attr_clone);
+ dom_set_visited_link_color (document, value);
+ g_free (value);
}
replaced = TRUE;
}
diff --git a/web-extensions/composer/e-html-editor-view-dom-functions.c
b/web-extensions/composer/e-html-editor-view-dom-functions.c
index 7f58d7d..098e705 100644
--- a/web-extensions/composer/e-html-editor-view-dom-functions.c
+++ b/web-extensions/composer/e-html-editor-view-dom-functions.c
@@ -1001,6 +1001,8 @@ dom_check_magic_links (WebKitDOMDocument *document,
text = webkit_dom_html_element_get_inner_text (
WEBKIT_DOM_HTML_ELEMENT (parent));
+ element_remove_class (parent, "-x-evo-visited-link");
+
if (strstr (href, "://") && !strstr (text, "://")) {
url = strstr (href, "://") + 3;
diff = strlen (text) - strlen (url);
@@ -5490,7 +5492,6 @@ replace_to_whitespaces (const GMatchInfo *info,
static void
process_elements (EHTMLEditorWebExtension *extension,
WebKitDOMNode *node,
- gboolean to_html,
gboolean changing_mode,
gboolean to_plain_text,
GString *buffer)
@@ -5516,27 +5517,34 @@ process_elements (EHTMLEditorWebExtension *extension,
webkit_dom_named_node_map_get_length (attributes);
for (ii = 0; ii < attributes_length; ii++) {
- gchar *name, *value;
+ gchar *name;
WebKitDOMNode *node =
webkit_dom_named_node_map_item (
attributes, ii);
name = webkit_dom_node_get_local_name (node);
- value = webkit_dom_node_get_node_value (node);
+ if (g_strcmp0 (name, "bgcolor") != 0 &&
+ g_strcmp0 (name, "text") != 0 &&
+ g_strcmp0 (name, "vlink") != 0 &&
+ g_strcmp0 (name, "link") != 0) {
+ gchar *value;
+
+ value = webkit_dom_node_get_node_value (node);
- g_string_append (buffer, name);
- g_string_append (buffer, "=\"");
- g_string_append (buffer, value);
- g_string_append (buffer, "\" ");
+ g_string_append (buffer, name);
+ g_string_append (buffer, "=\"");
+ g_string_append (buffer, value);
+ g_string_append (buffer, "\" ");
+ g_free (value);
+ }
g_free (name);
- g_free (value);
g_object_unref (node);
}
g_string_append (buffer, ">");
g_object_unref (attributes);
}
- if (to_html)
+ if (!to_plain_text)
remove_evolution_attributes (WEBKIT_DOM_ELEMENT (node));
}
@@ -5707,7 +5715,7 @@ process_elements (EHTMLEditorWebExtension *extension,
}
g_free (content);
}
- if (to_html) {
+ if (!to_plain_text) {
element_remove_class (
WEBKIT_DOM_ELEMENT (child),
"Applet-tab-span");
@@ -5738,7 +5746,7 @@ process_elements (EHTMLEditorWebExtension *extension,
}
}
process_blockquote (WEBKIT_DOM_ELEMENT (child));
- if (to_html)
+ if (!to_plain_text)
remove_base_attributes (WEBKIT_DOM_ELEMENT (child));
}
}
@@ -5769,7 +5777,7 @@ process_elements (EHTMLEditorWebExtension *extension,
WebKitDOMNode *image =
webkit_dom_node_get_first_child (child);
- if (to_html && WEBKIT_DOM_IS_HTML_IMAGE_ELEMENT (image)) {
+ if (!to_plain_text && WEBKIT_DOM_IS_HTML_IMAGE_ELEMENT (image)) {
remove_evolution_attributes (
WEBKIT_DOM_ELEMENT (image));
@@ -5791,7 +5799,7 @@ process_elements (EHTMLEditorWebExtension *extension,
skip_node = TRUE;
goto next;
}
- if (to_html) {
+ if (!to_plain_text) {
remove_base_attributes (WEBKIT_DOM_ELEMENT (child));
remove_evolution_attributes (WEBKIT_DOM_ELEMENT (child));
}
@@ -5804,7 +5812,7 @@ process_elements (EHTMLEditorWebExtension *extension,
first_child = webkit_dom_node_get_first_child (child);
- if (to_html) {
+ if (!to_plain_text) {
remove_base_attributes (
WEBKIT_DOM_ELEMENT (first_child));
remove_evolution_attributes (
@@ -5841,7 +5849,7 @@ process_elements (EHTMLEditorWebExtension *extension,
skip_node = TRUE;
goto next;
}
- if (to_html) {
+ if (!to_plain_text) {
WebKitDOMElement *img;
img = WEBKIT_DOM_ELEMENT (
@@ -5870,7 +5878,7 @@ process_elements (EHTMLEditorWebExtension *extension,
g_free (content);
skip_node = TRUE;
}
- if (to_html)
+ if (!to_plain_text)
remove_evolution_attributes (WEBKIT_DOM_ELEMENT (child));
}
@@ -5910,18 +5918,21 @@ process_elements (EHTMLEditorWebExtension *extension,
g_free (content);
skip_node = TRUE;
}
- if (!changing_mode && to_plain_text) {
- content = webkit_dom_html_element_get_inner_text (
- WEBKIT_DOM_HTML_ELEMENT (child));
- g_string_append (buffer, content);
- g_free (content);
- skip_node = TRUE;
+ if (!changing_mode) {
+ if (to_plain_text) {
+ content = webkit_dom_html_element_get_inner_text (
+ WEBKIT_DOM_HTML_ELEMENT (child));
+ g_string_append (buffer, content);
+ g_free (content);
+ skip_node = TRUE;
+ } else
+ remove_base_attributes (WEBKIT_DOM_ELEMENT (child));
}
}
next:
if (webkit_dom_node_has_child_nodes (child) && !skip_node)
process_elements (
- extension, child, to_html, changing_mode, to_plain_text, buffer);
+ extension, child, changing_mode, to_plain_text, buffer);
g_object_unref (child);
}
@@ -6135,9 +6146,12 @@ toggle_paragraphs_style (WebKitDOMDocument *document,
gchar *
dom_process_content_for_draft (WebKitDOMDocument *document)
{
+ gchar *content;
+ gint ii, length;
WebKitDOMHTMLElement *body;
WebKitDOMElement *document_element;
- gchar *content;
+ WebKitDOMNodeList *list;
+ WebKitDOMNode *document_element_clone;
body = webkit_dom_document_get_body (document);
@@ -6145,7 +6159,23 @@ dom_process_content_for_draft (WebKitDOMDocument *document)
WEBKIT_DOM_ELEMENT (body), "data-evo-draft", "", NULL);
document_element = webkit_dom_document_get_document_element (document);
- content = webkit_dom_element_get_outer_html (document_element);
+
+ document_element_clone = webkit_dom_node_clone_node (
+ WEBKIT_DOM_NODE (document_element), TRUE);
+
+ list = webkit_dom_element_query_selector_all (
+ WEBKIT_DOM_ELEMENT (document_element_clone), "a.-x-evo-visited-link", NULL);
+ length = webkit_dom_node_list_get_length (list);
+ for (ii = 0; ii < length; ii++) {
+ WebKitDOMNode *anchor;
+
+ anchor = webkit_dom_node_list_item (list, ii);
+ webkit_dom_element_remove_attribute (WEBKIT_DOM_ELEMENT (anchor), "class");
+ g_object_unref (anchor);
+ }
+ g_object_unref (list);
+
+ content = webkit_dom_element_get_outer_html (WEBKIT_DOM_ELEMENT (document_element_clone));
webkit_dom_element_remove_attribute (
WEBKIT_DOM_ELEMENT (body), "data-evo-draft");
@@ -6164,7 +6194,10 @@ process_content_for_mode_change (WebKitDOMDocument *document,
plain_text = g_string_sized_new (1024);
- process_elements (extension, body, FALSE, TRUE, TRUE, plain_text);
+ webkit_dom_element_remove_attribute (
+ WEBKIT_DOM_ELEMENT (body), "data-user-colors");
+
+ process_elements (extension, body, TRUE, TRUE, plain_text);
g_string_append (plain_text, "</body></html>");
@@ -6418,7 +6451,7 @@ dom_process_content_for_plain_text (WebKitDOMDocument *document,
quote_plain_text_recursive (document, source, source, 0);
}
- process_elements (extension, source, FALSE, FALSE, TRUE, plain_text);
+ process_elements (extension, source, FALSE, TRUE, plain_text);
if (clean)
remove_node (source);
@@ -6488,6 +6521,8 @@ dom_process_content_for_html (WebKitDOMDocument *document,
WebKitDOMElement *marker;
WebKitDOMNode *node, *document_clone;
WebKitDOMNodeList *list;
+ GSettings *settings;
+ gboolean send_editor_colors = FALSE;
if (from_domain != NULL)
inline_images_to_restore = dom_get_inline_images_data (document, extension, from_domain);
@@ -6502,6 +6537,10 @@ dom_process_content_for_html (WebKitDOMDocument *document,
WEBKIT_DOM_ELEMENT (document_clone), "style#-x-evo-a-color-style", NULL));
if (node)
remove_node (node);
+ node = WEBKIT_DOM_NODE (webkit_dom_element_query_selector (
+ WEBKIT_DOM_ELEMENT (document_clone), "style#-x-evo-a-color-style-visited", NULL));
+ if (node)
+ remove_node (node);
/* When the Ctrl + Enter is pressed for sending, the links are activated. */
node = WEBKIT_DOM_NODE (webkit_dom_element_query_selector (
WEBKIT_DOM_ELEMENT (document_clone), "style#-x-evo-style-a", NULL));
@@ -6518,6 +6557,19 @@ dom_process_content_for_html (WebKitDOMDocument *document,
if (marker)
remove_node (WEBKIT_DOM_NODE (marker));
+ settings = e_util_ref_settings ("org.gnome.evolution.mail");
+ send_editor_colors = g_settings_get_boolean (settings, "composer-inherit-theme-colors");
+ g_object_unref (settings);
+
+ if (webkit_dom_element_has_attribute (WEBKIT_DOM_ELEMENT (node), "data-user-colors")) {
+ webkit_dom_element_remove_attribute (WEBKIT_DOM_ELEMENT (node), "data-user-colors");
+ } else if (!send_editor_colors) {
+ webkit_dom_element_remove_attribute (WEBKIT_DOM_ELEMENT (node), "bgcolor");
+ webkit_dom_element_remove_attribute (WEBKIT_DOM_ELEMENT (node), "text");
+ webkit_dom_element_remove_attribute (WEBKIT_DOM_ELEMENT (node), "link");
+ webkit_dom_element_remove_attribute (WEBKIT_DOM_ELEMENT (node), "vlink");
+ }
+
list = webkit_dom_element_query_selector_all (
WEBKIT_DOM_ELEMENT (node), "span[data-hidden-space]", NULL);
length = webkit_dom_node_list_get_length (list);
@@ -6530,7 +6582,7 @@ dom_process_content_for_html (WebKitDOMDocument *document,
}
g_object_unref (list);
- process_elements (extension, node, TRUE, FALSE, FALSE, NULL);
+ process_elements (extension, node, FALSE, FALSE, NULL);
html_content = webkit_dom_element_get_outer_html (
WEBKIT_DOM_ELEMENT (document_clone));
@@ -7892,29 +7944,56 @@ dom_drag_and_drop_end (WebKitDOMDocument *document,
g_object_unref (dom_window);
}
-void
-dom_set_link_color (WebKitDOMDocument *document,
- const gchar *color)
+static void
+dom_set_link_color_in_document (WebKitDOMDocument *document,
+ const gchar *color,
+ gboolean visited)
{
gchar *color_str = NULL;
+ const gchar *style_id;
WebKitDOMHTMLHeadElement *head;
WebKitDOMElement *style_element;
+ WebKitDOMHTMLElement *body;
g_return_if_fail (color != NULL);
+ style_id = visited ? "-x-evo-a-color-style-visited" : "-x-evo-a-color-style";
+
head = webkit_dom_document_get_head (document);
+ body = webkit_dom_document_get_body (document);
- style_element = webkit_dom_document_get_element_by_id (document, "-x-evo-a-color-style");
+ style_element = webkit_dom_document_get_element_by_id (document, style_id);
if (!style_element) {
style_element = webkit_dom_document_create_element (document, "style", NULL);
- webkit_dom_element_set_id (style_element, "-x-evo-a-color-style");
+ webkit_dom_element_set_id (style_element, style_id);
webkit_dom_element_set_attribute (style_element, "type", "text/css", NULL);
webkit_dom_node_append_child (
WEBKIT_DOM_NODE (head), WEBKIT_DOM_NODE (style_element), NULL);
}
- color_str = g_strconcat ("a { color: ", color, "; }", NULL);
+ color_str = g_strdup_printf (
+ visited ? "a.-x-evo-visited-link { color: %s; }" : "a { color: %s; }", color);
webkit_dom_element_set_inner_html (style_element, color_str, NULL);
-
g_free (color_str);
+
+ if (visited)
+ webkit_dom_html_body_element_set_v_link (
+ WEBKIT_DOM_HTML_BODY_ELEMENT (body), color);
+ else
+ webkit_dom_html_body_element_set_link (
+ WEBKIT_DOM_HTML_BODY_ELEMENT (body), color);
+}
+
+void
+dom_set_link_color (WebKitDOMDocument *document,
+ const gchar *color)
+{
+ dom_set_link_color_in_document (document, color, FALSE);
+}
+
+void
+dom_set_visited_link_color (WebKitDOMDocument *document,
+ const gchar *color)
+{
+ dom_set_link_color_in_document (document, color, TRUE);
}
diff --git a/web-extensions/composer/e-html-editor-view-dom-functions.h
b/web-extensions/composer/e-html-editor-view-dom-functions.h
index ae7270e..aa35701 100644
--- a/web-extensions/composer/e-html-editor-view-dom-functions.h
+++ b/web-extensions/composer/e-html-editor-view-dom-functions.h
@@ -153,6 +153,9 @@ void dom_drag_and_drop_end (WebKitDOMDocument *document,
void dom_set_link_color (WebKitDOMDocument *document,
const gchar *color);
+void dom_set_visited_link_color (WebKitDOMDocument *document,
+ const gchar *color);
+
gboolean dom_change_quoted_block_to_normal
(WebKitDOMDocument *document,
EHTMLEditorWebExtension *extension);
diff --git a/web-extensions/composer/e-html-editor-web-extension.c
b/web-extensions/composer/e-html-editor-web-extension.c
index 52fab35..c77e891 100644
--- a/web-extensions/composer/e-html-editor-web-extension.c
+++ b/web-extensions/composer/e-html-editor-web-extension.c
@@ -814,6 +814,9 @@ handle_method_call (GDBusConnection *connection,
if (g_strcmp0 (selector, "body") == 0 &&
g_strcmp0 (attribute, "link") == 0)
dom_set_link_color (document, value);
+ else if (g_strcmp0 (selector, "body") == 0 &&
+ g_strcmp0 (attribute, "vlink") == 0)
+ dom_set_visited_link_color (document, value);
else
webkit_dom_element_set_attribute (
element, attribute, value, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]