[evolution] Bug 748574 - Upgrade to 3.16.1.1 from 3.12.11 has broken my email signature images
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 748574 - Upgrade to 3.16.1.1 from 3.12.11 has broken my email signature images
- Date: Wed, 13 May 2015 11:31:37 +0000 (UTC)
commit 1f32c52b1ef977f126aab33b0036da8937a6622c
Author: Tomas Popela <tpopela redhat com>
Date: Wed May 13 11:26:59 2015 +0200
Bug 748574 - Upgrade to 3.16.1.1 from 3.12.11 has broken my email signature images
When inserting HTML content into the composer we have to fix all the images with
file uris as their src. We have to also convert the HTML formatted signature when
the composer is in plain text mode.
composer/e-composer-private.c | 36 ++++++++++++++++++++++++++++--------
e-util/e-html-editor-selection.c | 1 +
e-util/e-html-editor-view.c | 26 ++++++++++++++++++++++++++
e-util/e-html-editor-view.h | 2 ++
4 files changed, 57 insertions(+), 8 deletions(-)
---
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 94ef230..9ac0b0f 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -1065,8 +1065,8 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
gchar *contents = NULL;
gsize length = 0;
const gchar *active_id;
- gboolean top_signature;
- gboolean is_html;
+ gboolean top_signature, is_html, html_mode;
+ gboolean start_bottom, is_message_from_edit_as_new;
GError *error = NULL;
EHTMLEditor *editor;
EHTMLEditorView *view;
@@ -1074,8 +1074,6 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
WebKitDOMNodeList *signatures;
gulong list_length, ii;
GSettings *settings;
- gboolean start_bottom;
- gboolean is_message_from_edit_as_new;
e_mail_signature_combo_box_load_selected_finish (
combo_box, result, &contents, &length, &is_html, &error);
@@ -1103,10 +1101,32 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
start_bottom = g_settings_get_boolean (settings, "composer-reply-start-bottom");
g_object_unref (settings);
+ document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
+ html_mode = e_html_editor_view_get_html_mode (view);
+
if (contents == NULL)
goto insert;
- if (!is_html) {
+ /* If inserting HTML signature in plain text composer we have to convert it. */
+ if (is_html && !html_mode) {
+ WebKitDOMElement *element;
+ gchar *inner_text;
+ gchar *html;
+
+ element = webkit_dom_document_create_element (document, "div", NULL);
+ webkit_dom_html_element_set_inner_html (
+ WEBKIT_DOM_HTML_ELEMENT (element), contents, NULL);
+ inner_text = webkit_dom_html_element_get_inner_text (
+ WEBKIT_DOM_HTML_ELEMENT (element));
+ html = camel_text_to_html (inner_text, 0, 0);
+ if (html) {
+ g_free (contents);
+
+ contents = html;
+ length = strlen (contents);
+ }
+ g_free (inner_text);
+ } else if (!is_html) {
gchar *html;
html = camel_text_to_html (contents, 0, 0);
@@ -1168,9 +1188,6 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
insert:
/* Remove the old signature and insert the new one. */
-
- document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
-
signatures = webkit_dom_document_get_elements_by_class_name (
document, "-x-evo-signature-wrapper");
list_length = webkit_dom_node_list_get_length (signatures);
@@ -1261,6 +1278,9 @@ insert:
g_string_free (html_buffer, TRUE);
}
+ if (is_html && html_mode)
+ e_html_editor_view_fix_file_uri_images (view);
+
composer_move_caret (composer);
exit:
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index 13c64b7..f1317d2 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -5397,6 +5397,7 @@ e_html_editor_selection_insert_html (EHTMLEditorSelection *selection,
}
e_html_editor_view_exec_command (view, command, html_text);
+ e_html_editor_view_fix_file_uri_images (view);
if (strstr (html_text, "id=\"-x-evo-selection-start-marker\""))
e_html_editor_selection_restore (selection);
e_html_editor_view_check_magic_links (view, FALSE);
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 094859c..e0325e5 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -10988,6 +10988,32 @@ e_html_editor_view_set_is_editting_message (EHTMLEditorView *view,
view->priv->is_editting_message = value;
}
+void
+e_html_editor_view_fix_file_uri_images (EHTMLEditorView *view)
+{
+ gint ii, length;
+ WebKitDOMNodeList *list;
+ WebKitDOMDocument *document;
+
+ document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
+ list = webkit_dom_document_query_selector_all (
+ document, "img[src^=\"file://\"]", NULL);
+ length = webkit_dom_node_list_get_length (list);
+
+ for (ii = 0; ii < length; ii++) {
+ WebKitDOMNode *node;
+ gchar *uri;
+
+ node = webkit_dom_node_list_item (list, ii);
+ uri = webkit_dom_element_get_attribute (WEBKIT_DOM_ELEMENT (node), "src");
+ e_html_editor_selection_replace_image_src (
+ view->priv->selection, WEBKIT_DOM_ELEMENT (node), uri);
+ g_free (uri);
+ }
+
+ g_object_unref (list);
+}
+
gboolean
e_html_editor_view_is_undo_redo_in_progress (EHTMLEditorView *view)
{
diff --git a/e-util/e-html-editor-view.h b/e-util/e-html-editor-view.h
index bd61513..d53098b 100644
--- a/e-util/e-html-editor-view.h
+++ b/e-util/e-html-editor-view.h
@@ -283,6 +283,8 @@ void e_html_editor_view_set_link_color
void e_html_editor_view_set_visited_link_color
(EHTMLEditorView *view,
GdkRGBA *color);
+void e_html_editor_view_fix_file_uri_images
+ (EHTMLEditorView *view);
gboolean e_html_editor_view_can_undo (EHTMLEditorView *view);
void e_html_editor_view_undo (EHTMLEditorView *view);
gboolean e_html_editor_view_can_redo (EHTMLEditorView *view);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]