0.8.8claws120
[claws.git] / src / summaryview.c
index 3d2f36e23e7343518521fb386c9b402ca6afefef..466733879d71617d5d18bc4f5a928f640d8105bb 100644 (file)
@@ -503,7 +503,7 @@ static gchar *search_descr_strings[] = {
        "Sg #",  N_("messages whose size is greater than #"),
        "Ss #",  N_("messages whose size is smaller than #"),
        "t S",   N_("messages which have been sent to S"),
-       "T",     N_("marked marked"),
+       "T",     N_("marked messages"),
        "U",     N_("unread messages"),
        "x S",   N_("messages which contain S in References header"),
        "y S",   N_("messages which contain S in X-Label header"),
@@ -1923,11 +1923,11 @@ static void summary_status_show(SummaryView *summaryview)
                n_selected++;
        }
 
-       if (summaryview->folder_item->folder->type == F_NEWS &&
-           prefs_common.ng_abbrev_len < strlen(summaryview->folder_item->path)) {
+       if (summaryview->folder_item->folder->type == F_NEWS) {
                gchar *group;
                group = get_abbrev_newsgroup_name
-                       (g_basename(summaryview->folder_item->path), prefs_common.ng_abbrev_len);
+                       (g_basename(summaryview->folder_item->path),
+                        prefs_common.ng_abbrev_len);
                gtk_label_set(GTK_LABEL(summaryview->statlabel_folder), group);
                g_free(group);
        } else {
@@ -2753,51 +2753,21 @@ void summary_set_marks_selected(SummaryView *summaryview)
                summary_set_row_marks(summaryview, GTK_CTREE_NODE(cur->data));
 }
 
-static gboolean summary_update_unread_children (SummaryView *summaryview, MsgInfo *info, gboolean newly_marked)
-{
-       GSList *children = procmsg_find_children(info);
-       GSList *cur;
-       gboolean changed = FALSE;
-       for (cur = children; cur != NULL; cur = g_slist_next(cur)) {
-               MsgInfo *tmp = (MsgInfo *)cur->data;
-               if(MSG_IS_UNREAD(tmp->flags) && !MSG_IS_IGNORE_THREAD(tmp->flags)) {
-                       if(newly_marked) 
-                               summaryview->unreadmarked++;
-                       else
-                               summaryview->unreadmarked--;
-                       changed = TRUE;
-               }
-               procmsg_msginfo_free(tmp);
-       }
-       return changed;
-}
-
 static void summary_mark_row(SummaryView *summaryview, GtkCTreeNode *row)
 {
-       gboolean changed = FALSE;
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        MsgInfo *msginfo;
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
        if (MSG_IS_DELETED(msginfo->flags))
                summaryview->deleted--;
-       if (MSG_IS_MOVE(msginfo->flags)) {
+       if (MSG_IS_MOVE(msginfo->flags))
                summaryview->moved--;
-               changed = TRUE;
-               msginfo->to_folder->op_count--;
-               if (msginfo->to_folder->op_count == 0)
-                       folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-       }
-       if (MSG_IS_COPY(msginfo->flags)) {
+       if (MSG_IS_COPY(msginfo->flags))
                summaryview->copied--;
-               changed = TRUE;
-               msginfo->to_folder->op_count--;
-               if (msginfo->to_folder->op_count == 0)
-                       folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-       }
-       changed |= summary_update_unread_children (summaryview, msginfo, TRUE);
+       procmsg_update_unread_children (msginfo, TRUE);
 
-       msginfo->to_folder = NULL;
+       procmsg_msginfo_set_to_folder(msginfo, NULL);
        procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, MSG_MOVE | MSG_COPY);
        procmsg_msginfo_set_flags(msginfo, MSG_MARKED, 0);
        summary_set_row_marks(summaryview, row);
@@ -2822,12 +2792,7 @@ static void summary_lock_row(SummaryView *summaryview, GtkCTreeNode *row)
                summaryview->copied--;
                changed = TRUE;
        }
-       if (changed && !prefs_common.immediate_exec) {
-               msginfo->to_folder->op_count--;
-               if (msginfo->to_folder->op_count == 0)
-                       folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-       }
-       msginfo->to_folder = NULL;
+       procmsg_msginfo_set_to_folder(msginfo, NULL);
        procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, MSG_MOVE | MSG_COPY);
        procmsg_msginfo_set_flags(msginfo, MSG_LOCKED, 0);
        summary_set_row_marks(summaryview, row);
@@ -2911,7 +2876,7 @@ static void summary_mark_row_as_unread(SummaryView *summaryview,
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
        if (MSG_IS_DELETED(msginfo->flags)) {
-               msginfo->to_folder = NULL;
+               procmsg_msginfo_set_to_folder(msginfo, NULL);
                procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, 0);
                summaryview->deleted--;
        }
@@ -2994,7 +2959,6 @@ static gboolean check_permission(SummaryView *summaryview, MsgInfo * msginfo)
 
 static void summary_delete_row(SummaryView *summaryview, GtkCTreeNode *row)
 {
-       gboolean changed = FALSE;
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        MsgInfo *msginfo;
 
@@ -3007,23 +2971,13 @@ static void summary_delete_row(SummaryView *summaryview, GtkCTreeNode *row)
 
        if (MSG_IS_DELETED(msginfo->flags)) return;
 
-       if (MSG_IS_MOVE(msginfo->flags)) {
+       if (MSG_IS_MOVE(msginfo->flags))
                summaryview->moved--;
-               changed = TRUE;
-               msginfo->to_folder->op_count--;
-               if (msginfo->to_folder->op_count == 0)
-                       folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-       }
-       if (MSG_IS_COPY(msginfo->flags)) {
+       if (MSG_IS_COPY(msginfo->flags))
                summaryview->copied--;
-               changed = TRUE;
-               msginfo->to_folder->op_count--;
-               if (msginfo->to_folder->op_count == 0)
-                       folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-       }
-       changed |= summary_update_unread_children (summaryview, msginfo, FALSE);
+       procmsg_update_unread_children (msginfo, FALSE);
 
-       msginfo->to_folder = NULL;
+       procmsg_msginfo_set_to_folder(msginfo, NULL);
        procmsg_msginfo_unset_flags(msginfo, MSG_MARKED, MSG_MOVE | MSG_COPY);
        procmsg_msginfo_set_flags(msginfo, MSG_DELETED, 0);
        summaryview->deleted++;
@@ -3091,10 +3045,12 @@ void summary_delete(SummaryView *summaryview)
 
        /* next code sets current row focus right. We need to find a row
         * that is not deleted. */
+       folder_item_update_freeze();     
        for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next) {
                sel_last = GTK_CTREE_NODE(cur->data);
                summary_delete_row(summaryview, sel_last);
        }
+       folder_item_update_thaw();
 
        node = summary_find_next_msg(summaryview, sel_last);
        if (!node)
@@ -3168,34 +3124,19 @@ static void summary_delete_duplicated_func(GtkCTree *ctree, GtkCTreeNode *node,
 
 static void summary_unmark_row(SummaryView *summaryview, GtkCTreeNode *row)
 {
-       gboolean changed = FALSE;
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        MsgInfo *msginfo;
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
        if (MSG_IS_DELETED(msginfo->flags))
                summaryview->deleted--;
-       if (MSG_IS_MOVE(msginfo->flags)) {
-               if (!prefs_common.immediate_exec) {
-                       msginfo->to_folder->op_count--;
-                       if (msginfo->to_folder->op_count == 0)
-                               folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-               }
+       if (MSG_IS_MOVE(msginfo->flags))
                summaryview->moved--;
-               changed = TRUE;
-       }
-       if (MSG_IS_COPY(msginfo->flags)) {
-               if (!prefs_common.immediate_exec) {
-                       msginfo->to_folder->op_count--;
-                       if (msginfo->to_folder->op_count == 0)
-                               folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-               }
+       if (MSG_IS_COPY(msginfo->flags))
                summaryview->copied--;
-               changed = TRUE;
-       }
-       changed |= summary_update_unread_children (summaryview, msginfo, FALSE);
+       procmsg_update_unread_children (msginfo, FALSE);
 
-       msginfo->to_folder = NULL;
+       procmsg_msginfo_set_to_folder(msginfo, NULL);
        procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_MOVE | MSG_COPY);
        summary_set_row_marks(summaryview, row);
 
@@ -3217,43 +3158,25 @@ void summary_unmark(SummaryView *summaryview)
 static void summary_move_row_to(SummaryView *summaryview, GtkCTreeNode *row,
                                FolderItem *to_folder)
 {
-       gboolean changed = FALSE;
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        MsgInfo *msginfo;
 
        g_return_if_fail(to_folder != NULL);
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
-       if (MSG_IS_MOVE(msginfo->flags)) {
-               if (!prefs_common.immediate_exec) {
-                       msginfo->to_folder->op_count--;
-                       if (msginfo->to_folder->op_count == 0) {
-                               folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-                               changed = TRUE;
-                       }
-               }
-       }
-       msginfo->to_folder = to_folder;
+       procmsg_msginfo_set_to_folder(msginfo, to_folder);
        if (MSG_IS_DELETED(msginfo->flags))
                summaryview->deleted--;
        if (MSG_IS_COPY(msginfo->flags)) {
                summaryview->copied--;
-               if (!prefs_common.immediate_exec)
-                       msginfo->to_folder->op_count--;
        }
        procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_COPY);
        if (!MSG_IS_MOVE(msginfo->flags)) {
                procmsg_msginfo_set_flags(msginfo, 0, MSG_MOVE);
                summaryview->moved++;
-               changed = TRUE;
        }
        if (!prefs_common.immediate_exec) {
                summary_set_row_marks(summaryview, row);
-               if (changed) {
-                       msginfo->to_folder->op_count++;
-                       if (msginfo->to_folder->op_count == 1)
-                               folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-               }
        }
 
        debug_print("Message %d is set to move to %s\n",
@@ -3312,42 +3235,25 @@ void summary_move_to(SummaryView *summaryview)
 static void summary_copy_row_to(SummaryView *summaryview, GtkCTreeNode *row,
                                FolderItem *to_folder)
 {
-       gboolean changed = FALSE;
        GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
        MsgInfo *msginfo;
 
        g_return_if_fail(to_folder != NULL);
 
        msginfo = gtk_ctree_node_get_row_data(ctree, row);
-       if (MSG_IS_COPY(msginfo->flags)) {
-               if (!prefs_common.immediate_exec) {
-                       msginfo->to_folder->op_count--;
-                       if (msginfo->to_folder->op_count == 0) {
-                               changed = TRUE;
-                       }
-               }
-       }
-       msginfo->to_folder = to_folder;
+       procmsg_msginfo_set_to_folder(msginfo, to_folder);
        if (MSG_IS_DELETED(msginfo->flags))
                summaryview->deleted--;
        if (MSG_IS_MOVE(msginfo->flags)) {
                summaryview->moved--;
-               if (!prefs_common.immediate_exec)
-                       msginfo->to_folder->op_count--;
        }
        procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_MOVE);
        if (!MSG_IS_COPY(msginfo->flags)) {
                procmsg_msginfo_set_flags(msginfo, 0, MSG_COPY);
                summaryview->copied++;
-               changed = TRUE;
        }
        if (!prefs_common.immediate_exec) {
                summary_set_row_marks(summaryview, row);
-               if (changed) {
-                       msginfo->to_folder->op_count++;
-                       if (msginfo->to_folder->op_count == 1)
-                               folder_item_update(msginfo->to_folder, F_ITEM_UPDATE_MSGCNT);
-               }
        }
 
        debug_print("Message %d is set to copy to %s\n",
@@ -3558,9 +3464,11 @@ gboolean summary_execute(SummaryView *summaryview)
        if (summaryview->threaded)
                summary_unthread_for_exec(summaryview);
 
+       folder_item_update_freeze();
        summary_execute_move(summaryview);
        summary_execute_copy(summaryview);
        summary_execute_delete(summaryview);
+       folder_item_update_thaw();
 
        node = GTK_CTREE_NODE(clist->row_list);
        while (node != NULL) {
@@ -3630,10 +3538,6 @@ static void summary_execute_move_func(GtkCTree *ctree, GtkCTreeNode *node,
        msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
 
        if (msginfo && MSG_IS_MOVE(msginfo->flags) && msginfo->to_folder) {
-               if (!prefs_common.immediate_exec &&
-                   msginfo->to_folder->op_count > 0)
-                       msginfo->to_folder->op_count--;
-
                summaryview->mlist =
                        g_slist_append(summaryview->mlist, msginfo);
                gtk_ctree_node_set_row_data(ctree, node, NULL);
@@ -3671,10 +3575,6 @@ static void summary_execute_copy_func(GtkCTree *ctree, GtkCTreeNode *node,
        msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
 
        if (msginfo && MSG_IS_COPY(msginfo->flags) && msginfo->to_folder) {
-               if (!prefs_common.immediate_exec &&
-                   msginfo->to_folder->op_count > 0)
-                       msginfo->to_folder->op_count--;
-
                summaryview->mlist =
                        g_slist_append(summaryview->mlist, msginfo);
 
@@ -5528,7 +5428,10 @@ static void summary_find_answers (SummaryView *summaryview, MsgInfo *msg)
                folderview_select(summaryview->mainwin->folderview, sent_folder);
        }
        
+       gtk_option_menu_set_history(GTK_OPTION_MENU(summaryview->search_type_opt),
+                                   S_SEARCH_EXTENDED);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(summaryview->toggle_search), TRUE);
+
        gtk_entry_set_text(GTK_ENTRY(summaryview->search_string), buf);
        g_free(buf);
        summary_show(summaryview, summaryview->folder_item);