[evolution] Bug 731508 - [webkit-composer] no option to paste as text (without formatting)



commit b5d682209bd8394c4fcccd6f2dd84ad53143a60c
Author: Tomas Popela <tpopela redhat com>
Date:   Wed Jun 25 14:13:39 2014 +0200

    Bug 731508 - [webkit-composer] no option to paste as text (without formatting)

 e-util/e-html-editor-actions.c   |   18 +++++++++++++++
 e-util/e-html-editor-manager.ui  |    2 +
 e-util/e-html-editor-selection.c |   16 +++++++++++++
 e-util/e-html-editor-selection.h |    9 +++++--
 e-util/e-html-editor-view.c      |   44 ++++++++++++++++++++++++++++++++++++++
 e-util/e-html-editor-view.h      |    2 +
 6 files changed, 88 insertions(+), 3 deletions(-)
---
diff --git a/e-util/e-html-editor-actions.c b/e-util/e-html-editor-actions.c
index 4d1751e..6b1276c 100644
--- a/e-util/e-html-editor-actions.c
+++ b/e-util/e-html-editor-actions.c
@@ -705,6 +705,16 @@ action_paste_cb (GtkAction *action,
 }
 
 static void
+action_paste_as_text_cb (GtkAction *action,
+                         EHTMLEditor *editor)
+{
+       EHTMLEditorView *view = e_html_editor_get_view (editor);
+
+       e_html_editor_view_paste_as_text (view);
+       e_html_editor_view_force_spell_check (view);
+}
+
+static void
 action_paste_quote_cb (GtkAction *action,
                        EHTMLEditor *editor)
 {
@@ -1337,6 +1347,14 @@ static GtkActionEntry html_entries[] = {
          NULL,
          NULL,
          NULL },
+
+       { "paste-as-text",
+         NULL,
+         N_("Paste As _Text"),
+         NULL,
+         NULL,
+         G_CALLBACK (action_paste_as_text_cb) },
+
 };
 
 static GtkToggleActionEntry html_toggle_entries[] = {
diff --git a/e-util/e-html-editor-manager.ui b/e-util/e-html-editor-manager.ui
index 75f2c34..1bdba8c 100644
--- a/e-util/e-html-editor-manager.ui
+++ b/e-util/e-html-editor-manager.ui
@@ -12,6 +12,7 @@
       <menuitem action='copy'/>
       <menuitem action='paste'/>
       <menuitem action='paste-quote'/>
+      <menuitem action='paste-as-text'/>
       <separator/>
       <menuitem action='select-all'/>
       <separator/>
@@ -145,6 +146,7 @@
     <menuitem action='copy'/>
     <menuitem action='paste'/>
     <menuitem action='paste-quote'/>
+    <menuitem action='paste-as-text'/>
     <separator/>
     <menuitem action='context-insert-link'/>
     <menuitem action='context-remove-link'/>
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index 4db05b4..bc0d6f4 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -3943,6 +3943,22 @@ e_html_editor_selection_insert_html (EHTMLEditorSelection *selection,
        g_object_unref (view);
 }
 
+void
+e_html_editor_selection_insert_as_text (EHTMLEditorSelection *selection,
+                                        const gchar *html_text)
+{
+       EHTMLEditorView *view;
+
+       g_return_if_fail (E_IS_HTML_EDITOR_SELECTION (selection));
+       g_return_if_fail (html_text != NULL);
+
+       view = e_html_editor_selection_ref_html_editor_view (selection);
+       g_return_if_fail (view != NULL);
+
+       e_html_editor_view_convert_and_insert_html_to_plain_text (view, html_text);
+
+       g_object_unref (view);
+}
 
 /************************* image_load_and_insert_async() *************************/
 
diff --git a/e-util/e-html-editor-selection.h b/e-util/e-html-editor-selection.h
index 1501687..2914405 100644
--- a/e-util/e-html-editor-selection.h
+++ b/e-util/e-html-editor-selection.h
@@ -165,9 +165,15 @@ const gchar *      e_html_editor_selection_get_string
                                                (EHTMLEditorSelection *selection);
 void           e_html_editor_selection_replace (EHTMLEditorSelection *selection,
                                                 const gchar *new_string);
+void           e_html_editor_selection_insert_text
+                                               (EHTMLEditorSelection *selection,
+                                                const gchar *plain_text);
 void           e_html_editor_selection_insert_html
                                                (EHTMLEditorSelection *selection,
                                                 const gchar *html_text);
+void           e_html_editor_selection_insert_as_text
+                                               (EHTMLEditorSelection *selection,
+                                                const gchar *html_text);
 void           e_html_editor_selection_replace_image_src
                                                (EHTMLEditorSelection *selection,
                                                 WebKitDOMElement *element,
@@ -175,9 +181,6 @@ void                e_html_editor_selection_replace_image_src
 void           e_html_editor_selection_insert_image
                                                (EHTMLEditorSelection *selection,
                                                 const gchar *image_uri);
-void           e_html_editor_selection_insert_text
-                                               (EHTMLEditorSelection *selection,
-                                                const gchar *plain_text);
 void           e_html_editor_selection_clear_caret_position_marker
                                                (EHTMLEditorSelection *selection);
 WebKitDOMNode *
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 343a0d3..0afd7a3 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -1589,6 +1589,21 @@ html_editor_view_set_links_active (EHTMLEditorView *view,
 }
 
 static void
+clipboard_text_received_for_paste_as_text (GtkClipboard *clipboard,
+                                           const gchar *text,
+                                           EHTMLEditorView *view)
+{
+       EHTMLEditorSelection *selection;
+
+       if (!text || !*text)
+               return;
+
+       selection = e_html_editor_view_get_selection (view);
+
+       e_html_editor_selection_insert_as_text (selection, text);
+}
+
+static void
 clipboard_text_received (GtkClipboard *clipboard,
                          const gchar *text,
                          EHTMLEditorView *view)
@@ -2273,6 +2288,21 @@ html_editor_view_key_release_event (GtkWidget *widget,
 }
 
 static void
+html_editor_view_paste_as_text (EHTMLEditorView *view)
+{
+       GtkClipboard *clipboard;
+
+       clipboard = gtk_clipboard_get_for_display (
+               gdk_display_get_default (),
+               GDK_SELECTION_CLIPBOARD);
+
+       gtk_clipboard_request_text (
+               clipboard,
+               (GtkClipboardTextReceivedFunc) clipboard_text_received_for_paste_as_text,
+               view);
+}
+
+static void
 html_editor_view_paste_clipboard_quoted (EHTMLEditorView *view)
 {
        GtkClipboard *clipboard;
@@ -6043,6 +6073,20 @@ e_html_editor_view_set_text_plain (EHTMLEditorView *view,
 }
 
 /**
+ * e_html_editor_view_paste_as_text:
+ * @view: an #EHTMLEditorView
+ *
+ * Pastes current content of clipboard into the editor without formatting
+ */
+void
+e_html_editor_view_paste_as_text (EHTMLEditorView *view)
+{
+       g_return_if_fail (E_IS_HTML_EDITOR_VIEW (view));
+
+       html_editor_view_paste_as_text (view);
+}
+
+/**
  * e_html_editor_view_paste_clipboard_quoted:
  * @view: an #EHTMLEditorView
  *
diff --git a/e-util/e-html-editor-view.h b/e-util/e-html-editor-view.h
index ea83158..2f27fb8 100644
--- a/e-util/e-html-editor-view.h
+++ b/e-util/e-html-editor-view.h
@@ -130,6 +130,8 @@ void                e_html_editor_view_set_text_html
 void           e_html_editor_view_set_text_plain
                                                (EHTMLEditorView *view,
                                                 const gchar *text);
+void           e_html_editor_view_paste_as_text
+                                               (EHTMLEditorView *view);
 void           e_html_editor_view_paste_clipboard_quoted
                                                (EHTMLEditorView *view);
 void           e_html_editor_view_embed_styles (EHTMLEditorView *view);


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