aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Popela <tpopela@redhat.com>2014-06-25 20:13:39 +0800
committerTomas Popela <tpopela@redhat.com>2014-06-25 21:59:50 +0800
commitb5d682209bd8394c4fcccd6f2dd84ad53143a60c (patch)
tree8859c95fbb8e35ebff2d8c14cbc89e49d65760b2
parent177b1a6abfe7b73d7534db819d52e3d87ad76756 (diff)
downloadgsoc2013-evolution-b5d682209bd8394c4fcccd6f2dd84ad53143a60c.tar
gsoc2013-evolution-b5d682209bd8394c4fcccd6f2dd84ad53143a60c.tar.gz
gsoc2013-evolution-b5d682209bd8394c4fcccd6f2dd84ad53143a60c.tar.bz2
gsoc2013-evolution-b5d682209bd8394c4fcccd6f2dd84ad53143a60c.tar.lz
gsoc2013-evolution-b5d682209bd8394c4fcccd6f2dd84ad53143a60c.tar.xz
gsoc2013-evolution-b5d682209bd8394c4fcccd6f2dd84ad53143a60c.tar.zst
gsoc2013-evolution-b5d682209bd8394c4fcccd6f2dd84ad53143a60c.zip
Bug 731508 - [webkit-composer] no option to paste as text (without formatting)
-rw-r--r--e-util/e-html-editor-actions.c18
-rw-r--r--e-util/e-html-editor-manager.ui2
-rw-r--r--e-util/e-html-editor-selection.c16
-rw-r--r--e-util/e-html-editor-selection.h9
-rw-r--r--e-util/e-html-editor-view.c44
-rw-r--r--e-util/e-html-editor-view.h2
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 4d1751e117..6b1276ceed 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 75f2c34b20..1bdba8cfc6 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 4db05b4730..bc0d6f4bf6 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 1501687d49..291440554b 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 343a0d3676..0afd7a3f78 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 ea8315884b..2f27fb8934 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);