aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Popela <tpopela@redhat.com>2014-06-18 16:28:18 +0800
committerTomas Popela <tpopela@redhat.com>2014-06-18 16:28:18 +0800
commit51dcc0b786b54f9169c000e2465a2c3a3ee89cb5 (patch)
treee139d04e064ae37c6b9bd9e970b8fa970a005b6a
parent3ef3e963573965827a6b72b8096e15b24c2db77f (diff)
downloadgsoc2013-evolution-51dcc0b786b54f9169c000e2465a2c3a3ee89cb5.tar
gsoc2013-evolution-51dcc0b786b54f9169c000e2465a2c3a3ee89cb5.tar.gz
gsoc2013-evolution-51dcc0b786b54f9169c000e2465a2c3a3ee89cb5.tar.bz2
gsoc2013-evolution-51dcc0b786b54f9169c000e2465a2c3a3ee89cb5.tar.lz
gsoc2013-evolution-51dcc0b786b54f9169c000e2465a2c3a3ee89cb5.tar.xz
gsoc2013-evolution-51dcc0b786b54f9169c000e2465a2c3a3ee89cb5.tar.zst
gsoc2013-evolution-51dcc0b786b54f9169c000e2465a2c3a3ee89cb5.zip
EHTMLEditor - When setting the body background image set it as its base64 data instead of uri
-rw-r--r--e-util/e-html-editor-page-dialog.c8
-rw-r--r--e-util/e-html-editor-selection.c29
-rw-r--r--e-util/e-html-editor-selection.h2
3 files changed, 26 insertions, 13 deletions
diff --git a/e-util/e-html-editor-page-dialog.c b/e-util/e-html-editor-page-dialog.c
index 53c8fce8c7..27552576c6 100644
--- a/e-util/e-html-editor-page-dialog.c
+++ b/e-util/e-html-editor-page-dialog.c
@@ -270,8 +270,12 @@ html_editor_page_dialog_set_background_image (EHTMLEditorPageDialog *dialog)
GTK_FILE_CHOOSER (
dialog->priv->background_image_filechooser));
- webkit_dom_html_body_element_set_background (
- WEBKIT_DOM_HTML_BODY_ELEMENT (body), uri ? uri : "");
+ if (uri && *uri) {
+ e_html_editor_selection_replace_image_src (
+ e_html_editor_view_get_selection (view),
+ WEBKIT_DOM_ELEMENT (body),
+ uri);
+ }
g_free (uri);
}
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index 62837f4f67..a48ffb77d0 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -3939,9 +3939,16 @@ replace_base64_image_src (EHTMLEditorSelection *selection,
e_html_editor_view_set_changed (view, TRUE);
g_object_unref (view);
- webkit_dom_html_image_element_set_src (
- WEBKIT_DOM_HTML_IMAGE_ELEMENT (element),
- base64_content);
+ if (WEBKIT_DOM_IS_HTML_IMAGE_ELEMENT (element))
+ webkit_dom_html_image_element_set_src (
+ WEBKIT_DOM_HTML_IMAGE_ELEMENT (element),
+ base64_content);
+ else
+ webkit_dom_element_set_attribute (
+ WEBKIT_DOM_ELEMENT (element),
+ "background",
+ base64_content,
+ NULL);
webkit_dom_element_set_attribute (
WEBKIT_DOM_ELEMENT (element), "data-uri", uri, NULL);
webkit_dom_element_set_attribute (
@@ -4249,24 +4256,26 @@ e_html_editor_selection_insert_image (EHTMLEditorSelection *selection,
/**
* e_html_editor_selection_replace_image_src:
* @selection: an #EHTMLEditorSelection
- * @image: #WebKitDOMElement representation of image
+ * @element: #WebKitDOMElement element
* @image_uri: an URI of the source image
*
- * Replace the src attribute of the given @image with @image_uri.
+ * If given @element is image we will replace the src attribute of it with base64
+ * data from given @image_uri. Otherwise we will set the base64 data to
+ * the background attribute of given @element.
*/
void
e_html_editor_selection_replace_image_src (EHTMLEditorSelection *selection,
- WebKitDOMElement *image,
+ WebKitDOMElement *element,
const gchar *image_uri)
{
g_return_if_fail (E_IS_HTML_EDITOR_SELECTION (selection));
g_return_if_fail (image_uri != NULL);
- g_return_if_fail (WEBKIT_DOM_IS_HTML_IMAGE_ELEMENT (image));
+ g_return_if_fail (element && WEBKIT_DOM_IS_ELEMENT (element));
if (strstr (image_uri, ";base64,")) {
if (g_str_has_prefix (image_uri, "data:"))
replace_base64_image_src (
- selection, image, image_uri, "", "");
+ selection, element, image_uri, "", "");
if (strstr (image_uri, ";data")) {
const gchar *base64_data = strstr (image_uri, ";") + 1;
gchar *filename;
@@ -4278,11 +4287,11 @@ e_html_editor_selection_replace_image_src (EHTMLEditorSelection *selection,
filename = g_strndup (image_uri, filename_length);
replace_base64_image_src (
- selection, image, base64_data, filename, "");
+ selection, element, base64_data, filename, "");
g_free (filename);
}
} else
- image_load_and_insert_async (selection, image, image_uri);
+ image_load_and_insert_async (selection, element, image_uri);
}
/**
diff --git a/e-util/e-html-editor-selection.h b/e-util/e-html-editor-selection.h
index c0d2d1817f..104a1a43d7 100644
--- a/e-util/e-html-editor-selection.h
+++ b/e-util/e-html-editor-selection.h
@@ -170,7 +170,7 @@ void e_html_editor_selection_insert_html
const gchar *html_text);
void e_html_editor_selection_replace_image_src
(EHTMLEditorSelection *selection,
- WebKitDOMElement *image,
+ WebKitDOMElement *element,
const gchar *image_uri);
void e_html_editor_selection_insert_image
(EHTMLEditorSelection *selection,