[evolution/wip/webkit2] Bug 744562 - Allow insert of emoticons in plain text mode



commit 6829e3aa1bfaaef127e994cea7171ddcf0bb3284
Author: Tomas Popela <tpopela redhat com>
Date:   Tue Mar 24 16:34:01 2015 +0100

    Bug 744562 - Allow insert of emoticons in plain text mode

 e-util/e-html-editor-manager.ui                   |    3 ++-
 web-extensions/e-html-editor-view-dom-functions.c |   17 +++++++++++------
 2 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/e-util/e-html-editor-manager.ui b/e-util/e-html-editor-manager.ui
index 4ee87ae..97a4861 100644
--- a/e-util/e-html-editor-manager.ui
+++ b/e-util/e-html-editor-manager.ui
@@ -116,6 +116,8 @@
     <separator/>
     <toolitem action='unindent'/>
     <toolitem action='indent'/>
+    <separator/>
+    <toolitem action='insert-emoticon'/>
   </toolbar>
   <toolbar name='html-toolbar'>
     <separator/>
@@ -129,7 +131,6 @@
     <toolitem action='insert-link'/>
     <toolitem action='insert-rule'/>
     <toolitem action='insert-table'/>
-    <toolitem action='insert-emoticon'/>
   </toolbar>
   <popup name='context-menu'>
     <placeholder name='context-spell-suggest'/>
diff --git a/web-extensions/e-html-editor-view-dom-functions.c 
b/web-extensions/e-html-editor-view-dom-functions.c
index 444f96c..1759f54 100644
--- a/web-extensions/e-html-editor-view-dom-functions.c
+++ b/web-extensions/e-html-editor-view-dom-functions.c
@@ -1329,6 +1329,7 @@ emoticon_read_async_cb (GFile *file,
 {
        EEmoticon *emoticon = load_context->emoticon;
        GError *error = NULL;
+       gboolean html_mode;
        gchar *html, *mime_type;
        gchar *base64_encoded, *output, *data;
        GFileInputStream *input_stream;
@@ -1353,16 +1354,20 @@ emoticon_read_async_cb (GFile *file,
        base64_encoded = g_base64_encode ((const guchar *) data, size);
        output = g_strconcat ("data:", mime_type, ";base64,", base64_encoded, NULL);
 
+       html_mode = e_html_editor_web_extension_get_html_mode (extension);
+
        /* Insert span with image representation and another one with text
         * represetation and hide/show them dependant on active composer mode */
        html = g_strdup_printf (
                "<span class=\"-x-evo-smiley-wrapper -x-evo-resizable-wrapper\">"
                "<img src=\"%s\" alt=\"%s\" x-evo-smiley=\"%s\" "
-               "class=\"-x-evo-smiley-img\" data-inline data-name=\"%s\"/>"
-               "<span class=\"-x-evo-smiley-text\" style=\"display: none;\">%s"
-               "</span></span>",
-               output, emoticon ? emoticon->text_face : "", emoticon->icon_name,
-               load_context->name, emoticon ? emoticon->text_face : "");
+               "class=\"-x-evo-smiley-img\" data-inline data-name=\"%s\"%s/>"
+               "<span class=\"-x-evo-smiley-text\"%s>%s</span></span>",
+               output, emoticon ? emoticon->text_face : "",
+               emoticon->icon_name, load_context->name,
+               html_mode ? "" : " style=\"display: none;\"",
+               html_mode ? " style=\"display: none;\"" : "",
+               emoticon ? emoticon->text_face : "");
 
        emoticon_insert_span (emoticon, load_context, html);
 
@@ -1647,7 +1652,7 @@ body_input_event_cb (WebKitDOMElement *element,
        html_mode = e_html_editor_web_extension_get_html_mode (extension);
        e_html_editor_web_extension_set_content_changed (extension);
 
-       if (e_html_editor_web_extension_get_magic_smileys_enabled (extension) && html_mode)
+       if (e_html_editor_web_extension_get_magic_smileys_enabled (extension))
                dom_check_magic_smileys (document, extension);
 
        if (e_html_editor_web_extension_get_return_key_pressed (extension) ||


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