[evolution/wip/webkit-composer] Bug 725236: [webkit-composer] Pasting HTML content strips formatting



commit cc8320abf7e876fe83503f718c665f0203aeea71
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 09170fa..6934d82 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -1730,6 +1730,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)
 {
@@ -2106,6 +2119,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, &nbsp; 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]