* src/summaryview.c
[claws.git] / src / summaryview.c
index ac2fbda191d68b3e3e483cd5e04f8c9a3d36a83c..c63e67be069d69a7a9b47cec2d4c72a84e6180c1 100644 (file)
@@ -74,7 +74,6 @@
 #include "imap.h"
 #include "addressbook.h"
 #include "addr_compl.h"
-#include "scoring.h"
 #include "folder_item_prefs.h"
 #include "filtering.h"
 #include "string_match.h"
@@ -84,7 +83,7 @@
 #include "matcher_parser.h"
 #include "hooks.h"
 #include "description_window.h"
-#include "folder.h"
+#include "folderutils.h"
 
 #define SUMMARY_COL_MARK_WIDTH         10
 #define SUMMARY_COL_STATUS_WIDTH       13
@@ -204,11 +203,6 @@ static void summary_copy_row_to            (SummaryView            *summaryview,
                                         GtkCTreeNode           *row,
                                         FolderItem             *to_folder);
 
-static void summary_delete_duplicated_func
-                                       (GtkCTree               *ctree,
-                                        GtkCTreeNode           *node,
-                                        SummaryView            *summaryview);
-
 static void summary_execute_move       (SummaryView            *summaryview);
 static void summary_execute_move_func  (GtkCTree               *ctree,
                                         GtkCTreeNode           *node,
@@ -304,6 +298,9 @@ static void summary_add_address_cb  (SummaryView            *summaryview,
 static void summary_create_filter_cb   (SummaryView            *summaryview,
                                         guint                   action,
                                         GtkWidget              *widget);
+static void summary_create_processing_cb(SummaryView           *summaryview,
+                                        guint                   action,
+                                        GtkWidget              *widget);
 
 static void summary_mark_clicked       (GtkWidget              *button,
                                         SummaryView            *summaryview);
@@ -443,6 +440,15 @@ static GtkItemFactoryEntry summary_popup_entries[] =
                                        NULL, summary_create_filter_cb, FILTER_BY_TO, NULL},
        {N_("/Create f_ilter rule/by _Subject"),
                                        NULL, summary_create_filter_cb, FILTER_BY_SUBJECT, NULL},
+       {N_("/Create processing rule"), NULL, NULL,             0, "<Branch>"},
+       {N_("/Create processing rule/_Automatically"),
+                                       NULL, summary_create_processing_cb, FILTER_BY_AUTO, NULL},
+       {N_("/Create processing rule/by _From"),
+                                       NULL, summary_create_processing_cb, FILTER_BY_FROM, NULL},
+       {N_("/Create processing rule/by _To"),
+                                       NULL, summary_create_processing_cb, FILTER_BY_TO, NULL},
+       {N_("/Create processing rule/by _Subject"),
+                                       NULL, summary_create_processing_cb, FILTER_BY_SUBJECT, NULL},
        {N_("/---"),                    NULL, NULL,             0, "<Separator>"},
        {N_("/_View"),                  NULL, NULL,             0, "<Branch>"},
        {N_("/_View/Open in new _window"),
@@ -477,8 +483,8 @@ static const gchar *const col_label[N_SUMMARY_COLS] = {
  */
 static gchar *search_descr_strings[] = {
        "a",     N_("all messages"),
-       "ag #",  N_("messages whose age is greather than #"),
-       "al #",  N_("messages whose age is greather than #"),
+       "ag #",  N_("messages whose age is greater than #"),
+       "al #",  N_("messages whose age is less than #"),
        "b S",   N_("messages which contain S in the message body"),
        "B S",   N_("messages which contain S in the whole message"),
        "c S",   N_("messages carbon-copied to S"),
@@ -508,6 +514,7 @@ static gchar *search_descr_strings[] = {
        "T",     N_("marked messages"),
        "U",     N_("unread messages"),
        "x S",   N_("messages which contain S in References header"),
+       "X cmd", N_("messages returning 0 when passed to command"),
        "y S",   N_("messages which contain S in X-Label header"),
         "",     "" ,
        "&",     N_("logical AND operator"),
@@ -771,13 +778,16 @@ void summary_init(SummaryView *summaryview)
                        (gtk_widget_get_style(summaryview->ctree));
                if (!smallfont)
                        smallfont = gtkut_font_load(SMALL_FONT);
-               small_style->font = smallfont;
+               if (smallfont)
+                       small_style->font = smallfont;
                small_marked_style = gtk_style_copy(small_style);
                small_marked_style->fg[GTK_STATE_NORMAL] =
                        summaryview->color_marked;
                small_deleted_style = gtk_style_copy(small_style);
                small_deleted_style->fg[GTK_STATE_NORMAL] =
                        summaryview->color_dim;
+
+               gtk_widget_set_style(summaryview->ctree, small_style);
        }
 
        style = gtk_style_copy(gtk_widget_get_style
@@ -813,6 +823,7 @@ void summary_init(SummaryView *summaryview)
 
 }
 
+#if 0
 GtkCTreeNode * summary_find_next_important_score(SummaryView *summaryview,
                                                 GtkCTreeNode *current_node)
 {
@@ -874,6 +885,7 @@ GtkCTreeNode * summary_find_prev_important_score(SummaryView *summaryview,
        else
                return best_node;
 }
+#endif
 
 #define CURRENTLY_DISPLAYED(m) \
 ( (m->msgnum == displayed_msgnum) \
@@ -889,6 +901,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
        guint selected_msgnum = 0;
        guint displayed_msgnum = 0;
        GSList *cur;
+        GSList *not_killed;
 
        if (summary_is_locked(summaryview)) return FALSE;
 
@@ -938,7 +951,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
        summary_set_column_titles(summaryview);
 
        buf = NULL;
-       if (!item || !item->path || !item->parent || item->no_select) {
+       if (!item || !item->path || !folder_item_parent(item) || item->no_select) {
                g_free(buf);
                debug_print("empty folder\n\n");
                summary_set_hide_read_msgs_menu(summaryview, FALSE);
@@ -974,19 +987,6 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
        BY OTHER PROGRAMS TO THE FOLDER
 */
        mlist = folder_item_get_msg_list(item);
-#if 0
-       summary_processing(summaryview, mlist);
-#endif
-       for(cur = mlist ; cur != NULL ; cur = g_slist_next(cur)) {
-               MsgInfo * msginfo = (MsgInfo *) cur->data;
-
-               msginfo->score = score_message(global_scoring, msginfo);
-               if (msginfo->score != MAX_SCORE &&
-                   msginfo->score != MIN_SCORE) {
-                       msginfo->score += score_message(item->prefs->scoring,
-                                                       msginfo);
-               }
-       }
 
        if (summaryview->folder_item->hide_read_msgs) {
                GSList *not_killed;
@@ -1072,7 +1072,8 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                g_slist_free(mlist);
                mlist = not_killed;
        }
-       
+
+#if 0  
        if ((global_scoring || item->prefs->scoring)) {
                GSList *not_killed;
                gint kill_score;
@@ -1092,6 +1093,18 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                g_slist_free(mlist);
                mlist = not_killed;
        }
+#endif
+        not_killed = NULL;
+        for(cur = mlist ; cur != NULL ; cur = g_slist_next(cur)) {
+                MsgInfo * msginfo = (MsgInfo *) cur->data;
+                
+                if (!msginfo->hidden)
+                        not_killed = g_slist_prepend(not_killed, msginfo);
+                else
+                        procmsg_msginfo_free(msginfo);
+        }
+        g_slist_free(mlist);
+        mlist = not_killed;
 
        STATUSBAR_POP(summaryview->mainwin);
 
@@ -1129,10 +1142,12 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                }
        } else {
                /* select first unread message */
+#if 0
                if (summaryview->sort_key == SORT_BY_SCORE)
                        node = summary_find_next_important_score(summaryview,
                                                                 NULL);
                else
+#endif
                node = summary_find_next_flagged_msg(summaryview, NULL,
                                                     MSG_UNREAD, FALSE);
                if (node == NULL && GTK_CLIST(ctree)->row_list != NULL) {
@@ -1144,7 +1159,9 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item)
                if (prefs_common.open_unread_on_enter ||
                    prefs_common.always_show_msg) {
                        summary_unlock(summaryview);
-                       summary_select_node(summaryview, node, TRUE, TRUE);
+                       summary_select_node(summaryview, node, 
+                                           messageview_is_visible(summaryview->messageview), 
+                                           TRUE);
                        summary_lock(summaryview);
                } else
                        summary_select_node(summaryview, node, FALSE, TRUE);
@@ -1332,6 +1349,7 @@ static void summary_set_menu_sensitive(SummaryView *summaryview)
 
                {"/Add sender to address book"  , M_SINGLE_TARGET_EXIST},
                {"/Create filter rule"          , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
+               {"/Create processing rule"      , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
 
                {"/View"                        , M_SINGLE_TARGET_EXIST},
                {"/View/Open in new window"     , M_SINGLE_TARGET_EXIST},
@@ -1361,7 +1379,7 @@ static void summary_set_menu_sensitive(SummaryView *summaryview)
        menuitem = gtk_item_factory_get_widget(ifactory, "/View/All header");
        gtk_check_menu_item_set_active
                (GTK_CHECK_MENU_ITEM(menuitem),
-                summaryview->messageview->textview->show_all_headers);
+                summaryview->messageview->mimeview->textview->show_all_headers);
        summary_unlock(summaryview);
 }
 
@@ -1876,7 +1894,8 @@ static void summary_set_marks_func(GtkCTree *ctree, GtkCTreeNode *node,
 
        msginfo = gtk_ctree_node_get_row_data(ctree, node);
 
-       if (MSG_IS_NEWS(msginfo->flags))
+       if (msginfo->folder && msginfo->folder->folder &&
+           msginfo->folder->folder->klass->type == F_NEWS)
                news_flag_crosspost(msginfo);
 
        if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags)
@@ -2155,8 +2174,7 @@ void summary_sort(SummaryView *summaryview,
                cmp_func = (GtkCListCompareFunc)summary_cmp_by_locked;
                break;
        case SORT_BY_NONE:
-               cmp_func = NULL;
-               return;
+               break;
        default:
                return;
        }
@@ -2166,6 +2184,11 @@ void summary_sort(SummaryView *summaryview,
 
        summary_set_column_titles(summaryview);
        summary_set_menu_sensitive(summaryview);
+
+       /* allow fallback to don't sort */
+       if (summaryview->sort_key == SORT_BY_NONE)
+               return;
+
        if(cmp_func != NULL) {
                debug_print("Sorting summary...");
                STATUSBAR_PUSH(summaryview->mainwin, _("Sorting summary..."));
@@ -2371,8 +2394,7 @@ static void summary_set_header(SummaryView *summaryview, gchar *text[],
 
        text[col_pos[S_COL_FROM]] = msginfo->fromname ? msginfo->fromname :
                _("(No From)");
-       if (prefs_common.swap_from && msginfo->from && msginfo->to &&
-           !MSG_IS_NEWS(msginfo->flags)) {
+       if (prefs_common.swap_from && msginfo->from && msginfo->to) {
                gchar *addr = NULL;
 
                Xstrdup_a(addr, msginfo->from, return);
@@ -2430,6 +2452,7 @@ static void summary_display_msg_full(SummaryView *summaryview,
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        MsgInfo *msginfo;
        MsgFlags flags;
+       gint val;
 
        if (!new_window) {
                if (summaryview->displayed == row)
@@ -2448,26 +2471,11 @@ static void summary_display_msg_full(SummaryView *summaryview,
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
 
-       if (new_window || !prefs_common.mark_as_read_on_new_window) {
-               if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags) 
-               && procmsg_msg_has_marked_parent(msginfo))
-                       summaryview->unreadmarked--;
-               if (MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags)) {
-                       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;
-               }
-       }
-
        if (new_window) {
                MessageView *msgview;
 
                msgview = messageview_create_with_new_window(summaryview->mainwin);
-               messageview_show(msgview, msginfo, all_headers);
+               val = messageview_show(msgview, msginfo, all_headers);
        } else {
                MessageView *msgview;
 
@@ -2476,17 +2484,29 @@ static void summary_display_msg_full(SummaryView *summaryview,
                summaryview->displayed = row;
                if (!messageview_is_visible(msgview))
                        main_window_toggle_message_view(summaryview->mainwin);
-               messageview_show(msgview, msginfo, all_headers);
-               if (msgview->type == MVIEW_TEXT ||
-                   (msgview->type == MVIEW_MIME &&
-                    (GTK_CLIST(msgview->mimeview->ctree)->row_list == NULL ||
-                     gtk_notebook_get_current_page
-                       (GTK_NOTEBOOK(msgview->mimeview->notebook)) == 0)))
+               val = messageview_show(msgview, msginfo, all_headers);
+               if (GTK_CLIST(msgview->mimeview->ctree)->row_list == NULL)
                        gtk_widget_grab_focus(summaryview->ctree);
                GTK_EVENTS_FLUSH();
                gtkut_ctree_node_move_if_on_the_edge(ctree, row);
        }
 
+       if (val == 0 &&
+           (new_window || !prefs_common.mark_as_read_on_new_window)) {
+               if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags) 
+               && procmsg_msg_has_marked_parent(msginfo))
+                       summaryview->unreadmarked--;
+               if (MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags)) {
+                       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;
+               }
+       }
+
        summary_set_menu_sensitive(summaryview);
        toolbar_main_set_sensitive(summaryview->mainwin);
 
@@ -2713,6 +2733,7 @@ static void summary_set_row_marks(SummaryView *summaryview, GtkCTreeNode *row)
                }
                        gtk_ctree_node_set_foreground
                                (ctree, row, &summaryview->color_marked);
+#if 0
        } else if ((global_scoring ||
                  summaryview->folder_item->prefs->scoring) &&
                 (msginfo->score >= summaryview->important_score) &&
@@ -2720,6 +2741,7 @@ static void summary_set_row_marks(SummaryView *summaryview, GtkCTreeNode *row)
                gtk_ctree_node_set_text(ctree, row, S_COL_MARK, "!");
                gtk_ctree_node_set_foreground(ctree, row,
                                              &summaryview->color_important);
+#endif
        } else {
                gtk_ctree_node_set_text(ctree, row, col_pos[S_COL_MARK], NULL);
        }
@@ -2747,7 +2769,7 @@ static void summary_set_row_marks(SummaryView *summaryview, GtkCTreeNode *row)
        } else {
                gtk_ctree_node_set_text(ctree, row, col_pos[S_COL_MIME], NULL);
        }
-        if (!style)
+       if (!style)
                style = small_style;
 
        gtk_ctree_node_set_row_style(ctree, row, style);
@@ -2933,7 +2955,6 @@ static void summary_mark_row_as_unread(SummaryView *summaryview,
        && procmsg_msg_has_marked_parent(msginfo))
                summaryview->unreadmarked++;
 
-       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);
@@ -3074,9 +3095,6 @@ void summary_delete(SummaryView *summaryview)
        GtkCTreeNode *node;
 
        if (!item) return;
-#if 0
-       if (!item || item->folder->type == F_NEWS) return;
-#endif
 
        if (summary_is_locked(summaryview)) return;
 
@@ -3118,57 +3136,6 @@ void summary_delete(SummaryView *summaryview)
        main_window_cursor_normal(summaryview->mainwin);
 }
 
-void summary_delete_duplicated(SummaryView *summaryview)
-{
-       if (!summaryview->folder_item ||
-           FOLDER_TYPE(summaryview->folder_item->folder) == F_NEWS) return;
-       if (summaryview->folder_item->stype == F_TRASH) return;
-
-       main_window_cursor_wait(summaryview->mainwin);
-       debug_print("Deleting duplicated messages...");
-       STATUSBAR_PUSH(summaryview->mainwin,
-                      _("Deleting duplicated messages..."));
-
-       folder_item_update_freeze();
-       
-       gtk_ctree_pre_recursive(GTK_CTREE(summaryview->ctree), NULL,
-                               GTK_CTREE_FUNC(summary_delete_duplicated_func),
-                               summaryview);
-
-       if (prefs_common.immediate_exec)
-               summary_execute(summaryview);
-       else
-               summary_status_show(summaryview);
-
-       folder_item_update_thaw();
-
-       debug_print("done.\n");
-       STATUSBAR_POP(summaryview->mainwin);
-       main_window_cursor_normal(summaryview->mainwin);
-}
-
-static void summary_delete_duplicated_func(GtkCTree *ctree, GtkCTreeNode *node,
-                                          SummaryView *summaryview)
-{
-       GtkCTreeNode *found;
-       MsgInfo *msginfo;
-       MsgInfo *dup_msginfo;
-
-       msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
-       
-       if (!msginfo || !msginfo->msgid || !*msginfo->msgid) return;
-
-       found = g_hash_table_lookup(summaryview->msgid_table, msginfo->msgid);
-       
-       if (found && found != node) {
-               dup_msginfo = gtk_ctree_node_get_row_data(ctree, found);
-               /* prefer to delete the unread one */
-               if ((MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_UNREAD(dup_msginfo->flags))
-               ||  (MSG_IS_UNREAD(msginfo->flags) == MSG_IS_UNREAD(dup_msginfo->flags)))
-                       summary_delete_row(summaryview, node);
-       }
-}
-
 static void summary_unmark_row(SummaryView *summaryview, GtkCTreeNode *row)
 {
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
@@ -3949,7 +3916,7 @@ void summary_collapse_threads(SummaryView *summaryview)
 
 void summary_filter(SummaryView *summaryview)
 {
-       if (!global_processing) {
+       if (!filtering_rules) {
                alertpanel_error(_("No filter rules defined."));
                return;
        }
@@ -3964,7 +3931,7 @@ void summary_filter(SummaryView *summaryview)
 
        gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
 
-       if (global_processing == NULL) {
+       if (filtering_rules == NULL) {
                gtk_ctree_pre_recursive(GTK_CTREE(summaryview->ctree), NULL,
                                        GTK_CTREE_FUNC(summary_filter_func),
                                        summaryview);
@@ -3997,7 +3964,7 @@ void summary_filter(SummaryView *summaryview)
         * CLAWS: summary_show() only valid after having a lock. ideally
         * we want the lock to be context aware...  
         */
-       if (global_processing) {
+       if (filtering_rules) {
                summary_show(summaryview, summaryview->folder_item);
        }               
 }
@@ -4007,26 +3974,51 @@ static void summary_filter_func(GtkCTree *ctree, GtkCTreeNode *node,
 {
        MsgInfo *msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
 
-       filter_message_by_msginfo(global_processing, msginfo);
+       filter_message_by_msginfo(filtering_rules, msginfo);
 }
 
-void summary_filter_open(SummaryView *summaryview, PrefsFilterType type)
+void summary_msginfo_filter_open(FolderItem * item, MsgInfo *msginfo,
+                                PrefsFilterType type, gint processing_rule)
 {
-       MsgInfo *msginfo;
        gchar *header = NULL;
        gchar *key = NULL;
 
+       procmsg_get_filter_keyword(msginfo, &header, &key, type);
+       
+       if (processing_rule) {
+               if (item == NULL)
+                       prefs_filtering_open(&pre_global_processing,
+                                            _("Processing rules to apply before folder rules"),
+                                            header, key);
+               else
+                       prefs_filtering_open(&item->prefs->processing,
+                                            _("Processing configuration"),
+                                            header, key);
+       }
+       else {
+               prefs_filtering_open(&filtering_rules,
+                                    _("Filtering configuration"),
+                                      header, key);
+       }
+       
+       g_free(header);
+       g_free(key);
+}
+
+void summary_filter_open(SummaryView *summaryview, PrefsFilterType type,
+                        gint processing_rule)
+{
+       MsgInfo *msginfo;
+       FolderItem * item;
+       
        if (!summaryview->selected) return;
 
        msginfo = gtk_ctree_node_get_row_data(GTK_CTREE(summaryview->ctree),
                                              summaryview->selected);
        if (!msginfo) return;
-
-       procmsg_get_filter_keyword(msginfo, &header, &key, type);
-       prefs_filtering_open(NULL, header, key);
-
-       g_free(header);
-       g_free(key);
+       
+       item = summaryview->folder_item;
+       summary_msginfo_filter_open(item, msginfo, type, processing_rule);
 }
 
 /* color label */
@@ -4440,12 +4432,18 @@ static gint summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
        GtkCTreeNode *node;
        MessageView *messageview;
        TextView *textview;
+       GtkAdjustment *adj;
 
        if (summary_is_locked(summaryview)) return TRUE;
        if (!event) return TRUE;
 
        switch (event->keyval) {
        case GDK_Left:          /* Move focus */
+               adj = gtk_scrolled_window_get_hadjustment
+                       (GTK_SCROLLED_WINDOW(summaryview->scrolledwin));
+               if (adj->lower != adj->value)
+                       break;
+               /* FALLTHROUGH */       
        case GDK_Escape:
                gtk_widget_grab_focus(summaryview->folderview->ctree);
                return TRUE;
@@ -4462,12 +4460,7 @@ static gint summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
        }
 
        messageview = summaryview->messageview;
-       if (messageview->type == MVIEW_MIME &&
-           gtk_notebook_get_current_page
-               (GTK_NOTEBOOK(messageview->mimeview->notebook)) == 1)
-               textview = messageview->mimeview->textview;
-       else
-               textview = messageview->textview;
+       textview = messageview->mimeview->textview;
 
        switch (event->keyval) {
        case GDK_space:         /* Page down or go to the next */
@@ -4495,12 +4488,6 @@ static gint summary_key_pressed(GtkWidget *widget, GdkEventKey *event,
                textview_scroll_one_line
                        (textview, (event->state & GDK_MOD1_MASK) != 0);
                break;
-       case GDK_asterisk:      /* Mark */
-               summary_mark(summaryview);
-               break;
-       case GDK_exclam:        /* Mark as unread */
-               summary_mark_as_unread(summaryview);
-               break;
        case GDK_Delete:
                BREAK_ON_MODIFIER_KEY();
                summary_delete(summaryview);
@@ -4734,7 +4721,13 @@ static void summary_add_address_cb(SummaryView *summaryview,
 static void summary_create_filter_cb(SummaryView *summaryview,
                                     guint action, GtkWidget *widget)
 {
-       summary_filter_open(summaryview, (PrefsFilterType)action);
+       summary_filter_open(summaryview, (PrefsFilterType)action, 0);
+}
+
+static void summary_create_processing_cb(SummaryView *summaryview,
+                                        guint action, GtkWidget *widget)
+{
+       summary_filter_open(summaryview, (PrefsFilterType)action, 1);
 }
 
 static void summary_sort_by_column_click(SummaryView *summaryview,
@@ -4914,25 +4907,25 @@ CMP_FUNC_DEF(summary_cmp_by_to, to);
 
 #undef CMP_FUNC_DEF
 
-static gint summary_cmp_by_subject(GtkCList *clist,                     \
-                                  gconstpointer ptr1,                   \
-                                  gconstpointer ptr2)                   \
-{                                                                       \
-       MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;                 \
-       MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;                 \
-                                                                        \
-       if (!msginfo1->subject)                                          \
-               return (msginfo2->subject != NULL);                      \
-       if (!msginfo2->subject)                                          \
-               return -1;                                               \
-                                                                        \
-       return subject_compare_for_sort                                  \
-               (msginfo1->subject, msginfo2->subject);                  \
+static gint summary_cmp_by_subject(GtkCList *clist,
+                                  gconstpointer ptr1,
+                                  gconstpointer ptr2)
+{
+       MsgInfo *msginfo1 = ((GtkCListRow *)ptr1)->data;
+       MsgInfo *msginfo2 = ((GtkCListRow *)ptr2)->data;
+
+       if (!msginfo1->subject)
+               return (msginfo2->subject != NULL);
+       if (!msginfo2->subject)
+               return -1;
+
+       return subject_compare_for_sort
+               (msginfo1->subject, msginfo2->subject);
 }
 
- static gint summary_cmp_by_from(GtkCList *clist, gconstpointer ptr1,
-                                gconstpointer ptr2)
- {
+static gint summary_cmp_by_from(GtkCList *clist, gconstpointer ptr1,
+                               gconstpointer ptr2)
+{
        const gchar *str1, *str2;
        const GtkCListRow *r1 = (const GtkCListRow *) ptr1;
        const GtkCListRow *r2 = (const GtkCListRow *) ptr2;
@@ -4950,9 +4943,9 @@ static gint summary_cmp_by_subject(GtkCList *clist,                        \
                return -1;
  
        return strcasecmp(str1, str2);
- }
+}
  
- static gint summary_cmp_by_simplified_subject
+static gint summary_cmp_by_simplified_subject
        (GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
 {
        const FolderItemPrefs *prefs;
@@ -4981,7 +4974,7 @@ static gint summary_cmp_by_subject(GtkCList *clist,                        \
        if (!prefs)
                return -1;
        
-       return strcasecmp(str1, str2);
+       return subject_compare_for_sort(str1, str2);
 }
 
 static gint summary_cmp_by_score(GtkCList *clist,
@@ -5005,9 +4998,15 @@ static void news_flag_crosspost(MsgInfo *msginfo)
        GString *line;
        gpointer key;
        gpointer value;
-       Folder *mff = msginfo->folder->folder;
+       Folder *mff;
+
+       g_return_if_fail(msginfo != NULL);
+       g_return_if_fail(msginfo->folder != NULL);
+       g_return_if_fail(msginfo->folder->folder != NULL);
+       mff = msginfo->folder->folder;
+       g_return_if_fail(mff->klass->type == F_NEWS);
 
-       if (mff->account->mark_crosspost_read && MSG_IS_NEWS(msginfo->flags)) {
+       if (mff->account->mark_crosspost_read) {
                line = g_string_sized_new(128);
                g_string_sprintf(line, "%s:%d", msginfo->folder->path, msginfo->msgnum);
                debug_print("nfcp: checking <%s>", line->str);
@@ -5246,6 +5245,7 @@ void summary_reflect_prefs_pixmap_theme(SummaryView *summaryview)
 
        folderview_unselect(summaryview->folderview);
        folderview_select(summaryview->folderview, summaryview->folder_item);
+       summary_set_column_titles(summaryview);
 }
 
 /*
@@ -5311,6 +5311,7 @@ void summary_set_prefs_from_folderitem(SummaryView *summaryview, FolderItem *ite
        summaryview->thread_collapsed = item->thread_collapsed;
 
        /* Scoring */
+#if 0
        if (global_scoring || item->prefs->scoring) {
                summaryview->important_score = prefs_common.important_score;
                if (item->prefs->important_score >
@@ -5318,6 +5319,7 @@ void summary_set_prefs_from_folderitem(SummaryView *summaryview, FolderItem *ite
                        summaryview->important_score =
                                item->prefs->important_score;
        }
+#endif
 }
 
 void summary_save_prefs_to_folderitem(SummaryView *summaryview, FolderItem *item)