diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-06-20 02:49:01 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-06-20 02:49:01 +0800 |
commit | dddc124a9d32d349106803a04040a3edad2a3cbb (patch) | |
tree | fda6957a85330d2aeac5944521708c38b50f1ce6 /mail/folder-browser.c | |
parent | 85698a3ff51a20052acd2d3b521c76285753481d (diff) | |
download | gsoc2013-evolution-dddc124a9d32d349106803a04040a3edad2a3cbb.tar gsoc2013-evolution-dddc124a9d32d349106803a04040a3edad2a3cbb.tar.gz gsoc2013-evolution-dddc124a9d32d349106803a04040a3edad2a3cbb.tar.bz2 gsoc2013-evolution-dddc124a9d32d349106803a04040a3edad2a3cbb.tar.lz gsoc2013-evolution-dddc124a9d32d349106803a04040a3edad2a3cbb.tar.xz gsoc2013-evolution-dddc124a9d32d349106803a04040a3edad2a3cbb.tar.zst gsoc2013-evolution-dddc124a9d32d349106803a04040a3edad2a3cbb.zip |
Accept text/uri-list mime types - this allows us to drag messages from
2001-06-19 Jeffrey Stedfast <fejj@ximian.com>
* component-factory.c (destination_folder_handle_drop): Accept
text/uri-list mime types - this allows us to drag messages from
Nautilus into an Evolution folder.
* folder-browser.c (message_list_drag_data_get): Do cleanup and
better error handling.
svn path=/trunk/; revision=10296
Diffstat (limited to 'mail/folder-browser.c')
-rw-r--r-- | mail/folder-browser.c | 78 |
1 files changed, 69 insertions, 9 deletions
diff --git a/mail/folder-browser.c b/mail/folder-browser.c index e9ce4df109..3dda5dc45a 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -57,14 +57,17 @@ enum DndTargetType { DND_TARGET_TYPE_X_EVOLUTION_MESSAGE, DND_TARGET_TYPE_MESSAGE_RFC822, + DND_TARGET_TYPE_TEXT_URI_LIST, }; #define X_EVOLUTION_MESSAGE_TYPE "x-evolution-message" #define MESSAGE_RFC822_TYPE "message/rfc822" +#define TEXT_URI_LIST_TYPE "text/uri-list" static GtkTargetEntry drag_types[] = { { X_EVOLUTION_MESSAGE_TYPE, 0, DND_TARGET_TYPE_X_EVOLUTION_MESSAGE }, { MESSAGE_RFC822_TYPE, 0, DND_TARGET_TYPE_MESSAGE_RFC822 }, + { TEXT_URI_LIST_TYPE, 0, DND_TARGET_TYPE_TEXT_URI_LIST }, }; static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]); @@ -206,15 +209,9 @@ add_uid (MessageList *ml, const char *uid, gpointer data) } static void -message_list_drag_data_get (ETree *tree, - int row, - ETreePath path, - int col, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint time, - gpointer user_data) +message_list_drag_data_get (ETree *tree, int row, ETreePath path, int col, + GdkDragContext *context, GtkSelectionData *selection_data, + guint info, guint time, gpointer user_data) { FolderBrowser *fb = FOLDER_BROWSER (user_data); GPtrArray *uids = NULL; @@ -224,6 +221,69 @@ message_list_drag_data_get (ETree *tree, message_list_foreach (fb->message_list, add_uid, uids); switch (info) { + case DND_TARGET_TYPE_TEXT_URI_LIST: + { + char dir_template[] = "/tmp/evolution-XXXXXX"; + const char *dirname, *filename; + CamelMimeMessage *message; + CamelStream *stream; + char *uri_list; + int fd; + + dirname = mktemp (dir_template); + if (!dirname) { + /* cleanup and abort */ + for (i = 0; i < uids->len; i++) + g_free (uids->pdata[i]); + g_ptr_array_free (uids, TRUE); + return; + } + + mkdir (dirname, 0700); + + message = camel_folder_get_message (fb->folder, uids->pdata[0], NULL); + g_free (uids->pdata[0]); + + if (uids->len == 1) { + filename = camel_mime_message_get_subject (message); + if (!filename) + filename = "Unknown"; + } else + filename = "mbox"; + + uri_list = g_strdup_printf ("file://%s/%s", dirname, filename); + + fd = open (uri_list + 7, O_WRONLY | O_CREAT, 0600); + if (fd == -1) { + /* cleanup and abort */ + camel_object_unref (CAMEL_OBJECT (message)); + for (i = 1; i < uids->len; i++) + g_free (uids->pdata[i]); + g_ptr_array_free (uids, TRUE); + g_free (uri_list); + return; + } + + stream = camel_stream_fs_new_with_fd (fd); + + camel_stream_write (stream, "From - \n", 8); + camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream); + camel_object_unref (CAMEL_OBJECT (message)); + for (i = 1; i < uids->len; i++) { + message = camel_folder_get_message (fb->folder, uids->pdata[i], NULL); + camel_stream_write (stream, "From - \n", 8); + camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), stream); + camel_object_unref (CAMEL_OBJECT (message)); + g_free (uids->pdata[i]); + } + + camel_object_unref (CAMEL_OBJECT (stream)); + + gtk_selection_data_set (selection_data, selection_data->target, 8, + uri_list, strlen (uri_list)); + g_free (uri_list); + } + break; case DND_TARGET_TYPE_MESSAGE_RFC822: { /* FIXME: this'll be fucking slow for the user... pthread this? */ |