* configure.in
[claws.git] / src / summaryview.c
index adf2f5a..67e0b3a 100644 (file)
@@ -844,6 +844,12 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item,
 
        g_slist_free(mlist);
 
+       summaryview->folder_item->new    = summaryview->newmsgs;
+       summaryview->folder_item->unread = summaryview->unread;
+       summaryview->folder_item->total  = summaryview->messages;
+       folderview_update_msg_num(summaryview->folderview,
+                                 summaryview->folderview->opened);
+
        summary_write_cache(summaryview);
 
        gtk_signal_handler_unblock_by_data(GTK_OBJECT(ctree), summaryview);
@@ -1662,6 +1668,10 @@ static void summary_status_show(SummaryView *summaryview)
                return;
        }
 
+       summaryview->newmsgs    = summaryview->folder_item->new;
+       summaryview->unread     = summaryview->folder_item->unread;
+       summaryview->messages   = summaryview->folder_item->total;
+
        rowlist = GTK_CLIST(summaryview->ctree)->selection;
        for (cur = rowlist; cur != NULL; cur = cur->next) {
                msginfo = gtk_ctree_node_get_row_data
@@ -1735,13 +1745,6 @@ static void summary_status_show(SummaryView *summaryview)
        }
        gtk_label_set(GTK_LABEL(summaryview->statlabel_msgs), str);
        g_free(str);
-
-       summaryview->folder_item->new    = summaryview->newmsgs;
-       summaryview->folder_item->unread = summaryview->unread;
-       summaryview->folder_item->total  = summaryview->messages;
-
-       folderview_update_msg_num(summaryview->folderview,
-                                 summaryview->folderview->opened);
 }
 
 static void summary_set_column_titles(SummaryView *summaryview)
@@ -2297,19 +2300,16 @@ static void summary_display_msg_full(SummaryView *summaryview,
        }
        g_free(filename);
 
+/* NOT NEEDED ANYMORE
        if (MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                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);
-       }
+*/
+       procmsg_msginfo_unset_flags(msginfo, MSG_NEW | MSG_UNREAD, 0);
+       summary_set_row_marks(summaryview, row);
+       gtk_clist_thaw(GTK_CLIST(ctree));
+       summary_status_show(summaryview);
 
        flags = msginfo->flags;
 
@@ -2337,14 +2337,6 @@ static void summary_display_msg_full(SummaryView *summaryview,
                gtkut_ctree_node_move_if_on_the_edge(ctree, row);
        }
 
-       if (MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags) ||
-           (MSG_IS_MIME(msginfo->flags) - MSG_IS_MIME(flags) != 0)) {
-               MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW | MSG_UNREAD);
-               CHANGE_FLAGS(msginfo);
-               summary_set_row_marks(summaryview, row);
-               gtk_clist_thaw(GTK_CLIST(ctree));
-               summary_status_show(summaryview);
-       }
        summary_set_menu_sensitive(summaryview);
        main_window_set_toolbar_sensitive(summaryview->mainwin);
 
@@ -2707,12 +2699,8 @@ static void summary_mark_row(SummaryView *summaryview, GtkCTreeNode *row)
                        folderview_update_item(msginfo->to_folder, 0);
        }
        msginfo->to_folder = NULL;
-       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);
+       procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, MSG_MOVE | MSG_COPY);
+       procmsg_msginfo_set_flags(msginfo, MSG_MARKED, 0);
        summary_set_row_marks(summaryview, row);
        debug_print(_("Message %s/%d is marked\n"), msginfo->folder->path, msginfo->msgnum);
 }
@@ -2741,12 +2729,8 @@ static void summary_lock_row(SummaryView *summaryview, GtkCTreeNode *row)
                        folderview_update_item(msginfo->to_folder, 0);
        }
        msginfo->to_folder = NULL;
-       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);
+       procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, MSG_MOVE | MSG_COPY);
+       procmsg_msginfo_set_flags(msginfo, MSG_LOCKED, 0);
        summary_set_row_marks(summaryview, row);
        debug_print(_("Message %d is locked\n"), msginfo->msgnum);
 }
@@ -2770,20 +2754,16 @@ static void summary_mark_row_as_read(SummaryView *summaryview,
        MsgInfo *msginfo;
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
+/* NOT NEEDED ANYMORE
        if (MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                summaryview->newmsgs--;
        if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                summaryview->unread--;
-       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"),
-                           msginfo->msgnum);
-       }
+*/
+       procmsg_msginfo_unset_flags(msginfo, MSG_NEW | MSG_UNREAD, 0);
+       summary_set_row_marks(summaryview, row);
+       debug_print(_("Message %d is marked as read\n"),
+               msginfo->msgnum);
 }
 
 void summary_mark_as_read(SummaryView *summaryview)
@@ -2827,22 +2807,18 @@ static void summary_mark_row_as_unread(SummaryView *summaryview,
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
        if (MSG_IS_DELETED(msginfo->flags)) {
                msginfo->to_folder = NULL;
-               MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_DELETED);
+               procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, 0);
                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);
+/* NOT NEEDED ANYMORE
+       if (!MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
                summaryview->unread++;
-               debug_print(_("Message %d is marked as unread\n"),
-                           msginfo->msgnum);
-       }
+*/
 
-       CHANGE_FLAGS(msginfo);
+       procmsg_msginfo_unset_flags(msginfo, MSG_REPLIED | MSG_FORWARDED, 0);
+       procmsg_msginfo_set_flags(msginfo, MSG_UNREAD, 0);
+       debug_print(_("Message %d is marked as unread\n"),
+               msginfo->msgnum);
 
        summary_set_row_marks(summaryview, row);
 }
@@ -2937,12 +2913,8 @@ static void summary_delete_row(SummaryView *summaryview, GtkCTreeNode *row)
                        folderview_update_item(msginfo->to_folder, 0);
        }
        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);
+       procmsg_msginfo_unset_flags(msginfo, MSG_MARKED, MSG_MOVE | MSG_COPY);
+       procmsg_msginfo_set_flags(msginfo, MSG_DELETED, 0);
        summaryview->deleted++;
 
        if (!prefs_common.immediate_exec && 
@@ -3068,11 +3040,7 @@ static void summary_unmark_row(SummaryView *summaryview, GtkCTreeNode *row)
                        folderview_update_item(msginfo->to_folder, 0);
        }
        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);
+       procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_MOVE | MSG_COPY);
        summary_set_row_marks(summaryview, row);
        debug_print(_("Message %s/%d is unmarked\n"),
                    msginfo->folder->path, msginfo->msgnum);
@@ -3116,12 +3084,9 @@ static void summary_move_row_to(SummaryView *summaryview, GtkCTreeNode *row,
                if (!prefs_common.immediate_exec)
                        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);
+       procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_COPY);
        if (!MSG_IS_MOVE(msginfo->flags)) {
-               MSG_SET_TMP_FLAGS(msginfo->flags, MSG_MOVE);
+               procmsg_msginfo_set_flags(msginfo, 0, MSG_MOVE);
                summaryview->moved++;
                changed = TRUE;
        }
@@ -3208,12 +3173,9 @@ static void summary_copy_row_to(SummaryView *summaryview, GtkCTreeNode *row,
                if (!prefs_common.immediate_exec)
                        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);
+       procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_MOVE);
        if (!MSG_IS_COPY(msginfo->flags)) {
-               MSG_SET_TMP_FLAGS(msginfo->flags, MSG_COPY);
+               procmsg_msginfo_set_flags(msginfo, 0, MSG_COPY);
                summaryview->copied++;
                changed = TRUE;
        }
@@ -3457,6 +3419,7 @@ static void summary_execute_move(SummaryView *summaryview)
                summaryview->mlist = NULL;
        }
 
+       folderview_update_item(summaryview->folder_item, FALSE);
        g_hash_table_destroy(summaryview->folder_table);
        summaryview->folder_table = NULL;
 }
@@ -3524,7 +3487,7 @@ static void summary_execute_copy_func(GtkCTree *ctree, GtkCTreeNode *node,
                summaryview->mlist =
                        g_slist_append(summaryview->mlist, msginfo);
 
-               MSG_UNSET_TMP_FLAGS(msginfo->flags, MSG_COPY);
+               procmsg_msginfo_unset_flags(msginfo, 0, MSG_COPY);
                summary_set_row_marks(summaryview, node);
        }
 }
@@ -3561,8 +3524,8 @@ static void summary_execute_delete(SummaryView *summaryview)
 
        if ((summaryview->folder_item != trash) && (trash != NULL)) {
                folder_item_scan(trash);
-               folderview_update_item(trash, FALSE);
        }
+       folderview_update_item(summaryview->folder_item, FALSE);
 }
 
 static void summary_execute_delete_func(GtkCTree *ctree, GtkCTreeNode *node,
@@ -4114,8 +4077,8 @@ void summary_set_colorlabel_color(GtkCTree *ctree, GtkCTreeNode *node,
        gint color_index;
 
        msginfo = gtk_ctree_node_get_row_data(ctree, node);
-       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_CLABEL_FLAG_MASK);
-       MSG_SET_COLORLABEL_VALUE(msginfo->flags, labelcolor);
+       procmsg_msginfo_unset_flags(msginfo, MSG_CLABEL_FLAG_MASK, 0);
+       procmsg_msginfo_set_flags(msginfo, MSG_COLORLABEL_TO_FLAGS(labelcolor), 0);
 
        color_index = labelcolor == 0 ? -1 : (gint)labelcolor - 1;
        ctree_style = gtk_widget_get_style(GTK_WIDGET(ctree));
@@ -4590,10 +4553,7 @@ static void summary_selected(GtkCTree *ctree, GtkCTreeNode *row,
        switch (column < 0 ? column : summaryview->col_state[column].type) {
        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);
+                       procmsg_msginfo_unset_flags(msginfo, MSG_MARKED, 0);
                        summary_set_row_marks(summaryview, row);
                } else
                        summary_mark_row(summaryview, row);
@@ -4610,8 +4570,7 @@ static void summary_selected(GtkCTree *ctree, GtkCTreeNode *row,
                break;
        case S_COL_LOCKED:
                if (MSG_IS_LOCKED(msginfo->flags)) {
-                       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_LOCKED);
-                       CHANGE_FLAGS(msginfo);
+                       procmsg_msginfo_unset_flags(msginfo, MSG_LOCKED, 0);
                        summary_set_row_marks(summaryview, row);
                }
                else
@@ -4936,13 +4895,13 @@ static void summary_ignore_thread_func(GtkCTree *ctree, GtkCTreeNode *row, gpoin
        MsgInfo *msginfo;
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
+/* NOT NEEDED ANYMORE
        if (MSG_IS_NEW(msginfo->flags))
                summaryview->newmsgs--;
        if (MSG_IS_UNREAD(msginfo->flags))
                summaryview->unread--;
-       MSG_SET_PERM_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
-
-       CHANGE_FLAGS(msginfo);
+*/
+       procmsg_msginfo_set_flags(msginfo, MSG_IGNORE_THREAD, 0);
 
        summary_set_row_marks(summaryview, row);
        debug_print(_("Message %d is marked as ignore thread\n"),
@@ -4968,14 +4927,14 @@ static void summary_unignore_thread_func(GtkCTree *ctree, GtkCTreeNode *row, gpo
        MsgInfo *msginfo;
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
+/* NOT NEEDED ANYMORE
        if (MSG_IS_NEW(msginfo->flags))
                summaryview->newmsgs++;
        if (MSG_IS_UNREAD(msginfo->flags))
                summaryview->unread++;
-       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_IGNORE_THREAD);
+*/
+       procmsg_msginfo_unset_flags(msginfo, MSG_IGNORE_THREAD, 0);
 
-       CHANGE_FLAGS(msginfo);
-               
        summary_set_row_marks(summaryview, row);
        debug_print(_("Message %d is marked as unignore thread\n"),
            msginfo->msgnum);