sync with 0.9.5cvs2
[claws.git] / src / summaryview.c
index fee3ae8f438a8e3d9461e88ff846c3cc5d8b2b16..3dcb70186d05fb8ed7e4e3282b2ed0fb01c5646f 100644 (file)
@@ -44,9 +44,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <regex.h>
 
 #include "intl.h"
 #include "main.h"
@@ -78,7 +75,7 @@
 #include "addressbook.h"
 #include "addr_compl.h"
 #include "scoring.h"
-#include "prefs_folder_item.h"
+#include "folder_item_prefs.h"
 #include "filtering.h"
 #include "string_match.h"
 #include "toolbar.h"
@@ -192,6 +189,8 @@ static void summary_mark_row                (SummaryView            *summaryview,
                                         GtkCTreeNode           *row);
 static void summary_lock_row           (SummaryView            *summaryview,
                                         GtkCTreeNode           *row);
+static void summary_unlock_row         (SummaryView            *summaryview,
+                                        GtkCTreeNode           *row);
 static void summary_mark_row_as_read   (SummaryView            *summaryview,
                                         GtkCTreeNode           *row);
 static void summary_mark_row_as_unread (SummaryView            *summaryview,
@@ -226,8 +225,8 @@ static void summary_execute_delete_func     (GtkCTree               *ctree,
                                         gpointer                data);
 
 static void summary_thread_init                (SummaryView            *summaryview);
-static void summary_ignore_thread      (SummaryView            *summaryview);
-static void summary_unignore_thread    (SummaryView            *summaryview);
+static void summary_ignore_thread      (SummaryView            *summaryview);
+static void summary_unignore_thread     (SummaryView            *summaryview);
 
 static void summary_unthread_for_exec          (SummaryView    *summaryview);
 static void summary_unthread_for_exec_func     (GtkCTree       *ctree,
@@ -255,7 +254,7 @@ static void summary_colorlabel_menu_create(SummaryView      *summaryview);
 static GtkWidget *summary_ctree_create (SummaryView    *summaryview);
 
 /* callback functions */
-static void summary_toggle_pressed     (GtkWidget              *eventbox,
+static gint summary_toggle_pressed     (GtkWidget              *eventbox,
                                         GdkEventButton         *event,
                                         SummaryView            *summaryview);
 static void summary_button_pressed     (GtkWidget              *ctree,
@@ -264,10 +263,10 @@ static void summary_button_pressed        (GtkWidget              *ctree,
 static void summary_button_released    (GtkWidget              *ctree,
                                         GdkEventButton         *event,
                                         SummaryView            *summaryview);
-static void summary_key_pressed                (GtkWidget              *ctree,
+static gint summary_key_pressed                (GtkWidget              *ctree,
                                         GdkEventKey            *event,
                                         SummaryView            *summaryview);
-static void summary_searchbar_pressed  (GtkWidget              *ctree,
+static gint summary_searchbar_pressed  (GtkWidget              *ctree,
                                         GdkEventKey            *event,
                                         SummaryView            *summaryview);
 static void summary_searchbar_focus_evt        (GtkWidget              *ctree,
@@ -430,6 +429,8 @@ static GtkItemFactoryEntry summary_popup_entries[] =
        {N_("/_Mark/Mark all read"),    NULL, summary_mark_all_read, 0, NULL},
        {N_("/_Mark/Ignore thread"),    NULL, summary_ignore_thread, 0, NULL},
        {N_("/_Mark/Unignore thread"),  NULL, summary_unignore_thread, 0, NULL},
+       {N_("/_Mark/Lock"),             NULL, summary_msgs_lock, 0, NULL},
+       {N_("/_Mark/Unlock"),           NULL, summary_msgs_unlock, 0, NULL},
        {N_("/Color la_bel"),           NULL, NULL,             0, NULL},
 
        {N_("/---"),                    NULL, NULL,             0, "<Separator>"},
@@ -525,7 +526,8 @@ static DescriptionWindow search_descr = {
        search_descr_strings
 };
        
-static void search_description_cb (GtkWidget *widget) {
+static void search_description_cb(GtkWidget *widget)
+{
        description_window_create(&search_descr);
 };
 
@@ -707,6 +709,8 @@ 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);
+
        /* CLAWS: need this to get the SummaryView * from
         * the CList */
        gtk_object_set_data(GTK_OBJECT(ctree), "summaryview", (gpointer)summaryview); 
@@ -721,6 +725,7 @@ void summary_init(SummaryView *summaryview)
        GtkStyle *style;
        GtkWidget *pixmap;
 
+       gtk_widget_realize(summaryview->ctree);
        stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_MARK,
                         &markxpm, &markxpmmask);
        stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_DELETED,
@@ -928,19 +933,12 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
 
        summary_clear_list(summaryview);
        summary_set_column_titles(summaryview);
-       if (!is_refresh)
-               messageview_clear(summaryview->messageview);
 
        buf = NULL;
-       if (!item || !item->path || !item->parent || item->no_select ||
-           (FOLDER_TYPE(item->folder) == F_MH &&
-            ((buf = folder_item_get_path(item)) == NULL ||
-             change_dir(buf) < 0))) {
+       if (!item || !item->path || !item->parent || item->no_select) {
                g_free(buf);
                debug_print("empty folder\n\n");
                summary_set_hide_read_msgs_menu(summaryview, FALSE);
-               if (is_refresh)
-                       messageview_clear(summaryview->messageview);
                summary_clear_all(summaryview);
                summaryview->folder_item = item;
                gtk_clist_thaw(GTK_CLIST(ctree));
@@ -950,6 +948,9 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
        }
        g_free(buf);
 
+       if (!is_refresh)
+               messageview_clear(summaryview->messageview);
+
        summaryview->folder_item = item;
        item->opened = TRUE;
 
@@ -1091,9 +1092,8 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
 
        STATUSBAR_POP(summaryview->mainwin);
 
-       /* set ctree and hash table from the msginfo list
-          creating thread, and count the number of messages */
-       
+       /* set ctree and hash table from the msginfo list, and
+          create the thread */
        summary_set_ctree_from_list(summaryview, mlist);
 
        g_slist_free(mlist);
@@ -1138,7 +1138,8 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                                 item->sort_type == SORT_DESCENDING
                                 ? 0 : GTK_CLIST(ctree)->rows - 1);
                }
-               if (prefs_common.open_unread_on_enter) {
+               if (prefs_common.open_unread_on_enter ||
+                   prefs_common.always_show_msg) {
                        summary_unlock(summaryview);
                        summary_select_node(summaryview, node, TRUE, TRUE);
                        summary_lock(summaryview);
@@ -1180,12 +1181,11 @@ void summary_clear_list(SummaryView *summaryview)
 
        summaryview->display_msg = FALSE;
 
-       summaryview->selected  = NULL;
+       summaryview->selected = NULL;
        summaryview->displayed = NULL;
-       summaryview->newmsgs   = summaryview->unread     = 0;
-       summaryview->messages  = summaryview->total_size = 0;
-       summaryview->deleted   = summaryview->moved      = 0;
-       summaryview->copied    = 0;
+       summaryview->total_size = 0;
+       summaryview->deleted = summaryview->moved = 0;
+       summaryview->copied = 0;
        if (summaryview->msgid_table) {
                g_hash_table_destroy(summaryview->msgid_table);
                summaryview->msgid_table = NULL;
@@ -1210,6 +1210,7 @@ void summary_clear_list(SummaryView *summaryview)
 
 void summary_clear_all(SummaryView *summaryview)
 {
+       messageview_clear(summaryview->messageview);
        summary_clear_list(summaryview);
        summary_set_menu_sensitive(summaryview);
        toolbar_main_set_sensitive(summaryview->mainwin);
@@ -1249,86 +1250,109 @@ SummarySelection summary_get_selection_type(SummaryView *summaryview)
        return selection;
 }
 
+GSList *summary_get_selected_msg_list(SummaryView *summaryview)
+{
+       GSList *mlist = NULL;
+       GList *cur;
+       MsgInfo *msginfo;
+
+       for (cur = GTK_CLIST(summaryview->ctree)->selection; cur != NULL;
+            cur = cur->next) {
+               msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(cur->data);
+               mlist = g_slist_prepend(mlist, msginfo);
+       }
+
+       mlist = g_slist_reverse(mlist);
+
+       return mlist;
+}
+
+GSList *summary_get_msg_list(SummaryView *summaryview)
+{
+       GSList *mlist = NULL;
+       GtkCTree *ctree;
+       GtkCTreeNode *node;
+       MsgInfo *msginfo;
+
+       ctree = GTK_CTREE(summaryview->ctree);
+
+       for (node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
+            node != NULL; node = gtkut_ctree_node_next(ctree, node)) {
+               msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
+               mlist = g_slist_prepend(mlist, msginfo);
+       }
+
+       mlist = g_slist_reverse(mlist);
+
+       return mlist;
+}
+
 static void summary_set_menu_sensitive(SummaryView *summaryview)
 {
        GtkItemFactory *ifactory = summaryview->popupfactory;
-       SummarySelection selection;
+       SensitiveCond state;
+       gboolean sensitive;
        GtkWidget *menuitem;
-       gboolean sens;
+       gint i;
+
+       static const struct {
+               gchar *const entry;
+               SensitiveCond cond;
+       } entry[] = {
+               {"/Reply"                       , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
+               {"/Reply to"                    , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
+               {"/Reply to/all"                , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
+               {"/Reply to/sender"             , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
+               {"/Reply to/mailing list"       , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
+               {"/Follow-up and reply to"      , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
+
+               {"/Forward"                     , M_HAVE_ACCOUNT|M_TARGET_EXIST},
+               {"/Redirect"                    , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
+
+               {"/Re-edit"                     , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
+
+               {"/Move..."                     , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
+               {"/Copy..."                     , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
+               {"/Delete"                      , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
+               {"/Cancel a news message"       , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
+               {"/Execute"                     , M_DELAY_EXEC},
+
+               {"/Mark"                        , M_TARGET_EXIST},
+               {"/Mark/Mark"                   , M_TARGET_EXIST},
+               {"/Mark/Unmark"                 , M_TARGET_EXIST},
+               {"/Mark/Mark as unread"         , M_TARGET_EXIST},
+               {"/Mark/Mark all read"          , M_TARGET_EXIST},
+               {"/Mark/Ignore thread"          , M_TARGET_EXIST},
+               {"/Mark/Lock"                   , M_TARGET_EXIST},
+               {"/Mark/Unlock"                 , M_TARGET_EXIST},
+               {"/Color label"                 , M_TARGET_EXIST},
+
+               {"/Add sender to address book"  , M_SINGLE_TARGET_EXIST},
+               {"/Create filter rule"          , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
+
+               {"/View"                        , M_SINGLE_TARGET_EXIST},
+               {"/View/Open in new window"     , M_SINGLE_TARGET_EXIST},
+               {"/View/Source"                 , M_SINGLE_TARGET_EXIST},
+               {"/View/All header"             , M_SINGLE_TARGET_EXIST},
+
+               {"/Save as..."                  , M_TARGET_EXIST|M_UNLOCKED},
+               {"/Print..."                    , M_TARGET_EXIST|M_UNLOCKED},
+
+               {"/Select thread"               , M_SINGLE_TARGET_EXIST},
+               {"/Select all"                  , M_TARGET_EXIST},
+
+               {NULL, 0}
+       };
 
-       selection = summary_get_selection_type(summaryview);
        main_window_set_menu_sensitive(summaryview->mainwin);
 
-       if (selection == SUMMARY_NONE) {
-               GtkWidget *submenu;
+       state = main_window_get_current_state(summaryview->mainwin);
 
-               submenu = gtk_item_factory_get_widget
-                       (summaryview->popupfactory, "/Mark");
-               menu_set_insensitive_all(GTK_MENU_SHELL(submenu));
-               menu_set_insensitive_all
-                       (GTK_MENU_SHELL(summaryview->popupmenu));
-               return;
+       for (i = 0; entry[i].entry != NULL; i++) {
+               sensitive = ((entry[i].cond & state) == entry[i].cond);
+               menu_set_sensitive(ifactory, entry[i].entry, sensitive);
        }
 
-       if (FOLDER_TYPE(summaryview->folder_item->folder) != F_NEWS)
-               menu_set_sensitive(ifactory, "/Move...", TRUE);
-       else
-               menu_set_sensitive(ifactory, "/Move...", FALSE);
-
-#if 0
-       menu_set_sensitive(ifactory, "/Delete", TRUE);
-#endif
-       menu_set_sensitive(ifactory, "/Copy...", TRUE);
-       menu_set_sensitive(ifactory, "/Execute", TRUE);
-
-       menu_set_sensitive(ifactory, "/Mark", TRUE);
-       menu_set_sensitive(ifactory, "/Mark/Mark",   TRUE);
-       menu_set_sensitive(ifactory, "/Mark/Unmark", TRUE);
-
-       menu_set_sensitive(ifactory, "/Mark/Mark as unread", TRUE);
-       menu_set_sensitive(ifactory, "/Mark/Mark as read",   TRUE);
-       menu_set_sensitive(ifactory, "/Mark/Mark all read", TRUE);
-       menu_set_sensitive(ifactory, "/Mark/Ignore thread",   TRUE);
-       menu_set_sensitive(ifactory, "/Mark/Unignore thread", TRUE);
-
-       menu_set_sensitive(ifactory, "/Color label", TRUE);
-
-       sens = (selection == SUMMARY_SELECTED_MULTIPLE) ? FALSE : TRUE;
-       menu_set_sensitive(ifactory, "/Reply",                    sens);
-       menu_set_sensitive(ifactory, "/Reply to",                 sens);
-       menu_set_sensitive(ifactory, "/Reply to/all",             sens);
-       menu_set_sensitive(ifactory, "/Reply to/sender",          sens);
-       menu_set_sensitive(ifactory, "/Reply to/mailing list",    sens);
-       menu_set_sensitive(ifactory, "/Forward",                  TRUE);
-       menu_set_sensitive(ifactory, "/Redirect",                 sens);
-
-       menu_set_sensitive(ifactory, "/Add sender to address book", sens);
-       menu_set_sensitive(ifactory, "/Create filter rule",         sens);
-
-       menu_set_sensitive(ifactory, "/View", sens);
-       menu_set_sensitive(ifactory, "/View/Open in new window", sens);
-       menu_set_sensitive(ifactory, "/View/Source", sens);
-       menu_set_sensitive(ifactory, "/View/All header", sens);
-       if (summaryview->folder_item->stype == F_OUTBOX ||
-           summaryview->folder_item->stype == F_DRAFT  ||
-           summaryview->folder_item->stype == F_QUEUE)
-               menu_set_sensitive(ifactory, "/Re-edit", sens);
-       else
-               menu_set_sensitive(ifactory, "/Re-edit", FALSE);
-
-       menu_set_sensitive(ifactory, "/Save as...", TRUE);
-       menu_set_sensitive(ifactory, "/Print...",   TRUE);
-
-       menu_set_sensitive(ifactory, "/Select all", TRUE);
-       menu_set_sensitive(ifactory, "/Select thread", sens);
-       if (summaryview->folder_item->folder->account)
-               sens = summaryview->folder_item->folder->account->protocol
-                       == A_NNTP;
-       else
-               sens = FALSE;
-       menu_set_sensitive(ifactory, "/Follow-up and reply to", sens);
-       menu_set_sensitive(ifactory, "/Cancel a news message", sens);
-       menu_set_sensitive(ifactory, "/Delete", !sens);
 
        summary_lock(summaryview);
        menuitem = gtk_item_factory_get_widget(ifactory, "/View/All header");
@@ -1852,10 +1876,6 @@ static void summary_set_marks_func(GtkCTree *ctree, GtkCTreeNode *node,
        if (MSG_IS_NEWS(msginfo->flags))
                news_flag_crosspost(msginfo);
 
-       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_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)
        && procmsg_msg_has_marked_parent(msginfo))
                summaryview->unreadmarked++;
@@ -1863,7 +1883,6 @@ static void summary_set_marks_func(GtkCTree *ctree, GtkCTreeNode *node,
        if (MSG_IS_DELETED(msginfo->flags))
                summaryview->deleted++;
 
-       summaryview->messages++;
        summaryview->total_size += msginfo->size;
 
        summary_set_row_marks(summaryview, node);
@@ -1875,18 +1894,13 @@ static void summary_update_status(SummaryView *summaryview)
        GtkCTreeNode *node;
        MsgInfo *msginfo;
 
-       summaryview->newmsgs = summaryview->unread =
-       summaryview->messages = summaryview->total_size =
+       summaryview->total_size =
        summaryview->deleted = summaryview->moved = summaryview->copied = 0;
 
        for (node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
             node != NULL; node = gtkut_ctree_node_next(ctree, node)) {
                msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
 
-               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_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)
                && procmsg_msg_has_marked_parent(msginfo))
                        summaryview->unreadmarked++;
@@ -1896,7 +1910,6 @@ static void summary_update_status(SummaryView *summaryview)
                        summaryview->moved++;
                if (MSG_IS_COPY(msginfo->flags))
                        summaryview->copied++;
-               summaryview->messages++;
                summaryview->total_size += msginfo->size;
        }
 }
@@ -1982,18 +1995,12 @@ static void summary_status_show(SummaryView *summaryview)
        g_free(cp);
        g_free(itstr);
 
-       if (FOLDER_IS_LOCAL(summaryview->folder_item->folder)) {
-               str = g_strdup_printf(_("%d new, %d unread, %d total (%s)"),
-                                     summaryview->newmsgs,
-                                     summaryview->unread,
-                                     summaryview->messages,
+       str = g_strdup_printf(_("%d new, %d unread, %d total (%s)"),
+
+                                     summaryview->folder_item->new_msgs,
+                                     summaryview->folder_item->unread_msgs,
+                                     summaryview->folder_item->total_msgs,
                                      to_human_readable(summaryview->total_size));
-       } else {
-               str = g_strdup_printf(_("%d new, %d unread, %d total"),
-                                     summaryview->newmsgs,
-                                     summaryview->unread,
-                                     summaryview->messages);
-       }
        gtk_label_set(GTK_LABEL(summaryview->statlabel_msgs), str);
        g_free(str);
 }
@@ -2323,10 +2330,12 @@ static gchar *summary_complete_address(const gchar *addr)
        res = NULL;
        if (1 < (count = complete_address(email_addr))) {
                tmp = get_complete_address(1);
+/*     tmp = addressbook_lookup_name( email_addr );
+       if( tmp ) { */
                res = procheader_get_fromname(tmp);
-               g_free(tmp);    
+               g_free(tmp);
        }
-       
+
        return res;
 }
 
@@ -2365,7 +2374,6 @@ static void summary_set_header(SummaryView *summaryview, gchar *text[],
 
                Xstrdup_a(addr, msginfo->from, return);
                extract_address(addr);
-
                if (prefs_common.use_addr_book) {
                        if (account_find_from_address(addr)) {
                                addr = summary_complete_address(msginfo->to);
@@ -2419,9 +2427,14 @@ static void summary_display_msg_full(SummaryView *summaryview,
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        MsgInfo *msginfo;
        MsgFlags flags;
-       gchar *filename;
 
-       if (!new_window && summaryview->displayed == row) return;
+       if (!new_window) {
+               if (summaryview->displayed == row)
+                       return;
+               else
+                       summaryview->messageview->filtered = FALSE;
+       }                       
+       
        g_return_if_fail(row != NULL);
 
        if (summary_is_locked(summaryview)) return;
@@ -2432,18 +2445,7 @@ static void summary_display_msg_full(SummaryView *summaryview,
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
 
-       filename = procmsg_get_message_file(msginfo);
-       if (!filename) {
-               summary_unlock(summaryview);
-               return;
-       }
-       g_free(filename);
-
        if (new_window || !prefs_common.mark_as_read_on_new_window) {
-               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_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags) 
                && procmsg_msg_has_marked_parent(msginfo))
                        summaryview->unreadmarked--;
@@ -2705,8 +2707,7 @@ static void summary_set_row_marks(SummaryView *summaryview, GtkCTreeNode *row)
                }
                        gtk_ctree_node_set_foreground
                                (ctree, row, &summaryview->color_marked);
-       }
-       else if ((global_scoring ||
+       } else if ((global_scoring ||
                  summaryview->folder_item->prefs->scoring) &&
                 (msginfo->score >= summaryview->important_score) &&
                 (MSG_IS_MARKED(msginfo->flags) || MSG_IS_MOVE(msginfo->flags) || MSG_IS_COPY(msginfo->flags))) {
@@ -2781,7 +2782,6 @@ static void summary_mark_row(SummaryView *summaryview, GtkCTreeNode *row)
 
 static void summary_lock_row(SummaryView *summaryview, GtkCTreeNode *row)
 {
-       /* almost verbatim summary_mark_row(); may want a menu action? */
        gboolean changed = FALSE;
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        MsgInfo *msginfo;
@@ -2804,6 +2804,20 @@ static void summary_lock_row(SummaryView *summaryview, GtkCTreeNode *row)
        debug_print("Message %d is locked\n", msginfo->msgnum);
 }
 
+static void summary_unlock_row(SummaryView *summaryview, GtkCTreeNode *row)
+{
+       GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
+       MsgInfo *msginfo;
+
+       msginfo = gtk_ctree_node_get_row_data(ctree, row);
+       if (!MSG_IS_LOCKED(msginfo->flags))
+               return;
+       procmsg_msginfo_set_to_folder(msginfo, NULL);
+       procmsg_msginfo_unset_flags(msginfo, MSG_LOCKED, 0);
+       summary_set_row_marks(summaryview, row);
+       debug_print("Message %d is unlocked\n", msginfo->msgnum);
+}
+
 void summary_mark(SummaryView *summaryview)
 {
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
@@ -2827,10 +2841,6 @@ static void summary_mark_row_as_read(SummaryView *summaryview,
        if(!(MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags)))
                return;
 
-       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_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)
        && procmsg_msg_has_marked_parent(msginfo))
                summaryview->unreadmarked--;
@@ -2855,6 +2865,34 @@ void summary_mark_as_read(SummaryView *summaryview)
        summary_status_show(summaryview);
 }
 
+void summary_msgs_lock(SummaryView *summaryview)
+{
+       GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
+       GList *cur;
+
+       folder_item_update_freeze();
+       for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
+               summary_lock_row(summaryview,
+                                        GTK_CTREE_NODE(cur->data));
+       folder_item_update_thaw();
+       
+       summary_status_show(summaryview);
+}
+
+void summary_msgs_unlock(SummaryView *summaryview)
+{
+       GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
+       GList *cur;
+
+       folder_item_update_freeze();
+       for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
+               summary_unlock_row(summaryview,
+                                  GTK_CTREE_NODE(cur->data));
+       folder_item_update_thaw();
+       
+       summary_status_show(summaryview);
+}
+
 void summary_mark_all_read(SummaryView *summaryview)
 {
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
@@ -2885,9 +2923,6 @@ static void summary_mark_row_as_unread(SummaryView *summaryview,
                summaryview->deleted--;
        }
 
-       if (!MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
-               summaryview->unread++;
-
        if (!MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)
        && procmsg_msg_has_marked_parent(msginfo))
                summaryview->unreadmarked++;
@@ -3064,18 +3099,8 @@ void summary_delete(SummaryView *summaryview)
        if (!node)
                node = summary_find_prev_msg(summaryview, sel_last);
 
-       if (node) {
-               if (sel_last && node == gtkut_ctree_node_next(ctree, sel_last))
-                       summary_step(summaryview, GTK_SCROLL_STEP_FORWARD);
-               else if (sel_last && node == GTK_CTREE_NODE_PREV(sel_last))
-                       summary_step(summaryview, GTK_SCROLL_STEP_BACKWARD);
-               else
-                       summary_select_node
-                               (summaryview, node,
-                                messageview_is_visible(summaryview->messageview),
-                                FALSE);
-       }
-
+       summary_select_node(summaryview, node, FALSE, FALSE);
+       
        if (prefs_common.immediate_exec || item->stype == F_TRASH) {
                summary_execute(summaryview);
                /* after deleting, the anchor may be at an invalid row
@@ -3120,10 +3145,12 @@ static void summary_delete_duplicated_func(GtkCTree *ctree, GtkCTreeNode *node,
                                           SummaryView *summaryview)
 {
        GtkCTreeNode *found;
-       MsgInfo *msginfo = GTK_CTREE_ROW(node)->row.data;
+       MsgInfo *msginfo;
        MsgInfo *dup_msginfo;
+
+       msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
        
-       if (!msginfo->msgid || !*msginfo->msgid) return;
+       if (!msginfo || !msginfo->msgid || !*msginfo->msgid) return;
 
        found = g_hash_table_lookup(summaryview->msgid_table, msginfo->msgid);
        
@@ -3331,7 +3358,9 @@ void summary_add_address(SummaryView *summaryview)
 
 void summary_select_all(SummaryView *summaryview)
 {
-       if (summaryview->messages >= 500) {
+       if (!summaryview->folder_item) return;
+
+       if (summaryview->folder_item->total_msgs >= 500) {
                STATUSBAR_PUSH(summaryview->mainwin,
                               _("Selecting all messages..."));
                main_window_cursor_wait(summaryview->mainwin);
@@ -3339,7 +3368,7 @@ void summary_select_all(SummaryView *summaryview)
 
        gtk_clist_select_all(GTK_CLIST(summaryview->ctree));
 
-       if (summaryview->messages >= 500) {
+       if (summaryview->folder_item->total_msgs >= 500) {
                STATUSBAR_POP(summaryview->mainwin);
                main_window_cursor_normal(summaryview->mainwin);
        }
@@ -3571,7 +3600,7 @@ static void summary_execute_move_func(GtkCTree *ctree, GtkCTreeNode *node,
 
        if (msginfo && MSG_IS_MOVE(msginfo->flags) && msginfo->to_folder) {
                summaryview->mlist =
-                       g_slist_append(summaryview->mlist, msginfo);
+                       g_slist_prepend(summaryview->mlist, msginfo);
                gtk_ctree_node_set_row_data(ctree, node, NULL);
 
                if (msginfo->msgid && *msginfo->msgid &&
@@ -3591,6 +3620,7 @@ static void summary_execute_copy(SummaryView *summaryview)
                                summaryview);
 
        if (summaryview->mlist) {
+               summaryview->mlist = g_slist_reverse(summaryview->mlist);
                procmsg_copy_messages(summaryview->mlist);
 
                g_slist_free(summaryview->mlist);
@@ -3608,7 +3638,7 @@ static void summary_execute_copy_func(GtkCTree *ctree, GtkCTreeNode *node,
 
        if (msginfo && MSG_IS_COPY(msginfo->flags) && msginfo->to_folder) {
                summaryview->mlist =
-                       g_slist_append(summaryview->mlist, msginfo);
+                       g_slist_prepend(summaryview->mlist, msginfo);
 
                procmsg_msginfo_unset_flags(msginfo, 0, MSG_COPY);
                summary_set_row_marks(summaryview, node);
@@ -3622,9 +3652,6 @@ static void summary_execute_delete(SummaryView *summaryview)
        GSList *cur;
 
        trash = summaryview->folder_item->folder->trash;
-       if (FOLDER_TYPE(summaryview->folder_item->folder) == F_MH) {
-               g_return_if_fail(trash != NULL);
-       }
 
        /* search deleting messages and execute */
        gtk_ctree_pre_recursive
@@ -3636,7 +3663,7 @@ static void summary_execute_delete(SummaryView *summaryview)
                folder_item_remove_msgs(summaryview->folder_item,
                                        summaryview->mlist);
        else
-               folder_item_move_msgs_with_dest(trash, summaryview->mlist);
+               folder_item_move_msgs(trash, summaryview->mlist);
 
        for (cur = summaryview->mlist; cur != NULL; cur = cur->next)
                procmsg_msginfo_free((MsgInfo *)cur->data);
@@ -3979,42 +4006,9 @@ static void summary_filter_func(GtkCTree *ctree, GtkCTreeNode *node,
 
 void summary_filter_open(SummaryView *summaryview, PrefsFilterType type)
 {
-       static HeaderEntry hentry[] = {{"X-BeenThere:",    NULL, FALSE},
-                                      {"X-ML-Name:",      NULL, FALSE},
-                                      {"X-List:",         NULL, FALSE},
-                                      {"X-Mailing-list:", NULL, FALSE},
-                                      {"List-Id:",        NULL, FALSE},
-                                      {NULL,              NULL, FALSE}};
-
-       static gchar *header_strs[] = {"From", "from", "To", "to", "Subject", "subject"};
-
-       static gchar *hentry_strs[]   = {"X-BeenThere", "X-ML-Name", "X-List",
-                                        "X-Mailing-List", "List-Id",
-                                        "header \"X-BeenThere\"", "header \"X-ML-Name\"",
-                                        "header \"X-List\"", "header \"X-Mailing-List\"",
-                                        "header \"List-Id\""};
-       enum
-       {
-               H_X_BEENTHERE    = 0,
-               H_X_ML_NAME      = 1,
-               H_X_LIST         = 2,
-               H_X_MAILING_LIST = 3,
-               H_LIST_ID        = 4
-       };
-
-       enum
-       {
-               H_FROM    = 0,
-               H_TO      = 2,
-               H_SUBJECT = 4
-       };
-
        MsgInfo *msginfo;
        gchar *header = NULL;
        gchar *key = NULL;
-       FILE *fp;
-       int header_offset;
-       int hentry_offset;
 
        if (!summaryview->selected) return;
 
@@ -4022,72 +4016,11 @@ void summary_filter_open(SummaryView *summaryview, PrefsFilterType type)
                                              summaryview->selected);
        if (!msginfo) return;
 
-       header_offset = 1;
-       hentry_offset = 5;
-
-       switch (type) {
-       case FILTER_BY_NONE:
-               break;
-       case FILTER_BY_AUTO:
-               if ((fp = procmsg_open_message(msginfo)) == NULL) return;
-               procheader_get_header_fields(fp, hentry);
-               fclose(fp);
-
-               if (hentry[H_X_BEENTHERE].body != NULL) {
-                       header = hentry_strs[H_X_BEENTHERE + hentry_offset];
-                       Xstrdup_a(key, hentry[H_X_BEENTHERE].body, );
-               } else if (hentry[H_X_ML_NAME].body != NULL) {
-                       header = hentry_strs[H_X_ML_NAME + hentry_offset];
-                       Xstrdup_a(key, hentry[H_X_ML_NAME].body, );
-               } else if (hentry[H_X_LIST].body != NULL) {
-                       header = hentry_strs[H_X_LIST + hentry_offset];
-                       Xstrdup_a(key, hentry[H_X_LIST].body, );
-               } else if (hentry[H_X_MAILING_LIST].body != NULL) {
-                       header = hentry_strs[H_X_MAILING_LIST + hentry_offset];
-                       Xstrdup_a(key, hentry[H_X_MAILING_LIST].body, );
-               } else if (hentry[H_LIST_ID].body != NULL) {
-                       header = hentry_strs[H_LIST_ID + hentry_offset];
-                       Xstrdup_a(key, hentry[H_LIST_ID].body, );
-               } else if (msginfo->subject) {
-                       header = header_strs[H_SUBJECT + header_offset];
-                       key = msginfo->subject;
-               }
-
-               g_free(hentry[H_X_BEENTHERE].body);
-               hentry[H_X_BEENTHERE].body = NULL;
-               g_free(hentry[H_X_ML_NAME].body);
-               hentry[H_X_ML_NAME].body = NULL;
-               g_free(hentry[H_X_LIST].body);
-               hentry[H_X_LIST].body = NULL;
-               g_free(hentry[H_X_MAILING_LIST].body);
-               hentry[H_X_MAILING_LIST].body = NULL;
-               g_free(hentry[H_LIST_ID].body);
-               hentry[H_LIST_ID].body = NULL;
-
-               break;
-       case FILTER_BY_FROM:
-               header = header_strs[H_FROM + header_offset];
-               key = msginfo->from;
-               break;
-       case FILTER_BY_TO:
-               header = header_strs[H_TO + header_offset];
-               key = msginfo->to;
-               break;
-       case FILTER_BY_SUBJECT:
-               header = header_strs[H_SUBJECT + header_offset];
-               key = msginfo->subject;
-               break;
-       default:
-               break;
-       }
-
-       /*
-        * NOTE: key may be allocated on the stack, so 
-        * prefs_filter[ing]_open() should have completed 
-        * and have set entries. Otherwise we're hosed.  
-        */
-
+       procmsg_get_filter_keyword(msginfo, &header, &key, type);
        prefs_filtering_open(NULL, header, key);
+
+       g_free(header);
+       g_free(key);
 }
 
 /* color label */
@@ -4454,12 +4387,12 @@ void summary_set_column_order(SummaryView *summaryview)
 
 /* callback functions */
 
-static void summary_toggle_pressed(GtkWidget *eventbox, GdkEventButton *event,
+static gint summary_toggle_pressed(GtkWidget *eventbox, GdkEventButton *event,
                                   SummaryView *summaryview)
 {
-       if (!event) return;
-
-       summary_toggle_view(summaryview);
+       if (event)  
+               summary_toggle_view(summaryview);
+       return TRUE;
 }
 
 static void summary_button_pressed(GtkWidget *ctree, GdkEventButton *event,
@@ -4495,9 +4428,9 @@ void summary_pass_key_press_event(SummaryView *summaryview, GdkEventKey *event)
        if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
 
 #define RETURN_IF_LOCKED() \
-       if (summaryview->mainwin->lock_count) return
+       if (summaryview->mainwin->lock_count) return TRUE
 
-static void summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
+static gint summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
                                SummaryView *summaryview)
 {
        GtkCTree *ctree = GTK_CTREE(widget);
@@ -4505,14 +4438,14 @@ static void summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
        MessageView *messageview;
        TextView *textview;
 
-       if (summary_is_locked(summaryview)) return;
-       if (!event) return;
+       if (summary_is_locked(summaryview)) return TRUE;
+       if (!event) return TRUE;
 
        switch (event->keyval) {
        case GDK_Left:          /* Move focus */
        case GDK_Escape:
                gtk_widget_grab_focus(summaryview->folderview->ctree);
-               return;
+               return TRUE;
        default:
                break;
        }
@@ -4522,7 +4455,7 @@ static void summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
                if (node)
                        gtk_sctree_select(GTK_SCTREE(ctree), node);
                else
-                       return;
+                       return TRUE;
        }
 
        messageview = summaryview->messageview;
@@ -4535,13 +4468,17 @@ static void summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
 
        switch (event->keyval) {
        case GDK_space:         /* Page down or go to the next */
-               if (summaryview->displayed != summaryview->selected) {
-                       summary_display_msg(summaryview,
-                                           summaryview->selected);
-                       break;
-               }
-               if (!textview_scroll_page(textview, FALSE))
-                       summary_select_next_unread(summaryview);
+               if (event->state & GDK_SHIFT_MASK) 
+                       textview_scroll_page(textview, TRUE);
+               else {
+                       if (summaryview->displayed != summaryview->selected) {
+                               summary_display_msg(summaryview,
+                                                   summaryview->selected);
+                               break;
+                       }
+                       if (!textview_scroll_page(textview, FALSE))
+                               summary_select_next_unread(summaryview);
+               }                               
                break;
        case GDK_BackSpace:     /* Page up */
                textview_scroll_page(textview, TRUE);
@@ -4569,13 +4506,15 @@ static void summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
        default:
                break;
        }
+       return TRUE;
 }
 
-static void summary_searchbar_pressed(GtkWidget *widget, GdkEventKey *event,
+static gint summary_searchbar_pressed(GtkWidget *widget, GdkEventKey *event,
                                SummaryView *summaryview)
 {
        if (event != NULL && event->keyval == GDK_Return)
                summary_show(summaryview, summaryview->folder_item);
+       return TRUE;            
 }
 
 static void summary_searchbar_focus_evt(GtkWidget *widget, GdkEventFocus *event,
@@ -4613,31 +4552,12 @@ static void tog_searchbar_cb(GtkWidget *w, gpointer data)
 {
        SummaryView *summaryview = (SummaryView *)data;
        GtkWidget *hbox= summaryview->hbox_search;
-       GtkAllocation size = hbox->allocation;
-       GtkAllocation msgview_size = summaryview->messageview->vbox->allocation;
-       GtkAllocation parent_size = summaryview->vbox->allocation;
        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) {
                prefs_common.show_searchbar = TRUE;
                gtk_widget_show(hbox);
-               if (!prefs_common.sep_msg && messageview_is_visible(summaryview->messageview)
-               &&  msgview_size.height > 1 && parent_size.height > 1) {
-                       gtk_widget_set_usize(GTK_WIDGET(summaryview->messageview->vbox),
-                                               -1,msgview_size.height - size.height - SUMMARY_VBOX_SPACING);
-                       gtk_widget_set_usize(GTK_WIDGET(summaryview->vbox),
-                                               -1,parent_size.height + size.height + SUMMARY_VBOX_SPACING);
-                       gtk_paned_set_position(GTK_PANED(summaryview->vbox->parent),-1);
-               }
        } else {
                prefs_common.show_searchbar = FALSE;
                gtk_widget_hide(hbox);
-               if (!prefs_common.sep_msg && messageview_is_visible(summaryview->messageview)
-               &&  msgview_size.height > 1 && parent_size.height > 1) {
-                       gtk_widget_set_usize(GTK_WIDGET(summaryview->messageview->vbox),
-                                               -1,msgview_size.height + size.height + SUMMARY_VBOX_SPACING);
-                       gtk_widget_set_usize(GTK_WIDGET(summaryview->vbox),
-                                               -1,parent_size.height - size.height - SUMMARY_VBOX_SPACING);
-                       gtk_paned_set_position(GTK_PANED(summaryview->vbox->parent),-1);
-               }
        }
 }
 
@@ -4687,10 +4607,15 @@ 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)) {
-                       summary_unmark_row(summaryview, row);
-               } else
-                       summary_mark_row(summaryview, row);
+               if (!MSG_IS_DELETED(msginfo->flags) &&
+                   !MSG_IS_MOVE(msginfo->flags) &&
+                   !MSG_IS_COPY(msginfo->flags)) {
+                       if (MSG_IS_MARKED(msginfo->flags)) {
+                               summary_unmark_row(summaryview, row);
+                       } else {
+                               summary_mark_row(summaryview, row);
+                       }
+               }
                break;
        case S_COL_STATUS:
                if (MSG_IS_UNREAD(msginfo->flags)) {
@@ -4718,7 +4643,7 @@ static void summary_selected(GtkCTree *ctree, GtkCTreeNode *row,
        }
 
        if (summaryview->display_msg ||
-           (prefs_common.show_msg_with_cursor_key &&
+           (prefs_common.always_show_msg &&
             messageview_is_visible(summaryview->messageview))) {
                summaryview->display_msg = FALSE;
                if (summaryview->displayed != row) {
@@ -4877,7 +4802,6 @@ static void summary_locked_clicked(GtkWidget *button,
 static void summary_start_drag(GtkWidget *widget, gint button, GdkEvent *event,
                               SummaryView *summaryview)
 {
-       GtkTargetList *list;
        GdkDragContext *context;
 
        g_return_if_fail(summaryview != NULL);
@@ -4885,9 +4809,7 @@ static void summary_start_drag(GtkWidget *widget, gint button, GdkEvent *event,
        g_return_if_fail(summaryview->folder_item->folder != NULL);
        if (summaryview->selected == NULL) return;
 
-       list = gtk_target_list_new(summary_drag_types, 1);
-
-       context = gtk_drag_begin(widget, list,
+       context = gtk_drag_begin(widget, summaryview->target_list,
                                 GDK_ACTION_MOVE|GDK_ACTION_COPY|GDK_ACTION_DEFAULT, button, event);
        gtk_drag_set_icon_default(context);
 }
@@ -5031,7 +4953,7 @@ static gint summary_cmp_by_subject(GtkCList *clist,                        \
  static gint summary_cmp_by_simplified_subject
        (GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
 {
-       const PrefsFolderItem *prefs;
+       const FolderItemPrefs *prefs;
        const gchar *str1, *str2;
        const GtkCListRow *r1 = (const GtkCListRow *) ptr1;
        const GtkCListRow *r2 = (const GtkCListRow *) ptr2;
@@ -5109,13 +5031,10 @@ static void summary_ignore_thread_func(GtkCTree *ctree, GtkCTreeNode *row, gpoin
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
 
-       if (MSG_IS_NEW(msginfo->flags))
-               summaryview->newmsgs--;
-       if (MSG_IS_UNREAD(msginfo->flags))
-               summaryview->unread--;
        if (MSG_IS_UNREAD(msginfo->flags) && procmsg_msg_has_marked_parent(msginfo))
                summaryview->unreadmarked--;
 
+       procmsg_msginfo_unset_flags(msginfo, MSG_NEW | MSG_UNREAD, 0);
        procmsg_msginfo_set_flags(msginfo, MSG_IGNORE_THREAD, 0);
 
        summary_set_row_marks(summaryview, row);
@@ -5128,9 +5047,14 @@ static void summary_ignore_thread(SummaryView *summaryview)
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        GList *cur;
 
-       for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next) {
-               gtk_ctree_pre_recursive(ctree, GTK_CTREE_NODE(cur->data), GTK_CTREE_FUNC(summary_ignore_thread_func), summaryview);
-       }
+       folder_item_update_freeze();
+
+       for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
+               gtk_ctree_pre_recursive(ctree, GTK_CTREE_NODE(cur->data), 
+                                       GTK_CTREE_FUNC(summary_ignore_thread_func), 
+                                       summaryview);
+
+       folder_item_update_thaw();
 
        summary_status_show(summaryview);
 }
@@ -5142,10 +5066,6 @@ static void summary_unignore_thread_func(GtkCTree *ctree, GtkCTreeNode *row, gpo
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
 
-       if (MSG_IS_NEW(msginfo->flags))
-               summaryview->newmsgs++;
-       if (MSG_IS_UNREAD(msginfo->flags))
-               summaryview->unread++;
        if (MSG_IS_UNREAD(msginfo->flags) && procmsg_msg_has_marked_parent(msginfo))
                summaryview->unreadmarked++;
 
@@ -5161,13 +5081,48 @@ static void summary_unignore_thread(SummaryView *summaryview)
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        GList *cur;
 
-       for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next) {
-               gtk_ctree_pre_recursive(ctree, GTK_CTREE_NODE(cur->data), GTK_CTREE_FUNC(summary_unignore_thread_func), summaryview);
-       }
+       folder_item_update_freeze();
+
+       for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
+               gtk_ctree_pre_recursive(ctree, GTK_CTREE_NODE(cur->data), 
+                                       GTK_CTREE_FUNC(summary_unignore_thread_func), 
+                                       summaryview);
+
+       folder_item_update_thaw();
 
        summary_status_show(summaryview);
 }
 
+static void summary_check_ignore_thread_func
+               (GtkCTree *ctree, GtkCTreeNode *row, gpointer data)
+{
+       MsgInfo *msginfo;
+       gint *found_ignore = (gint *) data;
+
+       if (*found_ignore) return;
+       else {
+               msginfo = gtk_ctree_node_get_row_data(ctree, row);
+               *found_ignore = MSG_IS_IGNORE_THREAD(msginfo->flags);
+       }               
+}
+
+void summary_toggle_ignore_thread(SummaryView *summaryview)
+{
+       GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
+       GList *cur;
+       gint found_ignore = 0;
+
+       for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
+               gtk_ctree_pre_recursive(ctree, GTK_CTREE_NODE(cur->data),
+                                       GTK_CTREE_FUNC(summary_check_ignore_thread_func),
+                                       &found_ignore);
+
+       if (found_ignore) 
+               summary_unignore_thread(summaryview);
+       else 
+               summary_ignore_thread(summaryview);
+}
+
 #if 0 /* OLD PROCESSING */
 static gboolean processing_apply_func(GNode *node, gpointer data)
 {
@@ -5383,10 +5338,12 @@ static gboolean summary_update_msg(gpointer source, gpointer data)
        g_return_val_if_fail(msginfo_update != NULL, TRUE);
        g_return_val_if_fail(summaryview != NULL, FALSE);
 
-       node = gtk_ctree_find_by_row_data(GTK_CTREE(summaryview->ctree), NULL, msginfo_update->msginfo);
-       
-       if (node) 
-               summary_set_row_marks(summaryview, node);
+       if (msginfo_update->flags & MSGINFO_UPDATE_FLAGS) {
+               node = gtk_ctree_find_by_row_data(GTK_CTREE(summaryview->ctree), NULL, msginfo_update->msginfo);
+
+               if (node) 
+                       summary_set_row_marks(summaryview, node);
+       }
 
        return FALSE;
 }