[evolution/wip/webkit-composer: 878/966] Bug 725236: [webkit-composer] Pasting HTML content strips formatting
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit-composer: 878/966] Bug 725236: [webkit-composer] Pasting HTML content strips formatting
- Date: Wed, 23 Apr 2014 11:07:15 +0000 (UTC)
commit d4f8b624224a1a6711cda408a13da877c4b28fbd
Author: Tomas Popela <tpopela redhat com>
Date: Fri Mar 7 11:54:39 2014 +0100
Bug 725236: [webkit-composer] Pasting HTML content strips formatting
Process GDK_SELECTION_PRIMARY (middle button paste) clipboard as well.
composer/e-msg-composer.c | 17 +++++++++++++++++
e-util/e-editor-widget.c | 24 +++++++++++++++++++++---
e-util/e-editor-widget.h | 2 ++
3 files changed, 40 insertions(+), 3 deletions(-)
---
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 7a51e41..88777fc 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -1732,6 +1732,19 @@ msg_composer_paste_clipboard_targets_cb (GtkClipboard *clipboard,
}
static void
+msg_composer_paste_primary_clipboard_cb (EEditorWidget *web_view,
+ EMsgComposer *composer)
+{
+ GtkClipboard *clipboard;
+
+ clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
+
+ gtk_clipboard_request_targets (
+ clipboard, (GtkClipboardTargetsReceivedFunc)
+ msg_composer_paste_clipboard_targets_cb, composer);
+}
+
+static void
msg_composer_paste_clipboard_cb (EEditorWidget *web_view,
EMsgComposer *composer)
{
@@ -2108,6 +2121,10 @@ msg_composer_constructed (GObject *object)
editor_widget, "paste-clipboard",
G_CALLBACK (msg_composer_paste_clipboard_cb), composer);
+ g_signal_connect (
+ editor_widget, "paste-primary-clipboard",
+ G_CALLBACK (msg_composer_paste_primary_clipboard_cb), composer);
+
/* Drag-and-Drop Support */
g_signal_connect (
diff --git a/e-util/e-editor-widget.c b/e-util/e-editor-widget.c
index c178217..9db9163 100644
--- a/e-util/e-editor-widget.c
+++ b/e-util/e-editor-widget.c
@@ -100,6 +100,7 @@ enum {
enum {
POPUP_EVENT,
+ PASTE_PRIMARY_CLIPBOARD,
LAST_SIGNAL
};
@@ -1445,13 +1446,17 @@ editor_widget_button_press_event (GtkWidget *widget,
{
gboolean event_handled;
- if (event->button != 3) {
- event_handled = FALSE;
- } else {
+ if (event->button == 2) {
+ /* Middle click paste */
+ g_signal_emit (widget, signals[PASTE_PRIMARY_CLIPBOARD], 0);
+ event_handled = TRUE;
+ } else if (event->button == 3) {
editor_widget_save_element_under_mouse_click (widget);
g_signal_emit (
widget, signals[POPUP_EVENT],
0, event, &event_handled);
+ } else {
+ event_handled = FALSE;
}
if (event_handled)
@@ -2057,6 +2062,19 @@ e_editor_widget_class_init (EEditorWidgetClass *class)
e_marshal_BOOLEAN__BOXED,
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+ /**
+ * EEditorWidget:paste-primary-clipboad
+ *
+ * Emitted when user presses middle button on EEditorWidget
+ */
+ signals[PASTE_PRIMARY_CLIPBOARD] = g_signal_new (
+ "paste-primary-clipboard",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EEditorWidgetClass, paste_primary_clipboard),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
/* This parses the HTML code (that contains just text, and BR elements)
diff --git a/e-util/e-editor-widget.h b/e-util/e-editor-widget.h
index b2fc783..37128f0 100644
--- a/e-util/e-editor-widget.h
+++ b/e-util/e-editor-widget.h
@@ -71,6 +71,8 @@ struct _EEditorWidgetClass {
(EEditorWidget *widget);
gboolean (*popup_event) (EEditorWidget *widget,
GdkEventButton *event);
+ void (*paste_primary_clipboard)
+ (EEditorWidget *widget);
};
GType e_editor_widget_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]