pressing CTRL while DND will copy the mail now
[claws.git] / src / summaryview.c
index 9f0076f20fcdb7ec599f60cd7fe426219e9e6cad..f6a6f6becd545134dcd83a7a864aeb770c1f3a37 100644 (file)
@@ -74,6 +74,7 @@
 #include "folder.h"
 #include "colorlabel.h"
 #include "inc.h"
+#include "imap.h"
 #include "addressbook.h"
 #include "addr_compl.h"
 #include "scoring.h"
@@ -2267,6 +2268,15 @@ static void summary_display_msg(SummaryView *summaryview, GtkCTreeNode *row,
                summaryview->newmsgs--;
        if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                summaryview->unread--;
+       if (MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags) || 
+           MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)) {
+               MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW | MSG_UNREAD);
+               if (MSG_IS_IMAP(msginfo->flags))
+                       imap_msg_unset_perm_flags(msginfo, MSG_NEW | MSG_UNREAD);
+               summary_set_row_marks(summaryview, row);
+               gtk_clist_thaw(GTK_CLIST(ctree));
+               summary_status_show(summaryview);
+       }
 
        if (new_window) {
                MessageView *msgview;
@@ -2598,9 +2608,10 @@ static void summary_mark_row(SummaryView *summaryview, GtkCTreeNode *row)
        MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
        MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE | MSG_COPY);
        MSG_SET_PERM_FLAGS(msginfo->flags, MSG_MARKED);
+       if (MSG_IS_IMAP(msginfo->flags))
+               imap_msg_set_perm_flags(msginfo, MSG_MARKED);
        CHANGE_FLAGS(msginfo);
        summary_set_row_marks(summaryview, row);
-       imap_do_mark(msginfo);
        debug_print(_("Message %s/%d is marked\n"), msginfo->folder->path, msginfo->msgnum);
 }
 
@@ -2631,6 +2642,8 @@ static void summary_lock_row(SummaryView *summaryview, GtkCTreeNode *row)
        MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
        MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE | MSG_COPY);
        MSG_SET_PERM_FLAGS(msginfo->flags, MSG_LOCKED);
+       if (MSG_IS_IMAP(msginfo->flags))
+               imap_msg_set_perm_flags(msginfo, MSG_LOCKED);
        CHANGE_FLAGS(msginfo);
        summary_set_row_marks(summaryview, row);
        debug_print(_("Message %d is locked\n"), msginfo->msgnum);
@@ -2662,6 +2675,8 @@ static void summary_mark_row_as_read(SummaryView *summaryview,
        if (MSG_IS_NEW(msginfo->flags) ||
            MSG_IS_UNREAD(msginfo->flags)) {
                MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW | MSG_UNREAD);
+               if (MSG_IS_IMAP(msginfo->flags))
+                       imap_msg_unset_perm_flags(msginfo, MSG_NEW | MSG_UNREAD);
                CHANGE_FLAGS(msginfo);
                summary_set_row_marks(summaryview, row);
                debug_print(_("Message %d is marked as read\n"),
@@ -2714,8 +2729,12 @@ static void summary_mark_row_as_unread(SummaryView *summaryview,
                summaryview->deleted--;
        }
        MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_REPLIED | MSG_FORWARDED);
+       if (MSG_IS_IMAP(msginfo->flags))
+               imap_msg_unset_perm_flags(msginfo, MSG_REPLIED);
        if (!MSG_IS_UNREAD(msginfo->flags)) {
                MSG_SET_PERM_FLAGS(msginfo->flags, MSG_UNREAD);
+               if (MSG_IS_IMAP(msginfo->flags))
+                       imap_msg_set_perm_flags(msginfo, MSG_UNREAD);
                summaryview->unread++;
                debug_print(_("Message %d is marked as unread\n"),
                            msginfo->msgnum);
@@ -2765,6 +2784,8 @@ static void summary_delete_row(SummaryView *summaryview, GtkCTreeNode *row)
        }
        msginfo->to_folder = NULL;
        MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED);
+       if (MSG_IS_IMAP(msginfo->flags))
+               imap_msg_unset_perm_flags(msginfo, MSG_MARKED);
        MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE | MSG_COPY);
        MSG_SET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
        CHANGE_FLAGS(msginfo);
@@ -2890,10 +2911,11 @@ static void summary_unmark_row(SummaryView *summaryview, GtkCTreeNode *row)
        }
        msginfo->to_folder = NULL;
        MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED | MSG_DELETED);
+       if (MSG_IS_IMAP(msginfo->flags))
+               imap_msg_unset_perm_flags(msginfo, MSG_MARKED);
        MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE | MSG_COPY);
        CHANGE_FLAGS(msginfo);
        summary_set_row_marks(summaryview, row);
-       imap_do_unmark(msginfo);
        debug_print(_("Message %s/%d is unmarked\n"),
                    msginfo->folder->path, msginfo->msgnum);
 }
@@ -2903,8 +2925,7 @@ void summary_unmark(SummaryView *summaryview)
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        GList *cur;
 
-       for (cur = GTK_CLIST(ctree)->selection; cur != NULL;
-            cur = cur->next)
+       for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
                summary_unmark_row(summaryview, GTK_CTREE_NODE(cur->data));
 
        summary_status_show(summaryview);
@@ -2938,6 +2959,8 @@ static void summary_move_row_to(SummaryView *summaryview, GtkCTreeNode *row,
                        msginfo->to_folder->op_count--;
        }
        MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED | MSG_DELETED);
+       if (MSG_IS_IMAP(msginfo->flags))
+               imap_msg_unset_perm_flags(msginfo, MSG_MARKED);
        MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_COPY);
        if (!MSG_IS_MOVE(msginfo->flags)) {
                MSG_SET_TMP_FLAGS(msginfo->flags, MSG_MOVE);
@@ -3027,6 +3050,8 @@ static void summary_copy_row_to(SummaryView *summaryview, GtkCTreeNode *row,
                        msginfo->to_folder->op_count--;
        }
        MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED | MSG_DELETED);
+       if (MSG_IS_IMAP(msginfo->flags))
+               imap_msg_unset_perm_flags(msginfo, MSG_MARKED);
        MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_MOVE);
        if (!MSG_IS_COPY(msginfo->flags)) {
                MSG_SET_TMP_FLAGS(msginfo->flags, MSG_COPY);
@@ -4041,8 +4066,16 @@ void summary_set_column_order(SummaryView *summaryview)
        GtkWidget *scrolledwin = summaryview->scrolledwin;
        GtkWidget *pixmap;
        FolderItem *item;
+       guint selected_msgnum = summary_get_msgnum(summaryview, summaryview->selected);
+       guint displayed_msgnum = summary_get_msgnum(summaryview, summaryview->displayed);
 
+       
        item = summaryview->folder_item;
+
+       summary_lock(summaryview);
+       summary_write_cache(summaryview);
+       summary_unlock(summaryview);
+       
        summary_clear_all(summaryview);
        gtk_widget_destroy(summaryview->ctree);
 
@@ -4059,6 +4092,13 @@ void summary_set_column_order(SummaryView *summaryview)
        gtk_widget_show(ctree);
 
        summary_show(summaryview, item, FALSE);
+
+       summary_select_by_msgnum(summaryview, selected_msgnum);
+       summaryview->displayed = summary_find_msg_by_msgnum(summaryview, displayed_msgnum);
+       if (!summaryview->displayed)
+               messageview_clear(summaryview->messageview);
+       else
+               summary_redisplay_msg(summaryview);
 }
 
 
@@ -4343,6 +4383,8 @@ static void summary_selected(GtkCTree *ctree, GtkCTreeNode *row,
        case S_COL_MARK:
                if (MSG_IS_MARKED(msginfo->flags)) {
                        MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_MARKED);
+                       if (MSG_IS_IMAP(msginfo->flags))
+                               imap_msg_unset_perm_flags(msginfo, MSG_MARKED);
                        CHANGE_FLAGS(msginfo);
                        summary_set_row_marks(summaryview, row);
                } else
@@ -4554,7 +4596,7 @@ static void summary_start_drag(GtkWidget *widget, gint button, GdkEvent *event,
        list = gtk_target_list_new(summary_drag_types, 1);
 
        context = gtk_drag_begin(widget, list,
-                                GDK_ACTION_MOVE, button, event);
+                                GDK_ACTION_MOVE|GDK_ACTION_COPY|GDK_ACTION_DEFAULT, button, event);
        gtk_drag_set_icon_default(context);
 }