correct display recipient on From...
[claws.git] / src / summaryview.c
index bf196cd56abb6730564d197daf073d198fce4571..5872d60e55fdb5aa8a9b9b7b0e20d2702161ce85 100644 (file)
@@ -62,6 +62,7 @@
 #include "prefs_common.h"
 #include "prefs_summary_column.h"
 #include "prefs_filter.h"
+#include "prefs_filtering.h"
 #include "account.h"
 #include "compose.h"
 #include "utils.h"
@@ -376,7 +377,6 @@ static gint summary_cmp_by_label    (GtkCList               *clist,
                                         gconstpointer           ptr1,
                                         gconstpointer           ptr2);
 
-static void news_process_crossposted   (MsgInfo *msginfo);
 static void news_flag_crosspost                (MsgInfo *msginfo);
 
 GtkTargetEntry summary_drag_types[1] =
@@ -692,9 +692,6 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item,
        guint displayed_msgnum = 0;
        GtkCTreeNode *selected_node = summaryview->folderview->selected;
        GSList *cur;
-       gint sort_mode;
-       gint sort_type;
-        static gboolean locked = FALSE;
 
        if (summary_is_locked(summaryview)) return FALSE;
 
@@ -815,7 +812,6 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item,
 
        if (summaryview->folder_item->hide_read_msgs) {
                GSList *not_killed;
-               gint kill_score;
                
                summary_set_hide_read_msgs_menu(summaryview, TRUE);
                not_killed = NULL;
@@ -868,9 +864,6 @@ 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);
 
@@ -904,7 +897,7 @@ gboolean summary_show(SummaryView *summaryview, FolderItem *item,
                }
        } else {
                /* select first unread message */
-               if (sort_mode == SORT_BY_SCORE)
+               if (item->sort_key == SORT_BY_SCORE)
                        node = summary_find_next_important_score(summaryview,
                                                                 NULL);
                else
@@ -1128,7 +1121,7 @@ void summary_select_prev_unread(SummaryView *summaryview)
                (summaryview, summaryview->selected, MSG_UNREAD, FALSE);
 
        if (!node) {
-               AlertValue val;
+               AlertValue val = 0;
 
                switch (prefs_common.next_unread_msg_dialog) {
                        case NEXTUNREADMSGDIALOG_ALWAYS:
@@ -1172,7 +1165,7 @@ void summary_select_next_unread(SummaryView *summaryview)
                node = summary_find_next_flagged_msg
                        (summaryview, NULL, MSG_UNREAD, FALSE);
                if (node == NULL) {
-                       AlertValue val;
+                       AlertValue val = 0;
 
                        switch (prefs_common.next_unread_msg_dialog) {
                                case NEXTUNREADMSGDIALOG_ALWAYS:
@@ -1500,7 +1493,11 @@ static GtkCTreeNode *summary_find_next_flagged_msg(SummaryView *summaryview,
 
        for (; node != NULL; node = gtkut_ctree_node_next(ctree, node)) {
                msginfo = gtk_ctree_node_get_row_data(ctree, node);
-               if ((msginfo->flags.perm_flags & flags) != 0) break;
+               /* Find msg with matching flags but ignore messages with
+                  ignore flags, if searching for new or unread messages */
+               if (!(((flags & (MSG_NEW | MSG_UNREAD)) != 0) && MSG_IS_IGNORE_THREAD(msginfo->flags)) && 
+                       ((msginfo->flags.perm_flags & flags) != 0))
+                       break;
        }
 
        return node;
@@ -1691,10 +1688,6 @@ 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
@@ -1944,7 +1937,7 @@ void summary_sort(SummaryView *summaryview,
        summary_set_column_titles(summaryview);
        summary_set_menu_sensitive(summaryview);
 
-       gtk_ctree_sort_recursive(ctree, NULL);
+       gtk_sctree_sort_recursive(ctree, NULL);
 
        gtk_ctree_node_moveto(ctree, summaryview->selected, -1, 0.5, 0);
 
@@ -1996,14 +1989,11 @@ static void summary_set_ctree_from_list(SummaryView *summaryview,
 {
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        MsgInfo *msginfo;
-       MsgInfo *parentinfo;
-       MsgInfo *cur_msginfo;
-       GtkCTreeNode *node = NULL;
+               GtkCTreeNode *node = NULL;
        GHashTable *msgid_table;
        GHashTable *subject_table;
        GSList * cur;
-       GtkCTreeNode *cur_parent;
-
+       
        if (!mlist) return;
 
        debug_print(_("\tSetting summary from message data..."));
@@ -2240,8 +2230,6 @@ static void summary_set_header(SummaryView *summaryview, gchar *text[],
 {
        static gchar date_modified[80];
        static gchar *to = NULL;
-       static gchar *from_name = NULL;
-       static gchar col_number[11];
        static gchar col_score[11];
        static gchar buf[BUFFSIZE];
        PrefsFolderItem *prefs = summaryview->folder_item->prefs;
@@ -2271,16 +2259,22 @@ static void summary_set_header(SummaryView *summaryview, gchar *text[],
            !MSG_IS_NEWS(msginfo->flags)) {
                gchar *addr = NULL;
 
-               if (prefs_common.use_addr_book) {
-                       Xstrdup_a(addr, msginfo->from, return);
-                       extract_address(addr);
+               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);
                                g_free(to);
                                to   = g_strconcat("-->", addr == NULL ? msginfo->to : addr, NULL);
                                text[col_pos[S_COL_FROM]] = to;
                        }
+               } else {
+                       if (cur_account && cur_account->address && !strcmp( addr, cur_account->address)) {
+                               g_free(to);
+                               to = g_strconcat("-->", msginfo->to, NULL);
+                               text[col_pos[S_COL_FROM]] = to;
+                       }
                }
        }
 
@@ -3739,7 +3733,6 @@ void summary_processing(SummaryView *summaryview, GSList * mlist)
        GSList * processing_list;
        FolderItem * folder_item;
        GSList * cur;
-       gchar * id;
        gchar * buf;
 
        folder_item = summaryview->folder_item;
@@ -4031,7 +4024,6 @@ void summary_filter_open(SummaryView *summaryview, PrefsFilterType type)
 
 void summary_reply(SummaryView *summaryview, ComposeMode mode)
 {
-       GtkWidget *widget;
        GList *sel = GTK_CLIST(summaryview->ctree)->selection;
        MsgInfo *msginfo;
        gchar *text;
@@ -4081,10 +4073,10 @@ void summary_reply(SummaryView *summaryview, ComposeMode mode)
                break;
        case COMPOSE_FORWARD:
                if (prefs_common.forward_as_attachment) {
-                       summary_reply_cb(summaryview, COMPOSE_FORWARD_AS_ATTACH, widget);
+                       summary_reply_cb(summaryview, COMPOSE_FORWARD_AS_ATTACH, NULL);
                        return;
                } else {
-                       summary_reply_cb(summaryview, COMPOSE_FORWARD_INLINE, widget);
+                       summary_reply_cb(summaryview, COMPOSE_FORWARD_INLINE, NULL);
                        return;
                }
                break;
@@ -4934,7 +4926,6 @@ static void news_flag_crosspost(MsgInfo *msginfo)
        GString *line;
        gpointer key;
        gpointer value;
-       MsgPermFlags flags;
        Folder *mff = msginfo->folder->folder;
 
        if (mff->account->mark_crosspost_read && MSG_IS_NEWS(msginfo->flags)) {
@@ -4943,10 +4934,10 @@ static void news_flag_crosspost(MsgInfo *msginfo)
                debug_print(_("nfcp: checking <%s>"), line->str);
                if (mff->newsart && 
                    g_hash_table_lookup_extended(mff->newsart, line->str, &key, &value)) {
-                       debug_print(_(" <%s>"), value);
+                       debug_print(_(" <%s>"), (gchar *)value);
                        if (MSG_IS_NEW(msginfo->flags) || MSG_IS_UNREAD(msginfo->flags)) {
-                               MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_NEW | MSG_UNREAD);
-                               MSG_SET_COLORLABEL_VALUE(msginfo->flags, mff->account->crosspost_col);
+                               procmsg_msginfo_unset_flags(msginfo, MSG_NEW | MSG_UNREAD, 0);
+                               procmsg_msginfo_set_flags(msginfo, mff->account->crosspost_col, 0);
                        }
                        g_hash_table_remove(mff->newsart, key);
                        g_free(key);
@@ -4956,41 +4947,6 @@ static void news_flag_crosspost(MsgInfo *msginfo)
        }
 }
 
-static void news_process_crossposted(MsgInfo *msginfo)
-{
-       gchar **crossref;
-       gchar **crp;
-       gchar *cp;
-       gint cnt;
-       static char *read = "read";
-       Folder *mff = msginfo->folder->folder;
-
-       /* Get the Xref: line */
-       if (msginfo->xref) {
-               /* Retrieve the cross-posted groups and message ids */
-               /* Format of Xref is Xref: server message:id message:id ... */
-               crossref = g_strsplit(msginfo->xref, " ", 1024);
-               for (crp = crossref+2, cnt = 0; *crp; crp++, cnt++) {
-                       if ((cp = strchr(*crp, ':'))) {
-                               *cp = '\0';
-                               if (!strcmp(*crp, msginfo->folder->path)) continue;
-                               *cp = ':';
-
-                               /* On first pass, create a GHashTable to hold the list of
-                                * article numbers per newsgroup that have been read. */
-                               if (!mff->newsart) {
-                                       mff->newsart = g_hash_table_new(g_str_hash, g_str_equal);
-                               }
-                               /* When a summary is selected, the articles for that
-                                * newsgroup are marked based on this entry */
-                               g_hash_table_insert(mff->newsart, g_strdup(*crp), read);
-                               debug_print(_("Cross-reference %d: Hash <%s>\n"), cnt, *crp);
-                       }
-               }
-               g_strfreev(crossref);
-       }
-}
-
 static gint summary_cmp_by_score(GtkCList *clist,
                                 gconstpointer ptr1, gconstpointer ptr2)
 {
@@ -5018,13 +4974,11 @@ static gint summary_cmp_by_locked(GtkCList *clist,
 
 static void summary_select_thread_func(GtkCTree *ctree, GtkCTreeNode *row, gpointer data)
 {
-       SummaryView *summaryview = (SummaryView *) data;
        MsgInfo *msginfo;
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
        gtk_ctree_select(GTK_CTREE(ctree), row);        
-       debug_print(_("Message %d selected\n"),
-           msginfo->msgnum);
+       debug_print(_("Message %d selected\n"), msginfo->msgnum);
 }
 
 /* select current thread */
@@ -5226,24 +5180,22 @@ static void summaryview_subject_filter_init(PrefsFolderItem *prefs)
 
 void summary_reflect_prefs_pixmap_theme(SummaryView *summaryview)
 {
-       GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
-       GtkCList *clist = GTK_CLIST(summaryview->ctree);
-       GtkCTreeNode *node;
+       GtkWidget *ctree = summaryview->ctree;
        GtkWidget *pixmap; 
 
        gtk_widget_destroy(summaryview->folder_pixmap);
 
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_MARK, &markxpm, &markxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_DELETED, &deletedxpm, &deletedxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_NEW, &newxpm, &newxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_UNREAD, &unreadxpm, &unreadxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_REPLIED, &repliedxpm, &repliedxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_FORWARDED, &forwardedxpm, &forwardedxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP, &clipxpm, &clipxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_LOCKED, &lockedxpm, &lockedxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_IGNORETHREAD, &ignorethreadxpm, &ignorethreadxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP_KEY, &clipkeyxpm, &clipkeyxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_KEY, &keyxpm, &keyxpmmask);
+       stock_pixmap_gdk(ctree, STOCK_PIXMAP_MARK, &markxpm, &markxpmmask);
+       stock_pixmap_gdk(ctree, STOCK_PIXMAP_DELETED, &deletedxpm, &deletedxpmmask);
+       stock_pixmap_gdk(ctree, STOCK_PIXMAP_NEW, &newxpm, &newxpmmask);
+       stock_pixmap_gdk(ctree, STOCK_PIXMAP_UNREAD, &unreadxpm, &unreadxpmmask);
+       stock_pixmap_gdk(ctree, STOCK_PIXMAP_REPLIED, &repliedxpm, &repliedxpmmask);
+       stock_pixmap_gdk(ctree, STOCK_PIXMAP_FORWARDED, &forwardedxpm, &forwardedxpmmask);
+       stock_pixmap_gdk(ctree, STOCK_PIXMAP_CLIP, &clipxpm, &clipxpmmask);
+       stock_pixmap_gdk(ctree, STOCK_PIXMAP_LOCKED, &lockedxpm, &lockedxpmmask);
+       stock_pixmap_gdk(ctree, STOCK_PIXMAP_IGNORETHREAD, &ignorethreadxpm, &ignorethreadxpmmask);
+       stock_pixmap_gdk(ctree, STOCK_PIXMAP_CLIP_KEY, &clipkeyxpm, &clipkeyxpmmask);
+       stock_pixmap_gdk(ctree, STOCK_PIXMAP_KEY, &keyxpm, &keyxpmmask);
 
        pixmap = stock_pixmap_widget(summaryview->hbox, STOCK_PIXMAP_DIR_OPEN);
        gtk_box_pack_start(GTK_BOX(summaryview->hbox), pixmap, FALSE, FALSE, 4);