From b5d682209bd8394c4fcccd6f2dd84ad53143a60c Mon Sep 17 00:00:00 2001 From: Tomas Popela Date: Wed, 25 Jun 2014 14:13:39 +0200 Subject: Bug 731508 - [webkit-composer] no option to paste as text (without formatting) --- e-util/e-html-editor-view.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'e-util/e-html-editor-view.c') diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c index 343a0d3676..0afd7a3f78 100644 --- a/e-util/e-html-editor-view.c +++ b/e-util/e-html-editor-view.c @@ -1588,6 +1588,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, @@ -2272,6 +2287,21 @@ html_editor_view_key_release_event (GtkWidget *widget, key_release_event (widget, event); } +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) { @@ -6042,6 +6072,20 @@ e_html_editor_view_set_text_plain (EHTMLEditorView *view, WEBKIT_WEB_VIEW (view), text, "text/plain", NULL, "file://"); } +/** + * 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 -- cgit v1.2.3