[evolution/gnome-3-24] Drag and drop to the editor can lock the Evolution



commit 2e9de004aa53d9c151b8f06c0d5ddba971cee361
Author: Tomas Popela <tpopela redhat com>
Date:   Wed Apr 12 10:54:03 2017 +0200

    Drag and drop to the editor can lock the Evolution
    
    The problem was that we were not disconnecting the drag-data-received
    handler in the composer if the drop was handled by editor. Then in the
    next drag and drop operation the callbacks in the composer were
    activated even before the drag and drop logic in the editor. Introduce
    the drop-handled signal that is emitted on the EContentEditor if the
    drop was successfully handled by it. In the composer we connect to this
    signal and remove the callback to the drag-data-received signal.

 src/composer/e-msg-composer.c               |   14 ++++++++++++++
 src/e-util/e-content-editor.c               |   23 +++++++++++++++++++++++
 src/e-util/e-content-editor.h               |    3 +++
 src/modules/webkit-editor/e-webkit-editor.c |    2 ++
 4 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/src/composer/e-msg-composer.c b/src/composer/e-msg-composer.c
index 33ac0a8..4cdfe9d 100644
--- a/src/composer/e-msg-composer.c
+++ b/src/composer/e-msg-composer.c
@@ -1866,6 +1866,16 @@ msg_composer_drag_drop_cb (GtkWidget *widget,
 }
 
 static void
+msg_composer_drop_handled_cb (EContentEditor *cnt_editor,
+                              EMsgComposer *composer)
+{
+       if (composer->priv->drag_data_received_handler_id != 0) {
+               g_signal_handler_disconnect (cnt_editor, composer->priv->drag_data_received_handler_id);
+               composer->priv->drag_data_received_handler_id = 0;
+       }
+}
+
+static void
 msg_composer_drag_begin_cb (GtkWidget *widget,
                             GdkDragContext *context,
                             EMsgComposer *composer)
@@ -2273,6 +2283,10 @@ msg_composer_constructed (GObject *object)
                G_CALLBACK (msg_composer_drag_begin_cb), composer);
 
        g_signal_connect (
+               cnt_editor, "drop-handled",
+               G_CALLBACK (msg_composer_drop_handled_cb), composer);
+
+       g_signal_connect (
                composer->priv->gallery_icon_view, "drag-data-get",
                G_CALLBACK (msg_composer_gallery_drag_data_get), NULL);
 
diff --git a/src/e-util/e-content-editor.c b/src/e-util/e-content-editor.c
index 7600da0..d70492d 100644
--- a/src/e-util/e-content-editor.c
+++ b/src/e-util/e-content-editor.c
@@ -34,6 +34,7 @@ enum {
        CONTEXT_MENU_REQUESTED,
        FIND_DONE,
        REPLACE_ALL_DONE,
+       DROP_HANDLED,
        LAST_SIGNAL
 };
 
@@ -507,6 +508,20 @@ e_content_editor_default_init (EContentEditorInterface *iface)
                NULL,
                G_TYPE_NONE, 1,
                G_TYPE_UINT);
+
+       /**
+        * EContentEditor:drop-handled
+        *
+        * Emitted when the content editor successfully handled the drop operation.
+        */
+       signals[DROP_HANDLED] = g_signal_new (
+               "drop-handled",
+               E_TYPE_CONTENT_EDITOR,
+               G_SIGNAL_RUN_LAST,
+               G_STRUCT_OFFSET (EContentEditorInterface, drop_handled),
+               NULL, NULL,
+               NULL,
+               G_TYPE_NONE, 0);
 }
 
 ESpellChecker *
@@ -3579,3 +3594,11 @@ e_content_editor_emit_replace_all_done (EContentEditor *editor,
 
        g_signal_emit (editor, signals[REPLACE_ALL_DONE], 0, replaced_count);
 }
+
+void
+e_content_editor_emit_drop_handled (EContentEditor *editor)
+{
+       g_return_if_fail (E_IS_CONTENT_EDITOR (editor));
+
+       g_signal_emit (editor, signals[DROP_HANDLED], 0);
+}
diff --git a/src/e-util/e-content-editor.h b/src/e-util/e-content-editor.h
index 8d3d64e..8db2a6f 100644
--- a/src/e-util/e-content-editor.h
+++ b/src/e-util/e-content-editor.h
@@ -437,6 +437,7 @@ struct _EContentEditorInterface {
                                                         guint match_count);
        void            (*replace_all_done)             (EContentEditor *editor,
                                                         guint replaced_count);
+       void            (*drop_handled)                 (EContentEditor *editor);
 };
 
 /* Properties */
@@ -1015,6 +1016,8 @@ void              e_content_editor_emit_find_done (EContentEditor *editor,
 void           e_content_editor_emit_replace_all_done
                                                (EContentEditor *editor,
                                                 guint replaced_count);
+void           e_content_editor_emit_drop_handled
+                                               (EContentEditor *editor);
 
 G_END_DECLS
 
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index 284906f..c907a8a 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -5916,6 +5916,7 @@ webkit_editor_drag_data_received_cb (GtkWidget *widget,
                g_signal_stop_emission_by_name (widget, "drag-data-received");
                if (!is_move)
                        webkit_editor_call_simple_extension_function (wk_editor, 
"DOMLastDropOperationDidCopy");
+               e_content_editor_emit_drop_handled (E_CONTENT_EDITOR (widget));
                return;
        }
 
@@ -5948,6 +5949,7 @@ webkit_editor_drag_data_received_cb (GtkWidget *widget,
 
                gtk_drag_finish (context, TRUE, is_move, time);
                g_signal_stop_emission_by_name (widget, "drag-data-received");
+               e_content_editor_emit_drop_handled (E_CONTENT_EDITOR (widget));
                return;
        }
 }


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