2006-02-05 [colin] 2.0.0cvs12
authorColin Leroy <colin@colino.net>
Sun, 5 Feb 2006 13:25:08 +0000 (13:25 +0000)
committerColin Leroy <colin@colino.net>
Sun, 5 Feb 2006 13:25:08 +0000 (13:25 +0000)
* src/folderview.c
* src/summaryview.c
* src/common/utils.c
* src/common/utils.h
Let dnd work from mime icons to summaryview
and to folderview too
Add a crude test to avoid trying to add files
drag'n'dropped when they're not mails

ChangeLog
PATCHSETS
configure.ac
src/common/utils.c
src/common/utils.h
src/folderview.c
src/summaryview.c

index 6a4e527bd4c2785687d45a39dc87080bcdd7cceb..adac77e5566da2b543bbbabfad7a1a667f5749af 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2006-02-05 [colin]     2.0.0cvs12
+
+       * src/folderview.c
+       * src/summaryview.c
+       * src/common/utils.c
+       * src/common/utils.h
+               Let dnd work from mime icons to summaryview
+               and to folderview too
+               Add a crude test to avoid trying to add files
+               drag'n'dropped when they're not mails
+
 2006-02-04 [colin]     2.0.0cvs11
 
        * src/summaryview.c
index 76ee770f052939def7ab450e3cf7e959d4a35825..bf5b7876b357ca2696196b500799db4d73c91434 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( 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
 ( cvs diff -u -r 1.395.2.161 -r 1.395.2.162 src/summaryview.c;  cvs diff -u -r 1.83.2.62 -r 1.83.2.63 src/mimeview.c;  ) > 2.0.0cvs11.patchset
+( cvs diff -u -r 1.207.2.86 -r 1.207.2.87 src/folderview.c;  cvs diff -u -r 1.395.2.162 -r 1.395.2.163 src/summaryview.c;  cvs diff -u -r 1.36.2.53 -r 1.36.2.54 src/common/utils.c;  cvs diff -u -r 1.20.2.31 -r 1.20.2.32 src/common/utils.h;  ) > 2.0.0cvs12.patchset
index e47269740ac1b9c997230e68b9d38347c7b21255..5a7c575ee08006212647630ffaa82ac13811b503 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=11
+EXTRA_VERSION=12
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index c2af46a55044cce161bab32865847d7e1451ecdd..0d0b0d487cffe24fcafdfc84644257674f55f474 100644 (file)
@@ -1199,7 +1199,7 @@ GList *add_history(GList *list, const gchar *str)
                last = g_list_last(list);
                if (last) {
                        g_free(last->data);
-                       g_list_remove(list, last->data);
+                       list = g_list_remove(list, last->data);
                }
        }
 
@@ -4746,3 +4746,30 @@ gint copy_dir(const gchar *src, const gchar *dst)
        }
        return 0;
 }
+
+/* crude test to see if a file is an email. */
+gboolean file_is_email (const gchar *filename)
+{
+       FILE *fp = NULL;
+       gchar buffer[2048];
+       gint i = 0;
+       gint score = 0;
+       if (filename == NULL)
+               return FALSE;
+       if ((fp = g_fopen(filename, "rb")) == NULL)
+               return FALSE;
+       while (i < 60 && score < 4
+              && fgets(buffer, sizeof (buffer), fp) > 0) {
+               if (!strncmp(buffer, "Return-Path:", strlen("Return-Path:")))
+                       score++;
+               if (!strncmp(buffer, "From:", strlen("From:")))
+                       score++;
+               if (!strncmp(buffer, "To:", strlen("To:")))
+                       score++;
+               if (!strncmp(buffer, "Subject:", strlen("Subject:")))
+                       score++;
+               i++;
+       }
+       fclose(fp);
+       return (score >= 4);
+}
index 4e6a3f949bb73373f2e617a6a66b5c3def289e49..5529ca3d6630ca655f284d5ae849b5ef9aa2bcb3 100644 (file)
@@ -554,6 +554,7 @@ gboolean get_email_part(const gchar *start, const gchar *scanpos,
 gchar *make_email_string(const gchar *bp, const gchar *ep);
 gchar *make_http_string(const gchar *bp, const gchar *ep);
 gchar *mailcap_get_command_for_type(const gchar *type);
+gboolean file_is_email (const gchar *filename);
 
 #ifdef __cplusplus
 }
index fb28a1f8539ac104408ffc534489ba1dd1eb235f..6eaf6bdf640bb533ca27ac65214d7506f08655a9 100644 (file)
@@ -2466,7 +2466,7 @@ 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) {
+               } else {
                        /* comes from another app */
                        /* we are adding messages, so only accept folder items that are 
                           no root items and can copy messages */
@@ -2615,10 +2615,14 @@ static void folderview_drag_received_cb(GtkWidget        *widget,
                        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);
+                       MsgFileInfo *info = NULL;
+                       
+                       if (file_is_email((gchar *)tmp->data)) {
+                               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);
index 7dc779a078cd1336718f8b462f83b93ffda6abe5..6ab8f82077405a29ac65e0fd08f9573848bf0b93 100644 (file)
@@ -5248,10 +5248,14 @@ static void summary_drag_data_received(GtkWidget        *widget,
                        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);
+                       MsgFileInfo *info = NULL;
+                       
+                       if (file_is_email((gchar *)tmp->data)) {
+                               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);