[evolution/gnome-3-28] Revert message composer part of the previous commit



commit bf8c36871392d578999a82a287371feec89dcfb2
Author: Milan Crha <mcrha redhat com>
Date:   Tue Apr 10 14:22:42 2018 +0200

    Revert message composer part of the previous commit
    
    It caused no message body being filled when replying to a message
    or such actions. There was also a runtime warning when an empty GBytes
    had been passed to WebKitGTK+, thus cover that as well.

 src/e-util/e-web-view.c                     |   15 ++++++-----
 src/modules/webkit-editor/e-webkit-editor.c |   33 ++++++--------------------
 2 files changed, 16 insertions(+), 32 deletions(-)
---
diff --git a/src/e-util/e-web-view.c b/src/e-util/e-web-view.c
index 24e169b..3f5f011 100644
--- a/src/e-util/e-web-view.c
+++ b/src/e-util/e-web-view.c
@@ -1448,14 +1448,15 @@ static void
 web_view_load_string (EWebView *web_view,
                       const gchar *string)
 {
-       GBytes *bytes;
-
-       if (string == NULL)
-               string = "";
+       if (!string || !*string) {
+               webkit_web_view_load_html (WEBKIT_WEB_VIEW (web_view), "", "evo-file://");
+       } else {
+               GBytes *bytes;
 
-       bytes = g_bytes_new (string, strlen (string));
-       webkit_web_view_load_bytes (WEBKIT_WEB_VIEW (web_view), bytes, NULL, NULL, "evo-file:///");
-       g_bytes_unref (bytes);
+               bytes = g_bytes_new (string, strlen (string));
+               webkit_web_view_load_bytes (WEBKIT_WEB_VIEW (web_view), bytes, NULL, NULL, "evo-file://");
+               g_bytes_unref (bytes);
+       }
 }
 
 static void
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index ff8d351..630806e 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -1763,26 +1763,6 @@ set_convert_in_situ (EWebKitEditor *wk_editor,
 }
 
 static void
-e_webkit_editor_load_html_as_bytes (EWebKitEditor *wk_editor,
-                                   const gchar *html)
-{
-       GBytes *bytes;
-
-       g_return_if_fail (E_IS_WEBKIT_EDITOR (wk_editor));
-
-       if (!html)
-               html = "";
-
-       bytes = g_bytes_new (html, strlen (html));
-
-       /* Make WebKit think we are displaying a local file, so that it
-        * does not block loading resources from file:// protocol */
-       webkit_web_view_load_bytes (WEBKIT_WEB_VIEW (wk_editor), bytes, NULL, NULL, "file://");
-
-       g_bytes_unref (bytes);
-}
-
-static void
 webkit_editor_insert_content (EContentEditor *editor,
                               const gchar *content,
                               EContentEditorInsertContentFlags flags)
@@ -1843,14 +1823,14 @@ webkit_editor_insert_content (EContentEditor *editor,
                if ((strstr (content, "data-evo-draft") ||
                     strstr (content, "data-evo-signature-plain-text-mode"))) {
                        wk_editor->priv->reload_in_progress = TRUE;
-                       e_webkit_editor_load_html_as_bytes (wk_editor, content);
+                       webkit_web_view_load_html (WEBKIT_WEB_VIEW (wk_editor), content, "file://");
                        return;
                }
 
                if (strstr (content, "data-evo-draft") && !(wk_editor->priv->html_mode)) {
                        set_convert_in_situ (wk_editor, TRUE);
                        wk_editor->priv->reload_in_progress = TRUE;
-                       e_webkit_editor_load_html_as_bytes (wk_editor, content);
+                       webkit_web_view_load_html (WEBKIT_WEB_VIEW (wk_editor), content, "file://");
                        return;
                }
 
@@ -1860,7 +1840,7 @@ webkit_editor_insert_content (EContentEditor *editor,
                                if (!show_lose_formatting_dialog (wk_editor)) {
                                        wk_editor->priv->reload_in_progress = TRUE;
                                        webkit_editor_set_html_mode (wk_editor, TRUE);
-                                       e_webkit_editor_load_html_as_bytes (wk_editor, content);
+                                       webkit_web_view_load_html (WEBKIT_WEB_VIEW (wk_editor), content, 
"file://");
                                        return;
                                }
                        }
@@ -1868,7 +1848,7 @@ webkit_editor_insert_content (EContentEditor *editor,
                }
 
                wk_editor->priv->reload_in_progress = TRUE;
-               e_webkit_editor_load_html_as_bytes (wk_editor, content);
+               webkit_web_view_load_html (WEBKIT_WEB_VIEW (wk_editor), content, "file://");
        } else if ((flags & E_CONTENT_EDITOR_INSERT_REPLACE_ALL) &&
                   (flags & E_CONTENT_EDITOR_INSERT_TEXT_PLAIN)) {
                e_util_invoke_g_dbus_proxy_call_with_error_check (
@@ -5223,7 +5203,10 @@ webkit_editor_constructed (GObject *object)
        webkit_settings_set_allow_file_access_from_file_urls (web_settings, TRUE);
        webkit_settings_set_enable_developer_extras (web_settings, e_util_get_webkit_developer_mode_enabled 
());
 
-       e_webkit_editor_load_html_as_bytes (wk_editor, "");
+       /* Make WebKit think we are displaying a local file, so that it
+        * does not block loading resources from file:// protocol */
+       webkit_web_view_load_html (WEBKIT_WEB_VIEW (wk_editor), "", "file://");
+
 }
 
 static GObjectConstructParam*


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