2006-02-04 [colin] 2.0.0cvs10
authorColin Leroy <colin@colino.net>
Sat, 4 Feb 2006 17:17:33 +0000 (17:17 +0000)
committerColin Leroy <colin@colino.net>
Sat, 4 Feb 2006 17:17:33 +0000 (17:17 +0000)
* src/compose.c
* src/folderview.c
* src/mimeview.c
* src/summaryview.c
* src/summaryview.h
Added various drag and drop capas:
From To
summaryview other apps
mimeview icons other apps
other apps summaryview
other apps folderview

This shouldn't have broken the existing:
From To
summaryview folderview
folderview folderview
summaryview compose's attachments

Tests welcomed.

ChangeLog
PATCHSETS
configure.ac
src/compose.c
src/folderview.c
src/mimeview.c
src/summaryview.c
src/summaryview.h

index 50d91f97b2cc5bec299b444652a63a571698e17e..d3b72650ea48b785fce132ea41c608ddb5139c67 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2006-02-04 [colin]     2.0.0cvs10
+
+       * src/compose.c
+       * src/folderview.c
+       * src/mimeview.c
+       * src/summaryview.c
+       * src/summaryview.h
+               Added various drag and drop capas:
+               From                    To
+               summaryview             other apps
+               mimeview icons          other apps
+               other apps              summaryview
+               other apps              folderview
+
+               This shouldn't have broken the existing:
+               From                    To
+               summaryview             folderview
+               folderview              folderview
+               summaryview             compose's attachments
+
+       Tests welcomed.
+
 2006-02-02 [paul]      2.0.0cvs9
 
        * src/mainwindow.c
index b631cb2f1c3669f60885e3eabc717d07a210f577..b93664650b450ab3832c37dbd043d246d9ff44bc 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.382.2.232 -r 1.382.2.233 src/compose.c;  cvs diff -u -r 1.105.2.47 -r 1.105.2.48 src/prefs_account.c;  cvs diff -u -r 1.204.2.73 -r 1.204.2.74 src/prefs_common.c;  cvs diff -u -r 1.9.2.21 -r 1.9.2.22 src/common/defs.h;  cvs diff -u -r 1.36.2.52 -r 1.36.2.53 src/common/utils.c;  cvs diff -u -r 1.20.2.30 -r 1.20.2.31 src/common/utils.h;  ) > 2.0.0cvs7.patchset
 ( cvs diff -u -r 1.83.2.60 -r 1.83.2.61 src/mimeview.c;  ) > 2.0.0cvs8.patchset
 ( cvs diff -u -r 1.274.2.94 -r 1.274.2.95 src/mainwindow.c;  ) > 2.0.0cvs9.patchset
+( cvs diff -u -r 1.382.2.233 -r 1.382.2.234 src/compose.c;  cvs diff -u -r 1.207.2.85 -r 1.207.2.86 src/folderview.c;  cvs diff -u -r 1.83.2.61 -r 1.83.2.62 src/mimeview.c;  cvs diff -u -r 1.395.2.160 -r 1.395.2.161 src/summaryview.c;  cvs diff -u -r 1.68.2.14 -r 1.68.2.15 src/summaryview.h;  ) > 2.0.0cvs10.patchset
index 52d18aa24a693c7cbe9a278cf974f86792821ebf..dcc364a71619935c82070ea586828396d35db92f 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=9
+EXTRA_VERSION=10
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index aa329d89e83e7d568f696da8f1dd27565babc200..ee5ce14d15a89e9e9f16e2bd8bc8384ffc803f01 100644 (file)
@@ -7916,7 +7916,7 @@ static void compose_toggle_ruler_cb(gpointer data, guint action,
 }
 
 static void compose_attach_drag_received_cb (GtkWidget         *widget,
-                                            GdkDragContext     *drag_context,
+                                            GdkDragContext     *context,
                                             gint                x,
                                             gint                y,
                                             GtkSelectionData   *data,
@@ -7928,7 +7928,8 @@ static void compose_attach_drag_received_cb (GtkWidget            *widget,
        GList *list, *tmp;
 
        if (gdk_atom_name(data->type) && 
-           !strcmp(gdk_atom_name(data->type), "text/uri-list")) {
+           !strcmp(gdk_atom_name(data->type), "text/uri-list")
+           && gtk_drag_get_source_widget(context) == NULL) {
                list = uri_list_extract_filenames((const gchar *)data->data);
                for (tmp = list; tmp != NULL; tmp = tmp->next)
                        compose_attach_append
@@ -7937,9 +7938,8 @@ static void compose_attach_drag_received_cb (GtkWidget            *widget,
                if (list) compose_changed_cb(NULL, compose);
                list_free_strings(list);
                g_list_free(list);
-       } else if (gdk_atom_name(data->type) && 
-                  !strcmp(gdk_atom_name(data->type), "text/plain") &&
-                  data->data && !strcmp(data->data, "Dummy-Summaryview")) {
+       } else if (gtk_drag_get_source_widget(context) 
+                  == mainwindow_get_mainwindow()->summaryview->ctree) {
                /* comes from our summaryview */
                SummaryView * summaryview = NULL;
                GSList * list = NULL, *cur = NULL;
index 91132fe79b6100d20601f6de092008a6a28531f0..fb28a1f8539ac104408ffc534489ba1dd1eb235f 100644 (file)
@@ -292,7 +292,8 @@ static GtkItemFactoryEntry folder_view_trash_popup_entries[] = {
 
 GtkTargetEntry folderview_drag_types[] =
 {
-       {"text/plain", GTK_TARGET_SAME_APP, TARGET_DUMMY}
+       {"text/plain", GTK_TARGET_SAME_APP, TARGET_DUMMY},
+       {"text/uri-list", 0, TARGET_MAIL_URI_LIST}
 };
 
 void folderview_initialize(void)
@@ -490,7 +491,7 @@ GtkWidget *folderview_ctree_create(FolderView *folderview)
 
         /* drop callback */
        gtk_drag_dest_set(ctree, GTK_DEST_DEFAULT_ALL & ~GTK_DEST_DEFAULT_HIGHLIGHT,
-                         summary_drag_types, 1,
+                         folderview_drag_types, 2,
                          GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_DEFAULT);
        g_signal_connect(G_OBJECT(ctree), "drag_motion",
                         G_CALLBACK(folderview_drag_motion_cb),
@@ -566,7 +567,7 @@ FolderView *folderview_create(void)
 
        gtk_widget_show_all(scrolledwin);
        
-       folderview->target_list = gtk_target_list_new(folderview_drag_types, 1);
+       folderview->target_list = gtk_target_list_new(folderview_drag_types, 2);
        folderview_list = g_list_append(folderview_list, folderview);
 
        return folderview;
@@ -2370,20 +2371,23 @@ static void folderview_drag_data_get(GtkWidget        *widget,
        FolderItem *item;
        GList *cur;
        gchar *source = NULL;
-
-       for (cur = GTK_CLIST(folderview->ctree)->selection;
-            cur != NULL; cur = cur->next) {
-               item = gtk_ctree_node_get_row_data
-                       (GTK_CTREE(folderview->ctree), 
-                        GTK_CTREE_NODE(cur->data));
-               if (item) {
-                       source = g_strdup_printf ("FROM_OTHER_FOLDER%s", folder_item_get_identifier(item));
-                       gtk_selection_data_set(selection_data,
-                                              selection_data->target, 8,
-                                              source, strlen(source));
-                       break;
-               } else
-                       return;
+       if (info == TARGET_DUMMY) {
+               for (cur = GTK_CLIST(folderview->ctree)->selection;
+                    cur != NULL; cur = cur->next) {
+                       item = gtk_ctree_node_get_row_data
+                               (GTK_CTREE(folderview->ctree), 
+                                GTK_CTREE_NODE(cur->data));
+                       if (item) {
+                               source = g_strdup_printf ("FROM_OTHER_FOLDER%s", folder_item_get_identifier(item));
+                               gtk_selection_data_set(selection_data,
+                                                      selection_data->target, 8,
+                                                      source, strlen(source));
+                               break;
+                       } else
+                               return;
+               }
+       } else {
+               g_warning("unknown info %d\n", info);
        }
 }
 
@@ -2462,6 +2466,13 @@ static gboolean folderview_drag_motion_cb(GtkWidget      *widget,
                            FOLDER_CLASS(item->folder)->copy_msg != NULL &&
                            FOLDER_CLASS(item->folder)->create_folder != NULL)
                                acceptable = TRUE;
+               } else if (srcwidget == NULL) {
+                       /* comes from another app */
+                       /* we are adding messages, so only accept folder items that are 
+                          no root items and can copy messages */
+                       if (item && item->folder && folder_item_parent(item) != NULL
+                           && FOLDER_CLASS(item->folder)->add_msg != NULL)
+                               acceptable = TRUE;
                }
        }
 
@@ -2496,6 +2507,11 @@ static void folderview_drag_leave_cb(GtkWidget      *widget,
        gtk_ctree_select(GTK_CTREE(widget), folderview->opened);
 }
 
+static void free_info (gpointer stuff, gpointer data)
+{
+       g_free(stuff);
+}
+
 static void folderview_drag_received_cb(GtkWidget        *widget,
                                        GdkDragContext   *drag_context,
                                        gint              x,
@@ -2506,75 +2522,116 @@ static void folderview_drag_received_cb(GtkWidget        *widget,
                                        FolderView       *folderview)
 {
        gint row, column;
-       FolderItem *item, *src_item;
+       FolderItem *item = NULL, *src_item;
        GtkCTreeNode *node;
 
-       drag_state_stop(folderview);
-       if ((void *)strstr(data->data, "FROM_OTHER_FOLDER") != (void *)data->data) {
-               /* comes from summaryview */
+       if (info == TARGET_DUMMY) {
+               drag_state_stop(folderview);
+               if ((void *)strstr(data->data, "FROM_OTHER_FOLDER") != (void *)data->data) {
+                       /* comes from summaryview */
+                       if (gtk_clist_get_selection_info
+                               (GTK_CLIST(widget), x - 24, y - 24, &row, &column) == 0)
+                               return;
+
+                       node = gtk_ctree_node_nth(GTK_CTREE(widget), row);
+                       item = gtk_ctree_node_get_row_data(GTK_CTREE(widget), node);
+                       src_item = folderview->summaryview->folder_item;
+
+                       /* re-check (due to acceptable possibly set for folder moves */
+                       if (!(item && item->folder && item->path && !item->no_select && 
+                             src_item && src_item != item && FOLDER_CLASS(item->folder)->copy_msg != NULL)) {
+                               return;
+                       }
+                       if (item && src_item) {
+                               switch (drag_context->action) {
+                               case GDK_ACTION_COPY:
+                                       summary_copy_selected_to(folderview->summaryview, item);
+                                       gtk_drag_finish(drag_context, TRUE, FALSE, time);
+                                       break;
+                               case GDK_ACTION_MOVE:
+                               case GDK_ACTION_DEFAULT:
+                               default:
+                                       if (FOLDER_CLASS(src_item->folder)->remove_msg == NULL)
+                                               summary_copy_selected_to(folderview->summaryview, item);
+                                       else
+                                               summary_move_selected_to(folderview->summaryview, item);
+                                       gtk_drag_finish(drag_context, TRUE, TRUE, time);
+                               }
+                       } else
+                               gtk_drag_finish(drag_context, FALSE, FALSE, time);
+               } else {
+                       /* comes from folderview */
+                       char *source;
+                       gboolean folder_is_normal = TRUE;
+
+                       source = data->data + 17;
+                       if (gtk_clist_get_selection_info
+                           (GTK_CLIST(widget), x - 24, y - 24, &row, &column) == 0
+                           || *source == 0) {
+                               gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
+                               return;
+                       }
+                       node = gtk_ctree_node_nth(GTK_CTREE(widget), row);
+                       item = gtk_ctree_node_get_row_data(GTK_CTREE(widget), node);
+                       src_item = folder_find_item_from_identifier(source);
+
+                       folder_is_normal = 
+                               src_item != NULL &&
+                               src_item->stype == F_NORMAL &&
+                               !folder_has_parent_of_type(src_item, F_OUTBOX) &&
+                               !folder_has_parent_of_type(src_item, F_DRAFT) &&
+                               !folder_has_parent_of_type(src_item, F_QUEUE) &&
+                               !folder_has_parent_of_type(src_item, F_TRASH);
+                       if (!item || item->no_select || !src_item 
+                       ||  !folder_is_normal) {
+                               gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
+                               return;
+                       }
+
+                       folderview_move_folder(folderview, src_item, item);
+                       gtk_drag_finish(drag_context, TRUE, TRUE, time);
+               }
+               folderview->nodes_to_recollapse = NULL;
+       } else if (info == TARGET_MAIL_URI_LIST) {
+               GList *list, *tmp;
+               GSList *msglist = NULL;
                if (gtk_clist_get_selection_info
                        (GTK_CLIST(widget), x - 24, y - 24, &row, &column) == 0)
                        return;
 
                node = gtk_ctree_node_nth(GTK_CTREE(widget), row);
-               item = gtk_ctree_node_get_row_data(GTK_CTREE(widget), node);
-               src_item = folderview->summaryview->folder_item;
-               
-               /* re-check (due to acceptable possibly set for folder moves */
-               if (!(item && item->folder && item->path && !item->no_select && 
-                     src_item && src_item != item && FOLDER_CLASS(item->folder)->copy_msg != NULL)) {
+               if (!node) {
+                       gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
                        return;
                }
-               if (item && src_item) {
-                       switch (drag_context->action) {
-                       case GDK_ACTION_COPY:
-                               summary_copy_selected_to(folderview->summaryview, item);
-                               gtk_drag_finish(drag_context, TRUE, FALSE, time);
-                               break;
-                       case GDK_ACTION_MOVE:
-                       case GDK_ACTION_DEFAULT:
-                       default:
-                               if (FOLDER_CLASS(src_item->folder)->remove_msg == NULL)
-                                       summary_copy_selected_to(folderview->summaryview, item);
-                               else
-                                       summary_move_selected_to(folderview->summaryview, item);
-                               gtk_drag_finish(drag_context, TRUE, TRUE, time);
-                       }
-               } else
-                       gtk_drag_finish(drag_context, FALSE, FALSE, time);
-       } else {
-               /* comes from folderview */
-               char *source;
-               gboolean folder_is_normal = TRUE;
-               
-               source = data->data + 17;
-               if (gtk_clist_get_selection_info
-                   (GTK_CLIST(widget), x - 24, y - 24, &row, &column) == 0
-                   || *source == 0) {
+               item = gtk_ctree_node_get_row_data(GTK_CTREE(widget), node);
+               if (!item) {
                        gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
                        return;
                }
-               node = gtk_ctree_node_nth(GTK_CTREE(widget), row);
-               item = gtk_ctree_node_get_row_data(GTK_CTREE(widget), node);
-               src_item = folder_find_item_from_identifier(source);
-
-               folder_is_normal = 
-                       src_item != NULL &&
-                       src_item->stype == F_NORMAL &&
-                       !folder_has_parent_of_type(src_item, F_OUTBOX) &&
-                       !folder_has_parent_of_type(src_item, F_DRAFT) &&
-                       !folder_has_parent_of_type(src_item, F_QUEUE) &&
-                       !folder_has_parent_of_type(src_item, F_TRASH);
-               if (!item || item->no_select || !src_item 
-               ||  !folder_is_normal) {
+               list = uri_list_extract_filenames((const gchar *)data->data);
+               if (!list) {
                        gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
                        return;
                }
-
-               folderview_move_folder(folderview, src_item, item);
-               gtk_drag_finish(drag_context, TRUE, TRUE, time);
+               for (tmp = list; tmp != NULL; tmp = tmp->next) {
+                       MsgFileInfo *info = g_new0(MsgFileInfo, 1);
+                       info->msginfo = NULL;
+                       info->file = (gchar *)tmp->data;
+                       msglist = g_slist_prepend(msglist, info);
+               }
+               if (msglist) {
+                       msglist = g_slist_reverse(msglist);
+                       folder_item_add_msgs(item, msglist, FALSE);
+                       g_slist_foreach(msglist, free_info, NULL);
+                       g_slist_free(msglist);
+                       gtk_drag_finish(drag_context, TRUE, FALSE, time);
+               } else {
+                       gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
+               }
+               list_free_strings(list);
+               g_list_free(list);
        }
-       folderview->nodes_to_recollapse = NULL;
 }
 
 static void folderview_drag_end_cb(GtkWidget       *widget, 
index 66ef999eb61d8a24cc5cc725477c76443d1b978d..641a7cb64d6259c80ae900d6e95afe7a9662280f 100644 (file)
@@ -60,6 +60,7 @@
 #include "utils.h"
 #include "gtkutils.h"
 #include "prefs_common.h"
+#include "procheader.h"
 #include "stock_pixmap.h"
 #include "gtk/gtkvscrollbutton.h"
 
@@ -1020,7 +1021,6 @@ static void mimeview_selected(GtkCTree *ctree, GtkCTreeNode *node, gint column,
                              MimeView *mimeview)
 {
        MimeInfo *partinfo;
-       AlertValue val;
        if (mimeview->opened == node) return;
        mimeview->opened = node;
        gtk_ctree_node_moveto(ctree, node, -1, 0.5, 0);
@@ -1266,7 +1266,7 @@ static void mimeview_drag_data_get(GtkWidget          *widget,
                                   guint             time,
                                   MimeView         *mimeview)
 {
-       gchar *filename, *uriname, *tmp;
+       gchar *filename = NULL, *uriname, *tmp;
        MimeInfo *partinfo;
 
        if (!mimeview->opened) return;
@@ -1275,8 +1275,39 @@ static void mimeview_drag_data_get(GtkWidget         *widget,
        partinfo = mimeview_get_selected_part(mimeview);
        if (!partinfo) return;
 
-       filename = g_path_get_basename(get_part_name(partinfo));
-       if (*filename == '\0') return;
+       if (strlen(get_part_name(partinfo)) > 0) {
+               filename = g_path_get_basename(get_part_name(partinfo));
+               if (*filename == '\0') return;
+       } else if (partinfo->type == MIMETYPE_MESSAGE 
+                  && !g_ascii_strcasecmp(partinfo->subtype, "rfc822")) {
+               gchar *name = NULL;
+               GPtrArray *headers = NULL;
+               FILE *fp;
+
+               fp = g_fopen(partinfo->data.filename, "rb");
+               fseek(fp, partinfo->offset, SEEK_SET);
+               headers = procheader_get_header_array_asis(fp);
+               if (headers) {
+                       gint i;
+                       for (i = 0; i < headers->len; i++) {
+                               Header *header = g_ptr_array_index(headers, i);
+                               if (procheader_headername_equal(header->name, "Subject")) {
+                                       unfold_line(header->body);
+                                       name = g_strconcat(header->body, ".txt", NULL);
+                                       subst_for_filename(name);
+                               }
+                       }
+                       procheader_header_array_destroy(headers);
+               }
+               fclose(fp);
+               if (name)
+                       filename = g_path_get_basename(name);
+               g_free(name);
+       }
+       if (filename == NULL)
+               filename = g_path_get_basename("Unnamed part");
+               
+
 
        tmp = filename;
        
@@ -1284,11 +1315,10 @@ static void mimeview_drag_data_get(GtkWidget        *widget,
                               filename, NULL);
 
        g_free(tmp);
-       
+
        if (procmime_get_part(filename, partinfo) < 0)
                alertpanel_error
                        (_("Can't save the part of multipart message."));
-
        uriname = g_strconcat("file://", filename, NULL);
        gtk_selection_data_set(selection_data, selection_data->target, 8,
                               uriname, strlen(uriname));
@@ -1990,10 +2020,14 @@ static void icon_list_append_icon (MimeView *mimeview, MimeInfo *mimeinfo)
        gtk_tooltips_set_tip(mimeview->tooltips, button, tip, NULL);
        g_free(tip);
        gtk_widget_show_all(button);
+       gtk_drag_source_set(button, GDK_BUTTON1_MASK|GDK_BUTTON3_MASK, 
+                           mimeview_mime_types, 1, GDK_ACTION_COPY);
        g_signal_connect(G_OBJECT(button), "button_release_event", 
                         G_CALLBACK(icon_clicked_cb), mimeview);
        g_signal_connect(G_OBJECT(button), "key_press_event", 
                         G_CALLBACK(icon_key_pressed), mimeview);
+       g_signal_connect(G_OBJECT(button), "drag_data_get",
+                        G_CALLBACK(mimeview_drag_data_get), mimeview);
        gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
 
 }
index 9956843184dfae799d841e939178ad5b57740c7b..5c3739cd064696202b80092c85c78cf989d74960 100644 (file)
@@ -336,6 +336,14 @@ static void summary_drag_data_get       (GtkWidget        *widget,
                                         guint             info,
                                         guint             time,
                                         SummaryView      *summaryview);
+static void summary_drag_data_received(GtkWidget        *widget,
+                                       GdkDragContext   *drag_context,
+                                       gint              x,
+                                       gint              y,
+                                       GtkSelectionData *data,
+                                       guint             info,
+                                       guint             time,
+                                       SummaryView       *summaryview);
 
 /* custom compare functions for sorting */
 
@@ -392,8 +400,9 @@ static void summary_find_answers    (SummaryView    *summaryview,
 
 static gboolean summary_update_msg     (gpointer source, gpointer data);
 
-GtkTargetEntry summary_drag_types[1] =
+GtkTargetEntry summary_drag_types[2] =
 {
+       {"text/uri-list", 0, TARGET_MAIL_URI_LIST},
        {"text/plain", GTK_TARGET_SAME_APP, TARGET_DUMMY}
 };
 
@@ -618,7 +627,7 @@ SummaryView *summary_create(void)
        summaryview->msginfo_update_callback_id =
                hooks_register_hook(MSGINFO_UPDATE_HOOKLIST, summary_update_msg, (gpointer) summaryview);
 
-       summaryview->target_list = gtk_target_list_new(summary_drag_types, 1);
+       summaryview->target_list = gtk_target_list_new(summary_drag_types, 2);
 
        summaryview->quicksearch = quicksearch;
 
@@ -4612,6 +4621,14 @@ static GtkWidget *summary_ctree_create(SummaryView *summaryview)
                         G_CALLBACK(summary_drag_data_get),
                         summaryview);
 
+       gtk_drag_dest_set(ctree, GTK_DEST_DEFAULT_ALL & ~GTK_DEST_DEFAULT_HIGHLIGHT,
+                         summary_drag_types, 2,
+                         GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_DEFAULT);
+
+       g_signal_connect(G_OBJECT(ctree), "drag_data_received",
+                        G_CALLBACK(summary_drag_data_received),
+                        summaryview);
+
        return ctree;
 }
 
@@ -5158,13 +5175,28 @@ static void summary_drag_data_get(GtkWidget        *widget,
                                (ctree, GTK_CTREE_NODE(cur->data));
                        tmp2 = procmsg_get_message_file(msginfo);
                        if (!tmp2) continue;
+                       if (msginfo->subject) {
+                               gchar *san_subject = g_strdup(msginfo->subject);
+                               gchar *dest = NULL;
+                               subst_for_filename(san_subject);
+                               dest = g_strdup_printf("%s%s%s.%d.txt",
+                                               get_tmp_dir(),
+                                               G_DIR_SEPARATOR_S,
+                                               san_subject, msginfo->msgnum);
+                               g_free(san_subject);
+
+                               if (copy_file(tmp2, dest, TRUE) == 0) {
+                                       g_free(tmp2);
+                                       tmp2 = dest;
+                               }
+                       } 
                        tmp1 = g_strconcat("file://", tmp2, NULL);
                        g_free(tmp2);
 
                        if (!mail_list) {
                                mail_list = tmp1;
                        } else {
-                               tmp2 = g_strconcat(mail_list, tmp1, NULL);
+                               tmp2 = g_strconcat(mail_list, "\n", tmp1, NULL);
                                g_free(mail_list);
                                g_free(tmp1);
                                mail_list = tmp2;
@@ -5186,6 +5218,53 @@ static void summary_drag_data_get(GtkWidget        *widget,
        }
 }
 
+static void free_info (gpointer stuff, gpointer data)
+{
+       g_free(stuff);
+}
+
+static void summary_drag_data_received(GtkWidget        *widget,
+                                       GdkDragContext   *drag_context,
+                                       gint              x,
+                                       gint              y,
+                                       GtkSelectionData *data,
+                                       guint             info,
+                                       guint             time,
+                                       SummaryView       *summaryview)
+{
+       if (info == TARGET_MAIL_URI_LIST) {
+               GList *list, *tmp;
+               GSList *msglist = NULL;
+               FolderItem *item = summaryview->folder_item;
+               if (!item) {
+                       gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
+                       return;
+               }
+               list = uri_list_extract_filenames((const gchar *)data->data);
+               if (!list) {
+                       gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
+                       return;
+               }
+               for (tmp = list; tmp != NULL; tmp = tmp->next) {
+                       MsgFileInfo *info = g_new0(MsgFileInfo, 1);
+                       info->msginfo = NULL;
+                       info->file = (gchar *)tmp->data;
+                       msglist = g_slist_prepend(msglist, info);
+               }
+               if (msglist) {
+                       msglist = g_slist_reverse(msglist);
+                       folder_item_add_msgs(item, msglist, FALSE);
+                       g_slist_foreach(msglist, free_info, NULL);
+                       g_slist_free(msglist);
+                       gtk_drag_finish(drag_context, TRUE, FALSE, time);
+               } else {
+                       gtk_drag_finish(drag_context, FALSE, FALSE, time);                      
+               }
+               list_free_strings(list);
+               g_list_free(list);
+       }
+}
+
 
 /* custom compare functions for sorting */
 
index 3f94049ab6d7420183b19878905fbff73046878d..90507b525b63e58a13eb6ab9b1b92b5e2b6224d1 100644 (file)
@@ -76,7 +76,7 @@ typedef enum
 #include "prefs_filtering.h"
 #include "quicksearch.h"
 
-extern GtkTargetEntry summary_drag_types[1];
+extern GtkTargetEntry summary_drag_types[2];
 
 struct _SummaryColumnState
 {