2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2002 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkscrolledwindow.h>
25 #include <gtk/gtkwidget.h>
26 #include <gtk/gtkpixmap.h>
27 #include <gtk/gtkctree.h>
28 #include <gtk/gtkcontainer.h>
29 #include <gtk/gtksignal.h>
30 #include <gtk/gtktext.h>
31 #include <gtk/gtkmenu.h>
32 #include <gtk/gtkmenuitem.h>
33 #include <gtk/gtkitemfactory.h>
34 #include <gtk/gtkvbox.h>
35 #include <gtk/gtkhbox.h>
36 #include <gtk/gtkwindow.h>
37 #include <gtk/gtkstyle.h>
38 #include <gtk/gtkarrow.h>
39 #include <gtk/gtkeventbox.h>
40 #include <gtk/gtkstatusbar.h>
41 #include <gtk/gtkmenuitem.h>
54 #include "mainwindow.h"
55 #include "folderview.h"
56 #include "summaryview.h"
57 #include "messageview.h"
58 #include "foldersel.h"
60 #include "procheader.h"
61 #include "sourcewindow.h"
62 #include "prefs_common.h"
63 #include "prefs_summary_column.h"
64 #include "prefs_filter.h"
65 #include "prefs_filtering.h"
70 #include "stock_pixmap.h"
72 #include "alertpanel.h"
73 #include "inputdialog.h"
74 #include "statusbar.h"
77 #include "colorlabel.h"
80 #include "addressbook.h"
81 #include "addr_compl.h"
83 #include "prefs_folder_item.h"
84 #include "filtering.h"
85 #include "string_match.h"
87 #define STATUSBAR_PUSH(mainwin, str) \
89 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
90 mainwin->summaryview_cid, str); \
91 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
94 #define STATUSBAR_POP(mainwin) \
96 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
97 mainwin->summaryview_cid); \
100 #define SUMMARY_COL_MARK_WIDTH 10
101 #define SUMMARY_COL_UNREAD_WIDTH 13
102 #define SUMMARY_COL_LOCKED_WIDTH 13
103 #define SUMMARY_COL_MIME_WIDTH 11
105 static GdkFont *boldfont;
106 static GdkFont *smallfont;
108 static GtkStyle *bold_style;
109 static GtkStyle *bold_marked_style;
110 static GtkStyle *bold_deleted_style;
111 static GtkStyle *small_style;
112 static GtkStyle *small_marked_style;
113 static GtkStyle *small_deleted_style;
115 static GdkPixmap *markxpm;
116 static GdkBitmap *markxpmmask;
117 static GdkPixmap *deletedxpm;
118 static GdkBitmap *deletedxpmmask;
120 static GdkPixmap *newxpm;
121 static GdkBitmap *newxpmmask;
122 static GdkPixmap *unreadxpm;
123 static GdkBitmap *unreadxpmmask;
124 static GdkPixmap *repliedxpm;
125 static GdkBitmap *repliedxpmmask;
126 static GdkPixmap *forwardedxpm;
127 static GdkBitmap *forwardedxpmmask;
128 static GdkPixmap *ignorethreadxpm;
129 static GdkBitmap *ignorethreadxpmmask;
130 static GdkPixmap *lockedxpm;
131 static GdkBitmap *lockedxpmmask;
133 static GdkPixmap *clipxpm;
134 static GdkBitmap *clipxpmmask;
135 static GdkPixmap *keyxpm;
136 static GdkBitmap *keyxpmmask;
137 static GdkPixmap *clipkeyxpm;
138 static GdkBitmap *clipkeyxpmmask;
140 static void summary_free_msginfo_func (GtkCTree *ctree,
143 static void summary_set_marks_func (GtkCTree *ctree,
146 static void summary_write_cache_func (GtkCTree *ctree,
150 static void summary_set_menu_sensitive (SummaryView *summaryview);
152 static void summary_set_hide_read_msgs_menu (SummaryView *summaryview,
155 static guint summary_get_msgnum (SummaryView *summaryview,
158 static GtkCTreeNode *summary_find_prev_msg
159 (SummaryView *summaryview,
160 GtkCTreeNode *current_node);
161 static GtkCTreeNode *summary_find_next_msg
162 (SummaryView *summaryview,
163 GtkCTreeNode *current_node);
165 static GtkCTreeNode *summary_find_prev_flagged_msg
166 (SummaryView *summaryview,
167 GtkCTreeNode *current_node,
169 gboolean start_from_prev);
170 static GtkCTreeNode *summary_find_next_flagged_msg
171 (SummaryView *summaryview,
172 GtkCTreeNode *current_node,
174 gboolean start_from_next);
176 static GtkCTreeNode *summary_find_msg_by_msgnum
177 (SummaryView *summaryview,
180 static void summary_update_status (SummaryView *summaryview);
182 /* display functions */
183 static void summary_status_show (SummaryView *summaryview);
184 static void summary_set_column_titles (SummaryView *summaryview);
185 static void summary_set_ctree_from_list (SummaryView *summaryview,
187 static void summary_set_header (SummaryView *summaryview,
190 static void summary_display_msg (SummaryView *summaryview,
192 static void summary_display_msg_full (SummaryView *summaryview,
195 gboolean all_headers);
196 static void summary_set_row_marks (SummaryView *summaryview,
198 static void summaryview_subject_filter_init (PrefsFolderItem *prefs);
200 /* message handling */
201 static void summary_mark_row (SummaryView *summaryview,
203 static void summary_lock_row (SummaryView *summaryview,
205 static void summary_mark_row_as_read (SummaryView *summaryview,
207 static void summary_mark_row_as_unread (SummaryView *summaryview,
209 static void summary_delete_row (SummaryView *summaryview,
211 static void summary_unmark_row (SummaryView *summaryview,
213 static void summary_move_row_to (SummaryView *summaryview,
215 FolderItem *to_folder);
216 static void summary_copy_row_to (SummaryView *summaryview,
218 FolderItem *to_folder);
220 static void summary_delete_duplicated_func
223 SummaryView *summaryview);
225 static void summary_execute_move (SummaryView *summaryview);
226 static void summary_execute_move_func (GtkCTree *ctree,
229 static void summary_execute_copy (SummaryView *summaryview);
230 static void summary_execute_copy_func (GtkCTree *ctree,
233 static void summary_execute_delete (SummaryView *summaryview);
234 static void summary_execute_delete_func (GtkCTree *ctree,
238 static void summary_thread_init (SummaryView *summaryview);
239 static void summary_ignore_thread (SummaryView *summaryview);
240 static void summary_unignore_thread (SummaryView *summaryview);
242 static void summary_unthread_for_exec (SummaryView *summaryview);
243 static void summary_unthread_for_exec_func (GtkCTree *ctree,
247 void summary_simplify_subject(SummaryView *summaryview, gchar * rexp,
250 void summary_processing(SummaryView *summaryview, GSList * mlist);
251 static void summary_filter_func (GtkCTree *ctree,
255 static void summary_colorlabel_menu_item_activate_cb
258 static void summary_colorlabel_menu_item_activate_item_cb
259 (GtkMenuItem *label_menu_item,
261 static void summary_colorlabel_menu_create(SummaryView *summaryview);
263 static GtkWidget *summary_ctree_create (SummaryView *summaryview);
265 /* callback functions */
266 static void summary_toggle_pressed (GtkWidget *eventbox,
267 GdkEventButton *event,
268 SummaryView *summaryview);
269 static void summary_button_pressed (GtkWidget *ctree,
270 GdkEventButton *event,
271 SummaryView *summaryview);
272 static void summary_button_released (GtkWidget *ctree,
273 GdkEventButton *event,
274 SummaryView *summaryview);
275 static void summary_key_pressed (GtkWidget *ctree,
277 SummaryView *summaryview);
278 static void summary_open_row (GtkSCTree *sctree,
279 SummaryView *summaryview);
280 static void summary_tree_expanded (GtkCTree *ctree,
282 SummaryView *summaryview);
283 static void summary_tree_collapsed (GtkCTree *ctree,
285 SummaryView *summaryview);
286 static void summary_selected (GtkCTree *ctree,
289 SummaryView *summaryview);
290 static void summary_col_resized (GtkCList *clist,
293 SummaryView *summaryview);
294 static void summary_reply_cb (SummaryView *summaryview,
297 static void summary_execute_cb (SummaryView *summaryview,
300 static void summary_show_all_header_cb (SummaryView *summaryview,
304 static void summary_add_address_cb (SummaryView *summaryview,
307 static void summary_create_filter_cb (SummaryView *summaryview,
311 static void summary_mark_clicked (GtkWidget *button,
312 SummaryView *summaryview);
313 static void summary_unread_clicked (GtkWidget *button,
314 SummaryView *summaryview);
315 static void summary_mime_clicked (GtkWidget *button,
316 SummaryView *summaryview);
317 static void summary_num_clicked (GtkWidget *button,
318 SummaryView *summaryview);
319 static void summary_score_clicked (GtkWidget *button,
320 SummaryView *summaryview);
321 static void summary_size_clicked (GtkWidget *button,
322 SummaryView *summaryview);
323 static void summary_date_clicked (GtkWidget *button,
324 SummaryView *summaryview);
325 static void summary_from_clicked (GtkWidget *button,
326 SummaryView *summaryview);
327 static void summary_subject_clicked (GtkWidget *button,
328 SummaryView *summaryview);
329 static void summary_score_clicked (GtkWidget *button,
330 SummaryView *summaryview);
331 static void summary_locked_clicked (GtkWidget *button,
332 SummaryView *summaryview);
334 static void summary_start_drag (GtkWidget *widget,
337 SummaryView *summaryview);
338 static void summary_drag_data_get (GtkWidget *widget,
339 GdkDragContext *drag_context,
340 GtkSelectionData *selection_data,
343 SummaryView *summaryview);
345 /* custom compare functions for sorting */
347 static gint summary_cmp_by_mark (GtkCList *clist,
350 static gint summary_cmp_by_unread (GtkCList *clist,
353 static gint summary_cmp_by_mime (GtkCList *clist,
356 static gint summary_cmp_by_num (GtkCList *clist,
359 static gint summary_cmp_by_size (GtkCList *clist,
362 static gint summary_cmp_by_date (GtkCList *clist,
365 static gint summary_cmp_by_from (GtkCList *clist,
368 static gint summary_cmp_by_subject (GtkCList *clist,
371 static gint summary_cmp_by_score (GtkCList *clist,
374 static gint summary_cmp_by_locked (GtkCList *clist,
375 gconstpointer ptr1, gconstpointer ptr2);
376 static gint summary_cmp_by_label (GtkCList *clist,
380 static void news_flag_crosspost (MsgInfo *msginfo);
382 GtkTargetEntry summary_drag_types[1] =
384 {"text/plain", GTK_TARGET_SAME_APP, TARGET_DUMMY}
387 static GtkItemFactoryEntry summary_popup_entries[] =
389 {N_("/_Reply"), NULL, summary_reply_cb, COMPOSE_REPLY, NULL},
390 {N_("/Repl_y to sender"), NULL, summary_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
391 {N_("/Follow-up and reply to"), NULL, summary_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
392 {N_("/Reply to a_ll"), NULL, summary_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
393 {N_("/_Forward"), NULL, summary_reply_cb, COMPOSE_FORWARD, NULL},
394 {N_("/Redirect"), NULL, summary_reply_cb, COMPOSE_REDIRECT, NULL},
395 {N_("/---"), NULL, NULL, 0, "<Separator>"},
396 {N_("/Re-_edit"), NULL, summary_reedit, 0, NULL},
397 {N_("/---"), NULL, NULL, 0, "<Separator>"},
398 {N_("/Select _thread"), NULL, summary_select_thread, 0, NULL},
399 {N_("/Select _all"), NULL, summary_select_all, 0, NULL},
400 {N_("/---"), NULL, NULL, 0, "<Separator>"},
401 {N_("/M_ove..."), NULL, summary_move_to, 0, NULL},
402 {N_("/_Copy..."), NULL, summary_copy_to, 0, NULL},
403 {N_("/_Delete"), NULL, summary_delete, 0, NULL},
404 {N_("/E_xecute"), NULL, summary_execute_cb, 0, NULL},
405 {N_("/---"), NULL, NULL, 0, "<Separator>"},
406 {N_("/_Mark"), NULL, NULL, 0, "<Branch>"},
407 {N_("/_Mark/_Mark"), NULL, summary_mark, 0, NULL},
408 {N_("/_Mark/_Unmark"), NULL, summary_unmark, 0, NULL},
409 {N_("/_Mark/---"), NULL, NULL, 0, "<Separator>"},
410 {N_("/_Mark/Mark as unr_ead"), NULL, summary_mark_as_unread, 0, NULL},
411 {N_("/_Mark/Mark as rea_d"), NULL, summary_mark_as_read, 0, NULL},
412 {N_("/_Mark/Mark all read"), NULL, summary_mark_all_read, 0, NULL},
413 {N_("/_Mark/Ignore thread"), NULL, summary_ignore_thread, 0, NULL},
414 {N_("/_Mark/Unignore thread"), NULL, summary_unignore_thread, 0, NULL},
415 {N_("/Color la_bel"), NULL, NULL, 0, NULL},
417 {N_("/---"), NULL, NULL, 0, "<Separator>"},
418 {N_("/Add sender to address boo_k"),
419 NULL, summary_add_address_cb, 0, NULL},
420 {N_("/Create f_ilter rule"), NULL, NULL, 0, "<Branch>"},
421 {N_("/Create f_ilter rule/_Automatically"),
422 NULL, summary_create_filter_cb, FILTER_BY_AUTO, NULL},
423 {N_("/Create f_ilter rule/by _From"),
424 NULL, summary_create_filter_cb, FILTER_BY_FROM, NULL},
425 {N_("/Create f_ilter rule/by _To"),
426 NULL, summary_create_filter_cb, FILTER_BY_TO, NULL},
427 {N_("/Create f_ilter rule/by _Subject"),
428 NULL, summary_create_filter_cb, FILTER_BY_SUBJECT, NULL},
429 {N_("/---"), NULL, NULL, 0, "<Separator>"},
430 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
431 {N_("/_View/Open in new _window"),
432 NULL, summary_open_msg, 0, NULL},
433 {N_("/_View/_Source"), NULL, summary_view_source, 0, NULL},
434 {N_("/_View/All _header"), NULL, summary_show_all_header_cb, 0, "<ToggleItem>"},
435 {N_("/---"), NULL, NULL, 0, "<Separator>"},
436 {N_("/_Save as..."), NULL, summary_save_as, 0, NULL},
437 {N_("/_Print..."), NULL, summary_print, 0, NULL},
440 static const gchar *const col_label[N_SUMMARY_COLS] = {
441 N_("M"), /* S_COL_MARK */
442 N_("U"), /* S_COL_UNREAD */
444 N_("Subject"), /* S_COL_SUBJECT */
445 N_("From"), /* S_COL_FROM */
446 N_("Date"), /* S_COL_DATE */
447 N_("Size"), /* S_COL_SIZE */
448 N_("No."), /* S_COL_NUMBER */
449 N_("Score"), /* S_COL_SCORE */
450 N_("L") /* S_COL_LOCKED */
453 SummaryView *summary_create(void)
455 SummaryView *summaryview;
457 GtkWidget *scrolledwin;
461 GtkWidget *statlabel_folder;
462 GtkWidget *statlabel_select;
463 GtkWidget *statlabel_msgs;
465 GtkWidget *toggle_eventbox;
466 GtkWidget *toggle_arrow;
467 GtkWidget *popupmenu;
468 GtkItemFactory *popupfactory;
471 debug_print(_("Creating summary view...\n"));
472 summaryview = g_new0(SummaryView, 1);
474 vbox = gtk_vbox_new(FALSE, 2);
476 scrolledwin = gtk_scrolled_window_new(NULL, NULL);
477 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
478 GTK_POLICY_AUTOMATIC,
480 gtk_box_pack_start(GTK_BOX(vbox), scrolledwin, TRUE, TRUE, 0);
481 gtk_widget_set_usize(vbox,
482 prefs_common.summaryview_width,
483 prefs_common.summaryview_height);
485 ctree = summary_ctree_create(summaryview);
487 gtk_scrolled_window_set_hadjustment(GTK_SCROLLED_WINDOW(scrolledwin),
488 GTK_CLIST(ctree)->hadjustment);
489 gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(scrolledwin),
490 GTK_CLIST(ctree)->vadjustment);
491 gtk_container_add(GTK_CONTAINER(scrolledwin), ctree);
493 /* create status label */
494 hbox = gtk_hbox_new(FALSE, 0);
495 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
497 hbox_l = gtk_hbox_new(FALSE, 0);
498 gtk_box_pack_start(GTK_BOX(hbox), hbox_l, TRUE, TRUE, 0);
500 statlabel_folder = gtk_label_new("");
501 gtk_box_pack_start(GTK_BOX(hbox_l), statlabel_folder, FALSE, FALSE, 2);
502 statlabel_select = gtk_label_new("");
503 gtk_box_pack_start(GTK_BOX(hbox_l), statlabel_select, FALSE, FALSE, 12);
505 /* toggle view button */
506 toggle_eventbox = gtk_event_box_new();
507 gtk_box_pack_end(GTK_BOX(hbox), toggle_eventbox, FALSE, FALSE, 4);
508 toggle_arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
509 gtk_container_add(GTK_CONTAINER(toggle_eventbox), toggle_arrow);
510 gtk_signal_connect(GTK_OBJECT(toggle_eventbox), "button_press_event",
511 GTK_SIGNAL_FUNC(summary_toggle_pressed),
514 statlabel_msgs = gtk_label_new("");
515 gtk_box_pack_end(GTK_BOX(hbox), statlabel_msgs, FALSE, FALSE, 4);
517 hbox_spc = gtk_hbox_new(FALSE, 0);
518 gtk_box_pack_end(GTK_BOX(hbox), hbox_spc, FALSE, FALSE, 6);
520 /* create popup menu */
521 n_entries = sizeof(summary_popup_entries) /
522 sizeof(summary_popup_entries[0]);
523 popupmenu = menu_create_items(summary_popup_entries, n_entries,
524 "<SummaryView>", &popupfactory,
527 summaryview->vbox = vbox;
528 summaryview->scrolledwin = scrolledwin;
529 summaryview->ctree = ctree;
530 summaryview->hbox = hbox;
531 summaryview->hbox_l = hbox_l;
532 summaryview->statlabel_folder = statlabel_folder;
533 summaryview->statlabel_select = statlabel_select;
534 summaryview->statlabel_msgs = statlabel_msgs;
535 summaryview->toggle_eventbox = toggle_eventbox;
536 summaryview->toggle_arrow = toggle_arrow;
537 summaryview->popupmenu = popupmenu;
538 summaryview->popupfactory = popupfactory;
539 summaryview->lock_count = 0;
541 gtk_widget_show_all(vbox);
546 void summary_init(SummaryView *summaryview)
551 stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_MARK,
552 &markxpm, &markxpmmask);
553 stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_DELETED,
554 &deletedxpm, &deletedxpmmask);
555 stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_NEW,
556 &newxpm, &newxpmmask);
557 stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_UNREAD,
558 &unreadxpm, &unreadxpmmask);
559 stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_REPLIED,
560 &repliedxpm, &repliedxpmmask);
561 stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_FORWARDED,
562 &forwardedxpm, &forwardedxpmmask);
563 stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP,
564 &clipxpm, &clipxpmmask);
565 stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_LOCKED,
566 &lockedxpm, &lockedxpmmask);
567 stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_IGNORETHREAD,
568 &ignorethreadxpm, &ignorethreadxpmmask);
569 stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP_KEY,
570 &clipkeyxpm, &clipkeyxpmmask);
571 stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_KEY,
572 &keyxpm, &keyxpmmask);
575 small_style = gtk_style_copy
576 (gtk_widget_get_style(summaryview->ctree));
578 smallfont = gdk_fontset_load(SMALL_FONT);
579 small_style->font = smallfont;
580 small_marked_style = gtk_style_copy(small_style);
581 small_marked_style->fg[GTK_STATE_NORMAL] =
582 summaryview->color_marked;
583 small_deleted_style = gtk_style_copy(small_style);
584 small_deleted_style->fg[GTK_STATE_NORMAL] =
585 summaryview->color_dim;
588 bold_style = gtk_style_copy
589 (gtk_widget_get_style(summaryview->ctree));
591 boldfont = gdk_fontset_load(BOLD_FONT);
592 bold_style->font = boldfont;
593 bold_marked_style = gtk_style_copy(bold_style);
594 bold_marked_style->fg[GTK_STATE_NORMAL] =
595 summaryview->color_marked;
596 bold_deleted_style = gtk_style_copy(bold_style);
597 bold_deleted_style->fg[GTK_STATE_NORMAL] =
598 summaryview->color_dim;
601 style = gtk_style_copy(gtk_widget_get_style
602 (summaryview->statlabel_folder));
604 gtk_widget_set_style(summaryview->statlabel_folder, style);
605 gtk_widget_set_style(summaryview->statlabel_select, style);
606 gtk_widget_set_style(summaryview->statlabel_msgs, style);
608 pixmap = stock_pixmap_widget(summaryview->hbox_l, STOCK_PIXMAP_DIR_OPEN);
609 gtk_box_pack_start(GTK_BOX(summaryview->hbox_l), pixmap, FALSE, FALSE, 4);
610 gtk_box_reorder_child(GTK_BOX(summaryview->hbox_l), pixmap, 0);
611 gtk_widget_show(pixmap);
612 summaryview->folder_pixmap = pixmap;
614 summary_clear_list(summaryview);
615 summary_set_column_titles(summaryview);
616 summary_colorlabel_menu_create(summaryview);
617 summary_set_menu_sensitive(summaryview);
621 GtkCTreeNode * summary_find_next_important_score(SummaryView *summaryview,
622 GtkCTreeNode *current_node)
624 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
627 gint best_score = MIN_SCORE;
628 GtkCTreeNode *best_node = NULL;
631 /*node = current_node;*/
632 node = GTK_CTREE_NODE_NEXT(current_node);
634 node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
636 for (; node != NULL; node = GTK_CTREE_NODE_NEXT(node)) {
637 msginfo = gtk_ctree_node_get_row_data(ctree, node);
638 if (msginfo->score >= summaryview->important_score)
640 if (msginfo->score > best_score) {
641 best_score = msginfo->score;
652 GtkCTreeNode * summary_find_prev_important_score(SummaryView *summaryview,
653 GtkCTreeNode *current_node)
655 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
658 gint best_score = MIN_SCORE;
659 GtkCTreeNode *best_node = NULL;
662 /*node = current_node;*/
663 node = GTK_CTREE_NODE_PREV(current_node);
665 node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
667 for (; node != NULL; node = GTK_CTREE_NODE_PREV(node)) {
668 msginfo = gtk_ctree_node_get_row_data(ctree, node);
669 if (msginfo->score >= summaryview->important_score)
671 if (msginfo->score > best_score) {
672 best_score = msginfo->score;
683 gboolean summary_show(SummaryView *summaryview, FolderItem *item,
684 gboolean update_cache)
686 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
688 GSList *mlist = NULL;
691 guint selected_msgnum = 0;
692 guint displayed_msgnum = 0;
693 GtkCTreeNode *selected_node = summaryview->folderview->selected;
696 if (summary_is_locked(summaryview)) return FALSE;
699 summary_lock(summaryview);
701 STATUSBAR_POP(summaryview->mainwin);
703 is_refresh = (!prefs_common.open_inbox_on_inc &&
704 item == summaryview->folder_item &&
705 update_cache == FALSE) ? TRUE : FALSE;
707 selected_msgnum = summary_get_msgnum(summaryview,
708 summaryview->selected);
709 displayed_msgnum = summary_get_msgnum(summaryview,
710 summaryview->displayed);
713 /* process the marks if any */
714 if (summaryview->mainwin->lock_count == 0 &&
715 (summaryview->moved > 0 || summaryview->copied > 0)) {
718 val = alertpanel(_("Process mark"),
719 _("Some marks are left. Process it?"),
720 _("Yes"), _("No"), _("Cancel"));
721 if (G_ALERTDEFAULT == val) {
722 summary_unlock(summaryview);
723 summary_execute(summaryview);
724 summary_lock(summaryview);
725 } else if (G_ALERTALTERNATE == val)
726 summary_write_cache(summaryview);
728 summary_unlock(summaryview);
732 folder_update_op_count();
735 * CLAWS: summary_show() is responsible for updating the caches.
736 * after filtering inc.c::inc_finished() forces the update of
737 * the cache by indirectly calling summary_show() (by re-selecting
738 * the currently selected mail folder).
739 * this collides with the new filtering system that may have set
740 * any message flag before calling summary_show().
741 * we can prevent this cache-write by checking the opened member
742 * of the folderview. if this is NULL, the folderview forced
743 * an update of the summary view.
745 if (summaryview->folderview->opened)
746 summary_write_cache(summaryview);
749 summaryview->folderview->opened = selected_node;
751 gtk_clist_freeze(GTK_CLIST(ctree));
753 summary_clear_list(summaryview);
754 summary_set_column_titles(summaryview);
756 messageview_clear(summaryview->messageview);
759 if (!item || !item->path || !item->parent || item->no_select ||
760 (item->folder->type == F_MH &&
761 ((buf = folder_item_get_path(item)) == NULL ||
762 change_dir(buf) < 0))) {
764 debug_print(_("empty folder\n\n"));
765 summary_set_hide_read_msgs_menu(summaryview, FALSE);
767 messageview_clear(summaryview->messageview);
768 summary_clear_all(summaryview);
769 summaryview->folder_item = item;
770 gtk_clist_thaw(GTK_CLIST(ctree));
771 summary_unlock(summaryview);
777 summaryview->folder_item = item;
780 gtk_signal_handler_block_by_data(GTK_OBJECT(ctree), summaryview);
782 buf = g_strdup_printf(_("Scanning folder (%s)..."), item->path);
783 debug_print("%s\n", buf);
784 STATUSBAR_PUSH(summaryview->mainwin, buf);
787 main_window_cursor_wait(summaryview->mainwin);
790 mlist = item->folder->get_msg_list(item->folder, item, !update_cache);
793 USE LIST FROM CACHE, WILL NOT DISPLAY ANY MESSAGES DROPED
794 BY OTHER PROGRAMS TO THE FOLDER
796 mlist = folder_item_get_msg_list(item);
798 summary_processing(summaryview, mlist);
800 for(cur = mlist ; cur != NULL ; cur = g_slist_next(cur)) {
801 MsgInfo * msginfo = (MsgInfo *) cur->data;
803 msginfo->score = score_message(global_scoring, msginfo);
804 if (msginfo->score != MAX_SCORE &&
805 msginfo->score != MIN_SCORE) {
806 msginfo->score += score_message(item->prefs->scoring,
811 summaryview->killed_messages = NULL;
813 if (summaryview->folder_item->hide_read_msgs) {
816 summary_set_hide_read_msgs_menu(summaryview, TRUE);
818 for(cur = mlist ; cur != NULL ; cur = g_slist_next(cur)) {
819 MsgInfo * msginfo = (MsgInfo *) cur->data;
821 if ((MSG_IS_UNREAD(msginfo->flags)
822 || MSG_IS_MARKED(msginfo->flags)
823 || MSG_IS_LOCKED(msginfo->flags))
824 && !MSG_IS_IGNORE_THREAD(msginfo->flags))
825 not_killed = g_slist_append(not_killed, msginfo);
827 summaryview->killed_messages =
828 g_slist_append(summaryview->killed_messages, msginfo);
833 summary_set_hide_read_msgs_menu(summaryview, FALSE);
836 if ((global_scoring || item->prefs->scoring) &&
837 (item->folder->type == F_NEWS)) {
842 kill_score = prefs_common.kill_score;
843 if (item->prefs->kill_score > kill_score)
844 kill_score = item->prefs->kill_score;
845 for(cur = mlist ; cur != NULL ; cur = g_slist_next(cur)) {
846 MsgInfo * msginfo = (MsgInfo *) cur->data;
848 if (MSG_IS_NEWS(msginfo->flags) &&
849 (msginfo->score <= kill_score))
850 summaryview->killed_messages = g_slist_append(summaryview->killed_messages, msginfo);
852 not_killed = g_slist_append(not_killed,
859 STATUSBAR_POP(summaryview->mainwin);
861 /* set ctree and hash table from the msginfo list
862 creating thread, and count the number of messages */
863 summary_set_ctree_from_list(summaryview, mlist);
867 folderview_update_msg_num(summaryview->folderview,
868 summaryview->folderview->opened);
870 if (item->sort_key != SORT_BY_NONE)
871 summary_sort(summaryview, item->sort_key, item->sort_type);
873 summary_write_cache(summaryview);
875 gtk_signal_handler_unblock_by_data(GTK_OBJECT(ctree), summaryview);
877 gtk_clist_thaw(GTK_CLIST(ctree));
880 summaryview->displayed =
881 summary_find_msg_by_msgnum(summaryview,
883 if (!summaryview->displayed)
884 messageview_clear(summaryview->messageview);
885 summary_select_by_msgnum(summaryview, selected_msgnum);
886 if (!summaryview->selected) {
887 /* no selected message - select first unread
888 message, but do not display it */
889 node = summary_find_next_flagged_msg(summaryview, NULL,
891 if (node == NULL && GTK_CLIST(ctree)->row_list != NULL)
892 node = gtk_ctree_node_nth
894 item->sort_type == SORT_DESCENDING
895 ? 0 : GTK_CLIST(ctree)->rows - 1);
896 summary_select_node(summaryview, node, FALSE, TRUE);
899 /* select first unread message */
900 if (item->sort_key == SORT_BY_SCORE)
901 node = summary_find_next_important_score(summaryview,
904 node = summary_find_next_flagged_msg(summaryview, NULL,
906 if (node == NULL && GTK_CLIST(ctree)->row_list != NULL) {
907 node = gtk_ctree_node_nth
909 item->sort_type == SORT_DESCENDING
910 ? 0 : GTK_CLIST(ctree)->rows - 1);
912 if (prefs_common.open_unread_on_enter) {
913 summary_unlock(summaryview);
914 summary_select_node(summaryview, node, TRUE, TRUE);
915 summary_lock(summaryview);
917 summary_select_node(summaryview, node, FALSE, TRUE);
920 summary_status_show(summaryview);
921 summary_set_menu_sensitive(summaryview);
922 main_window_set_toolbar_sensitive(summaryview->mainwin);
925 STATUSBAR_PUSH(summaryview->mainwin, _("Done."));
927 main_window_cursor_normal(summaryview->mainwin);
928 summary_unlock(summaryview);
934 void summary_clear_list(SummaryView *summaryview)
936 GtkCList *clist = GTK_CLIST(summaryview->ctree);
940 gtk_clist_freeze(clist);
942 for(cur = summaryview->killed_messages ; cur != NULL ;
943 cur = g_slist_next(cur)) {
944 MsgInfo * msginfo = (MsgInfo *) cur->data;
946 procmsg_msginfo_free(msginfo);
948 g_slist_free(summaryview->killed_messages);
949 summaryview->killed_messages = NULL;
951 gtk_ctree_pre_recursive(GTK_CTREE(summaryview->ctree),
952 NULL, summary_free_msginfo_func, NULL);
954 if (summaryview->folder_item) {
955 summaryview->folder_item->opened = FALSE;
956 summaryview->folder_item = NULL;
959 summaryview->display_msg = FALSE;
961 summaryview->selected = NULL;
962 summaryview->displayed = NULL;
963 summaryview->newmsgs = summaryview->unread = 0;
964 summaryview->messages = summaryview->total_size = 0;
965 summaryview->deleted = summaryview->moved = 0;
966 summaryview->copied = 0;
967 if (summaryview->msgid_table) {
968 g_hash_table_destroy(summaryview->msgid_table);
969 summaryview->msgid_table = NULL;
971 if (summaryview->subject_table) {
972 g_hash_table_destroy(summaryview->subject_table);
973 summaryview->subject_table = NULL;
975 summaryview->mlist = NULL;
976 if (summaryview->folder_table) {
977 g_hash_table_destroy(summaryview->folder_table);
978 summaryview->folder_table = NULL;
981 gtk_clist_clear(clist);
982 if (summaryview->col_pos[S_COL_SUBJECT] == N_SUMMARY_COLS - 1) {
983 optimal_width = gtk_clist_optimal_column_width
984 (clist, summaryview->col_pos[S_COL_SUBJECT]);
985 gtk_clist_set_column_width
986 (clist, summaryview->col_pos[S_COL_SUBJECT],
990 gtk_clist_thaw(clist);
993 void summary_clear_all(SummaryView *summaryview)
995 summary_clear_list(summaryview);
996 summary_set_menu_sensitive(summaryview);
997 main_window_set_toolbar_sensitive(summaryview->mainwin);
998 summary_status_show(summaryview);
1001 void summary_lock(SummaryView *summaryview)
1003 summaryview->lock_count++;
1006 void summary_unlock(SummaryView *summaryview)
1008 if (summaryview->lock_count)
1009 summaryview->lock_count--;
1012 gboolean summary_is_locked(SummaryView *summaryview)
1014 return summaryview->lock_count > 0;
1017 SummarySelection summary_get_selection_type(SummaryView *summaryview)
1019 GtkCList *clist = GTK_CLIST(summaryview->ctree);
1020 SummarySelection selection;
1022 if (!clist->row_list)
1023 selection = SUMMARY_NONE;
1024 else if (!clist->selection)
1025 selection = SUMMARY_SELECTED_NONE;
1026 else if (!clist->selection->next)
1027 selection = SUMMARY_SELECTED_SINGLE;
1029 selection = SUMMARY_SELECTED_MULTIPLE;
1034 static void summary_set_menu_sensitive(SummaryView *summaryview)
1036 GtkItemFactory *ifactory = summaryview->popupfactory;
1037 SummarySelection selection;
1038 GtkWidget *menuitem;
1041 selection = summary_get_selection_type(summaryview);
1042 main_window_set_menu_sensitive(summaryview->mainwin);
1044 if (selection == SUMMARY_NONE) {
1047 submenu = gtk_item_factory_get_widget
1048 (summaryview->popupfactory, "/Mark");
1049 menu_set_insensitive_all(GTK_MENU_SHELL(submenu));
1050 menu_set_insensitive_all
1051 (GTK_MENU_SHELL(summaryview->popupmenu));
1055 if (summaryview->folder_item->folder->type != F_NEWS)
1056 menu_set_sensitive(ifactory, "/Move...", TRUE);
1058 menu_set_sensitive(ifactory, "/Move...", FALSE);
1060 menu_set_sensitive(ifactory, "/Delete", TRUE);
1061 menu_set_sensitive(ifactory, "/Select all", TRUE);
1062 menu_set_sensitive(ifactory, "/Copy...", TRUE);
1063 menu_set_sensitive(ifactory, "/Execute", TRUE);
1065 menu_set_sensitive(ifactory, "/Mark", TRUE);
1066 menu_set_sensitive(ifactory, "/Mark/Mark", TRUE);
1067 menu_set_sensitive(ifactory, "/Mark/Unmark", TRUE);
1069 menu_set_sensitive(ifactory, "/Mark/Mark as unread", TRUE);
1070 menu_set_sensitive(ifactory, "/Mark/Mark as read", TRUE);
1071 menu_set_sensitive(ifactory, "/Mark/Mark all read", TRUE);
1072 menu_set_sensitive(ifactory, "/Mark/Ignore thread", TRUE);
1073 menu_set_sensitive(ifactory, "/Mark/Unignore thread", TRUE);
1075 menu_set_sensitive(ifactory, "/Color label", TRUE);
1077 sens = (selection == SUMMARY_SELECTED_MULTIPLE) ? FALSE : TRUE;
1078 menu_set_sensitive(ifactory, "/Reply", sens);
1079 menu_set_sensitive(ifactory, "/Reply to sender", sens);
1080 menu_set_sensitive(ifactory, "/Reply to all", sens);
1081 menu_set_sensitive(ifactory, "/Forward", TRUE);
1082 menu_set_sensitive(ifactory, "/Redirect", sens);
1084 menu_set_sensitive(ifactory, "/Add sender to address book", sens);
1085 menu_set_sensitive(ifactory, "/Create filter rule", sens);
1087 menu_set_sensitive(ifactory, "/View", sens);
1088 menu_set_sensitive(ifactory, "/View/Open in new window", sens);
1089 menu_set_sensitive(ifactory, "/View/Source", sens);
1090 menu_set_sensitive(ifactory, "/View/All header", sens);
1091 if (summaryview->folder_item->stype == F_OUTBOX ||
1092 summaryview->folder_item->stype == F_DRAFT ||
1093 summaryview->folder_item->stype == F_QUEUE)
1094 menu_set_sensitive(ifactory, "/Re-edit", sens);
1096 menu_set_sensitive(ifactory, "/Re-edit", FALSE);
1098 menu_set_sensitive(ifactory, "/Select thread", sens);
1099 menu_set_sensitive(ifactory, "/Save as...", sens);
1100 menu_set_sensitive(ifactory, "/Print...", TRUE);
1102 if (summaryview->folder_item->folder->account)
1103 sens = summaryview->folder_item->folder->account->protocol
1107 menu_set_sensitive(ifactory, "/Follow-up and reply to", sens);
1108 summary_lock(summaryview);
1109 menuitem = gtk_item_factory_get_widget(ifactory, "/View/All header");
1110 gtk_check_menu_item_set_active
1111 (GTK_CHECK_MENU_ITEM(menuitem),
1112 summaryview->messageview->textview->show_all_headers);
1113 summary_unlock(summaryview);
1116 void summary_select_prev_unread(SummaryView *summaryview)
1120 node = summary_find_prev_flagged_msg
1121 (summaryview, summaryview->selected, MSG_UNREAD, FALSE);
1126 switch (prefs_common.next_unread_msg_dialog) {
1127 case NEXTUNREADMSGDIALOG_ALWAYS:
1128 val = alertpanel(_("No more unread messages"),
1129 _("No unread message found. "
1130 "Search from the end?"),
1131 _("Yes"), _("No"), NULL);
1133 case NEXTUNREADMSGDIALOG_ASSUME_YES:
1134 val = G_ALERTDEFAULT;
1136 case NEXTUNREADMSGDIALOG_ASSUME_NO:
1137 val = !G_ALERTDEFAULT;
1141 _("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n"));
1143 if (val != G_ALERTDEFAULT) return;
1144 node = summary_find_prev_flagged_msg(summaryview, NULL,
1149 alertpanel_notice(_("No unread messages."));
1151 summary_select_node(summaryview, node, TRUE, FALSE);
1154 void summary_select_next_unread(SummaryView *summaryview)
1156 GtkCTreeNode *node = summaryview->selected;
1157 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
1159 node = summary_find_next_flagged_msg
1160 (summaryview, node, MSG_UNREAD, FALSE);
1163 summary_select_node(summaryview, node, TRUE, FALSE);
1165 node = summary_find_next_flagged_msg
1166 (summaryview, NULL, MSG_UNREAD, FALSE);
1170 switch (prefs_common.next_unread_msg_dialog) {
1171 case NEXTUNREADMSGDIALOG_ALWAYS:
1172 val = alertpanel(_("No more unread messages"),
1173 _("No unread message found. "
1174 "Go to next folder?"),
1175 _("Yes"), _("No"), NULL);
1177 case NEXTUNREADMSGDIALOG_ASSUME_YES:
1178 val = G_ALERTDEFAULT;
1180 case NEXTUNREADMSGDIALOG_ASSUME_NO:
1185 _("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n"));
1188 if (val == G_ALERTDEFAULT) {
1189 if (gtk_signal_n_emissions_by_name
1190 (GTK_OBJECT(ctree), "key_press_event") > 0)
1191 gtk_signal_emit_stop_by_name
1194 folderview_select_next_unread(summaryview->folderview);
1200 summary_select_node(summaryview, node, TRUE, FALSE);
1205 void summary_select_prev_new(SummaryView *summaryview)
1209 node = summary_find_prev_flagged_msg
1210 (summaryview, summaryview->selected, MSG_NEW, FALSE);
1215 val = alertpanel(_("No more new messages"),
1216 _("No new message found. "
1217 "Search from the end?"),
1218 _("Yes"), _("No"), NULL);
1219 if (val != G_ALERTDEFAULT) return;
1220 node = summary_find_prev_flagged_msg(summaryview, NULL,
1225 alertpanel_notice(_("No new messages."));
1227 summary_select_node(summaryview, node, TRUE, FALSE);
1230 void summary_select_next_new(SummaryView *summaryview)
1232 GtkCTreeNode *node = summaryview->selected;
1233 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
1235 while ((node = summary_find_next_flagged_msg
1236 (summaryview, node, MSG_NEW, FALSE)) == NULL) {
1239 val = alertpanel(_("No more new messages"),
1240 _("No new message found. "
1241 "Go to next folder?"),
1242 _("Yes"), _("Search again"), _("No"));
1243 if (val == G_ALERTDEFAULT) {
1244 if (gtk_signal_n_emissions_by_name
1245 (GTK_OBJECT(ctree), "key_press_event") > 0)
1246 gtk_signal_emit_stop_by_name
1249 folderview_select_next_unread(summaryview->folderview);
1251 } else if (val == G_ALERTALTERNATE)
1258 summary_select_node(summaryview, node, TRUE, FALSE);
1261 void summary_select_prev_marked(SummaryView *summaryview)
1265 node = summary_find_prev_flagged_msg
1266 (summaryview, summaryview->selected, MSG_MARKED, TRUE);
1271 val = alertpanel(_("No more marked messages"),
1272 _("No marked message found. "
1273 "Search from the end?"),
1274 _("Yes"), _("No"), NULL);
1275 if (val != G_ALERTDEFAULT) return;
1276 node = summary_find_prev_flagged_msg(summaryview, NULL,
1281 alertpanel_notice(_("No marked messages."));
1283 summary_select_node(summaryview, node, TRUE, FALSE);
1286 void summary_select_next_marked(SummaryView *summaryview)
1290 node = summary_find_next_flagged_msg
1291 (summaryview, summaryview->selected, MSG_MARKED, TRUE);
1296 val = alertpanel(_("No more marked messages"),
1297 _("No marked message found. "
1298 "Search from the beginning?"),
1299 _("Yes"), _("No"), NULL);
1300 if (val != G_ALERTDEFAULT) return;
1301 node = summary_find_next_flagged_msg(summaryview, NULL,
1306 alertpanel_notice(_("No marked messages."));
1308 summary_select_node(summaryview, node, TRUE, FALSE);
1311 void summary_select_prev_labeled(SummaryView *summaryview)
1315 node = summary_find_prev_flagged_msg
1316 (summaryview, summaryview->selected, MSG_CLABEL_FLAG_MASK, TRUE);
1321 val = alertpanel(_("No more labeled messages"),
1322 _("No labeled message found. "
1323 "Search from the end?"),
1324 _("Yes"), _("No"), NULL);
1325 if (val != G_ALERTDEFAULT) return;
1326 node = summary_find_prev_flagged_msg(summaryview, NULL,
1327 MSG_CLABEL_FLAG_MASK, TRUE);
1331 alertpanel_notice(_("No labeled messages."));
1333 summary_select_node(summaryview, node, TRUE, FALSE);
1336 void summary_select_next_labeled(SummaryView *summaryview)
1340 node = summary_find_next_flagged_msg
1341 (summaryview, summaryview->selected, MSG_CLABEL_FLAG_MASK, TRUE);
1346 val = alertpanel(_("No more labeled messages"),
1347 _("No labeled message found. "
1348 "Search from the beginning?"),
1349 _("Yes"), _("No"), NULL);
1350 if (val != G_ALERTDEFAULT) return;
1351 node = summary_find_next_flagged_msg(summaryview, NULL,
1352 MSG_CLABEL_FLAG_MASK, TRUE);
1356 alertpanel_notice(_("No labeled messages."));
1358 summary_select_node(summaryview, node, TRUE, FALSE);
1361 void summary_select_by_msgnum(SummaryView *summaryview, guint msgnum)
1365 node = summary_find_msg_by_msgnum(summaryview, msgnum);
1366 summary_select_node(summaryview, node, FALSE, TRUE);
1370 * summary_select_node:
1371 * @summaryview: Summary view.
1372 * @node: Summary tree node.
1373 * @display_msg: TRUE to display the selected message.
1374 * @do_refresh: TRUE to refresh the widget.
1376 * Select @node (bringing it into view by scrolling and expanding its
1377 * thread, if necessary) and unselect all others. If @display_msg is
1378 * TRUE, display the corresponding message in the message view.
1379 * If @do_refresh is TRUE, the widget is refreshed.
1381 void summary_select_node(SummaryView *summaryview, GtkCTreeNode *node,
1382 gboolean display_msg, gboolean do_refresh)
1384 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
1387 gtkut_ctree_expand_parent_all(ctree, node);
1390 gtk_widget_grab_focus(GTK_WIDGET(ctree));
1391 gtk_ctree_node_moveto(ctree, node, -1, 0.5, 0);
1393 gtk_sctree_unselect_all(GTK_SCTREE(ctree));
1394 if (display_msg && summaryview->displayed == node)
1395 summaryview->displayed = NULL;
1396 summaryview->display_msg = display_msg;
1397 gtk_sctree_select(GTK_SCTREE(ctree), node);
1401 static guint summary_get_msgnum(SummaryView *summaryview, GtkCTreeNode *node)
1403 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
1408 msginfo = gtk_ctree_node_get_row_data(ctree, node);
1409 return msginfo->msgnum;
1412 static GtkCTreeNode *summary_find_prev_msg(SummaryView *summaryview,
1413 GtkCTreeNode *current_node)
1415 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
1420 node = current_node;
1422 node = gtk_ctree_node_nth(ctree, GTK_CLIST(ctree)->rows - 1);
1424 for (; node != NULL; node = GTK_CTREE_NODE_PREV(node)) {
1425 msginfo = gtk_ctree_node_get_row_data(ctree, node);
1426 if (!MSG_IS_DELETED(msginfo->flags)) break;
1432 static GtkCTreeNode *summary_find_next_msg(SummaryView *summaryview,
1433 GtkCTreeNode *current_node)
1435 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
1440 node = current_node;
1442 node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
1444 for (; node != NULL; node = gtkut_ctree_node_next(ctree, node)) {
1445 msginfo = gtk_ctree_node_get_row_data(ctree, node);
1446 if (!MSG_IS_DELETED(msginfo->flags)) break;
1452 static GtkCTreeNode *summary_find_prev_flagged_msg(SummaryView *summaryview,
1453 GtkCTreeNode *current_node,
1455 gboolean start_from_prev)
1457 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
1462 if (start_from_prev)
1463 node = GTK_CTREE_NODE_PREV(current_node);
1465 node = current_node;
1467 node = gtk_ctree_node_nth(ctree, GTK_CLIST(ctree)->rows - 1);
1469 for (; node != NULL; node = GTK_CTREE_NODE_PREV(node)) {
1470 msginfo = gtk_ctree_node_get_row_data(ctree, node);
1471 if ((msginfo->flags.perm_flags & flags) != 0) break;
1477 static GtkCTreeNode *summary_find_next_flagged_msg(SummaryView *summaryview,
1478 GtkCTreeNode *current_node,
1480 gboolean start_from_next)
1482 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
1487 if (start_from_next)
1488 node = gtkut_ctree_node_next(ctree, current_node);
1490 node = current_node;
1492 node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
1494 for (; node != NULL; node = gtkut_ctree_node_next(ctree, node)) {
1495 msginfo = gtk_ctree_node_get_row_data(ctree, node);
1496 /* Find msg with matching flags but ignore messages with
1497 ignore flags, if searching for new or unread messages */
1498 if (!(((flags & (MSG_NEW | MSG_UNREAD)) != 0) && MSG_IS_IGNORE_THREAD(msginfo->flags)) &&
1499 ((msginfo->flags.perm_flags & flags) != 0))
1506 static GtkCTreeNode *summary_find_msg_by_msgnum(SummaryView *summaryview,
1509 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
1513 node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
1515 for (; node != NULL; node = gtkut_ctree_node_next(ctree, node)) {
1516 msginfo = gtk_ctree_node_get_row_data(ctree, node);
1517 if (msginfo->msgnum == msgnum) break;
1523 static guint attract_hash_func(gconstpointer key)
1529 Xstrdup_a(str, (const gchar *)key, return 0);
1536 for (p += 1; *p != '\0'; p++)
1537 h = (h << 5) - h + *p;
1543 static gint attract_compare_func(gconstpointer a, gconstpointer b)
1545 return subject_compare((const gchar *)a, (const gchar *)b) == 0;
1548 void summary_attract_by_subject(SummaryView *summaryview)
1550 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
1551 GtkCList *clist = GTK_CLIST(ctree);
1552 GtkCTreeNode *src_node;
1553 GtkCTreeNode *dst_node, *sibling;
1555 MsgInfo *src_msginfo, *dst_msginfo;
1556 GHashTable *subject_table;
1558 debug_print(_("Attracting messages by subject..."));
1559 STATUSBAR_PUSH(summaryview->mainwin,
1560 _("Attracting messages by subject..."));
1562 main_window_cursor_wait(summaryview->mainwin);
1563 gtk_clist_freeze(clist);
1565 subject_table = g_hash_table_new(attract_hash_func,
1566 attract_compare_func);
1568 for (src_node = GTK_CTREE_NODE(clist->row_list);
1571 tmp = GTK_CTREE_ROW(src_node)->sibling;
1572 src_msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(src_node);
1573 if (!src_msginfo) continue;
1574 if (!src_msginfo->subject) continue;
1576 /* find attracting node */
1577 dst_node = g_hash_table_lookup(subject_table,
1578 src_msginfo->subject);
1581 dst_msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(dst_node);
1583 /* if the time difference is more than 20 days,
1585 if (ABS(src_msginfo->date_t - dst_msginfo->date_t)
1586 > 60 * 60 * 24 * 20)
1589 sibling = GTK_CTREE_ROW(dst_node)->sibling;
1590 if (src_node != sibling)
1591 gtk_ctree_move(ctree, src_node, NULL, sibling);
1594 g_hash_table_insert(subject_table,
1595 src_msginfo->subject, src_node);
1598 g_hash_table_destroy(subject_table);
1600 gtk_ctree_node_moveto(ctree, summaryview->selected, -1, 0.5, 0);
1602 gtk_clist_thaw(clist);
1604 debug_print(_("done.\n"));
1605 STATUSBAR_POP(summaryview->mainwin);
1607 main_window_cursor_normal(summaryview->mainwin);
1610 static void summary_free_msginfo_func(GtkCTree *ctree, GtkCTreeNode *node,
1613 MsgInfo *msginfo = gtk_ctree_node_get_row_data(ctree, node);
1616 procmsg_msginfo_free(msginfo);
1619 static void summary_set_marks_func(GtkCTree *ctree, GtkCTreeNode *node,
1622 SummaryView *summaryview = data;
1625 msginfo = gtk_ctree_node_get_row_data(ctree, node);
1627 if (MSG_IS_NEWS(msginfo->flags))
1628 news_flag_crosspost(msginfo);
1630 if (MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
1631 summaryview->newmsgs++;
1632 if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
1633 summaryview->unread++;
1634 if (MSG_IS_DELETED(msginfo->flags))
1635 summaryview->deleted++;
1637 summaryview->messages++;
1638 summaryview->total_size += msginfo->size;
1640 summary_set_row_marks(summaryview, node);
1643 static void summary_update_status(SummaryView *summaryview)
1645 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
1649 summaryview->newmsgs = summaryview->unread =
1650 summaryview->messages = summaryview->total_size =
1651 summaryview->deleted = summaryview->moved = summaryview->copied = 0;
1653 for (node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
1654 node != NULL; node = gtkut_ctree_node_next(ctree, node)) {
1655 msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
1657 if (MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
1658 summaryview->newmsgs++;
1659 if (MSG_IS_UNREAD(msginfo->flags)&& !MSG_IS_IGNORE_THREAD(msginfo->flags))
1660 summaryview->unread++;
1661 if (MSG_IS_DELETED(msginfo->flags))
1662 summaryview->deleted++;
1663 if (MSG_IS_MOVE(msginfo->flags))
1664 summaryview->moved++;
1665 if (MSG_IS_COPY(msginfo->flags))
1666 summaryview->copied++;
1667 summaryview->messages++;
1668 summaryview->total_size += msginfo->size;
1672 static void summary_status_show(SummaryView *summaryview)
1675 gchar *del, *mv, *cp;
1679 GList *rowlist, *cur;
1680 guint n_selected = 0;
1684 if (!summaryview->folder_item) {
1685 gtk_label_set(GTK_LABEL(summaryview->statlabel_folder), "");
1686 gtk_label_set(GTK_LABEL(summaryview->statlabel_select), "");
1687 gtk_label_set(GTK_LABEL(summaryview->statlabel_msgs), "");
1691 rowlist = GTK_CLIST(summaryview->ctree)->selection;
1692 for (cur = rowlist; cur != NULL; cur = cur->next) {
1693 msginfo = gtk_ctree_node_get_row_data
1694 (GTK_CTREE(summaryview->ctree),
1695 GTK_CTREE_NODE(cur->data));
1696 sel_size += msginfo->size;
1700 if (summaryview->folder_item->folder->type == F_NEWS &&
1701 prefs_common.ng_abbrev_len < strlen(summaryview->folder_item->path)) {
1703 group = get_abbrev_newsgroup_name
1704 (g_basename(summaryview->folder_item->path));
1705 gtk_label_set(GTK_LABEL(summaryview->statlabel_folder), group);
1708 gtk_label_set(GTK_LABEL(summaryview->statlabel_folder),
1709 summaryview->folder_item->path);
1712 if (summaryview->deleted)
1713 del = g_strdup_printf(_("%d deleted"), summaryview->deleted);
1716 if (summaryview->moved)
1717 mv = g_strdup_printf(_("%s%d moved"),
1718 summaryview->deleted ? _(", ") : "",
1719 summaryview->moved);
1722 if (summaryview->copied)
1723 cp = g_strdup_printf(_("%s%d copied"),
1724 summaryview->deleted ||
1725 summaryview->moved ? _(", ") : "",
1726 summaryview->copied);
1730 if (summaryview->deleted || summaryview->moved || summaryview->copied)
1736 sel = g_strdup_printf(" (%s)", to_human_readable(sel_size));
1737 if (n_selected == 1)
1738 itstr = g_strdup(_(" item selected"));
1740 itstr = g_strdup(_(" items selected"));
1743 itstr = g_strdup("");
1746 str = g_strconcat(n_selected ? itos(n_selected) : "",
1747 itstr, sel, spc, del, mv, cp, NULL);
1748 gtk_label_set(GTK_LABEL(summaryview->statlabel_select), str);
1756 if (FOLDER_IS_LOCAL(summaryview->folder_item->folder)) {
1757 str = g_strdup_printf(_("%d new, %d unread, %d total (%s)"),
1758 summaryview->newmsgs,
1759 summaryview->unread,
1760 summaryview->messages,
1761 to_human_readable(summaryview->total_size));
1763 str = g_strdup_printf(_("%d new, %d unread, %d total"),
1764 summaryview->newmsgs,
1765 summaryview->unread,
1766 summaryview->messages);
1768 gtk_label_set(GTK_LABEL(summaryview->statlabel_msgs), str);
1772 static void summary_set_column_titles(SummaryView *summaryview)
1774 GtkCList *clist = GTK_CLIST(summaryview->ctree);
1780 SummaryColumnType type;
1781 gboolean single_char;
1782 GtkJustification justify;
1783 FolderItem *item = summaryview->folder_item;
1785 static FolderSortKey sort_by[N_SUMMARY_COLS] = {
1798 for (pos = 0; pos < N_SUMMARY_COLS; pos++) {
1799 type = summaryview->col_state[pos].type;
1801 /* CLAWS: mime and unread are single char headers */
1802 single_char = (type == S_COL_MIME || type == S_COL_UNREAD);
1803 justify = (type == S_COL_NUMBER || type == S_COL_SIZE)
1804 ? GTK_JUSTIFY_RIGHT : GTK_JUSTIFY_LEFT;
1811 if (prefs_common.trans_hdr)
1812 title = gettext(col_label[type]);
1814 title = col_label[type];
1816 /* CLAWS: dummies for mark and locked headers */
1822 title = gettext(col_label[type]);
1825 if (type == S_COL_MIME) {
1826 label = gtk_pixmap_new(clipxpm, clipxpmmask);
1827 gtk_widget_show(label);
1828 gtk_clist_set_column_widget(clist, pos, label);
1832 gtk_clist_set_column_title(clist, pos, title);
1836 /* CLAWS: changed so that locked and mark headers
1837 * show a pixmap instead of single character */
1838 hbox = gtk_hbox_new(FALSE, 4);
1840 if (type == S_COL_LOCKED)
1841 label = gtk_pixmap_new(lockedxpm, lockedxpmmask);
1842 else if (type == S_COL_MARK)
1843 label = gtk_pixmap_new(markxpm, markxpmmask);
1845 label = gtk_label_new(title);
1847 if (justify == GTK_JUSTIFY_RIGHT)
1848 gtk_box_pack_end(GTK_BOX(hbox), label,
1851 gtk_box_pack_start(GTK_BOX(hbox), label,
1854 if (item && item->sort_key == sort_by[type]) {
1855 arrow = gtk_arrow_new
1856 (item->sort_type == SORT_ASCENDING
1857 ? GTK_ARROW_DOWN : GTK_ARROW_UP,
1859 if (justify == GTK_JUSTIFY_RIGHT)
1860 gtk_box_pack_start(GTK_BOX(hbox), arrow,
1863 gtk_box_pack_end(GTK_BOX(hbox), arrow,
1867 gtk_widget_show_all(hbox);
1868 gtk_clist_set_column_widget(clist, pos, hbox);
1872 void summary_sort(SummaryView *summaryview,
1873 FolderSortKey sort_key, FolderSortType sort_type)
1875 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
1876 GtkCList *clist = GTK_CLIST(summaryview->ctree);
1877 GtkCListCompareFunc cmp_func;
1878 FolderItem *item = summaryview->folder_item;
1880 if (!item || !item->path || !item->parent || item->no_select) return;
1884 cmp_func = (GtkCListCompareFunc)summary_cmp_by_mark;
1886 case SORT_BY_UNREAD:
1887 cmp_func = (GtkCListCompareFunc)summary_cmp_by_unread;
1890 cmp_func = (GtkCListCompareFunc)summary_cmp_by_mime;
1892 case SORT_BY_NUMBER:
1893 cmp_func = (GtkCListCompareFunc)summary_cmp_by_num;
1896 cmp_func = (GtkCListCompareFunc)summary_cmp_by_size;
1899 cmp_func = (GtkCListCompareFunc)summary_cmp_by_date;
1902 cmp_func = (GtkCListCompareFunc)summary_cmp_by_from;
1904 case SORT_BY_SUBJECT:
1905 cmp_func = (GtkCListCompareFunc)summary_cmp_by_subject;
1908 cmp_func = (GtkCListCompareFunc)summary_cmp_by_score;
1910 case SORT_BY_LOCKED:
1911 cmp_func = (GtkCListCompareFunc)summary_cmp_by_locked;
1914 cmp_func = (GtkCListCompareFunc)summary_cmp_by_label;
1917 item->sort_key = sort_key;
1918 item->sort_type = SORT_ASCENDING;
1919 summary_set_column_titles(summaryview);
1920 summary_set_menu_sensitive(summaryview);
1926 debug_print(_("Sorting summary..."));
1927 STATUSBAR_PUSH(summaryview->mainwin, _("Sorting summary..."));
1929 main_window_cursor_wait(summaryview->mainwin);
1931 gtk_clist_set_compare_func(clist, cmp_func);
1933 gtk_clist_set_sort_type(clist, (GtkSortType)sort_type);
1934 item->sort_key = sort_key;
1935 item->sort_type = sort_type;
1937 summary_set_column_titles(summaryview);
1938 summary_set_menu_sensitive(summaryview);
1940 gtk_sctree_sort_recursive(ctree, NULL);
1942 gtk_ctree_node_moveto(ctree, summaryview->selected, -1, 0.5, 0);
1944 debug_print(_("done.\n"));
1945 STATUSBAR_POP(summaryview->mainwin);
1947 main_window_cursor_normal(summaryview->mainwin);
1950 gboolean summary_insert_gnode_func(GtkCTree *ctree, guint depth, GNode *gnode,
1951 GtkCTreeNode *cnode, gpointer data)
1953 SummaryView *summaryview = (SummaryView *)data;
1954 MsgInfo *msginfo = (MsgInfo *)gnode->data;
1955 gchar *text[N_SUMMARY_COLS];
1956 gint *col_pos = summaryview->col_pos;
1957 const gchar *msgid = msginfo->msgid;
1958 GHashTable *msgid_table = summaryview->msgid_table;
1960 summary_set_header(summaryview, text, msginfo);
1962 gtk_ctree_set_node_info(ctree, cnode, text[col_pos[S_COL_SUBJECT]], 2,
1963 NULL, NULL, NULL, NULL, FALSE,
1964 gnode->parent->parent ? TRUE : FALSE);
1965 #define SET_TEXT(col) \
1966 gtk_ctree_node_set_text(ctree, cnode, col_pos[col], \
1969 SET_TEXT(S_COL_NUMBER);
1970 SET_TEXT(S_COL_SCORE);
1971 SET_TEXT(S_COL_SIZE);
1972 SET_TEXT(S_COL_DATE);
1973 SET_TEXT(S_COL_FROM);
1974 SET_TEXT(S_COL_SUBJECT);
1978 GTKUT_CTREE_NODE_SET_ROW_DATA(cnode, msginfo);
1979 summary_set_marks_func(ctree, cnode, summaryview);
1981 if (msgid && msgid[0] != '\0')
1982 g_hash_table_insert(msgid_table, (gchar *)msgid, cnode);
1987 static void summary_set_ctree_from_list(SummaryView *summaryview,
1990 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
1992 GtkCTreeNode *node = NULL;
1993 GHashTable *msgid_table;
1994 GHashTable *subject_table;
1999 debug_print(_("\tSetting summary from message data..."));
2000 STATUSBAR_PUSH(summaryview->mainwin,
2001 _("Setting summary from message data..."));
2004 msgid_table = g_hash_table_new(g_str_hash, g_str_equal);
2005 summaryview->msgid_table = msgid_table;
2006 subject_table = g_hash_table_new(g_str_hash, g_str_equal);
2007 summaryview->subject_table = subject_table;
2009 if (prefs_common.use_addr_book)
2010 start_address_completion();
2012 for (cur = mlist ; cur != NULL; cur = cur->next) {
2013 msginfo = (MsgInfo *)cur->data;
2014 msginfo->threadscore = msginfo->score;
2017 if (global_scoring || summaryview->folder_item->prefs->scoring) {
2018 summaryview->important_score = prefs_common.important_score;
2019 if (summaryview->folder_item->prefs->important_score >
2020 summaryview->important_score)
2021 summaryview->important_score =
2022 summaryview->folder_item->prefs->important_score;
2025 summaryview_subject_filter_init(summaryview->folder_item->prefs);
2027 if (summaryview->folder_item->threaded) {
2028 GNode *root, *gnode;
2030 root = procmsg_get_thread_tree(mlist);
2032 for (gnode = root->children; gnode != NULL;
2033 gnode = gnode->next) {
2034 node = gtk_ctree_insert_gnode
2035 (ctree, NULL, node, gnode,
2036 summary_insert_gnode_func, summaryview);
2039 g_node_destroy(root);
2041 summary_thread_init(summaryview);
2043 gchar *text[N_SUMMARY_COLS];
2045 mlist = g_slist_reverse(mlist);
2046 for (; mlist != NULL; mlist = mlist->next) {
2047 msginfo = (MsgInfo *)mlist->data;
2049 summary_set_header(summaryview, text, msginfo);
2051 node = gtk_ctree_insert_node
2052 (ctree, NULL, node, text, 2,
2053 NULL, NULL, NULL, NULL, FALSE, FALSE);
2054 GTKUT_CTREE_NODE_SET_ROW_DATA(node, msginfo);
2055 summary_set_marks_func(ctree, node, summaryview);
2057 if (msginfo->msgid && msginfo->msgid[0] != '\0')
2058 g_hash_table_insert(msgid_table,
2059 msginfo->msgid, node);
2061 subject_table_insert(subject_table,
2065 mlist = g_slist_reverse(mlist);
2068 if (prefs_common.enable_hscrollbar &&
2069 summaryview->col_pos[S_COL_SUBJECT] == N_SUMMARY_COLS - 1) {
2072 optimal_width = gtk_clist_optimal_column_width
2073 (GTK_CLIST(ctree), summaryview->col_pos[S_COL_SUBJECT]);
2074 gtk_clist_set_column_width(GTK_CLIST(ctree),
2075 summaryview->col_pos[S_COL_SUBJECT],
2079 if (prefs_common.use_addr_book)
2080 end_address_completion();
2082 debug_print(_("done.\n"));
2083 STATUSBAR_POP(summaryview->mainwin);
2085 debug_print("\tmsgid hash table size = %d\n",
2086 g_hash_table_size(msgid_table));
2087 debug_print("\tsubject hash table size = %d\n",
2088 g_hash_table_size(subject_table));
2098 gint summary_write_cache(SummaryView *summaryview)
2100 struct wcachefp fps;
2101 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2102 gint ver = CACHE_VERSION;
2104 gchar *cachefile, *markfile;
2107 PrefsFolderItem *prefs;
2109 if (!summaryview->folder_item || !summaryview->folder_item->path)
2112 if (!summaryview->folder_item->cache)
2115 folder_item_write_cache(summaryview->folder_item);
2118 if (summaryview->folder_item->folder->update_mark != NULL)
2119 summaryview->folder_item->folder->update_mark(summaryview->folder_item->folder, summaryview->folder_item);
2121 cachefile = folder_item_get_cache_file(summaryview->folder_item);
2122 g_return_val_if_fail(cachefile != NULL, -1);
2123 if ((fps.cache_fp = fopen(cachefile, "wb")) == NULL) {
2124 FILE_OP_ERROR(cachefile, "fopen");
2128 if (change_file_mode_rw(fps.cache_fp, cachefile) < 0)
2129 FILE_OP_ERROR(cachefile, "chmod");
2131 prefs = summaryview->folder_item->prefs;
2132 if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
2133 /* for cache file */
2134 filemode = prefs->folder_chmod;
2135 if (filemode & S_IRGRP) filemode |= S_IWGRP;
2136 if (filemode & S_IROTH) filemode |= S_IWOTH;
2138 fchmod(fileno(fps.cache_fp), filemode);
2140 chmod(cachefile, filemode);
2146 markfile = folder_item_get_mark_file(summaryview->folder_item);
2147 if ((fps.mark_fp = fopen(markfile, "wb")) == NULL) {
2148 FILE_OP_ERROR(markfile, "fopen");
2149 fclose(fps.cache_fp);
2153 if (change_file_mode_rw(fps.mark_fp, markfile) < 0)
2154 FILE_OP_ERROR(markfile, "chmod");
2155 if (prefs && prefs->enable_folder_chmod && prefs->folder_chmod) {
2157 fchmod(fileno(fps.mark_fp), filemode);
2159 chmod(markfile, filemode);
2165 buf = g_strdup_printf(_("Writing summary cache (%s)..."),
2166 summaryview->folder_item->path);
2168 STATUSBAR_PUSH(summaryview->mainwin, buf);
2171 WRITE_CACHE_DATA_INT(ver, fps.cache_fp);
2173 WRITE_CACHE_DATA_INT(ver, fps.mark_fp);
2175 gtk_ctree_pre_recursive(ctree, NULL, summary_write_cache_func, &fps);
2177 for (cur = summaryview->killed_messages; cur != NULL; cur = cur->next) {
2178 MsgInfo *msginfo = (MsgInfo *)cur->data;
2179 procmsg_write_cache(msginfo, fps.cache_fp);
2180 procmsg_write_flags(msginfo, fps.mark_fp);
2183 procmsg_flush_mark_queue(summaryview->folder_item, fps.mark_fp);
2185 fclose(fps.cache_fp);
2186 fclose(fps.mark_fp);
2188 debug_print(_("done.\n"));
2189 STATUSBAR_POP(summaryview->mainwin);
2194 static void summary_write_cache_func(GtkCTree *ctree, GtkCTreeNode *node,
2197 struct wcachefp *fps = data;
2198 MsgInfo *msginfo = gtk_ctree_node_get_row_data(ctree, node);
2200 if (msginfo == NULL) return;
2202 procmsg_write_cache(msginfo, fps->cache_fp);
2203 procmsg_write_flags(msginfo, fps->mark_fp);
2206 static gchar *summary_complete_address(const gchar *addr)
2209 gchar *res, *tmp, *email_addr;
2211 Xstrdup_a(email_addr, addr, return NULL);
2212 extract_address(email_addr);
2213 g_return_val_if_fail(*email_addr, NULL);
2216 * completion stuff must be already initialized
2219 if (1 < (count = complete_address(email_addr))) {
2220 tmp = get_complete_address(1);
2221 res = procheader_get_fromname(tmp);
2228 static void summary_set_header(SummaryView *summaryview, gchar *text[],
2231 static gchar date_modified[80];
2232 static gchar *to = NULL;
2233 static gchar col_score[11];
2234 static gchar buf[BUFFSIZE];
2235 PrefsFolderItem *prefs = summaryview->folder_item->prefs;
2236 gint *col_pos = summaryview->col_pos;
2238 text[col_pos[S_COL_MARK]] = NULL;
2239 text[col_pos[S_COL_UNREAD]] = NULL;
2240 text[col_pos[S_COL_MIME]] = NULL;
2241 text[col_pos[S_COL_LOCKED]] = NULL;
2242 text[col_pos[S_COL_NUMBER]] = itos(msginfo->msgnum);
2243 text[col_pos[S_COL_SIZE]] = to_human_readable(msginfo->size);
2244 text[col_pos[S_COL_SCORE]] = itos_buf(col_score, msginfo->score);
2246 if (msginfo->date_t) {
2247 procheader_date_get_localtime(date_modified,
2248 sizeof(date_modified),
2250 text[col_pos[S_COL_DATE]] = date_modified;
2251 } else if (msginfo->date)
2252 text[col_pos[S_COL_DATE]] = msginfo->date;
2254 text[col_pos[S_COL_DATE]] = _("(No Date)");
2256 text[col_pos[S_COL_FROM]] = msginfo->fromname ? msginfo->fromname :
2258 if (prefs_common.swap_from && msginfo->from && msginfo->to &&
2259 !MSG_IS_NEWS(msginfo->flags)) {
2262 Xstrdup_a(addr, msginfo->from, return);
2263 extract_address(addr);
2265 if (prefs_common.use_addr_book) {
2266 if (account_find_from_address(addr)) {
2267 addr = summary_complete_address(msginfo->to);
2269 to = g_strconcat("-->", addr == NULL ? msginfo->to : addr, NULL);
2270 text[col_pos[S_COL_FROM]] = to;
2273 if (cur_account && cur_account->address && !strcmp( addr, cur_account->address)) {
2275 to = g_strconcat("-->", msginfo->to, NULL);
2276 text[col_pos[S_COL_FROM]] = to;
2282 * CLAWS: note that the "text[col_pos[S_COL_FROM]] != to" is really a hack,
2283 * checking whether the above block (which handles the special case of
2284 * the --> in sent boxes) was executed.
2286 if (text[col_pos[S_COL_FROM]] != to && prefs_common.use_addr_book && msginfo->from) {
2288 from = summary_complete_address(msginfo->from);
2291 * FIXME: this text[col_pos[S_COL_FROM]] should be freed
2292 * but may have been assigned _("No From"). Should be
2295 text[col_pos[S_COL_FROM]] = from;
2299 if (prefs->enable_simplify_subject
2300 && prefs->simplify_subject_preg != NULL )
2301 text[col_pos[S_COL_SUBJECT]] = msginfo->subject ?
2302 string_remove_match(buf, BUFFSIZE, msginfo->subject,
2303 prefs->simplify_subject_preg) :
2307 text[col_pos[S_COL_SUBJECT]] = msginfo->subject ? msginfo->subject :
2311 #define CHANGE_FLAGS(msginfo) \
2313 if (msginfo->folder->folder->change_flags != NULL) \
2314 msginfo->folder->folder->change_flags(msginfo->folder->folder, \
2319 static void summary_display_msg(SummaryView *summaryview, GtkCTreeNode *row)
2321 summary_display_msg_full(summaryview, row, FALSE, FALSE);
2324 static void summary_display_msg_full(SummaryView *summaryview,
2326 gboolean new_window, gboolean all_headers)
2328 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2333 if (!new_window && summaryview->displayed == row) return;
2334 g_return_if_fail(row != NULL);
2336 if (summary_is_locked(summaryview)) return;
2337 summary_lock(summaryview);
2339 STATUSBAR_POP(summaryview->mainwin);
2342 msginfo = gtk_ctree_node_get_row_data(ctree, row);
2344 filename = procmsg_get_message_file(msginfo);
2346 summary_unlock(summaryview);
2351 if (MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
2352 summaryview->newmsgs--;
2353 if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
2354 summaryview->unread--;
2356 procmsg_msginfo_unset_flags(msginfo, MSG_NEW | MSG_UNREAD, 0);
2357 summary_set_row_marks(summaryview, row);
2358 gtk_clist_thaw(GTK_CLIST(ctree));
2359 summary_status_show(summaryview);
2361 flags = msginfo->flags;
2364 MessageView *msgview;
2366 msgview = messageview_create_with_new_window();
2367 messageview_show(msgview, msginfo, all_headers);
2369 MessageView *msgview;
2371 msgview = summaryview->messageview;
2373 summaryview->displayed = row;
2374 if (!messageview_is_visible(msgview))
2375 main_window_toggle_message_view(summaryview->mainwin);
2376 messageview_show(msgview, msginfo, all_headers);
2377 if (msgview->type == MVIEW_TEXT ||
2378 (msgview->type == MVIEW_MIME &&
2379 (GTK_CLIST(msgview->mimeview->ctree)->row_list == NULL ||
2380 gtk_notebook_get_current_page
2381 (GTK_NOTEBOOK(msgview->mimeview->notebook)) == 0)))
2382 gtk_widget_grab_focus(summaryview->ctree);
2384 gtkut_ctree_node_move_if_on_the_edge(ctree, row);
2387 summary_set_menu_sensitive(summaryview);
2388 main_window_set_toolbar_sensitive(summaryview->mainwin);
2390 summary_unlock(summaryview);
2393 void summary_display_msg_selected(SummaryView *summaryview,
2394 gboolean all_headers)
2396 if (summary_is_locked(summaryview)) return;
2397 summaryview->displayed = NULL;
2398 summary_display_msg_full(summaryview, summaryview->selected, FALSE,
2402 void summary_redisplay_msg(SummaryView *summaryview)
2406 if (summaryview->displayed) {
2407 node = summaryview->displayed;
2408 summaryview->displayed = NULL;
2409 summary_display_msg(summaryview, node);
2413 void summary_open_msg(SummaryView *summaryview)
2415 if (!summaryview->selected) return;
2417 summary_display_msg_full(summaryview, summaryview->selected,
2421 void summary_view_source(SummaryView * summaryview)
2423 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2425 SourceWindow *srcwin;
2427 if (!summaryview->selected) return;
2429 srcwin = source_window_create();
2430 msginfo = gtk_ctree_node_get_row_data(ctree, summaryview->selected);
2431 source_window_show_msg(srcwin, msginfo);
2432 source_window_show(srcwin);
2435 void summary_reedit(SummaryView *summaryview)
2439 if (!summaryview->selected) return;
2440 if (!summaryview->folder_item) return;
2441 if (summaryview->folder_item->stype != F_OUTBOX &&
2442 summaryview->folder_item->stype != F_DRAFT &&
2443 summaryview->folder_item->stype != F_QUEUE) return;
2445 msginfo = gtk_ctree_node_get_row_data(GTK_CTREE(summaryview->ctree),
2446 summaryview->selected);
2447 if (!msginfo) return;
2449 compose_reedit(msginfo);
2452 void summary_step(SummaryView *summaryview, GtkScrollType type)
2454 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2457 if (summary_is_locked(summaryview)) return;
2459 if (type == GTK_SCROLL_STEP_FORWARD) {
2460 node = gtkut_ctree_node_next(ctree, summaryview->selected);
2462 gtkut_ctree_expand_parent_all(ctree, node);
2466 if (summaryview->selected) {
2467 node = GTK_CTREE_NODE_PREV(summaryview->selected);
2472 if (messageview_is_visible(summaryview->messageview))
2473 summaryview->display_msg = TRUE;
2475 gtk_signal_emit_by_name(GTK_OBJECT(ctree), "scroll_vertical",
2479 void summary_toggle_view(SummaryView *summaryview)
2481 if (!messageview_is_visible(summaryview->messageview) &&
2482 summaryview->selected)
2483 summary_display_msg(summaryview,
2484 summaryview->selected);
2486 main_window_toggle_message_view(summaryview->mainwin);
2489 static gboolean summary_search_unread_recursive(GtkCTree *ctree,
2495 msginfo = gtk_ctree_node_get_row_data(ctree, node);
2496 if (msginfo && MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
2498 node = GTK_CTREE_ROW(node)->children;
2500 node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
2503 if (summary_search_unread_recursive(ctree, node) == TRUE)
2505 node = GTK_CTREE_ROW(node)->sibling;
2511 static gboolean summary_have_unread_children(SummaryView *summaryview,
2514 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2516 if (!node) return FALSE;
2518 node = GTK_CTREE_ROW(node)->children;
2521 if (summary_search_unread_recursive(ctree, node) == TRUE)
2523 node = GTK_CTREE_ROW(node)->sibling;
2529 static void summary_set_row_marks(SummaryView *summaryview, GtkCTreeNode *row)
2531 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2532 GtkStyle *style = NULL;
2535 gint *col_pos = summaryview->col_pos;
2537 msginfo = gtk_ctree_node_get_row_data(ctree, row);
2538 if (!msginfo) return;
2540 flags = msginfo->flags;
2542 gtk_ctree_node_set_foreground(ctree, row, NULL);
2544 /* set new/unread column */
2545 if (MSG_IS_IGNORE_THREAD(flags)) {
2546 gtk_ctree_node_set_pixmap(ctree, row, col_pos[S_COL_UNREAD],
2547 ignorethreadxpm, ignorethreadxpmmask);
2548 } else if (MSG_IS_NEW(flags)) {
2549 gtk_ctree_node_set_pixmap(ctree, row, col_pos[S_COL_UNREAD],
2550 newxpm, newxpmmask);
2551 } else if (MSG_IS_UNREAD(flags)) {
2552 gtk_ctree_node_set_pixmap(ctree, row, col_pos[S_COL_UNREAD],
2553 unreadxpm, unreadxpmmask);
2554 } else if (MSG_IS_REPLIED(flags)) {
2555 gtk_ctree_node_set_pixmap(ctree, row, col_pos[S_COL_UNREAD],
2556 repliedxpm, repliedxpmmask);
2557 } else if (MSG_IS_FORWARDED(flags)) {
2558 gtk_ctree_node_set_pixmap(ctree, row, col_pos[S_COL_UNREAD],
2559 forwardedxpm, forwardedxpmmask);
2561 gtk_ctree_node_set_text(ctree, row, col_pos[S_COL_UNREAD],
2565 if (prefs_common.bold_unread &&
2566 ((MSG_IS_UNREAD(flags) && !MSG_IS_IGNORE_THREAD(flags)) ||
2567 (!GTK_CTREE_ROW(row)->expanded &&
2568 GTK_CTREE_ROW(row)->children &&
2569 summary_have_unread_children(summaryview, row))))
2572 /* set mark column */
2573 if (MSG_IS_DELETED(flags)) {
2574 gtk_ctree_node_set_pixmap(ctree, row, col_pos[S_COL_MARK],
2575 deletedxpm, deletedxpmmask);
2577 style = bold_deleted_style;
2579 style = small_deleted_style;
2581 gtk_ctree_node_set_foreground
2582 (ctree, row, &summaryview->color_dim);
2583 } else if (MSG_IS_MARKED(flags)) {
2584 gtk_ctree_node_set_pixmap(ctree, row, col_pos[S_COL_MARK],
2585 markxpm, markxpmmask);
2586 } else if (MSG_IS_MOVE(flags)) {
2587 gtk_ctree_node_set_text(ctree, row, col_pos[S_COL_MARK], "o");
2589 style = bold_marked_style;
2591 style = small_marked_style;
2593 gtk_ctree_node_set_foreground
2594 (ctree, row, &summaryview->color_marked);
2595 } else if (MSG_IS_COPY(flags)) {
2596 gtk_ctree_node_set_text(ctree, row, col_pos[S_COL_MARK], "O");
2598 style = bold_marked_style;
2600 style = small_marked_style;
2602 gtk_ctree_node_set_foreground
2603 (ctree, row, &summaryview->color_marked);
2605 else if ((global_scoring ||
2606 summaryview->folder_item->prefs->scoring) &&
2607 (msginfo->score >= summaryview->important_score) &&
2608 (MSG_IS_MARKED(msginfo->flags) || MSG_IS_MOVE(msginfo->flags) || MSG_IS_COPY(msginfo->flags))) {
2609 gtk_ctree_node_set_text(ctree, row, S_COL_MARK, "!");
2610 gtk_ctree_node_set_foreground(ctree, row,
2611 &summaryview->color_important);
2613 gtk_ctree_node_set_text(ctree, row, col_pos[S_COL_MARK], NULL);
2616 if (MSG_IS_LOCKED(flags)) {
2617 gtk_ctree_node_set_pixmap(ctree, row, col_pos[S_COL_LOCKED],
2618 lockedxpm, lockedxpmmask);
2621 gtk_ctree_node_set_text(ctree, row, col_pos[S_COL_LOCKED], NULL);
2624 if (MSG_IS_MIME(flags) && MSG_IS_ENCRYPTED(flags)) {
2625 gtk_ctree_node_set_pixmap(ctree, row, col_pos[S_COL_MIME],
2626 clipkeyxpm, clipkeyxpmmask);
2627 } else if (MSG_IS_ENCRYPTED(flags)) {
2628 gtk_ctree_node_set_pixmap(ctree, row, col_pos[S_COL_MIME],
2629 keyxpm, keyxpmmask);
2630 } else if (MSG_IS_MIME(flags)) {
2631 gtk_ctree_node_set_pixmap(ctree, row, col_pos[S_COL_MIME],
2632 clipxpm, clipxpmmask);
2634 gtk_ctree_node_set_text(ctree, row, col_pos[S_COL_MIME], NULL);
2637 style = small_style;
2639 gtk_ctree_node_set_row_style(ctree, row, style);
2641 if (MSG_GET_COLORLABEL(flags))
2642 summary_set_colorlabel_color(ctree, row, MSG_GET_COLORLABEL_VALUE(flags));
2645 void summary_set_marks_selected(SummaryView *summaryview)
2649 for (cur = GTK_CLIST(summaryview->ctree)->selection; cur != NULL;
2651 summary_set_row_marks(summaryview, GTK_CTREE_NODE(cur->data));
2654 static void summary_mark_row(SummaryView *summaryview, GtkCTreeNode *row)
2656 gboolean changed = FALSE;
2657 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2660 msginfo = gtk_ctree_node_get_row_data(ctree, row);
2661 if (MSG_IS_DELETED(msginfo->flags))
2662 summaryview->deleted--;
2663 if (MSG_IS_MOVE(msginfo->flags)) {
2664 summaryview->moved--;
2667 if (MSG_IS_COPY(msginfo->flags)) {
2668 summaryview->copied--;
2671 if (changed && !prefs_common.immediate_exec) {
2672 msginfo->to_folder->op_count--;
2673 if (msginfo->to_folder->op_count == 0)
2674 folderview_update_item(msginfo->to_folder, 0);
2676 msginfo->to_folder = NULL;
2677 procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, MSG_MOVE | MSG_COPY);
2678 procmsg_msginfo_set_flags(msginfo, MSG_MARKED, 0);
2679 summary_set_row_marks(summaryview, row);
2680 debug_print(_("Message %s/%d is marked\n"), msginfo->folder->path, msginfo->msgnum);
2683 static void summary_lock_row(SummaryView *summaryview, GtkCTreeNode *row)
2685 /* almost verbatim summary_mark_row(); may want a menu action? */
2686 gboolean changed = FALSE;
2687 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2690 msginfo = gtk_ctree_node_get_row_data(ctree, row);
2691 if (MSG_IS_DELETED(msginfo->flags))
2692 summaryview->deleted--;
2693 if (MSG_IS_MOVE(msginfo->flags)) {
2694 summaryview->moved--;
2697 if (MSG_IS_COPY(msginfo->flags)) {
2698 summaryview->copied--;
2701 if (changed && !prefs_common.immediate_exec) {
2702 msginfo->to_folder->op_count--;
2703 if (msginfo->to_folder->op_count == 0)
2704 folderview_update_item(msginfo->to_folder, 0);
2706 msginfo->to_folder = NULL;
2707 procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, MSG_MOVE | MSG_COPY);
2708 procmsg_msginfo_set_flags(msginfo, MSG_LOCKED, 0);
2709 summary_set_row_marks(summaryview, row);
2710 debug_print(_("Message %d is locked\n"), msginfo->msgnum);
2713 void summary_mark(SummaryView *summaryview)
2715 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2718 for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
2719 summary_mark_row(summaryview, GTK_CTREE_NODE(cur->data));
2721 /* summary_step(summaryview, GTK_SCROLL_STEP_FORWARD); */
2722 summary_status_show(summaryview);
2725 static void summary_mark_row_as_read(SummaryView *summaryview,
2728 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2731 msginfo = gtk_ctree_node_get_row_data(ctree, row);
2733 if (MSG_IS_NEW(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
2734 summaryview->newmsgs--;
2735 if (MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
2736 summaryview->unread--;
2738 procmsg_msginfo_unset_flags(msginfo, MSG_NEW | MSG_UNREAD, 0);
2739 summary_set_row_marks(summaryview, row);
2740 debug_print(_("Message %d is marked as read\n"),
2744 void summary_mark_as_read(SummaryView *summaryview)
2746 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2749 for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
2750 summary_mark_row_as_read(summaryview,
2751 GTK_CTREE_NODE(cur->data));
2753 summary_status_show(summaryview);
2756 void summary_mark_all_read(SummaryView *summaryview)
2758 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2759 GtkCList *clist = GTK_CLIST(summaryview->ctree);
2762 gtk_clist_freeze(clist);
2763 for (node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list); node != NULL;
2764 node = gtkut_ctree_node_next(ctree, node))
2765 summary_mark_row_as_read(summaryview, node);
2766 for (node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list); node != NULL;
2767 node = gtkut_ctree_node_next(ctree, node)) {
2768 if (!GTK_CTREE_ROW(node)->expanded)
2769 summary_set_row_marks(summaryview, node);
2771 gtk_clist_thaw(clist);
2773 summary_status_show(summaryview);
2776 static void summary_mark_row_as_unread(SummaryView *summaryview,
2779 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2782 msginfo = gtk_ctree_node_get_row_data(ctree, row);
2783 if (MSG_IS_DELETED(msginfo->flags)) {
2784 msginfo->to_folder = NULL;
2785 procmsg_msginfo_unset_flags(msginfo, MSG_DELETED, 0);
2786 summaryview->deleted--;
2789 if (!MSG_IS_UNREAD(msginfo->flags) && !MSG_IS_IGNORE_THREAD(msginfo->flags))
2790 summaryview->unread++;
2792 procmsg_msginfo_unset_flags(msginfo, MSG_REPLIED | MSG_FORWARDED, 0);
2793 procmsg_msginfo_set_flags(msginfo, MSG_UNREAD, 0);
2794 debug_print(_("Message %d is marked as unread\n"),
2797 summary_set_row_marks(summaryview, row);
2800 void summary_mark_as_unread(SummaryView *summaryview)
2802 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2805 for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
2806 summary_mark_row_as_unread(summaryview,
2807 GTK_CTREE_NODE(cur->data));
2809 summary_status_show(summaryview);
2812 static gboolean check_permission(SummaryView *summaryview, MsgInfo * msginfo)
2817 switch (summaryview->folder_item->folder->type) {
2822 security : checks if one the accounts correspond to
2823 the author of the post
2827 for(cur = account_get_list() ; cur != NULL ; cur = cur->next) {
2828 PrefsAccount * account;
2831 account = cur->data;
2832 if (account->name && *account->name)
2834 g_strdup_printf("%s <%s>",
2839 g_strdup_printf("%s",
2842 if (g_strcasecmp(from_name, msginfo->from) == 0) {
2851 alertpanel_error(_("You're not the author of the article\n"));
2861 static void summary_delete_row(SummaryView *summaryview, GtkCTreeNode *row)
2863 gboolean changed = FALSE;
2864 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2867 msginfo = gtk_ctree_node_get_row_data(ctree, row);
2869 if (!check_permission(summaryview, msginfo))
2872 if (MSG_IS_LOCKED(msginfo->flags)) return;
2874 if (MSG_IS_DELETED(msginfo->flags)) return;
2876 if (MSG_IS_MOVE(msginfo->flags)) {
2877 summaryview->moved--;
2880 if (MSG_IS_COPY(msginfo->flags)) {
2881 summaryview->copied--;
2884 if (changed && !prefs_common.immediate_exec) {
2885 msginfo->to_folder->op_count--;
2886 if (msginfo->to_folder->op_count == 0)
2887 folderview_update_item(msginfo->to_folder, 0);
2889 msginfo->to_folder = NULL;
2890 procmsg_msginfo_unset_flags(msginfo, MSG_MARKED, MSG_MOVE | MSG_COPY);
2891 procmsg_msginfo_set_flags(msginfo, MSG_DELETED, 0);
2892 summaryview->deleted++;
2894 if (!prefs_common.immediate_exec &&
2895 summaryview->folder_item->stype != F_TRASH)
2896 summary_set_row_marks(summaryview, row);
2898 debug_print(_("Message %s/%d is set to delete\n"),
2899 msginfo->folder->path, msginfo->msgnum);
2902 void summary_delete(SummaryView *summaryview)
2904 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
2905 FolderItem *item = summaryview->folder_item;
2907 GtkCTreeNode *sel_last = NULL;
2912 if (!item || item->folder->type == F_NEWS) return;
2915 if (summary_is_locked(summaryview)) return;
2917 /* if current folder is trash, ask for confirmation */
2918 if (item->stype == F_TRASH) {
2921 aval = alertpanel(_("Delete message(s)"),
2922 _("Do you really want to delete message(s) from the trash?"),
2923 _("Yes"), _("No"), NULL);
2924 if (aval != G_ALERTDEFAULT) return;
2927 /* next code sets current row focus right. We need to find a row
2928 * that is not deleted. */
2929 for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next) {
2930 sel_last = GTK_CTREE_NODE(cur->data);
2931 summary_delete_row(summaryview, sel_last);
2934 node = summary_find_next_msg(summaryview, sel_last);
2936 node = summary_find_prev_msg(summaryview, sel_last);
2939 if (sel_last && node == gtkut_ctree_node_next(ctree, sel_last))
2940 summary_step(summaryview, GTK_SCROLL_STEP_FORWARD);
2941 else if (sel_last && node == GTK_CTREE_NODE_PREV(sel_last))
2942 summary_step(summaryview, GTK_SCROLL_STEP_BACKWARD);
2946 messageview_is_visible(summaryview->messageview),
2950 if (prefs_common.immediate_exec || item->stype == F_TRASH)
2951 summary_execute(summaryview);
2953 summary_status_show(summaryview);
2956 void summary_delete_duplicated(SummaryView *summaryview)
2958 if (!summaryview->folder_item ||
2959 summaryview->folder_item->folder->type == F_NEWS) return;
2960 if (summaryview->folder_item->stype == F_TRASH) return;
2962 main_window_cursor_wait(summaryview->mainwin);
2963 debug_print(_("Deleting duplicated messages..."));
2964 STATUSBAR_PUSH(summaryview->mainwin,
2965 _("Deleting duplicated messages..."));
2967 gtk_ctree_pre_recursive(GTK_CTREE(summaryview->ctree), NULL,
2968 GTK_CTREE_FUNC(summary_delete_duplicated_func),
2971 if (prefs_common.immediate_exec)
2972 summary_execute(summaryview);
2974 summary_status_show(summaryview);
2976 debug_print(_("done.\n"));
2977 STATUSBAR_POP(summaryview->mainwin);
2978 main_window_cursor_normal(summaryview->mainwin);
2981 static void summary_delete_duplicated_func(GtkCTree *ctree, GtkCTreeNode *node,
2982 SummaryView *summaryview)
2984 GtkCTreeNode *found;
2985 MsgInfo *msginfo = GTK_CTREE_ROW(node)->row.data;
2987 if (!msginfo->msgid || !*msginfo->msgid) return;
2989 found = g_hash_table_lookup(summaryview->msgid_table, msginfo->msgid);
2991 if (found && found != node)
2992 summary_delete_row(summaryview, node);
2995 static void summary_unmark_row(SummaryView *summaryview, GtkCTreeNode *row)
2997 gboolean changed = FALSE;
2998 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3001 msginfo = gtk_ctree_node_get_row_data(ctree, row);
3002 if (MSG_IS_DELETED(msginfo->flags))
3003 summaryview->deleted--;
3004 if (MSG_IS_MOVE(msginfo->flags)) {
3005 summaryview->moved--;
3008 if (MSG_IS_COPY(msginfo->flags)) {
3009 summaryview->copied--;
3012 if (changed && !prefs_common.immediate_exec) {
3013 msginfo->to_folder->op_count--;
3014 if (msginfo->to_folder->op_count == 0)
3015 folderview_update_item(msginfo->to_folder, 0);
3017 msginfo->to_folder = NULL;
3018 procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_MOVE | MSG_COPY);
3019 summary_set_row_marks(summaryview, row);
3021 debug_print(_("Message %s/%d is unmarked\n"),
3022 msginfo->folder->path, msginfo->msgnum);
3025 void summary_unmark(SummaryView *summaryview)
3027 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3030 for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
3031 summary_unmark_row(summaryview, GTK_CTREE_NODE(cur->data));
3033 summary_status_show(summaryview);
3036 static void summary_move_row_to(SummaryView *summaryview, GtkCTreeNode *row,
3037 FolderItem *to_folder)
3039 gboolean changed = FALSE;
3040 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3043 g_return_if_fail(to_folder != NULL);
3045 msginfo = gtk_ctree_node_get_row_data(ctree, row);
3046 if (MSG_IS_MOVE(msginfo->flags)) {
3047 if (!prefs_common.immediate_exec) {
3048 msginfo->to_folder->op_count--;
3049 if (msginfo->to_folder->op_count == 0) {
3050 folderview_update_item(msginfo->to_folder, 0);
3055 msginfo->to_folder = to_folder;
3056 if (MSG_IS_DELETED(msginfo->flags))
3057 summaryview->deleted--;
3058 if (MSG_IS_COPY(msginfo->flags)) {
3059 summaryview->copied--;
3060 if (!prefs_common.immediate_exec)
3061 msginfo->to_folder->op_count--;
3063 procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_COPY);
3064 if (!MSG_IS_MOVE(msginfo->flags)) {
3065 procmsg_msginfo_set_flags(msginfo, 0, MSG_MOVE);
3066 summaryview->moved++;
3069 if (!prefs_common.immediate_exec) {
3070 summary_set_row_marks(summaryview, row);
3072 msginfo->to_folder->op_count++;
3073 if (msginfo->to_folder->op_count == 1)
3074 folderview_update_item(msginfo->to_folder, 0);
3078 debug_print(_("Message %d is set to move to %s\n"),
3079 msginfo->msgnum, to_folder->path);
3082 void summary_move_selected_to(SummaryView *summaryview, FolderItem *to_folder)
3086 if (!to_folder) return;
3087 if (!summaryview->folder_item ||
3088 summaryview->folder_item->folder->type == F_NEWS) return;
3090 if (summary_is_locked(summaryview)) return;
3092 if (summaryview->folder_item == to_folder) {
3093 alertpanel_notice(_("Destination is same as current folder."));
3097 for (cur = GTK_CLIST(summaryview->ctree)->selection;
3098 cur != NULL; cur = cur->next)
3100 (summaryview, GTK_CTREE_NODE(cur->data), to_folder);
3102 summary_step(summaryview, GTK_SCROLL_STEP_FORWARD);
3104 if (prefs_common.immediate_exec)
3105 summary_execute(summaryview);
3107 summary_status_show(summaryview);
3109 folderview_update_item(to_folder, 0);
3113 void summary_move_to(SummaryView *summaryview)
3115 FolderItem *to_folder;
3117 if (!summaryview->folder_item ||
3118 summaryview->folder_item->folder->type == F_NEWS) return;
3120 to_folder = foldersel_folder_sel(summaryview->folder_item->folder,
3121 FOLDER_SEL_MOVE, NULL);
3122 summary_move_selected_to(summaryview, to_folder);
3125 static void summary_copy_row_to(SummaryView *summaryview, GtkCTreeNode *row,
3126 FolderItem *to_folder)
3128 gboolean changed = FALSE;
3129 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3132 g_return_if_fail(to_folder != NULL);
3134 msginfo = gtk_ctree_node_get_row_data(ctree, row);
3135 if (MSG_IS_COPY(msginfo->flags)) {
3136 if (!prefs_common.immediate_exec) {
3137 msginfo->to_folder->op_count--;
3138 if (msginfo->to_folder->op_count == 0) {
3139 folderview_update_item(msginfo->to_folder, 0);
3144 msginfo->to_folder = to_folder;
3145 if (MSG_IS_DELETED(msginfo->flags))
3146 summaryview->deleted--;
3147 if (MSG_IS_MOVE(msginfo->flags)) {
3148 summaryview->moved--;
3149 if (!prefs_common.immediate_exec)
3150 msginfo->to_folder->op_count--;
3152 procmsg_msginfo_unset_flags(msginfo, MSG_MARKED | MSG_DELETED, MSG_MOVE);
3153 if (!MSG_IS_COPY(msginfo->flags)) {
3154 procmsg_msginfo_set_flags(msginfo, 0, MSG_COPY);
3155 summaryview->copied++;
3158 if (!prefs_common.immediate_exec) {
3159 summary_set_row_marks(summaryview, row);
3161 msginfo->to_folder->op_count++;
3162 if (msginfo->to_folder->op_count == 1)
3163 folderview_update_item(msginfo->to_folder, 0);
3167 debug_print(_("Message %d is set to copy to %s\n"),
3168 msginfo->msgnum, to_folder->path);
3171 void summary_copy_selected_to(SummaryView *summaryview, FolderItem *to_folder)
3175 if (!to_folder) return;
3176 if (!summaryview->folder_item) return;
3178 if (summary_is_locked(summaryview)) return;
3180 if (summaryview->folder_item == to_folder) {
3182 (_("Destination to copy is same as current folder."));
3186 for (cur = GTK_CLIST(summaryview->ctree)->selection;
3187 cur != NULL; cur = cur->next)
3189 (summaryview, GTK_CTREE_NODE(cur->data), to_folder);
3191 summary_step(summaryview, GTK_SCROLL_STEP_FORWARD);
3193 if (prefs_common.immediate_exec)
3194 summary_execute(summaryview);
3196 summary_status_show(summaryview);
3198 folderview_update_item(to_folder, 0);
3202 void summary_copy_to(SummaryView *summaryview)
3204 FolderItem *to_folder;
3206 if (!summaryview->folder_item) return;
3208 to_folder = foldersel_folder_sel(summaryview->folder_item->folder,
3209 FOLDER_SEL_COPY, NULL);
3210 summary_copy_selected_to(summaryview, to_folder);
3213 void summary_add_address(SummaryView *summaryview)
3218 msginfo = gtk_ctree_node_get_row_data(GTK_CTREE(summaryview->ctree),
3219 summaryview->selected);
3220 if (!msginfo) return;
3222 Xstrdup_a(from, msginfo->from, return);
3223 eliminate_address_comment(from);
3224 extract_address(from);
3225 addressbook_add_contact(msginfo->fromname, from, NULL);
3228 void summary_select_all(SummaryView *summaryview)
3230 if (summaryview->messages >= 500) {
3231 STATUSBAR_PUSH(summaryview->mainwin,
3232 _("Selecting all messages..."));
3233 main_window_cursor_wait(summaryview->mainwin);
3236 gtk_clist_select_all(GTK_CLIST(summaryview->ctree));
3238 if (summaryview->messages >= 500) {
3239 STATUSBAR_POP(summaryview->mainwin);
3240 main_window_cursor_normal(summaryview->mainwin);
3244 void summary_unselect_all(SummaryView *summaryview)
3246 gtk_sctree_unselect_all(GTK_SCTREE(summaryview->ctree));
3249 void summary_save_as(SummaryView *summaryview)
3251 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3253 gchar *filename = NULL;
3256 if (!summaryview->selected) return;
3257 msginfo = gtk_ctree_node_get_row_data(ctree, summaryview->selected);
3258 if (!msginfo) return;
3260 if (msginfo->subject) {
3261 Xstrdup_a(filename, msginfo->subject, return);
3262 subst_for_filename(filename);
3264 dest = filesel_select_file(_("Save as"), filename);
3266 if (is_file_exist(dest)) {
3269 aval = alertpanel(_("Overwrite"),
3270 _("Overwrite existing file?"),
3271 _("OK"), _("Cancel"), NULL);
3272 if (G_ALERTDEFAULT != aval) return;
3275 src = procmsg_get_message_file(msginfo);
3276 if (copy_file(src, dest) < 0) {
3277 alertpanel_error(_("Can't save the file `%s'."),
3283 void summary_print(SummaryView *summaryview)
3285 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3286 GtkCList *clist = GTK_CLIST(summaryview->ctree);
3292 if (clist->selection == NULL) return;
3294 cmdline = input_dialog(_("Print"),
3295 _("Enter the print command line:\n"
3296 "(`%s' will be replaced with file name)"),
3297 prefs_common.print_cmd);
3298 if (!cmdline) return;
3299 if (!(p = strchr(cmdline, '%')) || *(p + 1) != 's' ||
3300 strchr(p + 2, '%')) {
3301 alertpanel_error(_("Print command line is invalid:\n`%s'"),
3307 for (cur = clist->selection; cur != NULL; cur = cur->next) {
3308 msginfo = gtk_ctree_node_get_row_data
3309 (ctree, GTK_CTREE_NODE(cur->data));
3310 if (msginfo) procmsg_print_message(msginfo, cmdline);
3316 gboolean summary_execute(SummaryView *summaryview)
3318 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3319 GtkCList *clist = GTK_CLIST(summaryview->ctree);
3320 GtkCTreeNode *node, *next;
3322 if (!summaryview->folder_item) return FALSE;
3324 if (summary_is_locked(summaryview)) return FALSE;
3325 summary_lock(summaryview);
3327 gtk_clist_freeze(clist);
3329 if (summaryview->folder_item->threaded)
3330 summary_unthread_for_exec(summaryview);
3332 summary_execute_move(summaryview);
3333 summary_execute_copy(summaryview);
3334 summary_execute_delete(summaryview);
3336 node = GTK_CTREE_NODE(clist->row_list);
3337 while (node != NULL) {
3338 next = gtkut_ctree_node_next(ctree, node);
3339 if (gtk_ctree_node_get_row_data(ctree, node) == NULL) {
3340 if (node == summaryview->displayed) {
3341 messageview_clear(summaryview->messageview);
3342 summaryview->displayed = NULL;
3344 if (GTK_CTREE_ROW(node)->children != NULL)
3345 g_warning("summary_execute(): children != NULL\n");
3347 gtk_ctree_remove_node(ctree, node);
3352 if (summaryview->folder_item->threaded)
3353 summary_thread_build(summaryview);
3355 summaryview->selected = clist->selection ?
3356 GTK_CTREE_NODE(clist->selection->data) : NULL;
3358 if (!GTK_CLIST(summaryview->ctree)->row_list) {
3359 menu_set_insensitive_all
3360 (GTK_MENU_SHELL(summaryview->popupmenu));
3361 gtk_widget_grab_focus(summaryview->folderview->ctree);
3363 gtk_widget_grab_focus(summaryview->ctree);
3365 summary_update_status(summaryview);
3366 summary_status_show(summaryview);
3368 summary_write_cache(summaryview);
3370 gtk_ctree_node_moveto(ctree, summaryview->selected, -1, 0.5, 0);
3372 gtk_clist_thaw(clist);
3374 summary_unlock(summaryview);
3378 static void summary_execute_move(SummaryView *summaryview)
3380 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3383 summaryview->folder_table = g_hash_table_new(NULL, NULL);
3385 /* search moving messages and execute */
3386 gtk_ctree_pre_recursive(ctree, NULL, summary_execute_move_func,
3389 if (summaryview->mlist) {
3390 procmsg_move_messages(summaryview->mlist);
3392 folderview_update_item_foreach(summaryview->folder_table);
3394 for (cur = summaryview->mlist; cur != NULL; cur = cur->next)
3395 procmsg_msginfo_free((MsgInfo *)cur->data);
3396 g_slist_free(summaryview->mlist);
3397 summaryview->mlist = NULL;
3400 folderview_update_item(summaryview->folder_item, FALSE);
3401 g_hash_table_destroy(summaryview->folder_table);
3402 summaryview->folder_table = NULL;
3405 static void summary_execute_move_func(GtkCTree *ctree, GtkCTreeNode *node,
3408 SummaryView *summaryview = data;
3411 msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
3413 if (msginfo && MSG_IS_MOVE(msginfo->flags) && msginfo->to_folder) {
3414 if (!prefs_common.immediate_exec &&
3415 msginfo->to_folder->op_count > 0)
3416 msginfo->to_folder->op_count--;
3418 g_hash_table_insert(summaryview->folder_table,
3419 msginfo->to_folder, GINT_TO_POINTER(1));
3421 summaryview->mlist =
3422 g_slist_append(summaryview->mlist, msginfo);
3423 gtk_ctree_node_set_row_data(ctree, node, NULL);
3425 if (msginfo->msgid && *msginfo->msgid &&
3426 node == g_hash_table_lookup(summaryview->msgid_table,
3428 g_hash_table_remove(summaryview->msgid_table,
3433 static void summary_execute_copy(SummaryView *summaryview)
3435 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3437 summaryview->folder_table = g_hash_table_new(NULL, NULL);
3439 /* search copying messages and execute */
3440 gtk_ctree_pre_recursive(ctree, NULL, summary_execute_copy_func,
3443 if (summaryview->mlist) {
3444 procmsg_copy_messages(summaryview->mlist);
3446 /* folder_item_scan_foreach(summaryview->folder_table); */
3447 folderview_update_item_foreach(summaryview->folder_table);
3449 g_slist_free(summaryview->mlist);
3450 summaryview->mlist = NULL;
3453 g_hash_table_destroy(summaryview->folder_table);
3454 summaryview->folder_table = NULL;
3457 static void summary_execute_copy_func(GtkCTree *ctree, GtkCTreeNode *node,
3460 SummaryView *summaryview = data;
3463 msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
3465 if (msginfo && MSG_IS_COPY(msginfo->flags) && msginfo->to_folder) {
3466 if (!prefs_common.immediate_exec &&
3467 msginfo->to_folder->op_count > 0)
3468 msginfo->to_folder->op_count--;
3470 g_hash_table_insert(summaryview->folder_table,
3471 msginfo->to_folder, GINT_TO_POINTER(1));
3473 summaryview->mlist =
3474 g_slist_append(summaryview->mlist, msginfo);
3476 procmsg_msginfo_unset_flags(msginfo, 0, MSG_COPY);
3477 summary_set_row_marks(summaryview, node);
3481 static void summary_execute_delete(SummaryView *summaryview)
3483 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3487 trash = summaryview->folder_item->folder->trash;
3488 if (summaryview->folder_item->folder->type == F_MH) {
3489 g_return_if_fail(trash != NULL);
3492 /* search deleting messages and execute */
3493 gtk_ctree_pre_recursive
3494 (ctree, NULL, summary_execute_delete_func, summaryview);
3496 if (!summaryview->mlist) return;
3498 if (trash == NULL || summaryview->folder_item == trash)
3499 folder_item_remove_msgs(summaryview->folder_item,
3500 summaryview->mlist);
3502 folder_item_move_msgs_with_dest(trash, summaryview->mlist);
3504 for (cur = summaryview->mlist; cur != NULL; cur = cur->next)
3505 procmsg_msginfo_free((MsgInfo *)cur->data);
3507 g_slist_free(summaryview->mlist);
3508 summaryview->mlist = NULL;
3510 if ((summaryview->folder_item != trash) && (trash != NULL)) {
3511 folderview_update_item(trash, FALSE);
3513 folderview_update_item(summaryview->folder_item, FALSE);
3516 static void summary_execute_delete_func(GtkCTree *ctree, GtkCTreeNode *node,
3519 SummaryView *summaryview = data;
3522 msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
3524 if (msginfo && MSG_IS_DELETED(msginfo->flags)) {
3525 summaryview->mlist =
3526 g_slist_append(summaryview->mlist, msginfo);
3527 gtk_ctree_node_set_row_data(ctree, node, NULL);
3529 if (msginfo->msgid && *msginfo->msgid &&
3530 node == g_hash_table_lookup(summaryview->msgid_table,
3532 g_hash_table_remove(summaryview->msgid_table,
3537 /* thread functions */
3539 void summary_thread_build(SummaryView *summaryview)
3541 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3544 GtkCTreeNode *parent;
3547 summary_lock(summaryview);
3549 debug_print(_("Building threads..."));
3550 STATUSBAR_PUSH(summaryview->mainwin, _("Building threads..."));
3551 main_window_cursor_wait(summaryview->mainwin);
3553 gtk_signal_handler_block_by_func(GTK_OBJECT(ctree),
3554 summary_tree_expanded, summaryview);
3555 gtk_clist_freeze(GTK_CLIST(ctree));
3557 node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
3559 next = GTK_CTREE_ROW(node)->sibling;
3561 msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
3565 /* alfons - claws seems to prefer subject threading before
3566 * inreplyto threading. we should look more deeply in this,
3567 * because inreplyto should have precedence... */
3568 if (msginfo && msginfo->inreplyto) {
3569 parent = g_hash_table_lookup(summaryview->msgid_table,
3570 msginfo->inreplyto);
3573 if (parent == NULL) {
3574 parent = subject_table_lookup
3575 (summaryview->subject_table,
3579 if (parent && parent != node) {
3580 gtk_ctree_move(ctree, node, parent, NULL);
3581 gtk_ctree_expand(ctree, node);
3587 node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
3590 next = GTK_CTREE_NODE_NEXT(node);
3591 if (prefs_common.expand_thread)
3592 gtk_ctree_expand(ctree, node);
3593 if (prefs_common.bold_unread &&
3594 GTK_CTREE_ROW(node)->children)
3595 summary_set_row_marks(summaryview, node);
3599 gtk_clist_thaw(GTK_CLIST(ctree));
3600 gtk_signal_handler_unblock_by_func(GTK_OBJECT(ctree),
3601 summary_tree_expanded, summaryview);
3603 debug_print(_("done.\n"));
3604 STATUSBAR_POP(summaryview->mainwin);
3605 main_window_cursor_normal(summaryview->mainwin);
3607 summary_unlock(summaryview);
3610 static void summary_thread_init(SummaryView *summaryview)
3612 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3613 GtkCTreeNode *node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
3616 if (prefs_common.expand_thread) {
3618 next = GTK_CTREE_ROW(node)->sibling;
3619 if (GTK_CTREE_ROW(node)->children)
3620 gtk_ctree_expand(ctree, node);
3623 } else if (prefs_common.bold_unread) {
3625 next = GTK_CTREE_ROW(node)->sibling;
3626 if (GTK_CTREE_ROW(node)->children)
3627 summary_set_row_marks(summaryview, node);
3633 void summary_unthread(SummaryView *summaryview)
3635 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3637 GtkCTreeNode *child;
3638 GtkCTreeNode *sibling;
3639 GtkCTreeNode *next_child;
3641 summary_lock(summaryview);
3643 debug_print(_("Unthreading..."));
3644 STATUSBAR_PUSH(summaryview->mainwin, _("Unthreading..."));
3645 main_window_cursor_wait(summaryview->mainwin);
3647 gtk_signal_handler_block_by_func(GTK_OBJECT(ctree),
3648 summary_tree_collapsed, summaryview);
3649 gtk_clist_freeze(GTK_CLIST(ctree));
3651 for (node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
3652 node != NULL; node = GTK_CTREE_NODE_NEXT(node)) {
3653 child = GTK_CTREE_ROW(node)->children;
3654 sibling = GTK_CTREE_ROW(node)->sibling;
3656 while (child != NULL) {
3657 next_child = GTK_CTREE_ROW(child)->sibling;
3658 gtk_ctree_move(ctree, child, NULL, sibling);
3663 /* CLAWS: and sort it */
3664 gtk_sctree_sort_recursive(ctree, NULL);
3666 gtk_clist_thaw(GTK_CLIST(ctree));
3667 gtk_signal_handler_unblock_by_func(GTK_OBJECT(ctree),
3668 summary_tree_collapsed, summaryview);
3670 debug_print(_("done.\n"));
3671 STATUSBAR_POP(summaryview->mainwin);
3672 main_window_cursor_normal(summaryview->mainwin);
3674 summary_unlock(summaryview);
3677 static void summary_unthread_for_exec(SummaryView *summaryview)
3680 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3682 summary_lock(summaryview);
3684 debug_print(_("Unthreading for execution..."));
3686 gtk_clist_freeze(GTK_CLIST(ctree));
3688 for (node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
3689 node != NULL; node = GTK_CTREE_NODE_NEXT(node)) {
3690 summary_unthread_for_exec_func(ctree, node, NULL);
3693 gtk_clist_thaw(GTK_CLIST(ctree));
3695 debug_print(_("done.\n"));
3697 summary_unlock(summaryview);
3700 static void summary_unthread_for_exec_func(GtkCTree *ctree, GtkCTreeNode *node,
3704 GtkCTreeNode *top_parent;
3705 GtkCTreeNode *child;
3706 GtkCTreeNode *sibling;
3708 msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
3711 (!MSG_IS_MOVE(msginfo->flags) &&
3712 !MSG_IS_DELETED(msginfo->flags)))
3714 child = GTK_CTREE_ROW(node)->children;
3717 for (top_parent = node;
3718 GTK_CTREE_ROW(top_parent)->parent != NULL;
3719 top_parent = GTK_CTREE_ROW(top_parent)->parent)
3721 sibling = GTK_CTREE_ROW(top_parent)->sibling;
3723 while (child != NULL) {
3724 GtkCTreeNode *next_child;
3726 next_child = GTK_CTREE_ROW(child)->sibling;
3727 gtk_ctree_move(ctree, child, NULL, sibling);
3732 void summary_processing(SummaryView *summaryview, GSList * mlist)
3734 GSList * processing_list;
3735 FolderItem * folder_item;
3739 folder_item = summaryview->folder_item;
3740 if (folder_item == NULL)
3743 processing_list = folder_item->prefs->processing;
3745 if (processing_list == NULL)
3748 summary_lock(summaryview);
3750 buf = g_strdup_printf(_("Processing (%s)..."), folder_item->path);
3752 STATUSBAR_PUSH(summaryview->mainwin, buf);
3755 main_window_cursor_wait(summaryview->mainwin);
3757 summaryview->folder_table = g_hash_table_new(NULL, NULL);
3759 for(cur = mlist ; cur != NULL ; cur = cur->next) {
3762 msginfo = (MsgInfo *) cur->data;
3763 filter_message_by_msginfo(processing_list, msginfo,
3764 summaryview->folder_table);
3767 /* folder_item_scan_foreach(summaryview->folder_table); */
3768 folderview_update_item_foreach(summaryview->folder_table);
3770 g_hash_table_destroy(summaryview->folder_table);
3771 summaryview->folder_table = NULL;
3773 if (prefs_common.immediate_exec) {
3774 summary_unlock(summaryview);
3775 summary_execute(summaryview);
3776 summary_lock(summaryview);
3778 summary_status_show(summaryview);
3780 debug_print(_("done.\n"));
3781 STATUSBAR_POP(summaryview->mainwin);
3782 main_window_cursor_normal(summaryview->mainwin);
3784 summary_unlock(summaryview);
3787 void summary_expand_threads(SummaryView *summaryview)
3789 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3790 GtkCTreeNode *node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
3792 gtk_clist_freeze(GTK_CLIST(ctree));
3795 if (GTK_CTREE_ROW(node)->children)
3796 gtk_ctree_expand(ctree, node);
3797 node = GTK_CTREE_NODE_NEXT(node);
3800 gtk_clist_thaw(GTK_CLIST(ctree));
3802 gtk_ctree_node_moveto(ctree, summaryview->selected, -1, 0.5, 0);
3805 void summary_collapse_threads(SummaryView *summaryview)
3807 GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
3808 GtkCTreeNode *node = GTK_CTREE_NODE(GTK_CLIST(ctree)->row_list);
3810 gtk_clist_freeze(GTK_CLIST(ctree));
3813 if (GTK_CTREE_ROW(node)->children)
3814 gtk_ctree_collapse(ctree, node);
3815 node = GTK_CTREE_ROW(node)->sibling;
3818 gtk_clist_thaw(GTK_CLIST(ctree));
3820 gtk_ctree_node_moveto(ctree, summaryview->selected, -1, 0.5, 0);
3823 void summary_filter(SummaryView *summaryview)
3825 if (!prefs_common.fltlist && !global_processing) {
3826 alertpanel_error(_("No filter rules defined."));
3830 summary_lock(summaryview);
3832 debug_print(_("filtering..."));
3833 STATUSBAR_PUSH(summaryview->mainwin, _("Filtering..."));
3834 main_window_cursor_wait(summaryview->mainwin);
3836 gtk_clist_freeze(GTK_CLIST(summaryview->ctree));
3838 if (global_processing == NULL) {
3839 gtk_ctree_pre_recursive(GTK_CTREE(summaryview->ctree), NULL,
3840 GTK_CTREE_FUNC(summary_filter_func),
3843 gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
3845 if (prefs_common.immediate_exec) {
3846 summary_unlock(summaryview);
3847 summary_execute(summaryview);
3848 summary_lock(summaryview);
3850 summary_status_show(summaryview);
3853 summaryview->folder_table = g_hash_table_new(NULL, NULL);
3855 gtk_ctree_pre_recursive(GTK_CTREE(summaryview->ctree), NULL,
3856 GTK_CTREE_FUNC(summary_filter_func),
3859 gtk_clist_thaw(GTK_CLIST(summaryview->ctree));
3861 /* folder_item_scan_foreach(summaryview->folder_table); */
3862 folderview_update_item_foreach(summaryview->folder_table);
3864 g_hash_table_destroy(summaryview->folder_table);
3865 summaryview->folder_table = NULL;
3868 debug_print(_("done.\n"));
3869 STATUSBAR_POP(summaryview->mainwin);
3870 main_window_cursor_normal(summaryview->mainwin);
3872 summary_unlock(summaryview);
3875 * CLAWS: summary_show() only valid after having a lock. ideally
3876 * we want the lock to be context aware...
3878 if (global_processing) {
3879 summary_show(summaryview, summaryview->folder_item, TRUE);
3883 static void summary_filter_func(GtkCTree *ctree, GtkCTreeNode *node,
3886 MsgInfo *msginfo = GTKUT_CTREE_NODE_GET_ROW_DATA(node);
3887 SummaryView *summaryview = data;
3891 if (global_processing == NULL) {
3893 file = procmsg_get_message_file(msginfo);
3894 dest = filter_get_dest_folder(prefs_common.fltlist, file);
3897 if (dest && strcmp2(dest->path, FILTER_NOT_RECEIVE) != 0 &&
3898 summaryview->folder_item != dest)
3899 summary_move_row_to(summaryview, node, dest);
3901 filter_message_by_msginfo(global_processing, msginfo, summaryview->folder_table);
3904 void summary_filter_open(SummaryView *summaryview, PrefsFilterType type)
3906 static HeaderEntry hentry[] = {{"X-BeenThere:", NULL, FALSE},
3907 {"X-ML-Name:", NULL, FALSE},