diff options
author | Tomas Popela <tpopela@redhat.com> | 2014-06-17 20:21:03 +0800 |
---|---|---|
committer | Tomas Popela <tpopela@redhat.com> | 2014-06-17 20:24:49 +0800 |
commit | 4a2d762f5e859b2f44e7321f602d896987ecac58 (patch) | |
tree | 9abc057455b02a710060736ab29e4ed33174bb91 /composer | |
parent | ef20971fd3b7d8c9f47313e5686b4cd5103aa8ed (diff) | |
download | gsoc2013-evolution-4a2d762f5e859b2f44e7321f602d896987ecac58.tar gsoc2013-evolution-4a2d762f5e859b2f44e7321f602d896987ecac58.tar.gz gsoc2013-evolution-4a2d762f5e859b2f44e7321f602d896987ecac58.tar.bz2 gsoc2013-evolution-4a2d762f5e859b2f44e7321f602d896987ecac58.tar.lz gsoc2013-evolution-4a2d762f5e859b2f44e7321f602d896987ecac58.tar.xz gsoc2013-evolution-4a2d762f5e859b2f44e7321f602d896987ecac58.tar.zst gsoc2013-evolution-4a2d762f5e859b2f44e7321f602d896987ecac58.zip |
EMsgComposer - Allow drag and drop of text or html/text into composer
Diffstat (limited to 'composer')
-rw-r--r-- | composer/e-msg-composer.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 3660d522f5..ff970e4948 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -1829,6 +1829,8 @@ msg_composer_drag_data_received_cb (GtkWidget *widget, guint time, EMsgComposer *composer) { + GdkAtom atom; + gchar *name; EAttachmentView *view; EHTMLEditor *editor; EHTMLEditorView *html_editor_view; @@ -1838,6 +1840,48 @@ msg_composer_drag_data_received_cb (GtkWidget *widget, html_editor_view = e_html_editor_get_view (editor); editor_selection = e_html_editor_view_get_selection (html_editor_view); + atom = gtk_selection_data_get_target (selection); + name = gdk_atom_name (atom); + + if (g_strcmp0 (name, "UTF8_STRING") == 0 || g_strcmp0 (name, "text/html") == 0) { + gboolean is_text; + const guchar *data; + gint length; + gint list_len, len; + gchar *text; + + is_text = g_strcmp0 (name, "UTF8_STRING") == 0; + + data = gtk_selection_data_get_data (selection); + length = gtk_selection_data_get_length (selection); + + if (!data || length < 0) { + g_free (name); + return; + } + + list_len = length; + do { + text = next_uri ((guchar **) &data, &len, &list_len); + if (is_text) + e_html_editor_selection_insert_text (editor_selection, text); + else + e_html_editor_selection_insert_html (editor_selection, text); + } while (list_len); + + e_html_editor_view_check_magic_links (html_editor_view, FALSE); + e_html_editor_view_force_spell_check (html_editor_view); + + e_html_editor_selection_scroll_to_caret (editor_selection); + + /* Stop the signal from propagating */ + g_signal_stop_emission_by_name (widget, "drag-data-received"); + g_free (name); + return; + } + + g_free (name); + /* HTML mode has a few special cases for drops... */ if (e_html_editor_view_get_html_mode (html_editor_view)) { /* If we're receiving an image, we want the image to be |