2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2024 the Claws Mail team and 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 3 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, see <http://www.gnu.org/licenses/>.
23 #include <glib/gi18n.h>
24 #include <gdk/gdkkeysyms.h>
35 #include "mainwindow.h"
36 #include "folderview.h"
37 #include "summaryview.h"
38 #include "messageview.h"
40 #include "foldersel.h"
42 #include "procheader.h"
43 #include "sourcewindow.h"
44 #include "prefs_common.h"
45 #include "prefs_summary_column.h"
46 #include "prefs_summary_open.h"
47 #include "prefs_filtering.h"
50 #include "file-utils.h"
53 #include "stock_pixmap.h"
55 #include "alertpanel.h"
56 #include "inputdialog.h"
57 #include "statusbar.h"
59 #include "colorlabel.h"
62 #ifndef USE_ALT_ADDRBOOK
63 #include "addressbook.h"
65 #include "addressbook-dbus.h"
66 #include "addressadd.h"
68 #include "addr_compl.h"
69 #include "folder_item_prefs.h"
70 #include "filtering.h"
71 #include "string_match.h"
75 #include "description_window.h"
76 #include "folderutils.h"
77 #include "quicksearch.h"
78 #include "partial_download.h"
84 #include "manage_window.h"
87 #define SUMMARY_COL_MARK_WIDTH 10
88 #define SUMMARY_COL_STATUS_WIDTH 13
89 #define SUMMARY_COL_LOCKED_WIDTH 13
90 #define SUMMARY_COL_MIME_WIDTH 11
92 static int normal_row_height
= -1;
93 static GtkStyle
*bold_style
;
95 static GdkPixbuf
*markxpm
;
96 static GdkPixbuf
*deletedxpm
;
97 static GdkPixbuf
*movedxpm
;
98 static GdkPixbuf
*copiedxpm
;
100 static GdkPixbuf
*newxpm
;
101 static GdkPixbuf
*unreadxpm
;
102 static GdkPixbuf
*repliedxpm
;
103 static GdkPixbuf
*forwardedxpm
;
104 static GdkPixbuf
*repliedandforwardedxpm
;
105 static GdkPixbuf
*ignorethreadxpm
;
106 static GdkPixbuf
*watchthreadxpm
;
107 static GdkPixbuf
*lockedxpm
;
108 static GdkPixbuf
*spamxpm
;
110 static GdkPixbuf
*clipxpm
;
111 static GdkPixbuf
*keyxpm
;
112 static GdkPixbuf
*clipkeyxpm
;
113 static GdkPixbuf
*keysignxpm
;
114 static GdkPixbuf
*gpgsignedxpm
;
115 static GdkPixbuf
*clipgpgsignedxpm
;
117 static void summary_free_msginfo_func (GtkCMCTree
*ctree
,
118 GtkCMCTreeNode
*node
,
120 static void summary_set_marks_func (GtkCMCTree
*ctree
,
121 GtkCMCTreeNode
*node
,
124 void summary_set_menu_sensitive (SummaryView
*summaryview
);
125 guint
summary_get_msgnum (SummaryView
*summaryview
,
126 GtkCMCTreeNode
*node
);
129 static void summary_set_hide_menu (SummaryView
*summaryview
,
130 const gchar
*menu_item
,
133 static GtkCMCTreeNode
*summary_find_prev_msg
134 (SummaryView
*summaryview
,
135 GtkCMCTreeNode
*current_node
,
136 gboolean start_from_prev
);
137 static GtkCMCTreeNode
*summary_find_next_msg
138 (SummaryView
*summaryview
,
139 GtkCMCTreeNode
*current_node
,
140 gboolean start_from_next
);
142 static GtkCMCTreeNode
*summary_find_prev_flagged_msg
143 (SummaryView
*summaryview
,
144 GtkCMCTreeNode
*current_node
,
146 gboolean start_from_prev
);
147 static GtkCMCTreeNode
*summary_find_next_flagged_msg
148 (SummaryView
*summaryview
,
149 GtkCMCTreeNode
*current_node
,
151 gboolean start_from_next
);
153 static GtkCMCTreeNode
*summary_find_msg_by_msgnum
154 (SummaryView
*summaryview
,
157 static void summary_update_status (SummaryView
*summaryview
);
159 /* display functions */
160 static void summary_status_show (SummaryView
*summaryview
);
161 static void summary_set_column_titles (SummaryView
*summaryview
);
162 static void summary_set_ctree_from_list (SummaryView
*summaryview
,
164 guint selected_msgnum
);
165 static inline void summary_set_header (SummaryView
*summaryview
,
168 static void summary_display_msg (SummaryView
*summaryview
,
169 GtkCMCTreeNode
*row
);
170 static void summary_display_msg_full (SummaryView
*summaryview
,
173 gboolean all_headers
);
174 static void summary_set_row_marks (SummaryView
*summaryview
,
175 GtkCMCTreeNode
*row
);
177 static gboolean
summary_set_row_tag (SummaryView
*summaryview
,
182 /* message handling */
183 static void summary_mark_row (SummaryView
*summaryview
,
184 GtkCMCTreeNode
*row
);
185 static void summary_lock_row (SummaryView
*summaryview
,
186 GtkCMCTreeNode
*row
);
187 static void summary_unlock_row (SummaryView
*summaryview
,
188 GtkCMCTreeNode
*row
);
189 static void summary_mark_row_as_read (SummaryView
*summaryview
,
190 GtkCMCTreeNode
*row
);
191 static void summary_mark_row_as_unread (SummaryView
*summaryview
,
192 GtkCMCTreeNode
*row
);
193 static gboolean
summary_mark_all_read_confirm(gboolean ask_if_needed
);
194 static gboolean
summary_mark_all_unread_confirm(gboolean ask_if_needed
);
195 static void summary_delete_row (SummaryView
*summaryview
,
196 GtkCMCTreeNode
*row
);
197 static void summary_unmark_row (SummaryView
*summaryview
,
198 GtkCMCTreeNode
*row
);
199 static void summary_move_row_to (SummaryView
*summaryview
,
201 FolderItem
*to_folder
);
202 static void summary_copy_row_to (SummaryView
*summaryview
,
204 FolderItem
*to_folder
);
206 static gint
summary_execute_move (SummaryView
*summaryview
);
207 static void summary_execute_move_func (GtkCMCTree
*ctree
,
208 GtkCMCTreeNode
*node
,
210 static void summary_execute_copy (SummaryView
*summaryview
);
211 static void summary_execute_copy_func (GtkCMCTree
*ctree
,
212 GtkCMCTreeNode
*node
,
214 static void summary_execute_delete (SummaryView
*summaryview
);
215 static void summary_execute_delete_func (GtkCMCTree
*ctree
,
216 GtkCMCTreeNode
*node
,
218 static void summary_execute_expunge (SummaryView
*summaryview
);
220 static void summary_thread_init (SummaryView
*summaryview
);
222 static void summary_unthread_for_exec (SummaryView
*summaryview
);
223 static void summary_unthread_for_exec_func (GtkCMCTree
*ctree
,
224 GtkCMCTreeNode
*node
,
227 void summary_simplify_subject(SummaryView
*summaryview
, gchar
* rexp
,
230 static void summary_filter_func (MsgInfo
*msginfo
,
231 PrefsAccount
*ac_prefs
);
233 static void summary_colorlabel_menu_item_activate_cb
236 static void summary_colorlabel_menu_item_activate_item_cb
237 (GtkMenuItem
*label_menu_item
,
239 static void summary_colorlabel_menu_create(SummaryView
*summaryview
,
241 static void summary_tags_menu_item_activate_cb
244 static void summary_tags_menu_item_activate_item_cb
245 (GtkMenuItem
*label_menu_item
,
247 static void summary_tags_menu_create(SummaryView
*summaryview
,
250 static GtkWidget
*summary_ctree_create (SummaryView
*summaryview
);
252 /* callback functions */
253 static gint
summary_toggle_pressed (GtkWidget
*eventbox
,
254 GdkEventButton
*event
,
255 SummaryView
*summaryview
);
257 static void summary_toggle_multiple_pressed
259 SummaryView
*summaryview
);
261 static gint summary_folder_eventbox_pressed
262 (GtkWidget
*eventbox
,
263 GdkEventButton
*event
,
264 SummaryView
*summaryview
);
265 static gboolean
summary_button_pressed (GtkWidget
*ctree
,
266 GdkEventButton
*event
,
267 SummaryView
*summaryview
);
268 static gboolean
summary_button_released (GtkWidget
*ctree
,
269 GdkEventButton
*event
,
270 SummaryView
*summaryview
);
271 static gboolean
summary_key_pressed (GtkWidget
*ctree
,
273 SummaryView
*summaryview
);
274 static void summary_tree_expanded (GtkCMCTree
*ctree
,
275 GtkCMCTreeNode
*node
,
276 SummaryView
*summaryview
);
277 static void summary_tree_collapsed (GtkCMCTree
*ctree
,
278 GtkCMCTreeNode
*node
,
279 SummaryView
*summaryview
);
280 static void summary_selected (GtkCMCTree
*ctree
,
283 SummaryView
*summaryview
);
284 static void summary_unselected (GtkCMCTree
*ctree
,
287 SummaryView
*summaryview
);
288 static void summary_col_resized (GtkCMCList
*clist
,
291 SummaryView
*summaryview
);
292 static void summary_mark_clicked (GtkWidget
*button
,
293 SummaryView
*summaryview
);
294 static void summary_status_clicked (GtkWidget
*button
,
295 SummaryView
*summaryview
);
296 static void summary_mime_clicked (GtkWidget
*button
,
297 SummaryView
*summaryview
);
298 static void summary_num_clicked (GtkWidget
*button
,
299 SummaryView
*summaryview
);
300 static void summary_score_clicked (GtkWidget
*button
,
301 SummaryView
*summaryview
);
302 static void summary_size_clicked (GtkWidget
*button
,
303 SummaryView
*summaryview
);
304 static void summary_date_clicked (GtkWidget
*button
,
305 SummaryView
*summaryview
);
306 static void summary_from_clicked (GtkWidget
*button
,
307 SummaryView
*summaryview
);
308 static void summary_to_clicked (GtkWidget
*button
,
309 SummaryView
*summaryview
);
310 static void summary_subject_clicked (GtkWidget
*button
,
311 SummaryView
*summaryview
);
312 static void summary_score_clicked (GtkWidget
*button
,
313 SummaryView
*summaryview
);
314 static void summary_locked_clicked (GtkWidget
*button
,
315 SummaryView
*summaryview
);
316 static void summary_tags_clicked (GtkWidget
*button
,
317 SummaryView
*summaryview
);
319 static void summary_start_drag (GtkWidget
*widget
,
322 SummaryView
*summaryview
);
323 static void summary_drag_data_get (GtkWidget
*widget
,
324 GdkDragContext
*drag_context
,
325 GtkSelectionData
*selection_data
,
328 SummaryView
*summaryview
);
329 static void summary_drag_data_received(GtkWidget
*widget
,
330 GdkDragContext
*drag_context
,
333 GtkSelectionData
*data
,
336 SummaryView
*summaryview
);
337 static gboolean
summary_drag_motion_cb(GtkWidget
*widget
,
338 GdkDragContext
*context
,
342 SummaryView
*summaryview
);
343 static void summary_drag_end(GtkWidget
*widget
,
344 GdkDragContext
*drag_context
,
345 SummaryView
*summaryview
);
347 /* custom compare functions for sorting */
348 static gint
summary_cmp_by_mark (GtkCMCList
*clist
,
351 static gint
summary_cmp_by_status (GtkCMCList
*clist
,
354 static gint
summary_cmp_by_mime (GtkCMCList
*clist
,
357 static gint
summary_cmp_by_num (GtkCMCList
*clist
,
360 static gint
summary_cmp_by_size (GtkCMCList
*clist
,
363 static gint
summary_cmp_by_date (GtkCMCList
*clist
,
366 static gint
summary_cmp_by_thread_date (GtkCMCList
*clist
,
369 static gint
summary_cmp_by_from (GtkCMCList
*clist
,
372 static gint summary_cmp_by_simplified_subject
376 static gint
summary_cmp_by_score (GtkCMCList
*clist
,
379 static gint
summary_cmp_by_label (GtkCMCList
*clist
,
382 static gint
summary_cmp_by_to (GtkCMCList
*clist
,
385 static gint
summary_cmp_by_subject (GtkCMCList
*clist
,
388 static gint
summary_cmp_by_locked (GtkCMCList
*clist
,
391 static gint
summary_cmp_by_tags (GtkCMCList
*clist
,
395 static void quicksearch_execute_cb (QuickSearch
*quicksearch
,
398 static void tog_searchbar_cb (GtkWidget
*w
,
401 static void summary_find_answers (SummaryView
*summaryview
,
404 static gboolean
summary_update_msg (gpointer source
, gpointer data
);
405 static gboolean
summary_update_folder_item_hook(gpointer source
, gpointer data
);
406 static gboolean
summary_update_folder_hook(gpointer source
, gpointer data
);
407 static void summary_set_colorlabel_color (GtkCMCTree
*ctree
,
408 GtkCMCTreeNode
*node
,
410 static void summary_thread_build(SummaryView
*summaryview
);
412 GtkTargetEntry summary_drag_types
[3] =
414 {"text/uri-list", 0, TARGET_MAIL_URI_LIST
},
415 {"claws-mail/internal", GTK_TARGET_SAME_APP
, TARGET_DUMMY
},
416 {"claws-mail/msg-path-list", 0, TARGET_MAIL_CM_PATH_LIST
},
419 static void summary_reedit_cb(GtkAction
*gaction
, gpointer data
);
420 static void summary_reply_cb(GtkAction
*gaction
, gpointer data
);
422 /* Only submenus and specifically-handled menu entries here */
423 static GtkActionEntry summary_popup_entries
[] =
425 {"SummaryViewPopup", NULL
, "SummaryViewPopup", NULL
, NULL
, NULL
},
426 {"SummaryViewPopup/Reedit", NULL
, N_("Re-edit"), NULL
, NULL
, G_CALLBACK(summary_reedit_cb
) },
427 {"SummaryViewPopup/Reply", NULL
, N_("_Reply"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_REPLY */
428 {"SummaryViewPopup/ReplyTo", NULL
, N_("Repl_y to"), NULL
, NULL
, NULL
},
429 {"SummaryViewPopup/ReplyTo/All", NULL
, N_("_All"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_REPLY_TO_ALL */
430 {"SummaryViewPopup/ReplyTo/Sender", NULL
, N_("_Sender"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_REPLY_TO_SENDER */
431 {"SummaryViewPopup/ReplyTo/List", NULL
, N_("Mailing _list"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_REPLY_TO_LIST */
433 {"SummaryViewPopup/Forward", NULL
, N_("_Forward"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_FORWARD_INLINE */
434 {"SummaryViewPopup/ForwardAtt", NULL
, N_("For_ward as attachment"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_FORWARD_AS_ATTACH */
435 {"SummaryViewPopup/Redirect", NULL
, N_("Redirec_t"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_REDIRECT */
436 {"SummaryViewPopup/Mark", NULL
, N_("_Mark"), NULL
, NULL
, NULL
},
437 {"SummaryViewPopup/ColorLabel", NULL
, N_("Color la_bel"), NULL
, NULL
, NULL
},
438 {"SummaryViewPopup/Tags", NULL
, N_("Ta_gs"), NULL
, NULL
, NULL
},
439 {"SummaryViewPopup/CreateFilterRule", NULL
, N_("Create _filter rule"), NULL
, NULL
, NULL
},
441 {"SummaryViewPopup/CreateProcessingRule", NULL
, N_("Create processing rule"), NULL
, NULL
, NULL
},
443 {"SummaryViewPopup/View", NULL
, N_("_View"), NULL
, NULL
, NULL
},
446 static void summary_header_lock_sorting_cb(GtkAction
*gaction
, gpointer data
);
447 static void summary_header_set_displayed_columns_cb(GtkAction
*gaction
, gpointer data
);
449 static GtkActionEntry summary_header_popup_entries
[] =
451 {"SummaryViewHeaderPopup", NULL
, "SummaryViewHeaderPopup", NULL
, NULL
, NULL
},
452 {"SummaryViewHeaderPopup/SetDisplayedColumns", NULL
, N_("_Set displayed columns"), NULL
, NULL
, G_CALLBACK(summary_header_set_displayed_columns_cb
) }
455 static GtkToggleActionEntry summary_header_popup_toggle_entries
[] =
457 {"SummaryViewHeaderPopup/LockColumnHeaders", NULL
, N_("_Lock column headers"), NULL
, NULL
, G_CALLBACK(summary_header_lock_sorting_cb
), FALSE
}
460 static const gchar
*const col_label
[N_SUMMARY_COLS
] = {
462 N_("S"), /* S_COL_STATUS */
464 N_("Subject"), /* S_COL_SUBJECT */
465 N_("From"), /* S_COL_FROM */
466 N_("To"), /* S_COL_TO */
467 N_("Date"), /* S_COL_DATE */
468 N_("Size"), /* S_COL_SIZE */
469 N_("#"), /* S_COL_NUMBER */
470 N_("Score"), /* S_COL_SCORE */
471 "", /* S_COL_LOCKED */
472 N_("Tags"), /* S_COL_TAGS */
475 void summary_freeze(SummaryView
*summaryview
)
478 gtk_cmclist_freeze(GTK_CMCLIST(summaryview
->ctree
));
481 void summary_thaw(SummaryView
*summaryview
)
484 gtk_cmclist_thaw(GTK_CMCLIST(summaryview
->ctree
));
487 void summary_thaw_with_status(SummaryView
*summaryview
)
490 summary_status_show(summaryview
);
491 gtk_cmclist_thaw(GTK_CMCLIST(summaryview
->ctree
));
495 void summary_grab_focus(SummaryView
*summaryview
)
498 gtk_widget_grab_focus(summaryview
->ctree
);
501 GtkWidget
*summary_get_main_widget(SummaryView
*summaryview
)
504 return summaryview
->ctree
;
509 #define START_LONG_OPERATION(summaryview,force_freeze) { \
510 summary_lock(summaryview); \
511 main_window_cursor_wait(summaryview->mainwin); \
512 if (force_freeze || sc_g_list_bigger(GTK_CMCLIST(summaryview->ctree)->selection, 1)) {\
514 summary_freeze(summaryview); \
516 folder_item_update_freeze(); \
518 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST, \
519 summaryview->msginfo_update_callback_id); \
521 #define END_LONG_OPERATION(summaryview) { \
523 folder_item_update_thaw(); \
525 summary_thaw(summaryview); \
526 main_window_cursor_normal(summaryview->mainwin); \
527 summary_unlock(summaryview); \
528 summaryview->msginfo_update_callback_id = \
529 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST, \
530 summary_update_msg, (gpointer) summaryview); \
533 static void popup_menu_selection_done(GtkMenuShell
*shell
, gpointer user_data
)
535 SummaryView
*summaryview
= (SummaryView
*)user_data
;
537 cm_return_if_fail(summaryview
!= NULL
);
539 /* If a message is displayed, place cursor back on the message. */
540 if (summaryview
->displayed
!= NULL
&&
541 summaryview
->displayed
!= summaryview
->selected
) {
542 gtk_sctree_select(GTK_SCTREE(summaryview
->ctree
), summaryview
->displayed
);
546 SummaryView
*summary_create(MainWindow
*mainwin
)
548 SummaryView
*summaryview
;
550 GtkWidget
*scrolledwin
;
555 GtkWidget
*stat_box2
;
556 GtkWidget
*stat_vbox
;
557 GtkWidget
*statlabel_folder
;
558 GtkWidget
*statlabel_select
;
559 GtkWidget
*statlabel_msgs
;
561 GtkWidget
*toggle_eventbox
;
563 GtkWidget
*multiple_sel_togbtn
;
565 GtkWidget
*toggle_arrow
;
566 GtkWidget
*toggle_search
;
567 QuickSearch
*quicksearch
;
569 debug_print("Creating summary view...\n");
570 summaryview
= g_new0(SummaryView
, 1);
572 #define SUMMARY_VBOX_SPACING 3
573 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, SUMMARY_VBOX_SPACING
);
574 gtk_widget_set_name(GTK_WIDGET(vbox
), "summaryview");
576 /* create status label */
577 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
578 gtk_widget_show(hbox
);
580 stat_vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 0);
581 gtk_widget_show(stat_vbox
);
583 stat_box
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
584 gtk_widget_show(stat_box
);
586 stat_box2
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
587 gtk_widget_show(stat_box2
);
589 toggle_search
= gtk_toggle_button_new();
590 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle_search
),
591 prefs_common
.show_searchbar
);
592 gtk_widget_set_can_focus(toggle_search
, FALSE
);
593 gtk_widget_show(toggle_search
);
595 CLAWS_SET_TIP(toggle_search
, _("Toggle quick search bar"));
597 gtk_box_pack_start(GTK_BOX(hbox
), toggle_search
, FALSE
, FALSE
, 2);
599 gtk_box_pack_start(GTK_BOX(hbox
), stat_vbox
, TRUE
, TRUE
, 0);
600 gtk_box_pack_start(GTK_BOX(stat_vbox
), stat_box
, TRUE
, TRUE
, 0);
601 gtk_box_pack_start(GTK_BOX(stat_vbox
), stat_box2
, TRUE
, TRUE
, 0);
603 hbox_l
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
604 gtk_widget_show(hbox_l
);
605 gtk_box_pack_start(GTK_BOX(stat_box
), hbox_l
, TRUE
, TRUE
, 0);
607 statlabel_folder
= gtk_label_new("");
608 gtk_widget_show(statlabel_folder
);
609 gtk_box_pack_start(GTK_BOX(hbox_l
), statlabel_folder
, FALSE
, FALSE
, 2);
610 statlabel_select
= gtk_label_new("");
611 gtk_widget_show(statlabel_select
);
612 gtk_box_pack_start(GTK_BOX(hbox_l
), statlabel_select
, FALSE
, FALSE
, 12);
614 /* toggle view button */
615 toggle_eventbox
= gtk_event_box_new();
616 gtk_widget_show(toggle_eventbox
);
618 gtk_box_pack_end(GTK_BOX(hbox
), toggle_eventbox
, FALSE
, FALSE
, 4);
620 toggle_arrow
= gtk_image_new_from_icon_name("pan-down-symbolic", GTK_ICON_SIZE_MENU
);
621 gtk_widget_show(toggle_arrow
);
622 gtk_container_add(GTK_CONTAINER(toggle_eventbox
), toggle_arrow
);
623 g_signal_connect(G_OBJECT(toggle_eventbox
), "button_press_event",
624 G_CALLBACK(summary_toggle_pressed
),
628 multiple_sel_togbtn
= gtk_toggle_button_new();
629 gtk_widget_show(multiple_sel_togbtn
);
630 gtk_box_pack_end(GTK_BOX(hbox
), multiple_sel_togbtn
, FALSE
, FALSE
, 4);
631 CLAWS_SET_TIP(multiple_sel_togbtn
,
632 _("Toggle multiple selection"));
633 g_signal_connect(G_OBJECT(multiple_sel_togbtn
), "toggled",
634 G_CALLBACK(summary_toggle_multiple_pressed
),
638 statlabel_msgs
= gtk_label_new("");
639 gtk_widget_show(statlabel_msgs
);
640 gtk_box_pack_end(GTK_BOX(stat_box
), statlabel_msgs
, FALSE
, FALSE
, 4);
642 hbox_spc
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 0);
643 gtk_widget_show(hbox_spc
);
644 gtk_box_pack_end(GTK_BOX(hbox
), hbox_spc
, FALSE
, FALSE
, 6);
646 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
647 gtk_widget_show(scrolledwin
);
648 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
649 GTK_POLICY_AUTOMATIC
,
650 GTK_POLICY_AUTOMATIC
);
651 summaryview
->mainwidget_book
= gtk_notebook_new();
652 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(summaryview
->mainwidget_book
), FALSE
);
653 gtk_notebook_set_show_border(GTK_NOTEBOOK(summaryview
->mainwidget_book
), FALSE
);
655 gtk_container_add(GTK_CONTAINER(summaryview
->mainwidget_book
),
657 gtk_box_pack_start(GTK_BOX(vbox
), summaryview
->mainwidget_book
, TRUE
, TRUE
, 0);
660 ctree
= summary_ctree_create(summaryview
);
661 gtk_widget_show(ctree
);
663 gtk_scrolled_window_set_hadjustment(GTK_SCROLLED_WINDOW(scrolledwin
),
664 GTK_CMCLIST(ctree
)->hadjustment
);
665 gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(scrolledwin
),
666 GTK_CMCLIST(ctree
)->vadjustment
);
667 gtk_container_add(GTK_CONTAINER(scrolledwin
), ctree
);
670 gtk_widget_show_all(stat_vbox
);
671 gtk_box_pack_start(GTK_BOX(vbox
), hbox
, FALSE
, FALSE
, 0);
674 quicksearch
= quicksearch_new();
675 gtk_box_pack_start(GTK_BOX(vbox
), quicksearch_get_widget(quicksearch
), FALSE
, FALSE
, 0);
678 gtk_container_add(GTK_CONTAINER(summaryview
->mainwidget_book
),
680 gtk_box_pack_start(GTK_BOX(vbox
), summaryview
->mainwidget_book
, TRUE
, TRUE
, 0);
682 quicksearch_set_execute_callback(quicksearch
, quicksearch_execute_cb
, summaryview
);
684 g_signal_connect (G_OBJECT(toggle_search
), "toggled",
685 G_CALLBACK(tog_searchbar_cb
), summaryview
);
687 /* create popup menu */
689 gtk_action_group_add_actions(mainwin
->action_group
,
690 summary_popup_entries
,
691 G_N_ELEMENTS(summary_popup_entries
),
692 (gpointer
)summaryview
);
694 gtk_action_group_add_actions(mainwin
->action_group
,
695 summary_header_popup_entries
,
696 G_N_ELEMENTS(summary_header_popup_entries
),
697 (gpointer
)summaryview
);
699 gtk_action_group_add_toggle_actions(mainwin
->action_group
,
700 summary_header_popup_toggle_entries
,
701 G_N_ELEMENTS(summary_header_popup_toggle_entries
),
702 (gpointer
)summaryview
);
704 summaryview
->ui_manager
= gtk_ui_manager_new();
705 summaryview
->action_group
= cm_menu_create_action_group_full(summaryview
->ui_manager
,"Menu", summary_popup_entries
,
706 G_N_ELEMENTS(summary_popup_entries
), (gpointer
)summaryview
);
708 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus", "SummaryViewPopup", "SummaryViewPopup", GTK_UI_MANAGER_MENU
)
709 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Reedit", "SummaryViewPopup/Reedit", GTK_UI_MANAGER_MENUITEM
)
710 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Reply", "SummaryViewPopup/Reply", GTK_UI_MANAGER_MENUITEM
)
712 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "ReplyTo", "SummaryViewPopup/ReplyTo", GTK_UI_MANAGER_MENU
)
713 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator1", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
715 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Forward", "SummaryViewPopup/Forward", GTK_UI_MANAGER_MENUITEM
)
717 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "ForwardAtt", "SummaryViewPopup/ForwardAtt", GTK_UI_MANAGER_MENUITEM
)
718 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Redirect", "SummaryViewPopup/Redirect", GTK_UI_MANAGER_MENUITEM
)
720 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator2", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
721 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Move", "Message/Move", GTK_UI_MANAGER_MENUITEM
)
722 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Copy", "Message/Copy", GTK_UI_MANAGER_MENUITEM
)
723 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Trash", "Message/Trash", GTK_UI_MANAGER_MENUITEM
)
725 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Delete", "Message/Delete", GTK_UI_MANAGER_MENUITEM
)
727 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator3", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
728 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Mark", "SummaryViewPopup/Mark", GTK_UI_MANAGER_MENU
)
729 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "ColorLabel", "SummaryViewPopup/ColorLabel", GTK_UI_MANAGER_MENU
)
730 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Tags", "SummaryViewPopup/Tags", GTK_UI_MANAGER_MENU
)
732 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator4", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
734 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "AddSenderToAB", "Tools/AddSenderToAB", GTK_UI_MANAGER_MENUITEM
)
736 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "CreateFilterRule", "SummaryViewPopup/CreateFilterRule", GTK_UI_MANAGER_MENU
)
738 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "CreateProcessingRule", "SummaryViewPopup/CreateProcessingRule", GTK_UI_MANAGER_MENU
)
740 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator5", "Tools/---", GTK_UI_MANAGER_SEPARATOR
)
741 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "View", "SummaryViewPopup/View", GTK_UI_MANAGER_MENU
)
742 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "SaveAs", "File/SaveAs", GTK_UI_MANAGER_MENUITEM
)
744 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Print", "File/Print", GTK_UI_MANAGER_MENUITEM
)
746 /* last separator, for plugins */
747 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator6", "File/---", GTK_UI_MANAGER_SEPARATOR
)
749 /* submenus - replyto */
750 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/ReplyTo", "All", "SummaryViewPopup/ReplyTo/All", GTK_UI_MANAGER_MENUITEM
)
751 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/ReplyTo", "Sender", "SummaryViewPopup/ReplyTo/Sender", GTK_UI_MANAGER_MENUITEM
)
752 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/ReplyTo", "MailingList", "SummaryViewPopup/ReplyTo/List", GTK_UI_MANAGER_MENUITEM
)
754 /* submenus - mark */
755 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Mark", "Message/Mark/Mark", GTK_UI_MANAGER_MENUITEM
)
756 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Unmark", "Message/Mark/Unmark", GTK_UI_MANAGER_MENUITEM
)
757 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Separator1", "Message/Mark/---", GTK_UI_MANAGER_SEPARATOR
)
758 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkRead", "Message/Mark/MarkRead", GTK_UI_MANAGER_MENUITEM
)
759 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkUnread", "Message/Mark/MarkUnread", GTK_UI_MANAGER_MENUITEM
)
760 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Separator2", "Message/Mark/---", GTK_UI_MANAGER_SEPARATOR
)
761 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkAllRead", "Message/Mark/MarkAllRead", GTK_UI_MANAGER_MENUITEM
)
762 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkAllUnread", "Message/Mark/MarkAllUnread", GTK_UI_MANAGER_MENUITEM
)
763 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Separator3", "Message/Mark/---", GTK_UI_MANAGER_SEPARATOR
)
764 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "IgnoreThread", "Message/Mark/IgnoreThread", GTK_UI_MANAGER_MENUITEM
)
765 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "UnignoreThread", "Message/Mark/UnignoreThread", GTK_UI_MANAGER_MENUITEM
)
766 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "WatchThread", "Message/Mark/WatchThread", GTK_UI_MANAGER_MENUITEM
)
767 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "UnwatchThread", "Message/Mark/UnwatchThread", GTK_UI_MANAGER_MENUITEM
)
768 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Separator4", "Message/Mark/---", GTK_UI_MANAGER_SEPARATOR
)
769 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkSpam", "Message/Mark/MarkSpam", GTK_UI_MANAGER_MENUITEM
)
770 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkHam", "Message/Mark/MarkHam", GTK_UI_MANAGER_MENUITEM
)
771 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Separator5", "Message/Mark/---", GTK_UI_MANAGER_SEPARATOR
)
772 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Lock", "Message/Mark/Lock", GTK_UI_MANAGER_MENUITEM
)
773 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Unlock", "Message/Mark/Unlock", GTK_UI_MANAGER_MENUITEM
)
775 /* submenus - colorlabel and tags are dynamic */
776 /* submenus - createfilterrule */
777 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateFilterRule", "Automatically", "Tools/CreateFilterRule/Automatically", GTK_UI_MANAGER_MENUITEM
)
778 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateFilterRule", "ByFrom", "Tools/CreateFilterRule/ByFrom", GTK_UI_MANAGER_MENUITEM
)
779 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateFilterRule", "ByTo", "Tools/CreateFilterRule/ByTo", GTK_UI_MANAGER_MENUITEM
)
780 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateFilterRule", "BySubject", "Tools/CreateFilterRule/BySubject", GTK_UI_MANAGER_MENUITEM
)
781 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateFilterRule", "BySender", "Tools/CreateFilterRule/BySender", GTK_UI_MANAGER_MENUITEM
)
784 /* submenus - createprocessingrule */
785 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateProcessingRule", "Automatically", "Tools/CreateProcessingRule/Automatically", GTK_UI_MANAGER_MENUITEM
)
786 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateProcessingRule", "ByFrom", "Tools/CreateProcessingRule/ByFrom", GTK_UI_MANAGER_MENUITEM
)
787 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateProcessingRule", "ByTo", "Tools/CreateProcessingRule/ByTo", GTK_UI_MANAGER_MENUITEM
)
788 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateProcessingRule", "BySubject", "Tools/CreateProcessingRule/BySubject", GTK_UI_MANAGER_MENUITEM
)
789 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateProcessingRule", "BySender", "Tools/CreateProcessingRule/BySender", GTK_UI_MANAGER_MENUITEM
)
792 /* submenus - view */
793 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/View", "OpenNewWindow", "View/OpenNewWindow", GTK_UI_MANAGER_MENUITEM
)
794 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/View", "MessageSource", "View/MessageSource", GTK_UI_MANAGER_MENUITEM
)
796 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/View", "AllHeaders", "View/AllHeaders", GTK_UI_MANAGER_MENUITEM
)
799 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus", "SummaryViewHeaderPopup", "SummaryViewHeaderPopup", GTK_UI_MANAGER_MENU
)
800 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewHeaderPopup", "LockColumnHeaders", "SummaryViewHeaderPopup/LockColumnHeaders", GTK_UI_MANAGER_MENUITEM
)
801 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewHeaderPopup", "SetDisplayedColumns", "SummaryViewHeaderPopup/SetDisplayedColumns", GTK_UI_MANAGER_MENUITEM
)
803 summaryview
->popupmenu
= gtk_menu_item_get_submenu(GTK_MENU_ITEM(
804 gtk_ui_manager_get_widget(mainwin
->ui_manager
, "/Menus/SummaryViewPopup")) );
805 summaryview
->headerpopupmenu
= gtk_menu_item_get_submenu(GTK_MENU_ITEM(
806 gtk_ui_manager_get_widget(mainwin
->ui_manager
, "/Menus/SummaryViewHeaderPopup")) );
808 summaryview
->vbox
= vbox
;
809 summaryview
->scrolledwin
= scrolledwin
;
810 summaryview
->ctree
= ctree
;
811 summaryview
->hbox
= hbox
;
812 summaryview
->hbox_l
= hbox_l
;
813 summaryview
->hbox_spc
= hbox_spc
;
814 summaryview
->stat_box
= stat_box
;
815 summaryview
->stat_box2
= stat_box2
;
816 summaryview
->statlabel_folder
= statlabel_folder
;
817 summaryview
->statlabel_select
= statlabel_select
;
818 summaryview
->statlabel_msgs
= statlabel_msgs
;
819 summaryview
->toggle_eventbox
= toggle_eventbox
;
820 summaryview
->toggle_arrow
= toggle_arrow
;
822 summaryview
->multiple_sel_togbtn
= multiple_sel_togbtn
;
824 summaryview
->toggle_search
= toggle_search
;
825 summaryview
->lock_count
= 0;
826 summaryview
->msginfo_update_callback_id
=
827 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
, summary_update_msg
, (gpointer
) summaryview
);
828 summaryview
->folder_item_update_callback_id
=
829 hooks_register_hook(FOLDER_ITEM_UPDATE_HOOKLIST
,
830 summary_update_folder_item_hook
,
831 (gpointer
) summaryview
);
832 summaryview
->folder_update_callback_id
=
833 hooks_register_hook(FOLDER_UPDATE_HOOKLIST
,
834 summary_update_folder_hook
,
835 (gpointer
) summaryview
);
837 summaryview
->target_list
= gtk_target_list_new(summary_drag_types
, 3);
839 summaryview
->quicksearch
= quicksearch
;
841 /* CLAWS: need this to get the SummaryView * from
843 g_object_set_data(G_OBJECT(ctree
), "summaryview", (gpointer
)summaryview
);
845 gtk_widget_show_all(vbox
);
847 gtk_widget_show(vbox
);
849 if (prefs_common
.show_searchbar
)
850 quicksearch_show(quicksearch
);
852 quicksearch_hide(quicksearch
);
854 if (prefs_common
.layout_mode
== WIDE_MSGLIST_LAYOUT
||
855 prefs_common
.layout_mode
== SMALL_LAYOUT
)
856 gtk_widget_hide(summaryview
->toggle_eventbox
);
861 void summary_relayout(SummaryView
*summaryview
)
863 gtk_widget_realize(summaryview
->stat_box
);
865 g_object_ref(summaryview
->hbox_l
);
866 g_object_ref(summaryview
->statlabel_msgs
);
868 gtk_container_remove(GTK_CONTAINER(
869 gtk_widget_get_parent(summaryview
->hbox_l
)), summaryview
->hbox_l
);
870 gtk_container_remove(GTK_CONTAINER(
871 gtk_widget_get_parent(summaryview
->statlabel_msgs
)), summaryview
->statlabel_msgs
);
873 switch (prefs_common
.layout_mode
) {
876 case WIDE_MSGLIST_LAYOUT
:
877 gtk_box_pack_start(GTK_BOX(summaryview
->stat_box
), summaryview
->hbox_l
, TRUE
, TRUE
, 0);
878 gtk_box_pack_end(GTK_BOX(summaryview
->stat_box
), summaryview
->statlabel_msgs
, FALSE
, FALSE
, 4);
879 gtk_widget_show_all(summaryview
->stat_box
);
880 gtk_widget_show_all(summaryview
->stat_box2
);
881 if (prefs_common
.layout_mode
== WIDE_MSGLIST_LAYOUT
||
882 prefs_common
.layout_mode
== SMALL_LAYOUT
)
883 gtk_widget_hide(summaryview
->toggle_eventbox
);
885 gtk_widget_show(summaryview
->toggle_eventbox
);
887 case VERTICAL_LAYOUT
:
889 gtk_box_pack_start(GTK_BOX(summaryview
->stat_box
), summaryview
->hbox_l
, TRUE
, TRUE
, 0);
890 gtk_box_pack_start(GTK_BOX(summaryview
->stat_box2
), summaryview
->statlabel_msgs
, FALSE
, FALSE
, 4);
891 gtk_widget_show_all(summaryview
->stat_box
);
892 gtk_widget_show_all(summaryview
->stat_box2
);
893 if (prefs_common
.layout_mode
== SMALL_LAYOUT
) {
894 gtk_widget_hide(summaryview
->toggle_eventbox
);
895 gtk_widget_hide(summaryview
->statlabel_msgs
);
897 gtk_widget_show(summaryview
->toggle_eventbox
);
898 gtk_widget_show(summaryview
->statlabel_msgs
);
903 summary_set_column_order(summaryview
);
905 g_object_unref(summaryview
->hbox_l
);
906 g_object_unref(summaryview
->statlabel_msgs
);
907 quicksearch_relayout(summaryview
->quicksearch
);
908 if (prefs_common
.show_searchbar
)
909 quicksearch_show(summaryview
->quicksearch
);
911 quicksearch_hide(summaryview
->quicksearch
);
914 static void summary_set_fonts(SummaryView
*summaryview
)
916 PangoFontDescription
*font_desc
;
919 font_desc
= pango_font_description_from_string(NORMAL_FONT
);
921 gtk_widget_override_font(summaryview
->ctree
, font_desc
);
922 pango_font_description_free(font_desc
);
926 bold_style
= gtk_style_copy
927 (gtk_widget_get_style(summaryview
->ctree
));
929 if (prefs_common
.derive_from_normal_font
|| !BOLD_FONT
) {
930 font_desc
= pango_font_description_from_string(NORMAL_FONT
);
932 pango_font_description_free(bold_style
->font_desc
);
933 bold_style
->font_desc
= font_desc
;
935 pango_font_description_set_weight
936 (bold_style
->font_desc
, PANGO_WEIGHT_BOLD
);
938 font_desc
= pango_font_description_from_string(BOLD_FONT
);
940 pango_font_description_free(bold_style
->font_desc
);
941 bold_style
->font_desc
= font_desc
;
946 if (prefs_common
.derive_from_normal_font
|| !SMALL_FONT
) {
947 font_desc
= pango_font_description_new();
948 size
= pango_font_description_get_size
949 (gtk_widget_get_style(summaryview
->ctree
)->font_desc
);
950 pango_font_description_set_size(font_desc
, size
* PANGO_SCALE_SMALL
);
952 font_desc
= pango_font_description_from_string(SMALL_FONT
);
955 gtk_widget_override_font(summaryview
->statlabel_folder
, font_desc
);
956 gtk_widget_override_font(summaryview
->statlabel_select
, font_desc
);
957 gtk_widget_override_font(summaryview
->statlabel_msgs
, font_desc
);
958 pango_font_description_free(font_desc
);
963 static void summary_set_folder_pixmap(SummaryView
*summaryview
, StockPixmap icon
)
966 if (!summaryview
->folder_pixmap_eventbox
) {
967 summaryview
->folder_pixmap_eventbox
= gtk_event_box_new();
968 gtk_widget_show(summaryview
->folder_pixmap_eventbox
);
969 gtk_box_pack_start(GTK_BOX(summaryview
->hbox_l
), summaryview
->folder_pixmap_eventbox
, FALSE
, FALSE
, 4);
970 gtk_box_reorder_child(GTK_BOX(summaryview
->hbox_l
), summaryview
->folder_pixmap_eventbox
, 0); /* search_toggle before */
971 g_signal_connect(G_OBJECT(summaryview
->folder_pixmap_eventbox
), "button_press_event",
972 G_CALLBACK(summary_folder_eventbox_pressed
),
975 if (summaryview
->folder_pixmap
)
976 gtk_widget_destroy(summaryview
->folder_pixmap
);
978 pixmap
= stock_pixmap_widget(icon
);
979 gtk_container_add(GTK_CONTAINER(summaryview
->folder_pixmap_eventbox
), pixmap
);
980 gtk_widget_show(pixmap
);
981 summaryview
->folder_pixmap
= pixmap
;
984 void summary_init(SummaryView
*summaryview
)
988 gtk_widget_realize(summaryview
->ctree
);
989 stock_pixbuf_gdk(STOCK_PIXMAP_MARK
, &markxpm
);
990 stock_pixbuf_gdk(STOCK_PIXMAP_DELETED
, &deletedxpm
);
991 stock_pixbuf_gdk(STOCK_PIXMAP_NEW
, &newxpm
);
992 stock_pixbuf_gdk(STOCK_PIXMAP_UNREAD
, &unreadxpm
);
993 stock_pixbuf_gdk(STOCK_PIXMAP_REPLIED
, &repliedxpm
);
994 stock_pixbuf_gdk(STOCK_PIXMAP_FORWARDED
, &forwardedxpm
);
995 stock_pixbuf_gdk(STOCK_PIXMAP_REPLIED_AND_FORWARDED
, &repliedandforwardedxpm
);
996 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP
, &clipxpm
);
997 stock_pixbuf_gdk(STOCK_PIXMAP_LOCKED
, &lockedxpm
);
998 stock_pixbuf_gdk(STOCK_PIXMAP_IGNORETHREAD
, &ignorethreadxpm
);
999 stock_pixbuf_gdk(STOCK_PIXMAP_WATCHTHREAD
, &watchthreadxpm
);
1000 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP_KEY
, &clipkeyxpm
);
1001 stock_pixbuf_gdk(STOCK_PIXMAP_KEY_SIGN
, &keysignxpm
);
1002 stock_pixbuf_gdk(STOCK_PIXMAP_KEY
, &keyxpm
);
1003 stock_pixbuf_gdk(STOCK_PIXMAP_GPG_SIGNED
, &gpgsignedxpm
);
1004 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP_GPG_SIGNED
, &clipgpgsignedxpm
);
1005 stock_pixbuf_gdk(STOCK_PIXMAP_SPAM
, &spamxpm
);
1006 stock_pixbuf_gdk(STOCK_PIXMAP_MOVED
, &movedxpm
);
1007 stock_pixbuf_gdk(STOCK_PIXMAP_COPIED
, &copiedxpm
);
1009 summary_set_fonts(summaryview
);
1011 summary_set_folder_pixmap(summaryview
, STOCK_PIXMAP_DIR_OPEN
);
1013 pixmap
= stock_pixmap_widget(STOCK_PIXMAP_QUICKSEARCH
);
1014 gtk_container_add (GTK_CONTAINER(summaryview
->toggle_search
), pixmap
);
1015 gtk_widget_show(pixmap
);
1016 summaryview
->quick_search_pixmap
= pixmap
;
1019 pixmap
= stock_pixmap_widget(STOCK_PIXMAP_SELECTION
);
1020 gtk_container_add(GTK_CONTAINER(summaryview
->multiple_sel_togbtn
), pixmap
);
1021 gtk_widget_show(pixmap
);
1022 summaryview
->multiple_sel_image
= pixmap
;
1025 /* Init summaryview prefs */
1026 summaryview
->sort_key
= SORT_BY_NONE
;
1027 summaryview
->sort_type
= SORT_ASCENDING
;
1029 /* Init summaryview extra data */
1030 summaryview
->simplify_subject_preg
= NULL
;
1031 summary_clear_list(summaryview
);
1032 summary_set_column_titles(summaryview
);
1033 summary_colorlabel_menu_create(summaryview
, FALSE
);
1034 summary_tags_menu_create(summaryview
, FALSE
);
1035 main_create_mailing_list_menu (summaryview
->mainwin
, NULL
);
1036 summary_set_menu_sensitive(summaryview
);
1038 summaryview
->header_menu_lock
= FALSE
;
1041 #define CURRENTLY_DISPLAYED(m) \
1042 ( (m->msgnum == displayed_msgnum) \
1043 && (!g_ascii_strcasecmp(m->folder->name,item->name)) )
1045 #define FOLDER_SHOWS_TO_HDR(i) \
1046 ( i && (folder_has_parent_of_type(i, F_OUTBOX) \
1047 || folder_has_parent_of_type(i, F_DRAFT) \
1048 || folder_has_parent_of_type(i, F_QUEUE)) )
1050 static void summary_switch_from_to(SummaryView
*summaryview
, FolderItem
*item
)
1052 gboolean show_from
= FALSE
, show_to
= FALSE
;
1053 gboolean showing_from
= FALSE
, showing_to
= FALSE
;
1054 gint from_pos
= 0, to_pos
= 0;
1055 SummaryColumnState
*col_state
= summaryview
->col_state
;
1056 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
1058 if (!item
|| ((prefs_common
.layout_mode
== VERTICAL_LAYOUT
|| prefs_common
.layout_mode
== SMALL_LAYOUT
) && prefs_common
.two_line_vert
) )
1060 if (FOLDER_SHOWS_TO_HDR(item
))
1065 from_pos
= summaryview
->col_pos
[S_COL_FROM
];
1066 to_pos
= summaryview
->col_pos
[S_COL_TO
];
1067 showing_from
= col_state
[from_pos
].visible
;
1068 showing_to
= col_state
[to_pos
].visible
;
1070 if (showing_from
&& showing_to
) {
1071 debug_print("showing both\n");
1075 if (!showing_from
&& !showing_to
) {
1076 debug_print("showing none\n");
1080 debug_print("showing %s %s, must show %s %s\n",
1081 showing_from
?"From":"",
1083 show_from
?"From":"",
1086 if (showing_from
== show_from
&& showing_to
== show_to
)
1088 /* else we'll switch both */
1090 debug_print("switching columns\n");
1091 col_state
[from_pos
].type
= S_COL_TO
;
1092 col_state
[from_pos
].visible
= show_to
;
1094 col_state
[to_pos
].type
= S_COL_FROM
;
1095 col_state
[to_pos
].visible
= show_from
;
1097 summaryview
->col_pos
[S_COL_TO
] = from_pos
;
1098 summaryview
->col_pos
[S_COL_FROM
] = to_pos
;
1100 gtk_cmclist_set_column_visibility
1101 (GTK_CMCLIST(ctree
), from_pos
, col_state
[from_pos
].visible
);
1102 gtk_cmclist_set_column_visibility
1103 (GTK_CMCLIST(ctree
), to_pos
, col_state
[to_pos
].visible
);
1105 summary_set_column_titles(summaryview
);
1108 static void summaryview_reset_recursive_folder_match(SummaryView
*summaryview
)
1112 for (cur
= summaryview
->recursive_matched_folders
; cur
!= NULL
; cur
= cur
->next
) {
1113 folderview_update_search_icon(cur
->data
, FALSE
);
1116 g_slist_free(summaryview
->recursive_matched_folders
);
1117 summaryview
->recursive_matched_folders
= NULL
;
1118 summaryview
->search_root_folder
= NULL
;
1121 static gboolean
summaryview_quicksearch_recursive_progress(gpointer data
, guint at
, guint matched
, guint total
)
1123 QuickSearch
*search
= (QuickSearch
*) data
;
1124 gint interval
= quicksearch_is_fast(search
) ? 5000 : 100;
1126 statusbar_progress_all(at
, total
, interval
);
1127 if (at
% interval
== 0)
1136 static void summaryview_quicksearch_recurse_step(SummaryView
*summaryview
, FolderItem
*item
)
1138 MsgInfoList
*msgs
= NULL
;
1139 gboolean result
= TRUE
;
1141 statusbar_print_all(_("Searching in %s... \n"),
1142 item
->path
? item
->path
: "(null)");
1143 folder_item_update_freeze();
1145 quicksearch_set_on_progress_cb(summaryview
->quicksearch
, summaryview_quicksearch_recursive_progress
, summaryview
->quicksearch
);
1146 if (!quicksearch_run_on_folder(summaryview
->quicksearch
, item
, &msgs
))
1149 result
= result
&& msgs
!= NULL
;
1152 procmsg_msg_list_free(msgs
);
1154 folder_item_update_thaw();
1155 statusbar_progress_all(0, 0, 0);
1156 statusbar_pop_all();
1159 summaryview
->recursive_matched_folders
= g_slist_prepend(
1160 summaryview
->recursive_matched_folders
, item
);
1162 folderview_update_search_icon(item
, TRUE
);
1166 static void summaryview_quicksearch_search_subfolders(SummaryView
*summaryview
, FolderItem
*folder_item
)
1168 FolderItem
*cur
= NULL
;
1169 GNode
*node
= folder_item
->node
->children
;
1171 if (!prefs_common
.summary_quicksearch_recurse
1172 || !quicksearch_has_sat_predicate(summaryview
->quicksearch
)
1173 || quicksearch_is_in_typing(summaryview
->quicksearch
))
1176 for (; node
!= NULL
; node
= node
->next
) {
1177 if (!quicksearch_has_sat_predicate(summaryview
->quicksearch
))
1180 cur
= FOLDER_ITEM(node
->data
);
1181 summaryview_quicksearch_recurse_step(summaryview
, cur
);
1182 if (cur
->node
->children
)
1183 summaryview_quicksearch_search_subfolders(summaryview
, cur
);
1187 static void summaryview_quicksearch_recurse(SummaryView
*summaryview
)
1189 if (!prefs_common
.summary_quicksearch_recurse
1190 || !quicksearch_has_sat_predicate(summaryview
->quicksearch
)
1191 || summaryview
->folder_item
== NULL
) {
1195 main_window_cursor_wait(summaryview
->mainwin
);
1197 summaryview_reset_recursive_folder_match(summaryview
);
1198 summaryview
->search_root_folder
= summaryview
->folder_item
;
1200 summaryview_quicksearch_search_subfolders(summaryview
, summaryview
->folder_item
);
1202 main_window_cursor_normal(summaryview
->mainwin
);
1206 static gboolean
summary_check_consistency(FolderItem
*item
, GSList
*mlist
)
1208 int u
= 0, n
= 0, m
= 0, t
= 0, r
= 0, f
= 0, l
= 0, i
= 0, w
= 0;
1211 for(cur
= mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= g_slist_next(cur
)) {
1212 MsgInfo
* msginfo
= (MsgInfo
*) cur
->data
;
1214 if (MSG_IS_NEW(msginfo
->flags
))
1216 if (MSG_IS_UNREAD(msginfo
->flags
))
1218 if (MSG_IS_MARKED(msginfo
->flags
))
1220 if (MSG_IS_REPLIED(msginfo
->flags
))
1222 if (MSG_IS_FORWARDED(msginfo
->flags
))
1224 if (MSG_IS_LOCKED(msginfo
->flags
))
1226 if (MSG_IS_IGNORE_THREAD(msginfo
->flags
))
1228 if (MSG_IS_WATCH_THREAD(msginfo
->flags
))
1231 if (t
!= item
->total_msgs
1232 || n
!= item
->new_msgs
1233 || u
!= item
->unread_msgs
1234 || m
!= item
->marked_msgs
1235 || r
!= item
->replied_msgs
1236 || f
!= item
->forwarded_msgs
1237 || l
!= item
->locked_msgs
1238 || i
!= item
->ignored_msgs
1239 || w
!= item
->watched_msgs
1240 || (m
== 0 && item
->unreadmarked_msgs
!= 0)
1241 || item
->unreadmarked_msgs
< 0) {
1242 debug_print("Inconsistency\n");
1243 folder_item_scan_full(item
, FALSE
);
1251 gboolean
summaryview_search_root_progress(gpointer data
, guint at
, guint matched
, guint total
)
1253 SummaryView
*summaryview
= (SummaryView
*) data
;
1255 gint interval
= quicksearch_is_fast(summaryview
->quicksearch
) ? 5000 : 100;
1257 statusbar_progress_all(at
, total
, interval
);
1259 if (at
% interval
== 0)
1265 gboolean
summary_show(SummaryView
*summaryview
, FolderItem
*item
, gboolean avoid_refresh
)
1267 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
1268 GtkCMCTreeNode
*node
= NULL
;
1269 GSList
*mlist
= NULL
;
1271 gboolean is_refresh
;
1272 guint selected_msgnum
= 0;
1273 guint displayed_msgnum
= 0;
1276 gboolean hidden_removed
= FALSE
;
1278 if (summary_is_locked(summaryview
)) return FALSE
;
1280 if (!summaryview
->mainwin
)
1283 summary_switch_from_to(summaryview
, item
);
1286 summary_lock(summaryview
);
1288 menu_set_sensitive_all(GTK_MENU_SHELL(summaryview
->popupmenu
), TRUE
);
1292 is_refresh
= (item
== summaryview
->folder_item
&& !avoid_refresh
) ? TRUE
: FALSE
;
1294 if (item
&& item
->folder
->klass
->item_opened
) {
1295 item
->folder
->klass
->item_opened(item
);
1299 main_create_mailing_list_menu (summaryview
->mainwin
, NULL
);
1300 if (prefs_common
.layout_mode
== SMALL_LAYOUT
) {
1302 mainwindow_enter_folder(summaryview
->mainwin
);
1303 gtk_widget_grab_focus(summaryview
->ctree
);
1307 if (!prefs_common
.summary_quicksearch_sticky
1308 && (!prefs_common
.summary_quicksearch_recurse
1309 || !quicksearch_has_sat_predicate(summaryview
->quicksearch
)
1310 || (item
&& !folder_is_child_of(item
, summaryview
->search_root_folder
)))
1311 && !quicksearch_is_running(summaryview
->quicksearch
)
1313 quicksearch_set(summaryview
->quicksearch
, prefs_common
.summary_quicksearch_type
, "");
1316 /* STATUSBAR_POP(summaryview->mainwin); */
1319 selected_msgnum
= summary_get_msgnum(summaryview
,
1320 summaryview
->selected
);
1321 displayed_msgnum
= summary_get_msgnum(summaryview
,
1322 summaryview
->displayed
);
1325 /* process the marks if any */
1327 (summaryview
->mainwin
->lock_count
== 0 &&
1328 (summaryview
->moved
> 0 || summaryview
->copied
> 0))) {
1330 gboolean changed
= FALSE
;
1332 val
= alertpanel(_("Process mark"),
1333 _("Some marks are left. Process them?"),
1334 NULL
, _("_No"), NULL
, _("_Yes"), NULL
, _("_Cancel"),
1336 if (G_ALERTALTERNATE
== val
) {
1337 summary_unlock(summaryview
);
1338 summary_execute(summaryview
);
1339 summary_lock(summaryview
);
1341 } else if (G_ALERTDEFAULT
== val
) {
1344 summary_unlock(summaryview
);
1349 if (changed
|| !quicksearch_has_sat_predicate(summaryview
->quicksearch
))
1350 folder_update_op_count();
1353 summary_freeze(summaryview
);
1355 summary_clear_list(summaryview
);
1358 if (!item
|| !item
->path
|| !folder_item_parent(item
) || item
->no_select
) {
1360 debug_print("empty folder (%p %s %p %d)\n",
1362 (item
&& item
->path
)?item
->path
:"(null)",
1363 item
?folder_item_parent(item
):0x0,
1364 item
?item
->no_select
:FALSE
);
1365 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadMessages", FALSE
);
1366 summary_set_hide_menu(summaryview
, "/Menu/View/HideDelMessages", FALSE
);
1367 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadThreads", FALSE
);
1368 summary_clear_all(summaryview
);
1369 summaryview
->folder_item
= item
;
1370 summary_thaw(summaryview
);
1371 summary_unlock(summaryview
);
1379 messageview_clear(summaryview
->messageview
);
1381 summaryview
->folder_item
= item
;
1382 item
->opened
= TRUE
;
1384 buf
= g_strdup_printf(_("Scanning folder (%s)..."), item
->path
);
1385 debug_print("%s\n", buf
);
1386 STATUSBAR_PUSH(summaryview
->mainwin
, buf
);
1389 main_window_cursor_wait(summaryview
->mainwin
);
1391 mlist
= folder_item_get_msg_list(item
);
1393 if (!summary_check_consistency(item
, mlist
)) {
1394 debug_print("reloading due to inconsistency\n");
1395 procmsg_msg_list_free(mlist
);
1396 mlist
= folder_item_get_msg_list(item
);
1399 if (quicksearch_has_sat_predicate(summaryview
->quicksearch
)) {
1400 procmsg_msg_list_free(mlist
);
1403 START_TIMING("quicksearch");
1405 statusbar_print_all(_("Searching in %s... \n"),
1406 summaryview
->folder_item
->path
?
1407 summaryview
->folder_item
->path
: "(null)");
1409 folder_item_update_freeze();
1411 quicksearch_set_on_progress_cb(summaryview
->quicksearch
, summaryview_search_root_progress
, summaryview
);
1412 quicksearch_run_on_folder(summaryview
->quicksearch
, summaryview
->folder_item
, &mlist
);
1414 folder_item_update_thaw();
1415 statusbar_progress_all(0, 0, 0);
1416 statusbar_pop_all();
1418 if (!quicksearch_has_sat_predicate(summaryview
->quicksearch
)) {
1419 debug_print("search cancelled!\n");
1420 summary_thaw(summaryview
);
1421 STATUSBAR_POP(summaryview
->mainwin
);
1422 main_window_cursor_normal(summaryview
->mainwin
);
1423 summary_unlock(summaryview
);
1425 summary_show(summaryview
, summaryview
->folder_item
, FALSE
);
1432 if ((summaryview
->folder_item
->hide_read_msgs
1433 || summaryview
->folder_item
->hide_del_msgs
1434 || summaryview
->folder_item
->hide_read_threads
) &&
1435 quicksearch_has_sat_predicate(summaryview
->quicksearch
) == FALSE
) {
1438 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadMessages",
1439 summaryview
->folder_item
->hide_read_msgs
);
1440 summary_set_hide_menu(summaryview
, "/Menu/View/HideDelMessages",
1441 summaryview
->folder_item
->hide_del_msgs
);
1442 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadThreads",
1443 summaryview
->folder_item
->hide_read_threads
);
1445 for(cur
= mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= g_slist_next(cur
)) {
1446 MsgInfo
* msginfo
= (MsgInfo
*) cur
->data
;
1448 if (!msginfo
->hidden
) {
1449 if (MSG_IS_DELETED(msginfo
->flags
) && summaryview
->folder_item
->hide_del_msgs
) {
1450 procmsg_msginfo_free(&msginfo
);
1453 if (summaryview
->folder_item
->hide_read_msgs
) {
1454 if (MSG_IS_UNREAD(msginfo
->flags
) &&
1455 !MSG_IS_IGNORE_THREAD(msginfo
->flags
))
1456 not_killed
= g_slist_prepend(not_killed
, msginfo
);
1457 else if (MSG_IS_MARKED(msginfo
->flags
) ||
1458 MSG_IS_LOCKED(msginfo
->flags
))
1459 not_killed
= g_slist_prepend(not_killed
, msginfo
);
1460 else if (is_refresh
&&
1461 (msginfo
->msgnum
== selected_msgnum
||
1462 msginfo
->msgnum
== displayed_msgnum
))
1463 not_killed
= g_slist_prepend(not_killed
, msginfo
);
1465 procmsg_msginfo_free(&msginfo
);
1467 not_killed
= g_slist_prepend(not_killed
, msginfo
);
1470 procmsg_msginfo_free(&msginfo
);
1472 hidden_removed
= TRUE
;
1473 g_slist_free(mlist
);
1476 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadMessages",
1478 summary_set_hide_menu(summaryview
, "/Menu/View/HideDelMessages",
1480 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadThreads",
1484 if (!hidden_removed
) {
1485 START_TIMING("removing hidden");
1487 for(cur
= mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= g_slist_next(cur
)) {
1488 MsgInfo
* msginfo
= (MsgInfo
*) cur
->data
;
1490 if (!msginfo
->hidden
)
1491 not_killed
= g_slist_prepend(not_killed
, msginfo
);
1493 procmsg_msginfo_free(&msginfo
);
1495 g_slist_free(mlist
);
1500 STATUSBAR_POP(summaryview
->mainwin
);
1502 /* set ctree and hash table from the msginfo list, and
1503 create the thread */
1504 summary_set_ctree_from_list(summaryview
, mlist
, selected_msgnum
);
1506 g_slist_free(mlist
);
1509 if (!quicksearch_is_in_typing(summaryview
->quicksearch
)) {
1510 summaryview
->displayed
=
1511 summary_find_msg_by_msgnum(summaryview
,
1513 if (!summaryview
->displayed
)
1514 messageview_clear(summaryview
->messageview
);
1515 summary_unlock(summaryview
);
1517 if (quicksearch_is_running(summaryview
->quicksearch
))
1518 summary_select_by_msgnum(summaryview
, selected_msgnum
,
1519 OPEN_SELECTED_ON_SEARCH_RESULTS
);
1521 summary_select_by_msgnum(summaryview
, selected_msgnum
,
1524 summary_lock(summaryview
);
1525 if (!summaryview
->selected
) {
1526 /* no selected message - select first unread
1527 message, but do not display it */
1528 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1530 if (node
== NULL
&& GTK_CMCLIST(ctree
)->row_list
!= NULL
)
1531 node
= gtk_cmctree_node_nth
1533 item
->sort_type
== SORT_DESCENDING
1534 ? 0 : GTK_CMCLIST(ctree
)->rows
- 1);
1535 summary_unlock(summaryview
);
1537 if (quicksearch_is_running(summaryview
->quicksearch
))
1538 summary_select_node(summaryview
, node
,
1539 OPEN_SELECTED_ON_SEARCH_RESULTS
);
1541 summary_select_node(summaryview
, node
,
1542 OPEN_SELECTED_ON_FOLDER_OPEN
);
1544 summary_lock(summaryview
);
1547 /* just select first/last */
1548 if (GTK_CMCLIST(ctree
)->row_list
!= NULL
)
1549 node
= gtk_cmctree_node_nth
1551 item
->sort_type
== SORT_DESCENDING
1552 ? 0 : GTK_CMCLIST(ctree
)->rows
- 1);
1553 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_SEARCH_RESULTS
);
1556 /* backward compat */
1558 gboolean set
= FALSE
, stop
= FALSE
;
1559 for (i
= 0; i
< 6; i
++) {
1560 EntryAction act
= prefs_common
.summary_select_prio
[i
];
1562 if (act
!= ACTION_UNSET
) {
1568 prefs_summary_open_set_defaults();
1570 for (i
= 0; i
< 6 && node
== NULL
; i
++) {
1571 EntryAction act
= prefs_common
.summary_select_prio
[i
];
1574 case ACTION_OLDEST_MARKED
:
1575 if (summaryview
->sort_type
== SORT_ASCENDING
)
1576 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1579 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1582 case ACTION_NEWEST_MARKED
:
1583 if (summaryview
->sort_type
== SORT_ASCENDING
)
1584 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1587 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1590 case ACTION_OLDEST_NEW
:
1591 if (summaryview
->sort_type
== SORT_ASCENDING
)
1592 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1595 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1598 case ACTION_NEWEST_NEW
:
1599 if (summaryview
->sort_type
== SORT_ASCENDING
)
1600 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1603 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1606 case ACTION_OLDEST_UNREAD
:
1607 if (summaryview
->sort_type
== SORT_ASCENDING
)
1608 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1611 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1614 case ACTION_NEWEST_UNREAD
:
1615 if (summaryview
->sort_type
== SORT_ASCENDING
)
1616 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1619 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1622 case ACTION_LAST_OPENED
:
1623 if (summaryview
->folder_item
) {
1624 node
= summary_find_msg_by_msgnum(summaryview
,
1625 summaryview
->folder_item
->last_seen
);
1628 case ACTION_NEWEST_LIST
:
1629 if (GTK_CMCLIST(ctree
)->row_list
!= NULL
) {
1630 node
= gtk_cmctree_node_nth
1632 item
->sort_type
== SORT_DESCENDING
1633 ? 0 : GTK_CMCLIST(ctree
)->rows
- 1);
1636 case ACTION_OLDEST_LIST
:
1637 if (GTK_CMCLIST(ctree
)->row_list
!= NULL
) {
1638 node
= gtk_cmctree_node_nth
1640 item
->sort_type
== SORT_ASCENDING
1641 ? 0 : GTK_CMCLIST(ctree
)->rows
- 1);
1644 case ACTION_NOTHING
:
1655 summary_unlock(summaryview
);
1658 summary_select_node(summaryview
, node
,
1659 OPEN_SELECTED_ON_FOLDER_OPEN
);
1661 summary_lock(summaryview
);
1664 summary_status_show(summaryview
);
1665 summary_set_menu_sensitive(summaryview
);
1666 toolbar_main_set_sensitive(summaryview
->mainwin
);
1668 summary_thaw(summaryview
);
1670 STATUSBAR_PUSH(summaryview
->mainwin
, _("Done."));
1671 STATUSBAR_POP(summaryview
->mainwin
);
1672 main_window_cursor_normal(summaryview
->mainwin
);
1673 summary_unlock(summaryview
);
1679 #undef CURRENTLY_DISPLAYED
1681 static void summary_cancel_mark_read_timeout(SummaryView
*summaryview
) {
1682 if (summaryview
->mark_as_read_timeout_tag
!= 0) {
1683 g_source_remove(summaryview
->mark_as_read_timeout_tag
);
1684 summaryview
->mark_as_read_timeout_tag
= 0;
1688 void summary_clear_list(SummaryView
*summaryview
)
1690 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
1693 summary_freeze(summaryview
);
1695 gtk_cmctree_pre_recursive(GTK_CMCTREE(summaryview
->ctree
),
1696 NULL
, summary_free_msginfo_func
, NULL
);
1698 if (summaryview
->folder_item
) {
1699 summaryview
->folder_item
->opened
= FALSE
;
1700 summaryview
->folder_item
= NULL
;
1703 summary_cancel_mark_read_timeout(summaryview
);
1705 summaryview
->display_msg
= FALSE
;
1707 summaryview
->selected
= NULL
;
1708 summaryview
->displayed
= NULL
;
1709 summaryview
->total_size
= 0;
1710 summaryview
->deleted
= summaryview
->moved
= 0;
1711 summaryview
->copied
= 0;
1712 if (summaryview
->msgid_table
) {
1713 g_hash_table_destroy(summaryview
->msgid_table
);
1714 summaryview
->msgid_table
= NULL
;
1716 if (summaryview
->subject_table
) {
1717 g_hash_table_destroy(summaryview
->subject_table
);
1718 summaryview
->subject_table
= NULL
;
1720 summaryview
->mlist
= NULL
;
1722 gtk_cmclist_clear(clist
);
1723 if (summaryview
->col_pos
[S_COL_SUBJECT
] == N_SUMMARY_COLS
- 1) {
1724 optimal_width
= gtk_cmclist_optimal_column_width
1725 (clist
, summaryview
->col_pos
[S_COL_SUBJECT
]);
1726 gtk_cmclist_set_column_width
1727 (clist
, summaryview
->col_pos
[S_COL_SUBJECT
],
1731 summary_thaw(summaryview
);
1734 void summary_clear_all(SummaryView
*summaryview
)
1736 mimeview_clear(summaryview
->messageview
->mimeview
);
1737 messageview_clear(summaryview
->messageview
);
1738 summary_clear_list(summaryview
);
1739 summary_set_menu_sensitive(summaryview
);
1740 toolbar_main_set_sensitive(summaryview
->mainwin
);
1741 summary_status_show(summaryview
);
1744 void summary_lock(SummaryView
*summaryview
)
1746 summaryview
->lock_count
++;
1749 void summary_unlock(SummaryView
*summaryview
)
1751 if (summaryview
->lock_count
)
1752 summaryview
->lock_count
--;
1755 gboolean
summary_is_locked(SummaryView
*summaryview
)
1757 return summaryview
->lock_count
> 0;
1760 SummarySelection
summary_get_selection_type(SummaryView
*summaryview
)
1762 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
1763 SummarySelection selection
;
1765 if (!clist
->row_list
)
1766 selection
= SUMMARY_NONE
;
1767 else if (!clist
->selection
)
1768 selection
= SUMMARY_SELECTED_NONE
;
1769 else if (!clist
->selection
->next
)
1770 selection
= SUMMARY_SELECTED_SINGLE
;
1772 selection
= SUMMARY_SELECTED_MULTIPLE
;
1778 *\return MsgInfo * Selected message if there's one selected;
1779 * if multiple selected, or none, return NULL.
1781 MsgInfo
*summary_get_selected_msg(SummaryView
*summaryview
)
1783 /* summaryview->selected may be valid when multiple
1784 * messages were selected */
1785 GList
*sellist
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
1787 if (sellist
== NULL
|| sellist
->next
)
1790 return GTKUT_CTREE_NODE_GET_ROW_DATA(sellist
->data
);
1793 GSList
*summary_get_selected_msg_list(SummaryView
*summaryview
)
1795 GSList
*mlist
= NULL
;
1799 for (cur
= GTK_CMCLIST(summaryview
->ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
;
1801 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(cur
->data
);
1802 mlist
= g_slist_prepend(mlist
,
1803 procmsg_msginfo_new_ref(msginfo
));
1806 mlist
= g_slist_reverse(mlist
);
1811 void summary_set_menu_sensitive(SummaryView
*summaryview
)
1813 SensitiveCondMask state
;
1815 main_window_set_menu_sensitive(summaryview
->mainwin
);
1817 state
= main_window_get_current_state(summaryview
->mainwin
);
1819 #define SET_SENSITIVE(entry_str, ...) \
1821 SensitiveCondMask cond = main_window_get_mask(__VA_ARGS__, -1); \
1822 cm_menu_set_sensitive_full(summaryview->mainwin->ui_manager, \
1823 (const gchar *) entry_str, \
1824 ((cond & state) == cond)); \
1826 SET_SENSITIVE("Menus/SummaryViewPopup/Reedit", M_ALLOW_REEDIT
);
1827 SET_SENSITIVE("Menus/SummaryViewPopup/Reply", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1828 #ifndef GENERIC_UMPC
1829 SET_SENSITIVE("Menus/SummaryViewPopup/ReplyTo", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1830 SET_SENSITIVE("Menus/SummaryViewPopup/ReplyTo/All", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1831 SET_SENSITIVE("Menus/SummaryViewPopup/ReplyTo/Sender", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1832 SET_SENSITIVE("Menus/SummaryViewPopup/ReplyTo/MailingList", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1835 SET_SENSITIVE("Menus/SummaryViewPopup/Forward", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1836 #ifndef GENERIC_UMPC
1837 SET_SENSITIVE("Menus/SummaryViewPopup/ForwardAtt", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1838 SET_SENSITIVE("Menus/SummaryViewPopup/Redirect", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1841 SET_SENSITIVE("Menus/SummaryViewPopup/Move", M_TARGET_EXIST
, M_ALLOW_DELETE
, M_NOT_NEWS
);
1842 SET_SENSITIVE("Menus/SummaryViewPopup/Copy", M_TARGET_EXIST
, M_EXEC
);
1843 SET_SENSITIVE("Menus/SummaryViewPopup/Trash", M_TARGET_EXIST
, M_ALLOW_DELETE
, M_NOT_NEWS
, M_NOT_TRASH
);
1844 #ifndef GENERIC_UMPC
1845 SET_SENSITIVE("Menus/SummaryViewPopup/Delete", M_TARGET_EXIST
, M_ALLOW_DELETE
);
1848 SET_SENSITIVE("Menus/SummaryViewPopup/Mark", M_TARGET_EXIST
);
1849 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/Mark", M_TARGET_EXIST
);
1850 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/Unmark", M_TARGET_EXIST
);
1851 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/MarkRead", M_TARGET_EXIST
);
1852 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/MarkUnread", M_TARGET_EXIST
);
1853 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/MarkAllRead", M_TARGET_EXIST
);
1854 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/MarkAllUnread", M_TARGET_EXIST
);
1855 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/IgnoreThread", M_TARGET_EXIST
);
1856 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/UnignoreThread", M_TARGET_EXIST
);
1857 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/WatchThread", M_TARGET_EXIST
);
1858 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/UnwatchThread", M_TARGET_EXIST
);
1859 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/Lock", M_TARGET_EXIST
);
1860 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/Unlock", M_TARGET_EXIST
);
1861 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/MarkSpam", M_TARGET_EXIST
, M_CAN_LEARN_SPAM
);
1862 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/MarkHam", M_TARGET_EXIST
, M_CAN_LEARN_SPAM
);
1863 SET_SENSITIVE("Menus/SummaryViewPopup/ColorLabel", M_TARGET_EXIST
);
1864 SET_SENSITIVE("Menus/SummaryViewPopup/Tags", M_TARGET_EXIST
);
1866 #ifndef GENERIC_UMPC
1867 SET_SENSITIVE("Menus/SummaryViewPopup/AddSenderToAB", M_SINGLE_TARGET_EXIST
);
1869 SET_SENSITIVE("Menus/SummaryViewPopup/CreateFilterRule", M_SINGLE_TARGET_EXIST
, M_UNLOCKED
);
1870 #ifndef GENERIC_UMPC
1871 SET_SENSITIVE("Menus/SummaryViewPopup/CreateProcessingRule", M_SINGLE_TARGET_EXIST
, M_UNLOCKED
);
1874 SET_SENSITIVE("Menus/SummaryViewPopup/View", M_SINGLE_TARGET_EXIST
);
1875 SET_SENSITIVE("Menus/SummaryViewPopup/View/OpenNewWindow", M_SINGLE_TARGET_EXIST
);
1876 SET_SENSITIVE("Menus/SummaryViewPopup/View/MessageSource", M_SINGLE_TARGET_EXIST
);
1877 #ifndef GENERIC_UMPC
1878 SET_SENSITIVE("Menus/SummaryViewPopup/View/AllHeaders", M_SINGLE_TARGET_EXIST
);
1880 SET_SENSITIVE("Menus/SummaryViewPopup/SaveAs", M_TARGET_EXIST
);
1881 #ifndef GENERIC_UMPC
1882 SET_SENSITIVE("Menus/SummaryViewPopup/Print", M_TARGET_EXIST
);
1884 #undef SET_SENSITIVE
1886 summary_lock(summaryview
);
1887 #ifndef GENERIC_UMPC
1888 if (summaryview
->messageview
1889 && summaryview
->messageview
->mimeview
1890 && summaryview
->messageview
->mimeview
->textview
)
1891 cm_toggle_menu_set_active_full(summaryview
->mainwin
->ui_manager
, "Menus/SummaryViewPopup/View/AllHeaders",
1892 prefs_common
.show_all_headers
);
1894 summary_unlock(summaryview
);
1896 void summary_select_prev(SummaryView
*summaryview
)
1898 GtkCMCTreeNode
*node
= summaryview
->selected
;
1899 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
1901 if (summaryview
->sort_type
== SORT_ASCENDING
)
1902 node
= gtkut_ctree_node_prev(ctree
, node
);
1904 node
= gtkut_ctree_node_next(ctree
, node
);
1906 if (node
&& node
!= summaryview
->selected
)
1907 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
1910 void summary_select_next(SummaryView
*summaryview
)
1912 GtkCMCTreeNode
*node
= summaryview
->selected
;
1913 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
1915 if (summaryview
->sort_type
== SORT_ASCENDING
)
1916 node
= gtkut_ctree_node_next(ctree
, node
);
1918 node
= gtkut_ctree_node_prev(ctree
, node
);
1920 if (node
&& node
!= summaryview
->selected
)
1921 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
1924 void summary_select_prev_unread(SummaryView
*summaryview
)
1926 GtkCMCTreeNode
*node
;
1928 if (summaryview
->sort_type
== SORT_ASCENDING
)
1929 node
= summary_find_prev_flagged_msg
1930 (summaryview
, summaryview
->selected
, MSG_UNREAD
, TRUE
);
1932 node
= summary_find_next_flagged_msg
1933 (summaryview
, summaryview
->selected
, MSG_UNREAD
, TRUE
);
1935 if (!node
|| node
== summaryview
->selected
) {
1938 switch (prefs_common
.next_unread_msg_dialog
) {
1939 case NEXTUNREADMSGDIALOG_ALWAYS
:
1940 val
= alertpanel(_("No more unread messages"),
1941 _("No unread message found. "
1942 "Search from the end?"),
1943 NULL
, _("_No"), NULL
, _("_Yes"),
1944 NULL
, NULL
, ALERTFOCUS_SECOND
);
1946 case NEXTUNREADMSGDIALOG_ASSUME_YES
:
1947 val
= G_ALERTALTERNATE
;
1949 case NEXTUNREADMSGDIALOG_ASSUME_NO
:
1950 val
= !G_ALERTALTERNATE
;
1953 debug_print("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n");
1955 if (val
!= G_ALERTALTERNATE
) return;
1956 if (summaryview
->sort_type
== SORT_ASCENDING
)
1957 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1960 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1965 alertpanel_notice(_("No unread messages."));
1967 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
1970 void summary_select_next_unread(SummaryView
*summaryview
)
1972 GtkCMCTreeNode
*node
= summaryview
->selected
;
1974 if (summaryview
->sort_type
== SORT_ASCENDING
)
1975 node
= summary_find_next_flagged_msg
1976 (summaryview
, node
, MSG_UNREAD
, TRUE
);
1978 node
= summary_find_prev_flagged_msg
1979 (summaryview
, node
, MSG_UNREAD
, TRUE
);
1982 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
1986 switch (prefs_common
.next_unread_msg_dialog
) {
1987 case NEXTUNREADMSGDIALOG_ALWAYS
:
1988 val
= alertpanel(_("No more unread messages"),
1989 _("No unread message found. "
1990 "Go to next folder?"),
1991 NULL
, _("_No"), NULL
, _("_Yes"),
1992 NULL
, NULL
, ALERTFOCUS_SECOND
);
1994 case NEXTUNREADMSGDIALOG_ASSUME_YES
:
1995 val
= G_ALERTALTERNATE
;
1997 case NEXTUNREADMSGDIALOG_ASSUME_NO
:
2001 debug_print("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n");
2004 if (val
== G_ALERTALTERNATE
)
2005 folderview_select_next_with_flag(summaryview
->folderview
, MSG_UNREAD
);
2009 void summary_select_prev_new(SummaryView
*summaryview
)
2011 GtkCMCTreeNode
*node
;
2013 if (summaryview
->sort_type
== SORT_ASCENDING
)
2014 node
= summary_find_prev_flagged_msg
2015 (summaryview
, summaryview
->selected
, MSG_NEW
, TRUE
);
2017 node
= summary_find_next_flagged_msg
2018 (summaryview
, summaryview
->selected
, MSG_NEW
, TRUE
);
2020 if (!node
|| node
== summaryview
->selected
) {
2023 switch (prefs_common
.next_unread_msg_dialog
) {
2024 case NEXTUNREADMSGDIALOG_ALWAYS
:
2025 val
= alertpanel(_("No more new messages"),
2026 _("No new message found. "
2027 "Search from the end?"),
2028 NULL
, _("_No"), NULL
, _("_Yes"),
2029 NULL
, NULL
, ALERTFOCUS_SECOND
);
2031 case NEXTUNREADMSGDIALOG_ASSUME_YES
:
2032 val
= G_ALERTALTERNATE
;
2034 case NEXTUNREADMSGDIALOG_ASSUME_NO
:
2035 val
= !G_ALERTALTERNATE
;
2038 debug_print("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n");
2040 if (val
!= G_ALERTALTERNATE
) return;
2041 if (summaryview
->sort_type
== SORT_ASCENDING
)
2042 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
2045 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
2050 alertpanel_notice(_("No new messages."));
2052 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2055 void summary_select_next_new(SummaryView
*summaryview
)
2057 GtkCMCTreeNode
*node
= summaryview
->selected
;
2059 if (summaryview
->sort_type
== SORT_ASCENDING
)
2060 node
= summary_find_next_flagged_msg
2061 (summaryview
, node
, MSG_NEW
, TRUE
);
2063 node
= summary_find_prev_flagged_msg
2064 (summaryview
, node
, MSG_NEW
, TRUE
);
2067 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2071 switch (prefs_common
.next_unread_msg_dialog
) {
2072 case NEXTUNREADMSGDIALOG_ALWAYS
:
2073 val
= alertpanel(_("No more new messages"),
2074 _("No new message found. "
2075 "Go to next folder?"),
2076 NULL
, _("_No"), NULL
, _("_Yes"),
2077 NULL
, NULL
, ALERTFOCUS_SECOND
);
2079 case NEXTUNREADMSGDIALOG_ASSUME_YES
:
2080 val
= G_ALERTALTERNATE
;
2082 case NEXTUNREADMSGDIALOG_ASSUME_NO
:
2086 debug_print("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n");
2088 if (val
== G_ALERTALTERNATE
)
2089 folderview_select_next_with_flag(summaryview
->folderview
, MSG_NEW
);
2093 void summary_select_prev_marked(SummaryView
*summaryview
)
2095 GtkCMCTreeNode
*node
;
2097 if (summaryview
->sort_type
== SORT_ASCENDING
)
2098 node
= summary_find_prev_flagged_msg
2099 (summaryview
, summaryview
->selected
, MSG_MARKED
, TRUE
);
2101 node
= summary_find_next_flagged_msg
2102 (summaryview
, summaryview
->selected
, MSG_MARKED
, TRUE
);
2107 val
= alertpanel(_("No more marked messages"),
2108 _("No marked message found. "
2109 "Search from the end?"),
2110 NULL
, _("_No"), NULL
, _("_Yes"),
2111 NULL
, NULL
, ALERTFOCUS_SECOND
);
2112 if (val
!= G_ALERTALTERNATE
) return;
2113 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
2118 alertpanel_notice(_("No marked messages."));
2120 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2123 void summary_select_next_marked(SummaryView
*summaryview
)
2125 GtkCMCTreeNode
*node
= summaryview
->selected
;
2127 if (summaryview
->sort_type
== SORT_ASCENDING
)
2128 node
= summary_find_next_flagged_msg
2129 (summaryview
, node
, MSG_MARKED
, TRUE
);
2131 node
= summary_find_prev_flagged_msg
2132 (summaryview
, node
, MSG_MARKED
, TRUE
);
2135 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2139 switch (prefs_common
.next_unread_msg_dialog
) {
2140 case NEXTUNREADMSGDIALOG_ALWAYS
:
2141 val
= alertpanel(_("No more marked messages"),
2142 _("No marked message found. "
2143 "Go to next folder?"),
2144 NULL
, _("_No"), NULL
, _("_Yes"),
2145 NULL
, NULL
, ALERTFOCUS_SECOND
);
2147 case NEXTUNREADMSGDIALOG_ASSUME_YES
:
2148 val
= G_ALERTALTERNATE
;
2150 case NEXTUNREADMSGDIALOG_ASSUME_NO
:
2154 debug_print("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n");
2156 if (val
== G_ALERTALTERNATE
)
2157 folderview_select_next_with_flag(summaryview
->folderview
, MSG_MARKED
);
2161 void summary_select_prev_labeled(SummaryView
*summaryview
)
2163 GtkCMCTreeNode
*node
;
2165 if (summaryview
->sort_type
== SORT_ASCENDING
)
2166 node
= summary_find_prev_flagged_msg
2167 (summaryview
, summaryview
->selected
, MSG_CLABEL_FLAG_MASK
, TRUE
);
2169 node
= summary_find_next_flagged_msg
2170 (summaryview
, summaryview
->selected
, MSG_CLABEL_FLAG_MASK
, TRUE
);
2175 val
= alertpanel(_("No more labeled messages"),
2176 _("No labeled message found. "
2177 "Search from the end?"),
2178 NULL
, _("_No"), NULL
, _("_Yes"),
2179 NULL
, NULL
, ALERTFOCUS_SECOND
);
2180 if (val
!= G_ALERTALTERNATE
) return;
2181 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
2182 MSG_CLABEL_FLAG_MASK
, TRUE
);
2186 alertpanel_notice(_("No labeled messages."));
2188 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2191 void summary_select_next_labeled(SummaryView
*summaryview
)
2193 GtkCMCTreeNode
*node
;
2195 if (summaryview
->sort_type
== SORT_ASCENDING
)
2196 node
= summary_find_next_flagged_msg
2197 (summaryview
, summaryview
->selected
, MSG_CLABEL_FLAG_MASK
, TRUE
);
2199 node
= summary_find_prev_flagged_msg
2200 (summaryview
, summaryview
->selected
, MSG_CLABEL_FLAG_MASK
, TRUE
);
2205 val
= alertpanel(_("No more labeled messages"),
2206 _("No labeled message found. "
2207 "Search from the beginning?"),
2208 NULL
, _("_No"), NULL
, _("_Yes"),
2209 NULL
, NULL
, ALERTFOCUS_SECOND
);
2210 if (val
!= G_ALERTALTERNATE
) return;
2211 if (summaryview
->sort_type
== SORT_ASCENDING
)
2212 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
2213 MSG_CLABEL_FLAG_MASK
, TRUE
);
2215 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
2216 MSG_CLABEL_FLAG_MASK
, TRUE
);
2220 alertpanel_notice(_("No labeled messages."));
2222 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2225 void summary_select_parent(SummaryView
*summaryview
)
2227 GtkCMCTreeNode
*node
= NULL
;
2229 if (summaryview
->selected
)
2230 node
= GTK_CMCTREE_ROW(summaryview
->selected
)->parent
;
2232 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2235 void summary_select_by_msgnum(SummaryView
*summaryview
, guint msgnum
,
2238 GtkCMCTreeNode
*node
;
2240 node
= summary_find_msg_by_msgnum(summaryview
, msgnum
);
2241 summary_select_node(summaryview
, node
, show
);
2244 void summary_select_by_msg_list(SummaryView
*summaryview
, GSList
*msginfos
)
2247 GSList
*msgnum_list
, *walk
;
2248 gboolean froze
= FALSE
;
2250 ctree
= GTK_CMCTREE(summaryview
->ctree
);
2252 msgnum_list
= procmsg_get_number_list_for_msgs(msginfos
);
2254 START_LONG_OPERATION(summaryview
, FALSE
);
2255 for(walk
= msgnum_list
; walk
; walk
= walk
->next
) {
2256 GtkCMCTreeNode
*node
;
2257 node
= summary_find_msg_by_msgnum(summaryview
, GPOINTER_TO_UINT(walk
->data
));
2259 gtk_cmctree_select(ctree
, node
);
2261 END_LONG_OPERATION(summaryview
);
2262 g_slist_free(msgnum_list
);
2265 typedef struct _PostponedSelectData
2268 GtkCMCTreeNode
*row
;
2269 GtkCMCTreeNode
*node
;
2272 SummaryView
*summaryview
;
2273 gboolean display_msg
;
2274 } PostponedSelectData
;
2276 static gboolean
summary_select_retry(void *data
)
2278 PostponedSelectData
*psdata
= (PostponedSelectData
*)data
;
2279 debug_print("trying again\n");
2281 summary_selected(psdata
->ctree
, psdata
->row
,
2282 psdata
->column
, psdata
->summaryview
);
2283 else if (psdata
->node
)
2284 summary_select_node(psdata
->summaryview
, psdata
->node
,
2285 psdata
->display_msg
);
2291 * summary_select_node:
2292 * @summaryview: Summary view.
2293 * @node: Summary tree node.
2294 * @display_msg: whether to also display the message
2296 * Select @node (bringing it into view by scrolling and expanding its
2297 * thread, if necessary) and unselect all others.
2300 void summary_select_node(SummaryView
*summaryview
, GtkCMCTreeNode
*node
,
2301 gboolean display_msg
)
2303 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2305 /* If msgview is hidden, we never want to automatically display
2306 * a selected message, since that would unhide the msgview. */
2307 if (!messageview_is_visible(summaryview
->messageview
))
2308 display_msg
= FALSE
;
2310 if (summary_is_locked(summaryview
)
2311 && !GTK_SCTREE(ctree
)->selecting_range
2312 && summaryview
->messageview
->mimeview
2313 && summaryview
->messageview
->mimeview
->type
== MIMEVIEW_TEXT
2314 && summaryview
->messageview
->mimeview
->textview
->loading
) {
2315 PostponedSelectData
*data
= g_new0(PostponedSelectData
, 1);
2316 summaryview
->messageview
->mimeview
->textview
->stop_loading
= TRUE
;
2318 data
->ctree
= ctree
;
2321 data
->summaryview
= summaryview
;
2322 data
->display_msg
= display_msg
;
2323 debug_print("postponing open of message till end of load\n");
2324 g_timeout_add(100, summary_select_retry
, data
);
2327 if (summary_is_locked(summaryview
)) {
2330 if (!summaryview
->folder_item
)
2333 gtkut_ctree_expand_parent_all(ctree
, node
);
2335 summary_lock(summaryview
);
2337 summary_unlock(summaryview
);
2339 /* If quicksearch has focus, let's keep it there. */
2340 if (!quicksearch_has_focus(summaryview
->quicksearch
) ||
2341 quicksearch_is_running(summaryview
->quicksearch
))
2342 summary_grab_focus(summaryview
);
2344 gtkut_ctree_node_move_if_on_the_edge(ctree
, node
, -1);
2346 if (display_msg
&& summaryview
->displayed
== node
)
2347 summaryview
->displayed
= NULL
;
2348 summaryview
->display_msg
= display_msg
;
2349 gtk_sctree_select(GTK_SCTREE(ctree
), node
);
2350 if (summaryview
->selected
== NULL
)
2351 summaryview
->selected
= node
;
2355 guint
summary_get_msgnum(SummaryView
*summaryview
, GtkCMCTreeNode
*node
)
2357 GtkCMCTree
*ctree
=NULL
;
2362 ctree
= GTK_CMCTREE(summaryview
->ctree
);
2365 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2367 return msginfo
->msgnum
;
2372 static GtkCMCTreeNode
*summary_find_prev_msg(SummaryView
*summaryview
,
2373 GtkCMCTreeNode
*current_node
,
2374 gboolean start_from_prev
)
2376 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2377 GtkCMCTreeNode
*node
;
2381 if (start_from_prev
)
2382 node
= gtkut_ctree_node_prev(ctree
, current_node
);
2384 node
= current_node
;
2386 node
= gtk_cmctree_node_nth(ctree
, GTK_CMCLIST(ctree
)->rows
- 1);
2388 for (; node
!= NULL
; node
= gtkut_ctree_node_prev(ctree
, node
)) {
2389 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2390 if (msginfo
&& !MSG_IS_DELETED(msginfo
->flags
)) break;
2396 static GtkCMCTreeNode
*summary_find_next_msg(SummaryView
*summaryview
,
2397 GtkCMCTreeNode
*current_node
,
2398 gboolean start_from_next
)
2400 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2401 GtkCMCTreeNode
*node
;
2405 if (start_from_next
)
2406 node
= gtkut_ctree_node_next(ctree
, current_node
);
2408 node
= current_node
;
2410 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
2412 for (; node
!= NULL
; node
= gtkut_ctree_node_next(ctree
, node
)) {
2413 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2414 if (msginfo
&& !MSG_IS_DELETED(msginfo
->flags
)
2415 && !MSG_IS_MOVE(msginfo
->flags
)) break;
2421 static GtkCMCTreeNode
*summary_find_prev_flagged_msg(SummaryView
*summaryview
,
2422 GtkCMCTreeNode
*current_node
,
2424 gboolean start_from_prev
)
2426 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2427 GtkCMCTreeNode
*node
;
2431 if (start_from_prev
)
2432 node
= gtkut_ctree_node_prev(ctree
, current_node
);
2434 node
= current_node
;
2436 node
= gtk_cmctree_node_nth(ctree
, GTK_CMCLIST(ctree
)->rows
- 1);
2438 for (; node
!= NULL
; node
= gtkut_ctree_node_prev(ctree
, node
)) {
2439 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2440 if (msginfo
&& (msginfo
->flags
.perm_flags
& flags
) != 0) break;
2446 static GtkCMCTreeNode
*summary_find_next_flagged_msg(SummaryView
*summaryview
,
2447 GtkCMCTreeNode
*current_node
,
2449 gboolean start_from_next
)
2451 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2452 GtkCMCTreeNode
*node
;
2456 if (start_from_next
)
2457 node
= gtkut_ctree_node_next(ctree
, current_node
);
2459 node
= current_node
;
2461 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
2463 for (; node
!= NULL
; node
= gtkut_ctree_node_next(ctree
, node
)) {
2464 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2465 /* Find msg with matching flags but ignore messages with
2466 ignore flags, if searching for new or unread messages */
2467 if ((msginfo
&& (msginfo
->flags
.perm_flags
& flags
) != 0) &&
2468 !(((flags
& (MSG_NEW
| MSG_UNREAD
)) != 0) && MSG_IS_IGNORE_THREAD(msginfo
->flags
))
2476 static GtkCMCTreeNode
*summary_find_msg_by_msgnum(SummaryView
*summaryview
,
2479 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2480 GtkCMCTreeNode
*node
;
2483 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
2485 for (; node
!= NULL
; node
= gtkut_ctree_node_next(ctree
, node
)) {
2486 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2487 if (msginfo
&& msginfo
->msgnum
== msgnum
) break;
2493 static guint
attract_hash_func(gconstpointer key
)
2499 Xstrdup_a(str
, (const gchar
*)key
, return 0);
2506 for (p
+= 1; *p
!= '\0'; p
++)
2507 h
= (h
<< 5) - h
+ *p
;
2513 static gint
attract_compare_func(gconstpointer a
, gconstpointer b
)
2515 return subject_compare((const gchar
*)a
, (const gchar
*)b
) == 0;
2518 void summary_attract_by_subject(SummaryView
*summaryview
)
2520 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2521 GtkCMCList
*clist
= GTK_CMCLIST(ctree
);
2522 GtkCMCTreeNode
*src_node
;
2523 GtkCMCTreeNode
*dst_node
, *sibling
;
2524 GtkCMCTreeNode
*tmp
;
2525 MsgInfo
*src_msginfo
, *dst_msginfo
;
2526 GHashTable
*subject_table
;
2528 debug_print("Attracting messages by subject...\n");
2529 STATUSBAR_PUSH(summaryview
->mainwin
,
2530 _("Attracting messages by subject..."));
2532 main_window_cursor_wait(summaryview
->mainwin
);
2533 summary_freeze(summaryview
);
2535 subject_table
= g_hash_table_new(attract_hash_func
,
2536 attract_compare_func
);
2538 for (src_node
= GTK_CMCTREE_NODE(clist
->row_list
);
2541 tmp
= GTK_CMCTREE_ROW(src_node
)->sibling
;
2542 src_msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(src_node
);
2543 if (!src_msginfo
) continue;
2544 if (!src_msginfo
->subject
) continue;
2546 /* find attracting node */
2547 dst_node
= g_hash_table_lookup(subject_table
,
2548 src_msginfo
->subject
);
2551 dst_msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(dst_node
);
2553 /* if the time difference is more than 20 days,
2555 if (ABS(src_msginfo
->date_t
- dst_msginfo
->date_t
)
2556 > 60 * 60 * 24 * 20)
2559 sibling
= GTK_CMCTREE_ROW(dst_node
)->sibling
;
2560 if (src_node
!= sibling
)
2561 gtk_cmctree_move(ctree
, src_node
, NULL
, sibling
);
2564 g_hash_table_insert(subject_table
,
2565 src_msginfo
->subject
, src_node
);
2568 g_hash_table_destroy(subject_table
);
2570 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
2572 summary_thaw(summaryview
);
2574 debug_print("Attracting messages by subject done.\n");
2575 STATUSBAR_POP(summaryview
->mainwin
);
2577 main_window_cursor_normal(summaryview
->mainwin
);
2580 static void summary_free_msginfo_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
2583 MsgInfo
*msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2586 procmsg_msginfo_free(&msginfo
);
2589 static void summary_set_marks_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
2592 SummaryView
*summaryview
= data
;
2595 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2597 cm_return_if_fail(msginfo
!= NULL
);
2599 if (MSG_IS_DELETED(msginfo
->flags
))
2600 summaryview
->deleted
++;
2602 summaryview
->total_size
+= msginfo
->size
;
2604 summary_set_row_marks(summaryview
, node
);
2607 static void summary_update_status(SummaryView
*summaryview
)
2609 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2610 GtkCMCTreeNode
*node
;
2613 summaryview
->total_size
=
2614 summaryview
->deleted
= summaryview
->moved
= summaryview
->copied
= 0;
2616 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
2617 node
!= NULL
; node
= gtkut_ctree_node_next(ctree
, node
)) {
2618 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
2623 if (MSG_IS_DELETED(msginfo
->flags
))
2624 summaryview
->deleted
++;
2625 if (MSG_IS_MOVE(msginfo
->flags
))
2626 summaryview
->moved
++;
2627 if (MSG_IS_COPY(msginfo
->flags
))
2628 summaryview
->copied
++;
2629 summaryview
->total_size
+= msginfo
->size
;
2633 static void summary_status_show(SummaryView
*summaryview
)
2636 gchar
*del
, *mv
, *cp
;
2640 GList
*rowlist
, *cur
;
2641 guint n_selected
= 0, n_new
= 0, n_unread
= 0, n_total
= 0;
2642 guint n_marked
= 0, n_replied
= 0, n_forwarded
= 0, n_locked
= 0, n_ignored
= 0, n_watched
= 0;
2643 goffset sel_size
= 0, n_size
= 0;
2648 if (!summaryview
->folder_item
) {
2649 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_folder
), "");
2650 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_select
), "");
2651 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_msgs
), "");
2652 toolbar_main_set_sensitive(summaryview
->mainwin
);
2655 gtk_label_set_ellipsize(GTK_LABEL(summaryview
->statlabel_folder
), PANGO_ELLIPSIZE_END
);
2656 gtk_label_set_ellipsize(GTK_LABEL(summaryview
->statlabel_select
), PANGO_ELLIPSIZE_END
);
2657 gtk_label_set_ellipsize(GTK_LABEL(summaryview
->statlabel_msgs
), PANGO_ELLIPSIZE_START
);
2659 rowlist
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
2660 for (cur
= rowlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
2661 msginfo
= gtk_cmctree_node_get_row_data
2662 (GTK_CMCTREE(summaryview
->ctree
),
2663 GTK_CMCTREE_NODE(cur
->data
));
2665 sel_size
+= msginfo
->size
;
2670 if (summaryview
->folder_item
->hide_read_msgs
2671 || summaryview
->folder_item
->hide_del_msgs
2672 || summaryview
->folder_item
->hide_read_threads
2673 || quicksearch_has_sat_predicate(summaryview
->quicksearch
)) {
2674 rowlist
= GTK_CMCLIST(summaryview
->ctree
)->row_list
;
2675 for (cur
= rowlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
2676 msginfo
= gtk_cmctree_node_get_row_data
2677 (GTK_CMCTREE(summaryview
->ctree
),
2678 GTK_CMCTREE_NODE(cur
));
2680 n_size
+= msginfo
->size
;
2682 if (MSG_IS_NEW(msginfo
->flags
))
2684 if (MSG_IS_UNREAD(msginfo
->flags
))
2686 if (MSG_IS_MARKED(msginfo
->flags
))
2688 if (MSG_IS_REPLIED(msginfo
->flags
))
2690 if (MSG_IS_FORWARDED(msginfo
->flags
))
2692 if (MSG_IS_LOCKED(msginfo
->flags
))
2694 if (MSG_IS_IGNORE_THREAD(msginfo
->flags
))
2696 if (MSG_IS_WATCH_THREAD(msginfo
->flags
))
2701 n_new
= summaryview
->folder_item
->new_msgs
;
2702 n_unread
= summaryview
->folder_item
->unread_msgs
;
2703 n_marked
= summaryview
->folder_item
->marked_msgs
;
2704 n_replied
= summaryview
->folder_item
->replied_msgs
;
2705 n_forwarded
= summaryview
->folder_item
->forwarded_msgs
;
2706 n_locked
= summaryview
->folder_item
->locked_msgs
;
2707 n_ignored
= summaryview
->folder_item
->ignored_msgs
;
2708 n_watched
= summaryview
->folder_item
->watched_msgs
;
2709 n_total
= summaryview
->folder_item
->total_msgs
;
2710 n_size
= summaryview
->total_size
;
2713 name
= folder_item_get_name(summaryview
->folder_item
);
2714 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_folder
), name
);
2717 if (summaryview
->deleted
)
2718 del
= g_strdup_printf(_("%d deleted"), summaryview
->deleted
);
2721 if (summaryview
->moved
)
2722 mv
= g_strdup_printf(_("%s%d moved"),
2723 summaryview
->deleted
? ", " : "",
2724 summaryview
->moved
);
2727 if (summaryview
->copied
)
2728 cp
= g_strdup_printf(_("%s%d copied"),
2729 summaryview
->deleted
||
2730 summaryview
->moved
? ", " : "",
2731 summaryview
->copied
);
2735 if (summaryview
->deleted
|| summaryview
->moved
|| summaryview
->copied
)
2741 sel
= g_strdup_printf(" (%s)", to_human_readable((goffset
)sel_size
));
2742 itstr
= g_strdup_printf(ngettext(" item selected"," items selected", n_selected
));
2745 itstr
= g_strdup("");
2748 if (prefs_common
.layout_mode
!= SMALL_LAYOUT
) {
2749 str
= g_strconcat(n_selected
? itos(n_selected
) : "",
2750 itstr
, sel
, spc
, del
, mv
, cp
, NULL
);
2757 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_select
), str
);
2760 str
= g_strdup_printf(_("%d new, %d unread, %d total (%s)"),
2761 n_new
, n_unread
, n_total
,
2762 to_human_readable((goffset
)n_size
));
2764 g_signal_connect(G_OBJECT(summaryview
->popupmenu
), "selection-done",
2765 G_CALLBACK(popup_menu_selection_done
), summaryview
);
2767 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_msgs
), str
);
2769 tooltip
= g_strdup_printf("<b>%s</b>\n"
2780 _("Message summary"),
2782 _("Unread:"), n_unread
,
2783 _("Total:"), n_total
,
2784 _("Size:"), to_human_readable((goffset
)n_size
),
2785 _("Marked:"), n_marked
,
2786 _("Replied:"), n_replied
,
2787 _("Forwarded:"), n_forwarded
,
2788 _("Locked:"), n_locked
,
2789 _("Ignored:"), n_ignored
,
2790 _("Watched:"), n_watched
);
2792 gtk_widget_set_tooltip_markup(GTK_WIDGET(summaryview
->statlabel_msgs
),
2796 gchar
*ssize
, *tsize
;
2798 ssize
= g_strdup(to_human_readable((goffset
)sel_size
));
2799 tsize
= g_strdup(to_human_readable((goffset
)n_size
));
2800 str
= g_strdup_printf(_("%d/%d selected (%s/%s), %d unread"),
2801 n_selected
, n_total
, ssize
, tsize
, n_unread
);
2805 str
= g_strdup_printf(_("%d new, %d unread, %d total (%s)"),
2806 n_new
, n_unread
, n_total
, to_human_readable((goffset
)n_size
));
2813 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_select
), str
);
2817 summary_set_menu_sensitive(summaryview
);
2818 toolbar_main_set_sensitive(summaryview
->mainwin
);
2821 static void summary_set_column_titles(SummaryView
*summaryview
)
2823 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
2824 FolderItem
*item
= summaryview
->folder_item
;
2830 SummaryColumnType type
;
2831 GtkJustification justify
;
2833 static FolderSortKey sort_by
[N_SUMMARY_COLS
] = {
2848 for (pos
= 0; pos
< N_SUMMARY_COLS
; pos
++) {
2849 type
= summaryview
->col_state
[pos
].type
;
2851 /* CLAWS: mime and unread are single char headers */
2852 justify
= (type
== S_COL_NUMBER
|| type
== S_COL_SIZE
)
2853 ? GTK_JUSTIFY_RIGHT
: GTK_JUSTIFY_LEFT
;
2861 if(type
== S_COL_FROM
&& item
!= NULL
&&
2862 FOLDER_SHOWS_TO_HDR(item
) &&
2863 !summaryview
->col_state
[summaryview
->col_pos
[S_COL_TO
]].visible
)
2865 if(type
== S_COL_NUMBER
)
2866 title
= gettext(col_label
[type
]);
2868 title
= prefs_common_translated_header_name(col_label
[type
]);
2871 title
= gettext(col_label
[type
]);
2874 if (type
== S_COL_MIME
) {
2875 label
= gtk_image_new_from_pixbuf(clipxpm
);
2876 gtk_widget_show(label
);
2877 gtk_cmclist_set_column_widget(clist
, pos
, label
);
2878 gtk_sctree_set_column_tooltip(GTK_SCTREE(clist
), pos
, _("Attachment"));
2880 } else if (type
== S_COL_MARK
) {
2881 label
= gtk_image_new_from_pixbuf(markxpm
);
2882 gtk_widget_show(label
);
2883 gtk_cmclist_set_column_widget(clist
, pos
, label
);
2884 gtk_sctree_set_column_tooltip(GTK_SCTREE(clist
), pos
, C_("Column Header", "_Mark"));
2886 } else if (type
== S_COL_LOCKED
) {
2887 label
= gtk_image_new_from_pixbuf(lockedxpm
);
2888 gtk_widget_show(label
);
2889 gtk_cmclist_set_column_widget(clist
, pos
, label
);
2890 gtk_sctree_set_column_tooltip(GTK_SCTREE(clist
), pos
, _("Locked"));
2892 } else if (type
== S_COL_STATUS
) {
2893 gtk_cmclist_set_column_title(clist
, pos
, title
);
2894 gtk_sctree_set_column_tooltip(GTK_SCTREE(clist
), pos
, _("Status"));
2898 hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, 4);
2899 label
= gtk_label_new(title
);
2901 gtk_widget_set_size_request(hbox
, -1, 20);
2904 if (justify
== GTK_JUSTIFY_RIGHT
)
2905 gtk_box_pack_end(GTK_BOX(hbox
), label
,
2908 gtk_box_pack_start(GTK_BOX(hbox
), label
,
2911 if (summaryview
->sort_key
== sort_by
[type
] ||
2912 (summaryview
->sort_key
== SORT_BY_THREAD_DATE
&&
2913 sort_by
[SORT_BY_DATE
] && type
== S_COL_DATE
)) {
2914 arrow
= gtk_image_new_from_icon_name
2915 (summaryview
->sort_type
== SORT_ASCENDING
2916 ? "pan-down-symbolic" : "pan-up-symbolic",
2917 GTK_ICON_SIZE_MENU
);
2918 gtk_widget_set_size_request(GTK_WIDGET(arrow
), 10, 10);
2919 if (justify
== GTK_JUSTIFY_RIGHT
)
2920 gtk_box_pack_start(GTK_BOX(hbox
), arrow
,
2923 gtk_box_pack_end(GTK_BOX(hbox
), arrow
,
2927 gtk_widget_show_all(hbox
);
2928 gtk_cmclist_set_column_widget(clist
, pos
, hbox
);
2932 void summary_reflect_tags_changes(SummaryView
*summaryview
)
2935 GList
*children
, *cur
;
2936 GtkCMCTreeNode
*node
;
2937 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2938 gboolean froze
= FALSE
;
2939 gboolean redisplay
= FALSE
;
2941 /* re-create colorlabel submenu */
2942 menu
= GTK_MENU_SHELL(summaryview
->tags_menu
);
2943 cm_return_if_fail(menu
!= NULL
);
2945 /* clear items. get item pointers. */
2946 children
= gtk_container_get_children(GTK_CONTAINER(menu
));
2947 for (cur
= children
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
2948 gtk_menu_item_set_submenu(GTK_MENU_ITEM(cur
->data
), NULL
);
2950 g_list_free(children
);
2951 summary_tags_menu_create(summaryview
, TRUE
);
2953 START_LONG_OPERATION(summaryview
, TRUE
);
2954 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
); node
!= NULL
;
2955 node
= gtkut_ctree_node_next(ctree
, node
)) {
2956 redisplay
|= summary_set_row_tag(summaryview
,
2957 node
, TRUE
, FALSE
, 0);
2959 END_LONG_OPERATION(summaryview
);
2961 summary_redisplay_msg(summaryview
);
2965 void summary_reflect_prefs(void)
2967 static gchar
*last_smallfont
= NULL
;
2968 static gchar
*last_normalfont
= NULL
;
2969 static gchar
*last_boldfont
= NULL
;
2970 static gboolean last_derive
= 0;
2971 gboolean update_font
= FALSE
;
2972 SummaryView
*summaryview
= NULL
;
2974 if (!mainwindow_get_mainwindow())
2976 summaryview
= mainwindow_get_mainwindow()->summaryview
;
2978 if (!last_smallfont
|| strcmp(last_smallfont
, SMALL_FONT
) ||
2979 !last_normalfont
|| strcmp(last_normalfont
, NORMAL_FONT
) ||
2980 !last_boldfont
|| strcmp(last_boldfont
, BOLD_FONT
) ||
2981 last_derive
!= prefs_common
.derive_from_normal_font
)
2984 g_free(last_smallfont
);
2985 last_smallfont
= g_strdup(SMALL_FONT
);
2986 g_free(last_normalfont
);
2987 last_normalfont
= g_strdup(NORMAL_FONT
);
2988 g_free(last_boldfont
);
2989 last_boldfont
= g_strdup(BOLD_FONT
);
2990 last_derive
= prefs_common
.derive_from_normal_font
;
2992 #define STYLE_FREE(s) \
2994 g_object_unref(s); \
2999 STYLE_FREE(bold_style
);
3000 STYLE_FREE(bold_style
);
3001 summary_set_fonts(summaryview
);
3006 summary_set_column_titles(summaryview
);
3007 summary_relayout(summaryview
);
3009 if (summaryview
->folder_item
)
3010 summary_show(summaryview
, summaryview
->folder_item
, FALSE
);
3013 void summary_sort(SummaryView
*summaryview
,
3014 FolderSortKey sort_key
, FolderSortType sort_type
)
3016 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3017 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
3018 GtkCMCListCompareFunc cmp_func
= NULL
;
3020 g_signal_handlers_block_by_func(G_OBJECT(summaryview
->ctree
),
3021 G_CALLBACK(summary_tree_expanded
), summaryview
);
3022 summary_freeze(summaryview
);
3026 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_mark
;
3028 case SORT_BY_STATUS
:
3029 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_status
;
3032 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_mime
;
3034 case SORT_BY_NUMBER
:
3035 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_num
;
3038 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_size
;
3041 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_date
;
3043 case SORT_BY_THREAD_DATE
:
3044 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_thread_date
;
3047 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_from
;
3049 case SORT_BY_SUBJECT
:
3050 if (summaryview
->simplify_subject_preg
)
3051 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_simplified_subject
;
3053 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_subject
;
3056 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_score
;
3059 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_label
;
3062 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_to
;
3064 case SORT_BY_LOCKED
:
3065 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_locked
;
3068 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_tags
;
3076 summaryview
->sort_key
= sort_key
;
3077 summaryview
->sort_type
= sort_type
;
3079 summary_set_column_titles(summaryview
);
3080 summary_set_menu_sensitive(summaryview
);
3082 /* allow fallback to don't sort */
3083 if (summaryview
->sort_key
== SORT_BY_NONE
)
3086 if (cmp_func
!= NULL
) {
3087 debug_print("Sorting summary...\n");
3088 STATUSBAR_PUSH(summaryview
->mainwin
, _("Sorting summary..."));
3090 main_window_cursor_wait(summaryview
->mainwin
);
3092 gtk_cmclist_set_compare_func(clist
, cmp_func
);
3094 gtk_cmclist_set_sort_type(clist
, (GtkSortType
)sort_type
);
3095 gtk_sctree_sort_recursive(ctree
, NULL
);
3097 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
3099 main_window_cursor_normal(summaryview
->mainwin
);
3101 debug_print("Sorting summary done.\n");
3102 STATUSBAR_POP(summaryview
->mainwin
);
3105 summary_thaw(summaryview
);
3106 g_signal_handlers_unblock_by_func(G_OBJECT(summaryview
->ctree
),
3107 G_CALLBACK(summary_tree_expanded
), summaryview
);
3111 static gboolean
summary_update_thread_age(GNode
*node
, gpointer data
)
3113 MsgInfo
*msginfo
= node
->data
;
3114 time_t *most_recent
= (time_t *)data
;
3116 if (msginfo
->date_t
> *most_recent
) {
3117 *most_recent
= msginfo
->date_t
;
3122 static void summary_find_thread_age(GNode
*gnode
)
3124 MsgInfo
*msginfo
= (MsgInfo
*)gnode
->data
;
3129 most_recent
= msginfo
->thread_date
= msginfo
->date_t
;
3131 g_node_traverse(gnode
, G_IN_ORDER
, G_TRAVERSE_ALL
, -1, summary_update_thread_age
, &most_recent
);
3133 msginfo
->thread_date
= most_recent
;
3136 static gboolean
summary_update_is_read(GNode
*node
, gpointer data
)
3138 MsgInfo
*msginfo
= node
->data
;
3139 gboolean
*all_read
= (gboolean
*)data
;
3141 if (MSG_IS_UNREAD(msginfo
->flags
)) {
3148 static gboolean
summary_thread_is_read(GNode
*gnode
)
3150 MsgInfo
*msginfo
= (MsgInfo
*)gnode
->data
;
3151 gboolean all_read
= TRUE
;
3156 g_node_traverse(gnode
, G_IN_ORDER
, G_TRAVERSE_ALL
, -1, summary_update_is_read
, &all_read
);
3160 typedef struct _ThreadSelectedData
{
3162 gboolean is_selected
;
3163 } ThreadSelectedData
;
3165 static gboolean
summary_update_is_selected(GNode
*gnode
, gpointer data
)
3167 ThreadSelectedData
*selected
= (ThreadSelectedData
*)data
;
3168 MsgInfo
*msginfo
= (MsgInfo
*)gnode
->data
;
3170 if (msginfo
->msgnum
== selected
->msgnum
) {
3171 selected
->is_selected
= TRUE
;
3178 static gboolean
summary_thread_is_selected(GNode
*gnode
, guint selected_msgnum
)
3180 ThreadSelectedData selected
;
3182 selected
.msgnum
= selected_msgnum
;
3183 selected
.is_selected
= FALSE
;
3184 g_node_traverse(gnode
, G_IN_ORDER
, G_TRAVERSE_ALL
, -1,
3185 summary_update_is_selected
, &selected
);
3186 return selected
.is_selected
;
3189 static gboolean
summary_insert_gnode_func(GtkCMCTree
*ctree
, guint depth
, GNode
*gnode
,
3190 GtkCMCTreeNode
*cnode
, gpointer data
)
3192 SummaryView
*summaryview
= (SummaryView
*)data
;
3193 MsgInfo
*msginfo
= (MsgInfo
*)gnode
->data
;
3194 gchar
*text
[N_SUMMARY_COLS
];
3195 gint
*col_pos
= summaryview
->col_pos
;
3196 const gchar
*msgid
= msginfo
->msgid
;
3197 GHashTable
*msgid_table
= summaryview
->msgid_table
;
3198 gboolean vert_layout
= (prefs_common
.layout_mode
== VERTICAL_LAYOUT
);
3199 gboolean small_layout
= (prefs_common
.layout_mode
== SMALL_LAYOUT
);
3201 summary_set_header(summaryview
, text
, msginfo
);
3203 gtk_cmctree_set_node_info(ctree
, cnode
, text
[col_pos
[S_COL_SUBJECT
]], 2,
3204 NULL
, NULL
, FALSE
, summaryview
->threaded
&& !summaryview
->thread_collapsed
);
3205 #define SET_TEXT(col) { \
3206 gtk_cmctree_node_set_text(ctree, cnode, col_pos[col], \
3207 text[col_pos[col]]); \
3210 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_NUMBER
]].visible
)
3211 SET_TEXT(S_COL_NUMBER
);
3212 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_SCORE
]].visible
)
3213 SET_TEXT(S_COL_SCORE
);
3214 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_SIZE
]].visible
)
3215 SET_TEXT(S_COL_SIZE
);
3216 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_DATE
]].visible
)
3217 SET_TEXT(S_COL_DATE
);
3218 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_FROM
]].visible
)
3219 SET_TEXT(S_COL_FROM
);
3220 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_TO
]].visible
)
3222 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_TAGS
]].visible
)
3223 SET_TEXT(S_COL_TAGS
);
3225 if ((vert_layout
|| small_layout
) && prefs_common
.two_line_vert
)
3226 g_free(text
[summaryview
->col_pos
[S_COL_SUBJECT
]]);
3230 GTKUT_CTREE_NODE_SET_ROW_DATA(cnode
, msginfo
);
3231 summary_set_marks_func(ctree
, cnode
, summaryview
);
3233 if (msgid
&& msgid
[0] != '\0')
3234 g_hash_table_insert(msgid_table
, (gchar
*)msgid
, cnode
);
3239 static void summary_set_ctree_from_list(SummaryView
*summaryview
,
3240 GSList
*mlist
, guint selected_msgnum
)
3242 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3244 GtkCMCTreeNode
*node
= NULL
;
3245 GHashTable
*msgid_table
;
3246 GHashTable
*subject_table
= NULL
;
3248 GdkDisplay
*display
;
3250 gboolean vert_layout
= (prefs_common
.layout_mode
== VERTICAL_LAYOUT
);
3251 gboolean small_layout
= (prefs_common
.layout_mode
== SMALL_LAYOUT
);
3256 display
= gdk_display_get_default();
3258 debug_print("Setting summary from message data...\n");
3259 STATUSBAR_PUSH(summaryview
->mainwin
,
3260 _("Setting summary from message data..."));
3261 gdk_display_flush(display
);
3263 g_signal_handlers_block_by_func(G_OBJECT(ctree
),
3264 G_CALLBACK(summary_tree_expanded
), summaryview
);
3266 msgid_table
= g_hash_table_new(g_str_hash
, g_str_equal
);
3267 summaryview
->msgid_table
= msgid_table
;
3269 if (prefs_common
.thread_by_subject
) {
3270 subject_table
= g_hash_table_new(g_str_hash
, g_str_equal
);
3271 summaryview
->subject_table
= subject_table
;
3273 summaryview
->subject_table
= NULL
;
3276 if (prefs_common
.use_addr_book
)
3277 start_address_completion(NULL
);
3279 if (summaryview
->threaded
) {
3280 GNode
*root
, *gnode
;
3281 START_TIMING("threaded");
3282 root
= procmsg_get_thread_tree(mlist
);
3285 for (gnode
= root
->children
; gnode
!= NULL
;
3286 gnode
= gnode
->next
) {
3287 if (!summaryview
->folder_item
->hide_read_threads
||
3288 !summary_thread_is_read(gnode
) ||
3289 summary_thread_is_selected(gnode
, selected_msgnum
)) {
3290 summary_find_thread_age(gnode
);
3291 node
= gtk_sctree_insert_gnode
3292 (ctree
, NULL
, node
, gnode
,
3293 summary_insert_gnode_func
, summaryview
);
3297 g_node_destroy(root
);
3301 gchar
*text
[N_SUMMARY_COLS
];
3302 START_TIMING("unthreaded");
3304 for (; mlist
!= NULL
; mlist
= mlist
->next
) {
3305 msginfo
= (MsgInfo
*)mlist
->data
;
3307 summary_set_header(summaryview
, text
, msginfo
);
3309 node
= gtk_sctree_insert_node
3310 (ctree
, NULL
, node
, text
, 2,
3313 if ((vert_layout
|| small_layout
) && prefs_common
.two_line_vert
)
3314 g_free(text
[summaryview
->col_pos
[S_COL_SUBJECT
]]);
3316 GTKUT_CTREE_NODE_SET_ROW_DATA(node
, msginfo
);
3317 summary_set_marks_func(ctree
, node
, summaryview
);
3319 if (msginfo
->msgid
&& msginfo
->msgid
[0] != '\0')
3320 g_hash_table_insert(msgid_table
,
3321 msginfo
->msgid
, node
);
3323 if (prefs_common
.thread_by_subject
)
3324 subject_table_insert(subject_table
,
3332 if (prefs_common
.enable_hscrollbar
&&
3333 summaryview
->col_pos
[S_COL_SUBJECT
] == N_SUMMARY_COLS
- 1) {
3336 optimal_width
= gtk_cmclist_optimal_column_width
3337 (GTK_CMCLIST(ctree
), summaryview
->col_pos
[S_COL_SUBJECT
]);
3338 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
),
3339 summaryview
->col_pos
[S_COL_SUBJECT
],
3343 if (prefs_common
.use_addr_book
)
3344 end_address_completion();
3346 debug_print("Setting summary from message data done.\n");
3347 STATUSBAR_POP(summaryview
->mainwin
);
3348 if (debug_get_mode()) {
3349 debug_print("\tmsgid hash table size = %d\n",
3350 g_hash_table_size(msgid_table
));
3351 if (prefs_common
.thread_by_subject
)
3352 debug_print("\tsubject hash table size = %d\n",
3353 g_hash_table_size(subject_table
));
3356 summary_sort(summaryview
, summaryview
->sort_key
, summaryview
->sort_type
);
3358 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
3360 if (prefs_common
.bold_unread
|| prefs_common
.bold_marked
) {
3361 START_TIMING("bold_unread/bold_marked");
3363 GtkCMCTreeNode
*next
= GTK_CMCTREE_NODE_NEXT(node
);
3364 if (GTK_CMCTREE_ROW(node
)->children
)
3365 summary_set_row_marks(summaryview
, node
);
3371 g_signal_handlers_unblock_by_func(G_OBJECT(ctree
),
3372 G_CALLBACK(summary_tree_expanded
), summaryview
);
3376 static gchar
*summary_complete_address(const gchar
*addr
)
3379 gchar
*res
, *tmp
, *email_addr
;
3381 if (addr
== NULL
|| !strchr(addr
, '@'))
3384 Xstrdup_a(email_addr
, addr
, return NULL
);
3385 extract_address(email_addr
);
3390 * completion stuff must be already initialized
3393 if (1 < (count
= complete_address(email_addr
))) {
3394 tmp
= get_complete_address(1);
3395 res
= procheader_get_fromname(tmp
);
3402 static inline void summary_set_header(SummaryView
*summaryview
, gchar
*text
[],
3405 static gchar date_modified
[80];
3406 static gchar col_score
[11];
3407 static gchar from_buf
[BUFFSIZE
], to_buf
[BUFFSIZE
];
3408 static gchar tmp1
[BUFFSIZE
], tmp2
[BUFFSIZE
+4], tmp3
[BUFFSIZE
];
3409 gint
*col_pos
= summaryview
->col_pos
;
3410 gchar
*from_text
= NULL
, *to_text
= NULL
, *tags_text
= NULL
;
3411 gboolean should_swap
= FALSE
;
3412 gboolean vert_layout
= (prefs_common
.layout_mode
== VERTICAL_LAYOUT
);
3413 gboolean small_layout
= (prefs_common
.layout_mode
== SMALL_LAYOUT
);
3414 static const gchar
*color_dim_rgb
= NULL
;
3416 color_dim_rgb
= gtkut_gdk_rgba_to_string(&summaryview
->color_dim
);
3417 text
[col_pos
[S_COL_FROM
]] = "";
3418 text
[col_pos
[S_COL_TO
]] = "";
3419 text
[col_pos
[S_COL_SUBJECT
]]= "";
3420 text
[col_pos
[S_COL_MARK
]] = "";
3421 text
[col_pos
[S_COL_STATUS
]] = "";
3422 text
[col_pos
[S_COL_MIME
]] = "";
3423 text
[col_pos
[S_COL_LOCKED
]] = "";
3424 text
[col_pos
[S_COL_DATE
]] = "";
3425 text
[col_pos
[S_COL_TAGS
]] = "";
3426 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_NUMBER
]].visible
)
3427 text
[col_pos
[S_COL_NUMBER
]] = itos(msginfo
->msgnum
);
3429 text
[col_pos
[S_COL_NUMBER
]] = "";
3432 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_SIZE
]].visible
)
3433 text
[col_pos
[S_COL_SIZE
]] = to_human_readable(msginfo
->size
);
3435 text
[col_pos
[S_COL_SIZE
]] = "";
3437 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_SCORE
]].visible
)
3438 text
[col_pos
[S_COL_SCORE
]] = itos_buf(col_score
, msginfo
->score
);
3440 text
[col_pos
[S_COL_SCORE
]] = "";
3442 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_TAGS
]].visible
) {
3443 tags_text
= procmsg_msginfo_get_tags_str(msginfo
);
3445 text
[col_pos
[S_COL_TAGS
]] = "-";
3447 strncpy2(tmp1
, tags_text
, sizeof(tmp1
));
3448 tmp1
[sizeof(tmp1
)-1]='\0';
3450 text
[col_pos
[S_COL_TAGS
]] = tmp1
;
3453 text
[col_pos
[S_COL_TAGS
]] = "";
3456 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_DATE
]].visible
||
3457 ((vert_layout
|| small_layout
) && prefs_common
.two_line_vert
)) {
3458 if (msginfo
->date_t
&& msginfo
->date_t
> 0) {
3459 procheader_date_get_localtime(date_modified
,
3460 sizeof(date_modified
),
3462 text
[col_pos
[S_COL_DATE
]] = date_modified
;
3463 } else if (msginfo
->date
)
3464 text
[col_pos
[S_COL_DATE
]] = msginfo
->date
;
3466 text
[col_pos
[S_COL_DATE
]] = _("(No Date)");
3469 if (prefs_common
.swap_from
&& msginfo
->from
&& msginfo
->to
3470 && !summaryview
->col_state
[summaryview
->col_pos
[S_COL_TO
]].visible
) {
3473 addr
= g_strdup(msginfo
->from
);
3476 extract_address(addr
);
3477 if (account_find_from_address(addr
, FALSE
)) {
3484 if (!prefs_common
.use_addr_book
) {
3485 if (prefs_common
.summary_from_show
== SHOW_NAME
)
3486 from_text
= msginfo
->fromname
;
3487 else if (prefs_common
.summary_from_show
== SHOW_BOTH
)
3488 from_text
= msginfo
->from
;
3490 from_text
= msginfo
->from
;
3491 extract_address(from_text
);
3494 from_text
= _("(No From)");
3496 gchar
*tmp
= summary_complete_address(msginfo
->from
);
3498 strncpy2(from_buf
, tmp
, sizeof(from_buf
));
3500 from_text
= from_buf
;
3502 if (prefs_common
.summary_from_show
== SHOW_NAME
)
3503 from_text
= msginfo
->fromname
;
3504 else if (prefs_common
.summary_from_show
== SHOW_BOTH
)
3505 from_text
= msginfo
->from
;
3507 from_text
= msginfo
->from
;
3509 extract_address(from_text
);
3512 from_text
= _("(No From)");
3516 to_text
= msginfo
->to
? msginfo
->to
:
3517 (msginfo
->cc
? msginfo
->cc
:
3518 (msginfo
->newsgroups
? msginfo
->newsgroups
: NULL
3523 to_text
= _("(No Recipient)");
3525 if (prefs_common
.summary_from_show
== SHOW_NAME
) {
3526 gchar
*tmp
= procheader_get_fromname(to_text
);
3527 /* need to keep to_text pointing to stack, so heap-allocated
3528 * string from procheader_get_fromname() will be copied to to_buf */
3530 strncpy2(to_buf
, tmp
, sizeof(to_buf
));
3534 } else if (prefs_common
.summary_from_show
== SHOW_ADDR
)
3535 extract_address(to_text
);
3538 text
[col_pos
[S_COL_TO
]] = to_text
;
3540 text
[col_pos
[S_COL_FROM
]] = from_text
;
3542 if (prefs_common
.use_addr_book
) {
3543 gchar
*tmp
= summary_complete_address(to_text
);
3544 /* need to keep to_text pointing to stack, so heap-allocated
3545 * string from summary_complete_address() will be copied to to_buf */
3547 strncpy2(to_buf
, tmp
, sizeof(to_buf
));
3551 to_text
= to_text
? to_text
: _("(No From)");
3554 snprintf(tmp2
, BUFFSIZE
+4, "➜ %s", to_text
);
3555 tmp2
[BUFFSIZE
-1]='\0';
3556 text
[col_pos
[S_COL_FROM
]] = tmp2
;
3559 if (summaryview
->simplify_subject_preg
!= NULL
)
3560 text
[col_pos
[S_COL_SUBJECT
]] = msginfo
->subject
?
3561 string_remove_match(tmp3
, BUFFSIZE
, msginfo
->subject
,
3562 summaryview
->simplify_subject_preg
) :
3565 text
[col_pos
[S_COL_SUBJECT
]] = msginfo
->subject
? msginfo
->subject
:
3567 if ((vert_layout
|| small_layout
) && prefs_common
.two_line_vert
) {
3568 if (!FOLDER_SHOWS_TO_HDR(summaryview
->folder_item
)) {
3569 gchar
*tmp
= g_markup_printf_escaped(g_strconcat("%s\n",
3570 "<span color='%s' style='italic'>",
3571 _("From: %s, on %s"), "</span>", NULL
),
3572 text
[col_pos
[S_COL_SUBJECT
]],
3574 text
[col_pos
[S_COL_FROM
]],
3575 text
[col_pos
[S_COL_DATE
]]);
3576 text
[col_pos
[S_COL_SUBJECT
]] = tmp
;
3578 gchar
*tmp
= g_markup_printf_escaped(g_strconcat("%s\n",
3579 "<span color='%s' style='italic'>",
3580 _("To: %s, on %s"), "</span>", NULL
),
3581 text
[col_pos
[S_COL_SUBJECT
]],
3583 text
[col_pos
[S_COL_TO
]],
3584 text
[col_pos
[S_COL_DATE
]]);
3585 text
[col_pos
[S_COL_SUBJECT
]] = tmp
;
3590 static void summary_display_msg(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
3592 summary_display_msg_full(summaryview
, row
, FALSE
, FALSE
);
3595 static gboolean
defer_change(gpointer data
);
3601 typedef struct _ChangeData
{
3604 MsgPermFlags set_flags
;
3605 MsgTmpFlags set_tmp_flags
;
3606 MsgPermFlags unset_flags
;
3607 MsgTmpFlags unset_tmp_flags
;
3610 static void summary_msginfo_unset_flags(MsgInfo
*msginfo
, MsgPermFlags flags
, MsgTmpFlags tmp_flags
)
3612 if (!msginfo
->folder
|| !msginfo
->folder
->processing_pending
) {
3613 debug_print("flags: doing unset now\n");
3614 procmsg_msginfo_unset_flags(msginfo
, flags
, tmp_flags
);
3616 ChangeData
*unset_data
= g_new0(ChangeData
, 1);
3617 unset_data
->info
= msginfo
;
3618 unset_data
->op
= FLAGS_UNSET
;
3619 unset_data
->unset_flags
= flags
;
3620 unset_data
->unset_tmp_flags
= tmp_flags
;
3621 debug_print("flags: deferring unset\n");
3622 g_timeout_add(100, defer_change
, unset_data
);
3626 static void summary_msginfo_set_flags(MsgInfo
*msginfo
, MsgPermFlags flags
, MsgTmpFlags tmp_flags
)
3628 if (!msginfo
->folder
|| !msginfo
->folder
->processing_pending
) {
3629 debug_print("flags: doing set now\n");
3630 procmsg_msginfo_set_flags(msginfo
, flags
, tmp_flags
);
3632 ChangeData
*set_data
= g_new0(ChangeData
, 1);
3633 set_data
->info
= msginfo
;
3634 set_data
->op
= FLAGS_SET
;
3635 set_data
->set_flags
= flags
;
3636 set_data
->set_tmp_flags
= tmp_flags
;
3637 debug_print("flags: deferring set\n");
3638 g_timeout_add(100, defer_change
, set_data
);
3642 static void summary_msginfo_change_flags(MsgInfo
*msginfo
,
3643 MsgPermFlags add_flags
, MsgTmpFlags add_tmp_flags
,
3644 MsgPermFlags rem_flags
, MsgTmpFlags rem_tmp_flags
)
3646 if (!msginfo
->folder
|| !msginfo
->folder
->processing_pending
) {
3647 debug_print("flags: doing change now\n");
3648 procmsg_msginfo_change_flags(msginfo
, add_flags
, add_tmp_flags
,
3649 rem_flags
, rem_tmp_flags
);
3651 ChangeData
*change_data
= g_new0(ChangeData
, 1);
3652 change_data
->info
= msginfo
;
3653 change_data
->op
= FLAGS_CHANGE
;
3654 change_data
->set_flags
= add_flags
;
3655 change_data
->set_tmp_flags
= add_tmp_flags
;
3656 change_data
->unset_flags
= rem_flags
;
3657 change_data
->unset_tmp_flags
= rem_tmp_flags
;
3658 debug_print("flags: deferring change\n");
3659 g_timeout_add(100, defer_change
, change_data
);
3663 gboolean
defer_change(gpointer data
)
3665 ChangeData
*chg
= (ChangeData
*)data
;
3666 if (chg
->info
->folder
&& chg
->info
->folder
->processing_pending
) {
3667 debug_print("flags: trying later\n");
3668 return TRUE
; /* try again */
3670 debug_print("flags: finally doing it\n");
3673 procmsg_msginfo_unset_flags(chg
->info
, chg
->unset_flags
, chg
->unset_tmp_flags
);
3676 procmsg_msginfo_set_flags(chg
->info
, chg
->set_flags
, chg
->set_tmp_flags
);
3679 procmsg_msginfo_change_flags(chg
->info
, chg
->set_flags
, chg
->set_tmp_flags
,
3680 chg
->unset_flags
, chg
->unset_tmp_flags
);
3683 g_warning("unknown change op");
3690 static void msginfo_mark_as_read (SummaryView
*summaryview
, MsgInfo
*msginfo
,
3691 GtkCMCTreeNode
*row
)
3693 cm_return_if_fail(summaryview
!= NULL
);
3694 cm_return_if_fail(msginfo
!= NULL
);
3695 cm_return_if_fail(row
!= NULL
);
3697 if (MSG_IS_NEW(msginfo
->flags
) || MSG_IS_UNREAD(msginfo
->flags
)) {
3698 summary_msginfo_unset_flags
3699 (msginfo
, MSG_NEW
| MSG_UNREAD
, 0);
3700 summary_set_row_marks(summaryview
, row
);
3701 summary_status_show(summaryview
);
3707 SummaryView
*summaryview
;
3710 static int msginfo_mark_as_read_timeout(void *data
)
3712 MarkAsReadData
*mdata
= (MarkAsReadData
*)data
;
3716 summary_lock(mdata
->summaryview
);
3717 if (mdata
->msginfo
== summary_get_selected_msg(mdata
->summaryview
))
3718 msginfo_mark_as_read(mdata
->summaryview
, mdata
->msginfo
,
3719 mdata
->summaryview
->selected
);
3720 procmsg_msginfo_free(&(mdata
->msginfo
));
3722 mdata
->summaryview
->mark_as_read_timeout_tag
= 0;
3723 summary_unlock(mdata
->summaryview
);
3729 static void summary_display_msg_full(SummaryView
*summaryview
,
3730 GtkCMCTreeNode
*row
,
3731 gboolean new_window
, gboolean all_headers
)
3733 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3738 if (summaryview
->displayed
== row
&&
3739 messageview_is_visible(summaryview
->messageview
))
3741 else if (summaryview
->messageview
)
3742 summaryview
->messageview
->filtered
= FALSE
;
3744 cm_return_if_fail(row
!= NULL
);
3746 if (summary_is_locked(summaryview
)) return;
3747 summary_lock(summaryview
);
3749 STATUSBAR_POP(summaryview
->mainwin
);
3752 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
3755 debug_print("NULL msginfo\n");
3756 summary_unlock(summaryview
);
3761 if (new_window
&& prefs_common
.layout_mode
!= SMALL_LAYOUT
) {
3762 MessageView
*msgview
;
3764 msgview
= messageview_create_with_new_window(summaryview
->mainwin
);
3765 val
= messageview_show(msgview
, msginfo
, all_headers
);
3767 MessageView
*msgview
;
3769 if (prefs_common
.layout_mode
== SMALL_LAYOUT
) {
3770 if (summaryview
->ext_messageview
== NULL
)
3771 summaryview
->ext_messageview
= messageview_create_with_new_window(summaryview
->mainwin
);
3773 gtkut_window_popup(summaryview
->ext_messageview
->window
);
3774 msgview
= summaryview
->ext_messageview
;
3775 summaryview
->displayed
= row
;
3776 val
= messageview_show(msgview
, msginfo
, all_headers
);
3777 if (mimeview_tree_is_empty(msgview
->mimeview
))
3778 gtk_widget_grab_focus(summaryview
->ctree
);
3779 gtkut_ctree_node_move_if_on_the_edge(ctree
, row
,
3780 GTK_CMCLIST(summaryview
->ctree
)->focus_row
);
3782 msgview
= summaryview
->messageview
;
3783 summaryview
->displayed
= row
;
3784 if (!messageview_is_visible(msgview
) &&
3785 gtk_window_is_active(GTK_WINDOW(summaryview
->mainwin
->window
))) {
3786 main_window_toggle_message_view(summaryview
->mainwin
);
3789 val
= messageview_show(msgview
, msginfo
, all_headers
);
3790 if (mimeview_tree_is_empty(msgview
->mimeview
))
3791 gtk_widget_grab_focus(summaryview
->ctree
);
3792 gtkut_ctree_node_move_if_on_the_edge(ctree
, row
,
3793 GTK_CMCLIST(summaryview
->ctree
)->focus_row
);
3797 if (val
== 0 && MSG_IS_UNREAD(msginfo
->flags
)) {
3798 if (!prefs_common
.mark_as_read_on_new_window
&&
3799 prefs_common
.mark_as_read_delay
) {
3800 MarkAsReadData
*data
= g_new0(MarkAsReadData
, 1);
3801 data
->summaryview
= summaryview
;
3802 data
->msginfo
= procmsg_msginfo_new_ref(msginfo
);
3803 if (summaryview
->mark_as_read_timeout_tag
!= 0)
3804 g_source_remove(summaryview
->mark_as_read_timeout_tag
);
3805 summaryview
->mark_as_read_timeout_tag
=
3806 g_timeout_add_seconds(prefs_common
.mark_as_read_delay
,
3807 msginfo_mark_as_read_timeout
, data
);
3808 } else if (new_window
|| !prefs_common
.mark_as_read_on_new_window
) {
3809 msginfo_mark_as_read(summaryview
, msginfo
, row
);
3813 summary_set_menu_sensitive(summaryview
);
3814 toolbar_main_set_sensitive(summaryview
->mainwin
);
3815 messageview_set_menu_sensitive(summaryview
->messageview
);
3817 summary_unlock(summaryview
);
3821 void summary_display_msg_selected(SummaryView
*summaryview
,
3822 gboolean all_headers
)
3824 if (summary_is_locked(summaryview
)) return;
3825 summaryview
->displayed
= NULL
;
3826 summary_display_msg_full(summaryview
, summaryview
->selected
, FALSE
,
3830 void summary_redisplay_msg(SummaryView
*summaryview
)
3832 GtkCMCTreeNode
*node
;
3834 if (summaryview
->displayed
) {
3835 node
= summaryview
->displayed
;
3836 summaryview
->displayed
= NULL
;
3837 summary_display_msg(summaryview
, node
);
3841 void summary_open_msg(SummaryView
*summaryview
)
3843 if (!summaryview
->selected
) return;
3845 /* CLAWS: if separate message view, don't open a new window
3846 * but rather use the current separated message view */
3847 summary_display_msg_full(summaryview
, summaryview
->selected
,
3851 void summary_view_source(SummaryView
* summaryview
)
3853 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3855 SourceWindow
*srcwin
;
3857 if (!summaryview
->selected
) return;
3859 srcwin
= source_window_create();
3860 msginfo
= gtk_cmctree_node_get_row_data(ctree
, summaryview
->selected
);
3861 source_window_show(srcwin
);
3862 source_window_show_msg(srcwin
, msginfo
);
3865 void summary_reedit(SummaryView
*summaryview
)
3869 if (!summaryview
->selected
) return;
3870 if (!summaryview
->folder_item
) return;
3871 if (!FOLDER_SHOWS_TO_HDR(summaryview
->folder_item
))
3874 msginfo
= gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview
->ctree
),
3875 summaryview
->selected
);
3876 if (!msginfo
) return;
3878 compose_reedit(msginfo
, FALSE
);
3881 gboolean
summary_is_list(SummaryView
*summaryview
)
3883 return (gtk_notebook_get_current_page(
3884 GTK_NOTEBOOK(summaryview
->mainwidget_book
)) == 0);
3887 void summary_toggle_view(SummaryView
*summaryview
)
3889 if (prefs_common
.layout_mode
== SMALL_LAYOUT
)
3891 if (summary_is_locked(summaryview
))
3893 if (!messageview_is_visible(summaryview
->messageview
) &&
3894 summaryview
->selected
&& summary_is_list(summaryview
))
3895 summary_display_msg(summaryview
,
3896 summaryview
->selected
);
3898 main_window_toggle_message_view(summaryview
->mainwin
);
3901 static gboolean
summary_search_unread_recursive(GtkCMCTree
*ctree
,
3902 GtkCMCTreeNode
*node
)
3907 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
3908 if (msginfo
&& MSG_IS_UNREAD(msginfo
->flags
) && !MSG_IS_IGNORE_THREAD(msginfo
->flags
))
3910 node
= GTK_CMCTREE_ROW(node
)->children
;
3912 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
3915 if (summary_search_unread_recursive(ctree
, node
) == TRUE
)
3917 node
= GTK_CMCTREE_ROW(node
)->sibling
;
3923 static gboolean
summary_have_unread_children(SummaryView
*summaryview
,
3924 GtkCMCTreeNode
*node
)
3926 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3928 if (!node
) return FALSE
;
3930 node
= GTK_CMCTREE_ROW(node
)->children
;
3933 if (summary_search_unread_recursive(ctree
, node
) == TRUE
)
3935 node
= GTK_CMCTREE_ROW(node
)->sibling
;
3940 static void summary_set_row_marks(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
3942 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3943 GtkStyle
*style
= NULL
;
3946 gint
*col_pos
= summaryview
->col_pos
;
3948 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
3949 if (!msginfo
) return;
3951 flags
= msginfo
->flags
;
3953 gtk_cmctree_node_set_foreground(ctree
, row
, NULL
);
3955 /* set new/unread column */
3956 if (MSG_IS_IGNORE_THREAD(flags
)) {
3957 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3959 } else if (MSG_IS_WATCH_THREAD(flags
)) {
3960 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3962 } else if (MSG_IS_SPAM(flags
)) {
3963 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3965 } else if (MSG_IS_NEW(flags
)) {
3966 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3968 } else if (MSG_IS_UNREAD(flags
)) {
3969 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3971 } else if (MSG_IS_REPLIED(flags
) && MSG_IS_FORWARDED(flags
)) {
3972 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3973 repliedandforwardedxpm
);
3974 } else if (MSG_IS_REPLIED(flags
)) {
3975 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3977 } else if (MSG_IS_FORWARDED(flags
)) {
3978 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3981 gtk_cmctree_node_set_text(ctree
, row
, col_pos
[S_COL_STATUS
],
3985 if ((((prefs_common
.bold_unread
&& MSG_IS_UNREAD(flags
)) ||
3986 (prefs_common
.bold_marked
&& MSG_IS_MARKED(flags
))) &&
3987 !MSG_IS_IGNORE_THREAD(flags
)) ||
3988 (!GTK_CMCTREE_ROW(row
)->expanded
&&
3989 GTK_CMCTREE_ROW(row
)->children
&&
3990 summary_have_unread_children(summaryview
, row
)))
3993 /* set mark column */
3994 if (MSG_IS_DELETED(flags
)) {
3995 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MARK
],
3999 gtk_cmctree_node_set_foreground
4000 (ctree
, row
, &summaryview
->color_dim
);
4001 } else if (MSG_IS_MARKED(flags
)) {
4002 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MARK
],
4004 } else if (MSG_IS_MOVE(flags
)) {
4005 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MARK
],
4007 if (!msginfo
->to_folder
||
4008 !folder_has_parent_of_type(msginfo
->to_folder
, F_TRASH
)) {
4011 gtk_cmctree_node_set_foreground
4012 (ctree
, row
, &summaryview
->color_marked
);
4016 gtk_cmctree_node_set_foreground
4017 (ctree
, row
, &summaryview
->color_dim
);
4019 } else if (MSG_IS_COPY(flags
)) {
4020 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MARK
],
4024 gtk_cmctree_node_set_foreground
4025 (ctree
, row
, &summaryview
->color_marked
);
4027 gtk_cmctree_node_set_text(ctree
, row
, col_pos
[S_COL_MARK
], "");
4030 if (MSG_IS_LOCKED(flags
)) {
4031 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_LOCKED
],
4035 gtk_cmctree_node_set_text(ctree
, row
, col_pos
[S_COL_LOCKED
], "");
4038 if (MSG_IS_WITH_ATTACHMENT(flags
) && MSG_IS_SIGNED(flags
)) {
4039 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4041 } else if (MSG_IS_SIGNED(flags
)) {
4042 if (MSG_IS_ENCRYPTED(flags
)) {
4043 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4046 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4049 } else if (MSG_IS_WITH_ATTACHMENT(flags
) && MSG_IS_ENCRYPTED(flags
)) {
4050 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4052 } else if (MSG_IS_ENCRYPTED(flags
)) {
4053 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4055 } else if (MSG_IS_WITH_ATTACHMENT(flags
)) {
4056 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4059 gtk_cmctree_node_set_text(ctree
, row
, col_pos
[S_COL_MIME
], "");
4062 gtk_cmctree_node_set_row_style(ctree
, row
, style
);
4064 if (MSG_GET_COLORLABEL(flags
))
4065 summary_set_colorlabel_color(ctree
, row
, MSG_GET_COLORLABEL_VALUE(flags
));
4068 static void summary_mark_row(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
4070 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4073 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4074 cm_return_if_fail(msginfo
);
4075 if (MSG_IS_DELETED(msginfo
->flags
))
4076 summaryview
->deleted
--;
4077 if (MSG_IS_MOVE(msginfo
->flags
))
4078 summaryview
->moved
--;
4079 if (MSG_IS_COPY(msginfo
->flags
))
4080 summaryview
->copied
--;
4082 procmsg_msginfo_set_to_folder(msginfo
, NULL
);
4083 summary_msginfo_change_flags(msginfo
, MSG_MARKED
, 0, MSG_DELETED
,
4084 MSG_MOVE
| MSG_COPY
| MSG_MOVE_DONE
);
4085 summary_set_row_marks(summaryview
, row
);
4086 debug_print("Message %s/%d is marked\n", msginfo
->folder
->path
, msginfo
->msgnum
);
4089 static void summary_lock_row(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
4091 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4094 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4095 cm_return_if_fail(msginfo
);
4096 if (MSG_IS_DELETED(msginfo
->flags
))
4097 summaryview
->deleted
--;
4098 if (MSG_IS_MOVE(msginfo
->flags
)) {
4099 summaryview
->moved
--;
4101 if (MSG_IS_COPY(msginfo
->flags
)) {
4102 summaryview
->copied
--;
4104 procmsg_msginfo_set_to_folder(msginfo
, NULL
);
4105 summary_msginfo_change_flags(msginfo
, MSG_LOCKED
, 0, MSG_DELETED
,
4106 MSG_MOVE
| MSG_COPY
| MSG_MOVE_DONE
);
4108 summary_set_row_marks(summaryview
, row
);
4109 debug_print("Message %d is locked\n", msginfo
->msgnum
);
4112 static void summary_unlock_row(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
4114 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4117 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4118 cm_return_if_fail(msginfo
);
4119 if (!MSG_IS_LOCKED(msginfo
->flags
))
4121 procmsg_msginfo_set_to_folder(msginfo
, NULL
);
4122 summary_msginfo_unset_flags(msginfo
, MSG_LOCKED
, 0);
4123 summary_set_row_marks(summaryview
, row
);
4124 debug_print("Message %d is unlocked\n", msginfo
->msgnum
);
4127 void summary_mark(SummaryView
*summaryview
)
4129 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4131 gboolean froze
= FALSE
;
4133 if (summary_is_locked(summaryview
))
4135 START_LONG_OPERATION(summaryview
, FALSE
);
4136 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4137 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4138 summary_mark_row(summaryview
, GTK_CMCTREE_NODE(cur
->data
));
4139 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4140 END_LONG_OPERATION(summaryview
);
4142 summary_status_show(summaryview
);
4145 static void summary_mark_row_as_read(SummaryView
*summaryview
,
4146 GtkCMCTreeNode
*row
)
4148 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4151 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4152 cm_return_if_fail(msginfo
);
4154 if(!(MSG_IS_NEW(msginfo
->flags
) || MSG_IS_UNREAD(msginfo
->flags
)))
4157 summary_msginfo_unset_flags(msginfo
, MSG_NEW
| MSG_UNREAD
, 0);
4158 summary_set_row_marks(summaryview
, row
);
4159 debug_print("Message %d is marked as read\n",
4163 static void summary_mark_row_as_unread(SummaryView
*summaryview
,
4164 GtkCMCTreeNode
*row
)
4166 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4169 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4170 cm_return_if_fail(msginfo
);
4172 if(MSG_IS_NEW(msginfo
->flags
) || MSG_IS_UNREAD(msginfo
->flags
))
4175 summary_msginfo_set_flags(msginfo
, MSG_UNREAD
, 0);
4176 summary_set_row_marks(summaryview
, row
);
4177 debug_print("Message %d is marked as unread\n",
4181 void summary_mark_as_read(SummaryView
*summaryview
)
4183 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4185 gboolean froze
= FALSE
;
4187 if (summary_is_locked(summaryview
))
4190 if (!summaryview
->folder_item
)
4193 if ((summaryview
->folder_item
->total_msgs
== (gint
)g_list_length(GTK_CMCLIST(ctree
)->selection
) &&
4194 summaryview
->folder_item
->total_msgs
> 1) &&
4195 !summary_mark_all_read_confirm(TRUE
))
4198 START_LONG_OPERATION(summaryview
, FALSE
);
4199 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4200 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4201 summary_mark_row_as_read(summaryview
,
4202 GTK_CMCTREE_NODE(cur
->data
));
4203 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4204 END_LONG_OPERATION(summaryview
);
4206 summary_status_show(summaryview
);
4209 void summary_mark_as_unread(SummaryView
*summaryview
)
4211 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4213 gboolean froze
= FALSE
;
4215 if (summary_is_locked(summaryview
))
4218 if ((summaryview
->folder_item
->total_msgs
== (gint
)g_list_length(GTK_CMCLIST(ctree
)->selection
) &&
4219 summaryview
->folder_item
->total_msgs
> 1) &&
4220 !summary_mark_all_unread_confirm(TRUE
))
4223 START_LONG_OPERATION(summaryview
, FALSE
);
4224 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4225 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4226 summary_mark_row_as_unread(summaryview
,
4227 GTK_CMCTREE_NODE(cur
->data
));
4228 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4229 END_LONG_OPERATION(summaryview
);
4231 summary_status_show(summaryview
);
4234 void summary_msgs_lock(SummaryView
*summaryview
)
4236 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4238 gboolean froze
= FALSE
;
4240 if (summary_is_locked(summaryview
))
4242 START_LONG_OPERATION(summaryview
, FALSE
);
4243 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4244 summary_lock_row(summaryview
,
4245 GTK_CMCTREE_NODE(cur
->data
));
4246 END_LONG_OPERATION(summaryview
);
4248 summary_status_show(summaryview
);
4251 void summary_msgs_unlock(SummaryView
*summaryview
)
4253 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4255 gboolean froze
= FALSE
;
4257 if (summary_is_locked(summaryview
))
4259 START_LONG_OPERATION(summaryview
, FALSE
);
4260 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4261 summary_unlock_row(summaryview
,
4262 GTK_CMCTREE_NODE(cur
->data
));
4263 END_LONG_OPERATION(summaryview
);
4265 summary_status_show(summaryview
);
4268 static gboolean
summary_mark_all_read_confirm(gboolean ask_if_needed
)
4270 /* ask_if_needed is FALSE when user-asking is performed by caller,
4271 commonly when the caller is a mark-as-read-recursive func */
4272 if (ask_if_needed
&& prefs_common
.ask_mark_all_read
) {
4273 AlertValue val
= alertpanel_full(_("Mark all as read"),
4274 _("Do you really want to mark all mails in this folder as read?"),
4275 NULL
, _("_No"), NULL
, _("_Yes"), NULL
, NULL
, ALERTFOCUS_FIRST
,
4276 TRUE
, NULL
, ALERT_QUESTION
);
4278 if ((val
& ~G_ALERTDISABLE
) != G_ALERTALTERNATE
)
4280 else if (val
& G_ALERTDISABLE
)
4281 prefs_common
.ask_mark_all_read
= FALSE
;
4286 void summary_mark_all_read(SummaryView
*summaryview
, gboolean ask_if_needed
)
4288 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4289 GtkCMCTreeNode
*node
;
4290 gboolean froze
= FALSE
;
4292 if (summary_is_locked(summaryview
))
4295 if (!summary_mark_all_read_confirm(ask_if_needed
))
4298 START_LONG_OPERATION(summaryview
, TRUE
);
4299 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4300 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
); node
!= NULL
;
4301 node
= gtkut_ctree_node_next(ctree
, node
))
4302 summary_mark_row_as_read(summaryview
, node
);
4303 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4304 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
); node
!= NULL
;
4305 node
= gtkut_ctree_node_next(ctree
, node
)) {
4306 if (!GTK_CMCTREE_ROW(node
)->expanded
)
4307 summary_set_row_marks(summaryview
, node
);
4309 END_LONG_OPERATION(summaryview
);
4311 summary_status_show(summaryview
);
4314 static gboolean
summary_mark_all_unread_confirm(gboolean ask_if_needed
)
4316 /* ask_if_needed is FALSE when user-asking is performed by caller,
4317 commonly when the caller is a mark-as-unread-recursive func */
4318 if (ask_if_needed
&& prefs_common
.ask_mark_all_read
) {
4319 AlertValue val
= alertpanel_full(_("Mark all as unread"),
4320 _("Do you really want to mark all mails in this folder as unread?"),
4321 NULL
, _("_No"), NULL
, _("_Yes"), NULL
, NULL
, ALERTFOCUS_FIRST
,
4322 TRUE
, NULL
, ALERT_QUESTION
);
4324 if ((val
& ~G_ALERTDISABLE
) != G_ALERTALTERNATE
)
4326 else if (val
& G_ALERTDISABLE
)
4327 prefs_common
.ask_mark_all_read
= FALSE
;
4332 void summary_mark_all_unread(SummaryView
*summaryview
, gboolean ask_if_needed
)
4334 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4335 GtkCMCTreeNode
*node
;
4336 gboolean froze
= FALSE
;
4338 if (summary_is_locked(summaryview
))
4341 if (!summary_mark_all_unread_confirm(ask_if_needed
))
4344 START_LONG_OPERATION(summaryview
, TRUE
);
4345 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4346 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
); node
!= NULL
;
4347 node
= gtkut_ctree_node_next(ctree
, node
))
4348 summary_mark_row_as_unread(summaryview
, node
);
4349 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4350 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
); node
!= NULL
;
4351 node
= gtkut_ctree_node_next(ctree
, node
)) {
4352 if (!GTK_CMCTREE_ROW(node
)->expanded
)
4353 summary_set_row_marks(summaryview
, node
);
4355 END_LONG_OPERATION(summaryview
);
4357 summary_status_show(summaryview
);
4360 void summary_mark_as_spam(SummaryView
*summaryview
, guint action
, GtkWidget
*widget
)
4362 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4364 gboolean is_spam
= action
;
4365 GSList
*msgs
= NULL
;
4366 gboolean immediate_exec
= prefs_common
.immediate_exec
;
4367 gboolean moved
= FALSE
;
4368 gboolean froze
= FALSE
;
4371 if (summary_is_locked(summaryview
))
4374 prefs_common
.immediate_exec
= FALSE
;
4375 START_LONG_OPERATION(summaryview
, FALSE
);
4376 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4377 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
4378 GtkCMCTreeNode
*row
= GTK_CMCTREE_NODE(cur
->data
);
4379 MsgInfo
*msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4381 msgs
= g_slist_prepend(msgs
, msginfo
);
4384 if (procmsg_spam_learner_learn(NULL
, msgs
, is_spam
) == 0) {
4385 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
4386 GtkCMCTreeNode
*row
= GTK_CMCTREE_NODE(cur
->data
);
4387 MsgInfo
*msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4391 summary_msginfo_change_flags(msginfo
, MSG_SPAM
, 0, MSG_NEW
|MSG_UNREAD
, 0);
4392 if (procmsg_spam_get_folder(msginfo
) != summaryview
->folder_item
) {
4393 summary_move_row_to(summaryview
, row
,
4394 procmsg_spam_get_folder(msginfo
));
4398 summary_msginfo_unset_flags(msginfo
, MSG_SPAM
, 0);
4400 summaryview
->display_msg
= prefs_common
.always_show_msg
;
4402 summary_set_row_marks(summaryview
, row
);
4405 log_error(LOG_PROTOCOL
, _("An error happened while learning.\n"));
4408 prefs_common
.immediate_exec
= immediate_exec
;
4409 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4410 END_LONG_OPERATION(summaryview
);
4412 if (prefs_common
.immediate_exec
&& moved
) {
4413 summary_execute(summaryview
);
4416 if (!moved
&& msgs
) {
4417 MsgInfo
*msginfo
= (MsgInfo
*)msgs
->data
;
4418 toolbar_set_learn_button
4419 (summaryview
->mainwin
->toolbar
,
4420 MSG_IS_SPAM(msginfo
->flags
)?LEARN_HAM
:LEARN_SPAM
);
4424 summary_status_show(summaryview
);
4427 static gboolean
check_permission(SummaryView
*summaryview
, MsgInfo
* msginfo
)
4432 switch (FOLDER_TYPE(summaryview
->folder_item
->folder
)) {
4437 security : checks if one the accounts correspond to
4438 the author of the post
4442 for(cur
= account_get_list() ; cur
!= NULL
; cur
= cur
->next
) {
4443 PrefsAccount
* account
;
4446 account
= cur
->data
;
4447 if (account
->name
&& *account
->name
)
4449 g_strdup_printf("%s <%s>",
4454 g_strdup_printf("%s",
4457 if (g_utf8_collate(from_name
, msginfo
->from
) == 0) {
4466 alertpanel_error(_("You're not the author of the article."));
4476 static void summary_delete_row(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
4478 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4481 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4482 cm_return_if_fail(msginfo
);
4484 if (MSG_IS_LOCKED(msginfo
->flags
)) return;
4486 if (MSG_IS_DELETED(msginfo
->flags
)) return;
4488 if (MSG_IS_MOVE(msginfo
->flags
))
4489 summaryview
->moved
--;
4490 if (MSG_IS_COPY(msginfo
->flags
))
4491 summaryview
->copied
--;
4493 procmsg_msginfo_set_to_folder(msginfo
, NULL
);
4494 summary_msginfo_change_flags(msginfo
, MSG_DELETED
, 0, MSG_MARKED
,
4495 MSG_MOVE
| MSG_COPY
| MSG_MOVE_DONE
);
4496 summaryview
->deleted
++;
4498 if (!prefs_common
.immediate_exec
&&
4499 !folder_has_parent_of_type(summaryview
->folder_item
, F_TRASH
)) {
4500 summary_set_row_marks(summaryview
, row
);
4502 debug_print("Message %s/%d is set to delete\n",
4503 msginfo
->folder
->path
, msginfo
->msgnum
);
4506 void summary_cancel(SummaryView
*summaryview
)
4510 msginfo
= gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview
->ctree
),
4511 summaryview
->selected
);
4512 if (!msginfo
) return;
4514 if (!check_permission(summaryview
, msginfo
))
4517 news_cancel_article(summaryview
->folder_item
->folder
, msginfo
);
4519 if (summary_is_locked(summaryview
)) return;
4521 summary_lock(summaryview
);
4523 summary_freeze(summaryview
);
4525 summary_update_status(summaryview
);
4526 summary_status_show(summaryview
);
4528 summary_thaw(summaryview
);
4530 summary_unlock(summaryview
);
4533 void summary_delete(SummaryView
*summaryview
)
4535 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4536 FolderItem
*item
= summaryview
->folder_item
;
4538 GtkCMCTreeNode
*sel_last
= NULL
;
4539 GtkCMCTreeNode
*node
;
4542 gboolean froze
= FALSE
;
4546 if (summary_is_locked(summaryview
)) return;
4548 if (!summaryview
->folder_item
) return;
4550 START_LONG_OPERATION(summaryview
, FALSE
);
4552 if (!prefs_common
.live_dangerously
) {
4554 guint num
= g_list_length(GTK_CMCLIST(summaryview
->ctree
)->selection
);
4555 buf
= g_strdup_printf(ngettext(
4556 "Do you really want to delete the selected message?",
4557 "Do you really want to delete the %d selected messages?", num
),
4559 aval
= alertpanel(ngettext("Delete message", "Delete messages", num
),
4561 NULL
, _("_Cancel"), NULL
, _("_Delete"), NULL
, NULL
, ALERTFOCUS_SECOND
);
4563 if (aval
!= G_ALERTALTERNATE
) {
4564 END_LONG_OPERATION(summaryview
);
4569 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
;
4571 GtkCMCTreeNode
*row
= GTK_CMCTREE_NODE(cur
->data
);
4572 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4573 if (msginfo
&& msginfo
->total_size
!= 0 &&
4574 msginfo
->size
!= (goffset
)msginfo
->total_size
)
4575 partial_mark_for_delete(msginfo
);
4578 main_window_cursor_wait(summaryview
->mainwin
);
4580 /* next code sets current row focus right. We need to find a row
4581 * that is not deleted. */
4582 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4583 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
4584 sel_last
= GTK_CMCTREE_NODE(cur
->data
);
4585 summary_delete_row(summaryview
, sel_last
);
4587 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4588 END_LONG_OPERATION(summaryview
);
4590 if (summaryview
->sort_type
== SORT_ASCENDING
) {
4591 node
= summary_find_next_msg(summaryview
, sel_last
, TRUE
);
4592 if (!node
|| prefs_common
.next_on_delete
== FALSE
)
4593 node
= summary_find_prev_msg(summaryview
, sel_last
,TRUE
);
4595 node
= summary_find_prev_msg(summaryview
, sel_last
,TRUE
);
4596 if (!node
|| prefs_common
.next_on_delete
== FALSE
)
4597 node
= summary_find_next_msg(summaryview
, sel_last
,TRUE
);
4599 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_DELETEMOVE
);
4601 if (prefs_common
.immediate_exec
|| folder_has_parent_of_type(item
, F_TRASH
)) {
4602 summary_execute(summaryview
);
4603 /* after deleting, the anchor may be at an invalid row
4604 * so reset it to the node we found earlier */
4605 gtk_sctree_set_anchor_row(GTK_SCTREE(ctree
), node
);
4607 summary_status_show(summaryview
);
4610 main_window_cursor_normal(summaryview
->mainwin
);
4613 void summary_delete_trash(SummaryView
*summaryview
)
4615 FolderItem
*to_folder
= NULL
;
4617 if (!summaryview
->folder_item
||
4618 FOLDER_TYPE(summaryview
->folder_item
->folder
) == F_NEWS
) return;
4620 if (NULL
!= (ac
= account_find_from_item(summaryview
->folder_item
)))
4621 to_folder
= account_get_special_folder(ac
, F_TRASH
);
4623 if (to_folder
== NULL
)
4624 to_folder
= summaryview
->folder_item
->folder
->trash
;
4626 if (to_folder
== NULL
|| to_folder
== summaryview
->folder_item
4627 || folder_has_parent_of_type(summaryview
->folder_item
, F_TRASH
))
4628 summary_delete(summaryview
);
4630 summary_move_selected_to(summaryview
, to_folder
);
4634 static void summary_unmark_row(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
4636 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4639 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4640 cm_return_if_fail(msginfo
);
4641 if (MSG_IS_DELETED(msginfo
->flags
))
4642 summaryview
->deleted
--;
4643 if (MSG_IS_MOVE(msginfo
->flags
))
4644 summaryview
->moved
--;
4645 if (MSG_IS_COPY(msginfo
->flags
))
4646 summaryview
->copied
--;
4648 procmsg_msginfo_set_to_folder(msginfo
, NULL
);
4649 summary_msginfo_unset_flags(msginfo
, MSG_MARKED
| MSG_DELETED
,
4650 MSG_MOVE
| MSG_COPY
| MSG_MOVE_DONE
);
4651 summary_set_row_marks(summaryview
, row
);
4653 debug_print("Message %s/%d is unmarked\n",
4654 msginfo
->folder
->path
, msginfo
->msgnum
);
4657 void summary_unmark(SummaryView
*summaryview
)
4659 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4661 gboolean froze
= FALSE
;
4663 if (summary_is_locked(summaryview
))
4665 START_LONG_OPERATION(summaryview
, FALSE
);
4666 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4667 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4668 summary_unmark_row(summaryview
, GTK_CMCTREE_NODE(cur
->data
));
4669 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4670 END_LONG_OPERATION(summaryview
);
4672 summary_status_show(summaryview
);
4675 static void summary_move_row_to(SummaryView
*summaryview
, GtkCMCTreeNode
*row
,
4676 FolderItem
*to_folder
)
4678 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4681 cm_return_if_fail(to_folder
!= NULL
);
4683 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4684 cm_return_if_fail(msginfo
);
4685 if (MSG_IS_LOCKED(msginfo
->flags
))
4688 procmsg_msginfo_set_to_folder(msginfo
, to_folder
);
4689 if (MSG_IS_DELETED(msginfo
->flags
))
4690 summaryview
->deleted
--;
4691 if (MSG_IS_COPY(msginfo
->flags
)) {
4692 summaryview
->copied
--;
4694 if (!MSG_IS_MOVE(msginfo
->flags
)) {
4695 summary_msginfo_change_flags(msginfo
, 0, MSG_MOVE
, MSG_DELETED
,
4696 MSG_COPY
| MSG_MOVE_DONE
);
4697 summaryview
->moved
++;
4699 summary_msginfo_unset_flags(msginfo
, MSG_DELETED
, MSG_COPY
);
4702 if (!prefs_common
.immediate_exec
) {
4703 summary_set_row_marks(summaryview
, row
);
4706 debug_print("Message %d is set to move to %s\n",
4707 msginfo
->msgnum
, to_folder
->path
);
4710 void summary_move_selected_to(SummaryView
*summaryview
, FolderItem
*to_folder
)
4713 GtkCMCTreeNode
*sel_last
= NULL
;
4714 gboolean froze
= FALSE
;
4716 if (!to_folder
) return;
4717 if (!summaryview
->folder_item
||
4718 FOLDER_TYPE(summaryview
->folder_item
->folder
) == F_NEWS
) return;
4720 if (summary_is_locked(summaryview
)) return;
4722 if (summaryview
->folder_item
== to_folder
) {
4723 alertpanel_error(_("Destination is same as current folder."));
4727 if (to_folder
->no_select
) {
4728 alertpanel_error(_("The destination folder can only be used to "
4729 "store subfolders."));
4733 START_LONG_OPERATION(summaryview
, FALSE
);
4735 for (cur
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
4736 cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
4737 sel_last
= GTK_CMCTREE_NODE(cur
->data
);
4739 (summaryview
, GTK_CMCTREE_NODE(cur
->data
), to_folder
);
4741 END_LONG_OPERATION(summaryview
);
4743 if (prefs_common
.immediate_exec
) {
4744 summary_execute(summaryview
);
4746 GtkCMCTreeNode
*node
= NULL
;
4747 if (summaryview
->sort_type
== SORT_ASCENDING
) {
4748 node
= summary_find_next_msg(summaryview
, sel_last
,TRUE
);
4749 if (!node
|| prefs_common
.next_on_delete
== FALSE
)
4750 node
= summary_find_prev_msg(summaryview
, sel_last
,TRUE
);
4752 node
= summary_find_prev_msg(summaryview
, sel_last
,TRUE
);
4753 if (!node
|| prefs_common
.next_on_delete
== FALSE
)
4754 node
= summary_find_next_msg(summaryview
, sel_last
,TRUE
);
4756 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_DELETEMOVE
);
4757 summary_status_show(summaryview
);
4760 if (!summaryview
->selected
) { /* this was the last message */
4761 GtkCMCTreeNode
*node
= gtk_cmctree_node_nth (GTK_CMCTREE(summaryview
->ctree
),
4762 GTK_CMCLIST(summaryview
->ctree
)->rows
- 1);
4764 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_DELETEMOVE
);
4769 void summary_move_to(SummaryView
*summaryview
)
4771 FolderItem
*to_folder
;
4773 if (!summaryview
->folder_item
||
4774 FOLDER_TYPE(summaryview
->folder_item
->folder
) == F_NEWS
) return;
4776 to_folder
= foldersel_folder_sel(NULL
, FOLDER_SEL_MOVE
, NULL
, FALSE
,
4778 "Select folder to move selected message to",
4779 "Select folder to move selected messages to",
4780 g_list_length(GTK_CMCLIST(summaryview
->ctree
)->selection
))
4782 summary_move_selected_to(summaryview
, to_folder
);
4785 static void summary_copy_row_to(SummaryView
*summaryview
, GtkCMCTreeNode
*row
,
4786 FolderItem
*to_folder
)
4788 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4791 cm_return_if_fail(to_folder
!= NULL
);
4793 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4794 cm_return_if_fail(msginfo
);
4795 procmsg_msginfo_set_to_folder(msginfo
, to_folder
);
4796 if (MSG_IS_DELETED(msginfo
->flags
))
4797 summaryview
->deleted
--;
4798 if (MSG_IS_MOVE(msginfo
->flags
)) {
4799 summaryview
->moved
--;
4802 if (!MSG_IS_COPY(msginfo
->flags
)) {
4803 summary_msginfo_change_flags(msginfo
, 0, MSG_COPY
, MSG_DELETED
,
4804 MSG_MOVE
| MSG_MOVE_DONE
);
4805 summaryview
->copied
++;
4807 summary_msginfo_unset_flags(msginfo
, MSG_DELETED
, MSG_MOVE
);
4809 if (!prefs_common
.immediate_exec
) {
4810 summary_set_row_marks(summaryview
, row
);
4813 debug_print("Message %d is set to copy to %s\n",
4814 msginfo
->msgnum
, to_folder
->path
);
4817 void summary_copy_selected_to(SummaryView
*summaryview
, FolderItem
*to_folder
)
4820 gboolean froze
= FALSE
;
4822 if (!to_folder
) return;
4823 if (!summaryview
->folder_item
) return;
4825 if (summary_is_locked(summaryview
)) return;
4827 if (summaryview
->folder_item
== to_folder
) {
4829 (_("Destination to copy is same as current folder."));
4833 if (to_folder
->no_select
) {
4834 alertpanel_error(_("The destination folder can only be used to "
4835 "store subfolders."));
4839 START_LONG_OPERATION(summaryview
, FALSE
);
4841 for (cur
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
4842 cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4844 (summaryview
, GTK_CMCTREE_NODE(cur
->data
), to_folder
);
4846 END_LONG_OPERATION(summaryview
);
4848 if (prefs_common
.immediate_exec
)
4849 summary_execute(summaryview
);
4851 summary_status_show(summaryview
);
4855 void summary_copy_to(SummaryView
*summaryview
)
4857 FolderItem
*to_folder
;
4859 if (!summaryview
->folder_item
) return;
4861 to_folder
= foldersel_folder_sel(NULL
, FOLDER_SEL_COPY
, NULL
, FALSE
,
4863 "Select folder to copy selected message to",
4864 "Select folder to copy selected messages to",
4865 g_list_length(GTK_CMCLIST(summaryview
->ctree
)->selection
))
4867 summary_copy_selected_to(summaryview
, to_folder
);
4870 void summary_add_address(SummaryView
*summaryview
)
4872 MsgInfo
*msginfo
, *full_msginfo
;
4874 GdkPixbuf
*picture
= NULL
;
4875 AvatarRender
*avatarr
;
4877 msginfo
= gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview
->ctree
),
4878 summaryview
->selected
);
4879 if (!msginfo
|| !msginfo
->from
)
4882 Xstrdup_a(from
, msginfo
->from
, return);
4883 eliminate_address_comment(from
);
4884 extract_address(from
);
4886 full_msginfo
= procmsg_msginfo_get_full_info(msginfo
);
4888 avatarr
= avatars_avatarrender_new(full_msginfo
);
4889 hooks_invoke(AVATAR_IMAGE_RENDER_HOOKLIST
, avatarr
);
4891 procmsg_msginfo_free(&full_msginfo
);
4894 picture
= gtk_image_get_pixbuf(GTK_IMAGE(avatarr
->image
));
4896 #ifndef USE_ALT_ADDRBOOK
4897 addressbook_add_contact(msginfo
->fromname
, from
, NULL
, picture
);
4899 if (addressadd_selection(msginfo
->fromname
, from
, NULL
, picture
)) {
4900 debug_print( "addressbook_add_contact - added\n" );
4903 avatars_avatarrender_free(avatarr
);
4906 void summary_select_all(SummaryView
*summaryview
)
4908 GtkCMCTreeNode
*node
;
4910 if (!summaryview
->folder_item
) return;
4912 if (GTK_CMCLIST(summaryview
->ctree
)->focus_row
< 0) {
4913 /* If no row is selected, select (but do not open) the first
4914 * row, to get summaryview into correct state for selecting all. */
4915 debug_print("summary_select_all: no row selected, selecting first one\n");
4916 if (GTK_CMCLIST(summaryview
->ctree
)->row_list
!= NULL
) {
4917 node
= gtk_cmctree_node_nth(GTK_CMCTREE(summaryview
->ctree
), 0);
4918 summary_select_node(summaryview
, node
, FALSE
);
4922 /* Now select all rows while locking the summaryview for
4923 * faster performance. */
4924 summary_lock(summaryview
);
4925 gtk_cmclist_select_all(GTK_CMCLIST(summaryview
->ctree
));
4926 summary_unlock(summaryview
);
4928 summary_status_show(summaryview
);
4931 void summary_unselect_all(SummaryView
*summaryview
)
4933 summary_lock(summaryview
);
4934 gtk_sctree_unselect_all(GTK_SCTREE(summaryview
->ctree
));
4935 summary_unlock(summaryview
);
4936 summary_status_show(summaryview
);
4939 void summary_select_thread(SummaryView
*summaryview
, gboolean delete_thread
,
4940 gboolean trash_thread
)
4942 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4943 GtkCMCTreeNode
*node
= NULL
;
4944 gboolean froze
= FALSE
;
4947 if (!GTK_CMCLIST(summaryview
->ctree
)->selection
)
4951 START_LONG_OPERATION(summaryview
, FALSE
);
4952 copy
= g_list_copy(GTK_CMCLIST(summaryview
->ctree
)->selection
);
4953 for (cur
= copy
; cur
!= NULL
&& cur
->data
!= NULL
;
4955 node
= GTK_CMCTREE_NODE(cur
->data
);
4958 while (GTK_CMCTREE_ROW(node
)->parent
!= NULL
)
4959 node
= GTK_CMCTREE_ROW(node
)->parent
;
4961 gtk_cmctree_select_recursive(ctree
, node
);
4964 END_LONG_OPERATION(summaryview
);
4967 if (FOLDER_TYPE(summaryview
->folder_item
->folder
) == F_NEWS
)
4968 summary_delete(summaryview
);
4970 summary_delete_trash(summaryview
);
4971 } else if (delete_thread
)
4972 summary_delete(summaryview
);
4974 summary_status_show(summaryview
);
4977 void summary_save_as(SummaryView
*summaryview
)
4979 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4981 gchar
*filename
= NULL
;
4984 gchar
*filedir
= NULL
;
4985 gchar
*converted_filename
= NULL
;
4986 gchar
* filepath
= NULL
;
4988 AlertValue aval
= 0;
4990 if (!summaryview
->selected
) return;
4991 msginfo
= gtk_cmctree_node_get_row_data(ctree
, summaryview
->selected
);
4992 if (!msginfo
) return;
4994 if (msginfo
->subject
) {
4995 Xstrdup_a(filename
, msginfo
->subject
, return);
4996 subst_for_filename(filename
);
4999 manage_window_focus_in(summaryview
->window
, NULL
, NULL
);
5001 if (filename
&& !g_utf8_validate(filename
, -1, NULL
)) {
5002 converted_filename
= conv_codeset_strdup(filename
,
5003 conv_get_locale_charset_str(),
5005 if (!converted_filename
) {
5006 g_warning("summary_save_as(): failed to convert character set");
5008 filename
= converted_filename
;
5014 if (prefs_common
.attach_save_dir
&& *prefs_common
.attach_save_dir
) {
5015 filepath
= g_strconcat(prefs_common
.attach_save_dir
, G_DIR_SEPARATOR_S
,
5018 dest
= filesel_select_file_save(_("Save as"), filepath
? filepath
: filename
);
5021 if (converted_filename
)
5022 g_free(converted_filename
);
5026 if (is_file_exist(dest
)) {
5027 aval
= alertpanel(_("Append or Overwrite"),
5028 _("Append or overwrite existing file?"),
5029 NULL
, _("_Append"), NULL
, _("_Overwrite"),
5030 NULL
, _("_Cancel"), ALERTFOCUS_FIRST
);
5031 if (aval
!= 0 && aval
!= 1)
5035 src
= procmsg_get_message_file(msginfo
);
5036 tmp
= g_path_get_basename(dest
);
5038 if ( aval
==0 ) { /* append */
5039 if (append_file(src
, dest
, TRUE
) < 0)
5040 alertpanel_error(_("Couldn't save the file '%s'."), tmp
);
5041 } else { /* overwrite */
5042 if (copy_file(src
, dest
, TRUE
) < 0)
5043 alertpanel_error(_("Couldn't save the file '%s'."), tmp
);
5048 * If two or more msgs are selected,
5049 * append them to the output file.
5051 if (GTK_CMCLIST(ctree
)->selection
->next
) {
5053 for (item
= GTK_CMCLIST(ctree
)->selection
->next
; item
!= NULL
; item
=item
->next
) {
5054 msginfo
= gtk_cmctree_node_get_row_data(ctree
, GTK_CMCTREE_NODE(item
->data
));
5055 if (!msginfo
) break;
5056 src
= procmsg_get_message_file(msginfo
);
5057 if (append_file(src
, dest
, TRUE
) < 0) {
5058 alertpanel_error(_("Couldn't save the file '%s'."), tmp
);
5064 filedir
= g_path_get_dirname(dest
);
5066 if (strcmp(filedir
, ".")) {
5067 g_free(prefs_common
.attach_save_dir
);
5068 prefs_common
.attach_save_dir
= g_filename_to_utf8(filedir
, -1, NULL
, NULL
, NULL
);
5077 void summary_print(SummaryView
*summaryview
)
5079 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
5081 gchar
*msg
= g_strdup_printf(_("You are about to print %d "
5082 "messages, one by one. Do you "
5083 "want to continue?"),
5084 g_list_length(clist
->selection
));
5085 if (g_list_length(clist
->selection
) > 9
5086 && alertpanel(_("Warning"), msg
, NULL
, _("_Cancel"), NULL
, _("_Yes"),
5087 NULL
, NULL
, ALERTFOCUS_SECOND
) != G_ALERTALTERNATE
) {
5093 if (clist
->selection
== NULL
) return;
5094 for (cur
= clist
->selection
;
5095 cur
!= NULL
&& cur
->data
!= NULL
;
5097 GtkCMCTreeNode
*node
= GTK_CMCTREE_NODE(cur
->data
);
5098 MsgInfo
*msginfo
= gtk_cmctree_node_get_row_data(
5099 GTK_CMCTREE(summaryview
->ctree
),
5101 gint sel_start
= -1, sel_end
= -1, partnum
= 0;
5103 if (node
== summaryview
->displayed
) {
5104 partnum
= mimeview_get_selected_part_num(summaryview
->messageview
->mimeview
);
5105 textview_get_selection_offsets(summaryview
->messageview
->mimeview
->textview
,
5106 &sel_start
, &sel_end
);
5108 messageview_print(msginfo
, summaryview
->messageview
->all_headers
,
5109 sel_start
, sel_end
, partnum
);
5113 gboolean
summary_execute(SummaryView
*summaryview
)
5115 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5116 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
5117 GtkCMCTreeNode
*node
, *next
;
5118 GtkCMCTreeNode
*new_selected
= NULL
;
5121 if (!summaryview
->folder_item
) return FALSE
;
5123 if (summary_is_locked(summaryview
)) return FALSE
;
5124 summary_lock(summaryview
);
5126 summary_freeze(summaryview
);
5128 main_window_cursor_wait(summaryview
->mainwin
);
5130 if (summaryview
->threaded
)
5131 summary_unthread_for_exec(summaryview
);
5133 folder_item_update_freeze();
5134 move_val
= summary_execute_move(summaryview
);
5135 summary_execute_copy(summaryview
);
5136 summary_execute_delete(summaryview
);
5138 node
= GTK_CMCTREE_NODE(clist
->row_list
);
5139 for (; node
!= NULL
; node
= next
) {
5140 next
= gtkut_ctree_node_next(ctree
, node
);
5141 if (gtk_cmctree_node_get_row_data(ctree
, node
) != NULL
) continue;
5143 if (node
== summaryview
->displayed
) {
5144 messageview_clear(summaryview
->messageview
);
5145 summary_cancel_mark_read_timeout(summaryview
);
5146 summaryview
->displayed
= NULL
;
5148 if (GTK_CMCTREE_ROW(node
)->children
!= NULL
) {
5150 if (GTK_CMCTREE_ROW(node
)->sibling
) {
5151 next
= GTK_CMCTREE_ROW(node
)->sibling
;
5153 GtkCMCTreeNode
*parent
= NULL
;
5154 for (parent
= GTK_CMCTREE_ROW(node
)->parent
; parent
!= NULL
;
5155 parent
= GTK_CMCTREE_ROW(parent
)->parent
) {
5156 if (GTK_CMCTREE_ROW(parent
)->sibling
) {
5157 next
= GTK_CMCTREE_ROW(parent
)->sibling
;
5163 if (!new_selected
&&
5164 gtkut_ctree_node_is_selected(ctree
, node
)) {
5165 summary_unselect_all(summaryview
);
5166 if (summaryview
->sort_type
== SORT_ASCENDING
) {
5167 new_selected
= summary_find_next_msg(summaryview
, node
,TRUE
);
5168 if (!new_selected
|| prefs_common
.next_on_delete
== FALSE
)
5169 new_selected
= summary_find_prev_msg(summaryview
, node
,TRUE
);
5171 new_selected
= summary_find_prev_msg(summaryview
, node
,TRUE
);
5172 if (!new_selected
|| prefs_common
.next_on_delete
== FALSE
)
5173 new_selected
= summary_find_next_msg(summaryview
, node
,TRUE
);
5177 gtk_sctree_remove_node((GtkSCTree
*)ctree
, node
);
5180 folder_item_update_thaw();
5183 summary_unlock(summaryview
);
5184 summary_select_node(summaryview
, new_selected
, OPEN_SELECTED_ON_DELETEMOVE
);
5185 summary_lock(summaryview
);
5188 if (summaryview
->threaded
) {
5189 summary_thread_build(summaryview
);
5190 summary_thread_init(summaryview
);
5193 summary_thaw(summaryview
);
5195 summaryview
->selected
= clist
->selection
?
5196 GTK_CMCTREE_NODE(clist
->selection
->data
) : NULL
;
5198 if (!GTK_CMCLIST(summaryview
->ctree
)->row_list
) {
5199 menu_set_insensitive_all
5200 (GTK_MENU_SHELL(summaryview
->popupmenu
));
5201 folderview_grab_focus(summaryview
->folderview
);
5203 menu_set_sensitive_all(GTK_MENU_SHELL(summaryview
->popupmenu
), TRUE
);
5204 gtk_widget_grab_focus(summaryview
->ctree
);
5206 summary_update_status(summaryview
);
5207 summary_status_show(summaryview
);
5209 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
5211 summary_unlock(summaryview
);
5213 main_window_cursor_normal(summaryview
->mainwin
);
5216 summary_show(summaryview
, summaryview
->folder_item
, FALSE
);
5220 gboolean
summary_expunge(SummaryView
*summaryview
)
5222 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5223 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
5224 GtkCMCTreeNode
*node
, *next
;
5225 GtkCMCTreeNode
*new_selected
= NULL
;
5227 if (!summaryview
->folder_item
) return FALSE
;
5229 if (summary_is_locked(summaryview
)) return FALSE
;
5231 summary_lock(summaryview
);
5233 summary_freeze(summaryview
);
5235 main_window_cursor_wait(summaryview
->mainwin
);
5237 if (summaryview
->threaded
)
5238 summary_unthread_for_exec(summaryview
);
5240 folder_item_update_freeze();
5241 summary_execute_expunge(summaryview
);
5243 node
= GTK_CMCTREE_NODE(clist
->row_list
);
5244 for (; node
!= NULL
; node
= next
) {
5245 next
= gtkut_ctree_node_next(ctree
, node
);
5246 if (gtk_cmctree_node_get_row_data(ctree
, node
) != NULL
) continue;
5248 if (node
== summaryview
->displayed
) {
5249 messageview_clear(summaryview
->messageview
);
5250 summary_cancel_mark_read_timeout(summaryview
);
5251 summaryview
->displayed
= NULL
;
5253 if (GTK_CMCTREE_ROW(node
)->children
!= NULL
) {
5255 if (GTK_CMCTREE_ROW(node
)->sibling
) {
5256 next
= GTK_CMCTREE_ROW(node
)->sibling
;
5258 GtkCMCTreeNode
*parent
= NULL
;
5259 for (parent
= GTK_CMCTREE_ROW(node
)->parent
; parent
!= NULL
;
5260 parent
= GTK_CMCTREE_ROW(parent
)->parent
) {
5261 if (GTK_CMCTREE_ROW(parent
)->sibling
) {
5262 next
= GTK_CMCTREE_ROW(parent
)->sibling
;
5268 if (!new_selected
&&
5269 gtkut_ctree_node_is_selected(ctree
, node
)) {
5270 summary_unselect_all(summaryview
);
5271 new_selected
= summary_find_next_msg(summaryview
, node
,TRUE
);
5273 new_selected
= summary_find_prev_msg
5274 (summaryview
, node
,TRUE
);
5277 gtk_sctree_remove_node((GtkSCTree
*)ctree
, node
);
5280 folder_item_update_thaw();
5283 summary_unlock(summaryview
);
5284 summary_select_node(summaryview
, new_selected
, OPEN_SELECTED_ON_DELETEMOVE
);
5285 summary_lock(summaryview
);
5288 if (summaryview
->threaded
) {
5289 summary_thread_build(summaryview
);
5290 summary_thread_init(summaryview
);
5293 summary_thaw(summaryview
);
5295 summaryview
->selected
= clist
->selection
?
5296 GTK_CMCTREE_NODE(clist
->selection
->data
) : NULL
;
5298 if (!GTK_CMCLIST(summaryview
->ctree
)->row_list
) {
5299 menu_set_insensitive_all
5300 (GTK_MENU_SHELL(summaryview
->popupmenu
));
5301 folderview_grab_focus(summaryview
->folderview
);
5303 menu_set_sensitive_all(GTK_MENU_SHELL(summaryview
->popupmenu
), TRUE
);
5304 gtk_widget_grab_focus(summaryview
->ctree
);
5307 summary_update_status(summaryview
);
5308 summary_status_show(summaryview
);
5310 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
5312 summary_unlock(summaryview
);
5314 main_window_cursor_normal(summaryview
->mainwin
);
5319 static gint
summary_execute_move(SummaryView
*summaryview
)
5321 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5324 /* search moving messages and execute */
5326 gtk_cmctree_pre_recursive(ctree
, NULL
, summary_execute_move_func
,
5329 if (summaryview
->mlist
) {
5330 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST
,
5331 summaryview
->msginfo_update_callback_id
);
5332 val
= procmsg_move_messages(summaryview
->mlist
);
5333 summaryview
->msginfo_update_callback_id
=
5334 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
,
5335 summary_update_msg
, (gpointer
) summaryview
);
5337 for (cur
= summaryview
->mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
5338 procmsg_msginfo_free((MsgInfo
**)&(cur
->data
));
5341 g_slist_free(summaryview
->mlist
);
5342 summaryview
->mlist
= NULL
;
5348 static void summary_execute_move_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5351 SummaryView
*summaryview
= data
;
5354 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5356 if (msginfo
&& MSG_IS_MOVE(msginfo
->flags
) && msginfo
->to_folder
) {
5357 summaryview
->mlist
=
5358 g_slist_prepend(summaryview
->mlist
, msginfo
);
5359 gtk_cmctree_node_set_row_data(ctree
, node
, NULL
);
5361 if (msginfo
->msgid
&& *msginfo
->msgid
&&
5362 node
== g_hash_table_lookup(summaryview
->msgid_table
,
5364 g_hash_table_remove(summaryview
->msgid_table
,
5366 if (prefs_common
.thread_by_subject
&&
5367 msginfo
->subject
&& *msginfo
->subject
&&
5368 node
== subject_table_lookup(summaryview
->subject_table
,
5369 msginfo
->subject
)) {
5370 subject_table_remove(summaryview
->subject_table
,
5376 static void summary_execute_copy(SummaryView
*summaryview
)
5378 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5380 /* search copying messages and execute */
5381 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST
,
5382 summaryview
->msginfo_update_callback_id
);
5383 gtk_cmctree_pre_recursive(ctree
, NULL
, summary_execute_copy_func
,
5386 if (summaryview
->mlist
) {
5387 summaryview
->mlist
= g_slist_reverse(summaryview
->mlist
);
5388 procmsg_copy_messages(summaryview
->mlist
);
5390 g_slist_free(summaryview
->mlist
);
5391 summaryview
->mlist
= NULL
;
5393 summaryview
->msginfo_update_callback_id
=
5394 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
,
5395 summary_update_msg
, (gpointer
) summaryview
);
5398 static void summary_execute_copy_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5401 SummaryView
*summaryview
= data
;
5404 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5406 if (msginfo
&& MSG_IS_COPY(msginfo
->flags
) && msginfo
->to_folder
) {
5407 summaryview
->mlist
=
5408 g_slist_prepend(summaryview
->mlist
, msginfo
);
5410 summary_msginfo_unset_flags(msginfo
, 0, MSG_COPY
);
5411 summary_set_row_marks(summaryview
, node
);
5415 static void summary_execute_delete(SummaryView
*summaryview
)
5417 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5420 /* search deleting messages and execute */
5421 gtk_cmctree_pre_recursive
5422 (ctree
, NULL
, summary_execute_delete_func
, summaryview
);
5424 if (!summaryview
->mlist
) return;
5426 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST
,
5427 summaryview
->msginfo_update_callback_id
);
5429 folder_item_remove_msgs(summaryview
->folder_item
,
5430 summaryview
->mlist
);
5432 summaryview
->msginfo_update_callback_id
=
5433 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
,
5434 summary_update_msg
, (gpointer
) summaryview
);
5436 for (cur
= summaryview
->mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
5437 procmsg_msginfo_free((MsgInfo
**)&(cur
->data
));
5440 g_slist_free(summaryview
->mlist
);
5441 summaryview
->mlist
= NULL
;
5444 static void summary_execute_delete_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5447 SummaryView
*summaryview
= data
;
5450 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5452 if (msginfo
&& MSG_IS_DELETED(msginfo
->flags
)) {
5453 summaryview
->mlist
=
5454 g_slist_prepend(summaryview
->mlist
, msginfo
);
5455 gtk_cmctree_node_set_row_data(ctree
, node
, NULL
);
5457 if (msginfo
->msgid
&& *msginfo
->msgid
&&
5458 node
== g_hash_table_lookup(summaryview
->msgid_table
,
5460 g_hash_table_remove(summaryview
->msgid_table
,
5463 if (prefs_common
.thread_by_subject
&&
5464 msginfo
->subject
&& *msginfo
->subject
&&
5465 node
== subject_table_lookup(summaryview
->subject_table
,
5466 msginfo
->subject
)) {
5467 subject_table_remove(summaryview
->subject_table
,
5473 static void summary_execute_expunge_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5476 SummaryView
*summaryview
= data
;
5479 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5481 if (msginfo
&& MSG_IS_DELETED(msginfo
->flags
)) {
5482 summaryview
->mlist
=
5483 g_slist_prepend(summaryview
->mlist
, msginfo
);
5484 gtk_cmctree_node_set_row_data(ctree
, node
, NULL
);
5486 if (msginfo
->msgid
&& *msginfo
->msgid
&&
5487 node
== g_hash_table_lookup(summaryview
->msgid_table
,
5489 g_hash_table_remove(summaryview
->msgid_table
,
5492 if (prefs_common
.thread_by_subject
&&
5493 msginfo
->subject
&& *msginfo
->subject
&&
5494 node
== subject_table_lookup(summaryview
->subject_table
,
5495 msginfo
->subject
)) {
5496 subject_table_remove(summaryview
->subject_table
,
5502 static void summary_execute_expunge(SummaryView
*summaryview
)
5504 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5507 gtk_cmctree_pre_recursive
5508 (ctree
, NULL
, summary_execute_expunge_func
, summaryview
);
5510 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST
,
5511 summaryview
->msginfo_update_callback_id
);
5513 folder_item_expunge(summaryview
->folder_item
);
5515 summaryview
->msginfo_update_callback_id
=
5516 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
,
5517 summary_update_msg
, (gpointer
) summaryview
);
5518 for (cur
= summaryview
->mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
5519 procmsg_msginfo_free((MsgInfo
**)&(cur
->data
));
5521 g_slist_free(summaryview
->mlist
);
5522 summaryview
->mlist
= NULL
;
5525 /* thread functions */
5527 static void summary_thread_build(SummaryView
*summaryview
)
5529 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5530 GtkCMCTreeNode
*node
;
5531 GtkCMCTreeNode
*next
;
5532 GtkCMCTreeNode
*parent
;
5536 summary_lock(summaryview
);
5538 debug_print("Building threads...\n");
5539 STATUSBAR_PUSH(summaryview
->mainwin
, _("Building threads..."));
5540 main_window_cursor_wait(summaryview
->mainwin
);
5542 g_signal_handlers_block_by_func(G_OBJECT(ctree
),
5543 G_CALLBACK(summary_tree_expanded
), summaryview
);
5544 summary_freeze(summaryview
);
5546 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
5548 next
= GTK_CMCTREE_ROW(node
)->sibling
;
5550 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5554 if (msginfo
&& msginfo
->inreplyto
) {
5555 parent
= g_hash_table_lookup(summaryview
->msgid_table
,
5556 msginfo
->inreplyto
);
5558 if (!parent
&& msginfo
->references
) {
5559 for (reflist
= msginfo
->references
;
5560 reflist
!= NULL
; reflist
= reflist
->next
)
5561 if ((parent
= g_hash_table_lookup
5562 (summaryview
->msgid_table
,
5568 if (msginfo
&& prefs_common
.thread_by_subject
&& parent
== NULL
) {
5569 parent
= subject_table_lookup
5570 (summaryview
->subject_table
,
5574 if (parent
&& parent
!= node
&& parent
!= GTK_CMCTREE_ROW(node
)->parent
) {
5575 gtk_cmctree_move(ctree
, node
, parent
, NULL
);
5581 gtkut_ctree_set_focus_row(ctree
, summaryview
->selected
);
5583 summary_thaw(summaryview
);
5584 g_signal_handlers_unblock_by_func(G_OBJECT(ctree
),
5585 G_CALLBACK(summary_tree_expanded
), summaryview
);
5587 debug_print("Building threads done.\n");
5588 STATUSBAR_POP(summaryview
->mainwin
);
5589 main_window_cursor_normal(summaryview
->mainwin
);
5591 summaryview
->threaded
= TRUE
;
5593 summary_unlock(summaryview
);
5596 static void summary_thread_init(SummaryView
*summaryview
)
5598 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5599 GtkCMCTreeNode
*node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
5600 GtkCMCTreeNode
*next
;
5602 if (!summaryview
->thread_collapsed
) {
5603 g_signal_handlers_block_by_func(G_OBJECT(ctree
),
5604 G_CALLBACK(summary_tree_expanded
), summaryview
);
5606 next
= GTK_CMCTREE_ROW(node
)->sibling
;
5607 if (GTK_CMCTREE_ROW(node
)->children
)
5608 gtk_cmctree_expand_recursive(ctree
, node
);
5611 g_signal_handlers_unblock_by_func(G_OBJECT(ctree
),
5612 G_CALLBACK(summary_tree_expanded
), summaryview
);
5617 static void summary_unthread_for_exec(SummaryView
*summaryview
)
5619 GtkCMCTreeNode
*node
;
5620 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5621 gboolean froze
= FALSE
;
5623 debug_print("Unthreading for execution...\n");
5625 START_LONG_OPERATION(summaryview
, TRUE
);
5626 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
5627 node
!= NULL
; node
= GTK_CMCTREE_NODE_NEXT(node
)) {
5628 summary_unthread_for_exec_func(ctree
, node
, summaryview
);
5631 END_LONG_OPERATION(summaryview
);
5633 debug_print("Unthreading for execution done.\n");
5636 static void summary_unthread_for_exec_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5640 GtkCMCTreeNode
*top_parent
;
5641 GtkCMCTreeNode
*child
;
5642 GtkCMCTreeNode
*sibling
;
5643 SummaryView
* summaryview
= (SummaryView
*)data
;
5644 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5647 (!MSG_IS_MOVE(msginfo
->flags
) &&
5648 !MSG_IS_DELETED(msginfo
->flags
)))
5650 child
= GTK_CMCTREE_ROW(node
)->children
;
5653 if (node
== summaryview
->selected
)
5654 summaryview
->selected
= NULL
;
5655 if (node
== summaryview
->displayed
)
5656 summaryview
->displayed
= NULL
;
5658 summary_cancel_mark_read_timeout(summaryview
);
5660 for (top_parent
= node
;
5661 GTK_CMCTREE_ROW(top_parent
)->parent
!= NULL
;
5662 top_parent
= GTK_CMCTREE_ROW(top_parent
)->parent
)
5664 sibling
= GTK_CMCTREE_ROW(top_parent
)->sibling
;
5666 GTK_SCTREE(ctree
)->sorting
= TRUE
;
5667 while (child
!= NULL
) {
5668 GtkCMCTreeNode
*next_child
;
5669 MsgInfo
*cinfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(child
);
5671 next_child
= GTK_CMCTREE_ROW(child
)->sibling
;
5673 if (!MSG_IS_MOVE(cinfo
->flags
) && !MSG_IS_DELETED(cinfo
->flags
)) {
5674 gtk_cmctree_move(ctree
, child
,
5678 if (child
== summaryview
->displayed
) {
5679 messageview_clear(summaryview
->messageview
);
5680 summaryview
->displayed
= NULL
;
5682 if (child
== summaryview
->selected
) {
5683 messageview_clear(summaryview
->messageview
);
5684 summaryview
->selected
= NULL
;
5689 GTK_SCTREE(ctree
)->sorting
= FALSE
;
5692 void summary_expand_threads(SummaryView
*summaryview
)
5694 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5695 GtkCMCTreeNode
*node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
5696 GtkCMCTreeNode
*focus_node
= GTK_CMCTREE_NODE (g_list_nth (GTK_CMCLIST(ctree
)->row_list
, GTK_CMCLIST(ctree
)->focus_row
));
5698 g_signal_handlers_block_by_func(G_OBJECT(ctree
),
5699 G_CALLBACK(summary_tree_expanded
), summaryview
);
5700 summary_freeze(summaryview
);
5701 GTK_SCTREE(ctree
)->sorting
= TRUE
;
5704 if (GTK_CMCTREE_ROW(node
)->children
) {
5705 gtk_cmctree_expand(ctree
, node
);
5706 summary_set_row_marks(summaryview
, node
);
5708 node
= GTK_CMCTREE_NODE_NEXT(node
);
5711 GTK_SCTREE(ctree
)->sorting
= FALSE
;
5713 GTK_CMCLIST(ctree
)->focus_row
= g_list_position (GTK_CMCLIST(ctree
)->row_list
,(GList
*)focus_node
);
5715 summary_thaw(summaryview
);
5717 g_signal_handlers_unblock_by_func(G_OBJECT(ctree
),
5718 G_CALLBACK(summary_tree_expanded
), summaryview
);
5720 summaryview
->thread_collapsed
= FALSE
;
5722 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
5725 void summary_collapse_threads(SummaryView
*summaryview
)
5727 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5728 GtkCMCTreeNode
*node
= NULL
;
5729 GtkCMCTreeNode
*focus_node
= GTK_CMCTREE_NODE (g_list_nth (GTK_CMCLIST(ctree
)->row_list
, GTK_CMCLIST(ctree
)->focus_row
));
5731 g_signal_handlers_block_by_func(G_OBJECT(ctree
),
5732 G_CALLBACK(summary_tree_collapsed
), summaryview
);
5733 summary_freeze(summaryview
);
5734 GTK_SCTREE(ctree
)->sorting
= TRUE
;
5737 while (node
&& GTK_CMCTREE_ROW(node
)->parent
) {
5738 focus_node
= node
= GTK_CMCTREE_ROW(node
)->parent
;
5740 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_DIRECTIONAL
);
5741 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
5743 if (GTK_CMCTREE_ROW(node
)->children
) {
5744 gtk_cmctree_collapse(ctree
, node
);
5745 summary_set_row_marks(summaryview
, node
);
5747 node
= GTK_CMCTREE_ROW(node
)->sibling
;
5750 GTK_SCTREE(ctree
)->sorting
= FALSE
;
5752 GTK_CMCLIST(ctree
)->focus_row
= g_list_position (GTK_CMCLIST(ctree
)->row_list
,(GList
*)focus_node
);
5754 GTK_SCTREE(ctree
)->anchor_row
=
5755 gtk_cmctree_node_nth(ctree
, GTK_CMCLIST(ctree
)->focus_row
);
5756 summary_thaw(summaryview
);
5757 g_signal_handlers_unblock_by_func(G_OBJECT(ctree
),
5758 G_CALLBACK(summary_tree_collapsed
), summaryview
);
5760 summaryview
->thread_collapsed
= TRUE
;
5762 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
5765 static void account_rules_radio_button_toggled_cb(GtkToggleButton
*btn
, gpointer data
)
5767 prefs_common
.apply_per_account_filtering_rules
= GPOINTER_TO_INT(data
);
5770 static gboolean
summary_filter_get_mode(void)
5771 /* ask what to do w/ them: skip them, apply them regardless to the account,
5772 use the current account */
5774 /* TODO: eventually also propose to use the current folder's default account,
5776 /* TODO: eventually allow to select the account to use from a optmenu */
5779 GtkWidget
*account_rules_skip
;
5780 GtkWidget
*account_rules_force
;
5781 GtkWidget
*account_rules_user_current
;
5784 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 0);
5786 account_rules_skip
= gtk_radio_button_new_with_label
5787 (NULL
, _("Skip these rules"));
5788 account_rules_force
= gtk_radio_button_new_with_label_from_widget
5789 (GTK_RADIO_BUTTON(account_rules_skip
),
5790 _("Apply these rules regardless of the account they belong to"));
5791 account_rules_user_current
= gtk_radio_button_new_with_label_from_widget
5792 (GTK_RADIO_BUTTON(account_rules_skip
),
5793 _("Apply these rules if they apply to the current account"));
5794 gtk_box_pack_start (GTK_BOX (vbox
), account_rules_skip
, FALSE
, FALSE
, 0);
5795 gtk_box_pack_start (GTK_BOX (vbox
), account_rules_force
, FALSE
, FALSE
, 0);
5796 gtk_box_pack_start (GTK_BOX (vbox
), account_rules_user_current
, FALSE
, FALSE
, 0);
5797 g_signal_connect(G_OBJECT(account_rules_skip
), "toggled",
5798 G_CALLBACK(account_rules_radio_button_toggled_cb
),
5799 GINT_TO_POINTER(FILTERING_ACCOUNT_RULES_SKIP
));
5800 g_signal_connect(G_OBJECT(account_rules_force
), "toggled",
5801 G_CALLBACK(account_rules_radio_button_toggled_cb
),
5802 GINT_TO_POINTER(FILTERING_ACCOUNT_RULES_FORCE
));
5803 g_signal_connect(G_OBJECT(account_rules_user_current
), "toggled",
5804 G_CALLBACK(account_rules_radio_button_toggled_cb
),
5805 GINT_TO_POINTER(FILTERING_ACCOUNT_RULES_USE_CURRENT
));
5806 switch (prefs_common
.apply_per_account_filtering_rules
) {
5807 case FILTERING_ACCOUNT_RULES_SKIP
:
5808 gtk_toggle_button_set_active(
5809 GTK_TOGGLE_BUTTON(account_rules_skip
), TRUE
);
5811 case FILTERING_ACCOUNT_RULES_FORCE
:
5812 gtk_toggle_button_set_active(
5813 GTK_TOGGLE_BUTTON(account_rules_force
), TRUE
);
5815 case FILTERING_ACCOUNT_RULES_USE_CURRENT
:
5816 gtk_toggle_button_set_active(
5817 GTK_TOGGLE_BUTTON(account_rules_user_current
), TRUE
);
5821 val
= alertpanel_with_widget(
5823 _("There are some filtering rules that belong to an account.\n"
5824 "Please choose what to do with these rules:"),
5825 NULL
, _("_Cancel"), NULL
, _("_Filter"), NULL
, NULL
,
5826 ALERTFOCUS_SECOND
, TRUE
, vbox
);
5828 if ((val
& ~G_ALERTDISABLE
) != G_ALERTALTERNATE
) {
5830 } else if (val
& G_ALERTDISABLE
)
5831 prefs_common
.ask_apply_per_account_filtering_rules
= FALSE
;
5836 void summary_filter(SummaryView
*summaryview
, gboolean selected_only
)
5838 GSList
*mlist
= NULL
, *cur_list
;
5839 PrefsAccount
*ac_prefs
= NULL
;
5840 summary_lock(summaryview
);
5842 /* are there any per-account filtering rules? */
5843 if (prefs_common
.ask_apply_per_account_filtering_rules
== TRUE
&&
5844 filtering_peek_per_account_rules(filtering_rules
)) {
5846 if (summary_filter_get_mode() == FALSE
) {
5847 summary_unlock(summaryview
);
5852 folder_item_update_freeze();
5854 debug_print("filtering...\n");
5855 STATUSBAR_PUSH(summaryview
->mainwin
, _("Filtering..."));
5856 main_window_cursor_wait(summaryview
->mainwin
);
5858 summary_freeze(summaryview
);
5860 if (selected_only
) {
5863 for (cur
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
5864 cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
5865 mlist
= g_slist_prepend(mlist
,
5866 procmsg_msginfo_new_ref(
5867 GTKUT_CTREE_NODE_GET_ROW_DATA(cur
->data
)));
5869 mlist
= g_slist_reverse(mlist
);
5871 mlist
= folder_item_get_msg_list(summaryview
->folder_item
);
5874 ac_prefs
= ((summaryview
->folder_item
->folder
!= NULL
) &&
5875 (summaryview
->folder_item
->folder
->account
!= NULL
))
5876 ? summaryview
->folder_item
->folder
->account
: NULL
;
5878 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
5879 for (cur_list
= mlist
; cur_list
; cur_list
= cur_list
->next
) {
5880 summary_filter_func((MsgInfo
*)cur_list
->data
, ac_prefs
);
5882 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
5884 filtering_move_and_copy_msgs(mlist
);
5886 for (cur_list
= mlist
; cur_list
; cur_list
= cur_list
->next
) {
5887 procmsg_msginfo_free((MsgInfo
**)&(cur_list
->data
));
5889 g_slist_free(mlist
);
5891 summary_thaw(summaryview
);
5893 folder_item_update_thaw();
5894 debug_print("filtering done.\n");
5895 STATUSBAR_POP(summaryview
->mainwin
);
5896 main_window_cursor_normal(summaryview
->mainwin
);
5898 summary_unlock(summaryview
);
5901 * CLAWS: summary_show() only valid after having a lock. ideally
5902 * we want the lock to be context aware...
5904 summary_show(summaryview
, summaryview
->folder_item
, TRUE
);
5907 static void summary_filter_func(MsgInfo
*msginfo
, PrefsAccount
*ac_prefs
)
5909 MailFilteringData mail_filtering_data
;
5911 mail_filtering_data
.msginfo
= msginfo
;
5912 mail_filtering_data
.msglist
= NULL
;
5913 mail_filtering_data
.filtered
= NULL
;
5914 mail_filtering_data
.unfiltered
= NULL
;
5915 if (hooks_invoke(MAIL_MANUAL_FILTERING_HOOKLIST
, &mail_filtering_data
))
5918 filter_message_by_msginfo(filtering_rules
, msginfo
, ac_prefs
,
5919 FILTERING_MANUALLY
, NULL
);
5922 void summary_msginfo_filter_open(FolderItem
* item
, MsgInfo
*msginfo
,
5923 PrefsFilterType type
, gint processing_rule
)
5925 gchar
*header
= NULL
;
5928 procmsg_get_filter_keyword(msginfo
, &header
, &key
, type
);
5930 if (processing_rule
) {
5932 prefs_filtering_open(&pre_global_processing
,
5933 _("Processing rules to apply before folder rules"),
5934 MANUAL_ANCHOR_PROCESSING
,
5935 header
, key
, FALSE
);
5937 prefs_filtering_open(&item
->prefs
->processing
,
5938 _("Processing configuration"),
5939 MANUAL_ANCHOR_PROCESSING
,
5940 header
, key
, FALSE
);
5943 prefs_filtering_open(&filtering_rules
,
5944 _("Filtering configuration"),
5945 MANUAL_ANCHOR_FILTERING
,
5953 void summary_filter_open(SummaryView
*summaryview
, PrefsFilterType type
,
5954 gint processing_rule
)
5959 if (!summaryview
->selected
) return;
5961 msginfo
= gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview
->ctree
),
5962 summaryview
->selected
);
5963 if (!msginfo
) return;
5965 item
= summaryview
->folder_item
;
5966 summary_msginfo_filter_open(item
, msginfo
, type
, processing_rule
);
5971 #define N_COLOR_LABELS colorlabel_get_color_count()
5973 static void summary_colorlabel_menu_item_activate_cb(GtkWidget
*widget
,
5976 guint color
= GPOINTER_TO_UINT(data
);
5977 SummaryView
*summaryview
;
5979 summaryview
= g_object_get_data(G_OBJECT(widget
), "summaryview");
5980 cm_return_if_fail(summaryview
!= NULL
);
5982 /* "dont_toggle" state set? */
5983 if (g_object_get_data(G_OBJECT(summaryview
->colorlabel_menu
),
5987 summary_set_colorlabel(summaryview
, color
, NULL
);
5990 /* summary_set_colorlabel_color() - labelcolor parameter is the color *flag*
5991 * for the message; not the color index */
5992 void summary_set_colorlabel_color(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5997 GtkStyle
*style
, *prev_style
, *ctree_style
;
6001 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
6002 cm_return_if_fail(msginfo
);
6004 color_index
= labelcolor
== 0 ? -1 : (gint
)labelcolor
- 1;
6005 ctree_style
= gtk_widget_get_style(GTK_WIDGET(ctree
));
6006 prev_style
= gtk_cmctree_node_get_row_style(ctree
, node
);
6008 if (color_index
< 0 || color_index
>= N_COLOR_LABELS
) {
6009 if (!prev_style
) return;
6010 style
= gtk_style_copy(prev_style
);
6011 color
= ctree_style
->text
[GTK_STATE_NORMAL
];
6012 style
->text
[GTK_STATE_NORMAL
] = color
;
6013 color
= ctree_style
->text
[GTK_STATE_SELECTED
];
6014 style
->text
[GTK_STATE_SELECTED
] = color
;
6017 style
= gtk_style_copy(prev_style
);
6019 style
= gtk_style_copy(ctree_style
);
6020 rgba
= colorlabel_get_color(color_index
);
6021 GTKUT_GDKRGBA_TO_GDKCOLOR(rgba
, color
);
6022 style
->text
[GTK_STATE_NORMAL
] = color
;
6023 /* get the average of label color and selected fg color
6025 style
->text
[GTK_STATE_SELECTED
].red
= (color
.red
+ 3*ctree_style
->text
[GTK_STATE_SELECTED
].red
) / 4;
6026 style
->text
[GTK_STATE_SELECTED
].green
= (color
.green
+ 3*ctree_style
->text
[GTK_STATE_SELECTED
].green
) / 4;
6027 style
->text
[GTK_STATE_SELECTED
].blue
= (color
.blue
+ 3*ctree_style
->text
[GTK_STATE_SELECTED
].blue
) / 4;
6030 gtk_cmctree_node_set_row_style(ctree
, node
, style
);
6031 g_object_unref(style
);
6034 static void summary_set_row_colorlabel(SummaryView
*summaryview
, GtkCMCTreeNode
*row
, guint labelcolor
)
6036 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
6039 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
6040 cm_return_if_fail(msginfo
);
6042 summary_msginfo_change_flags(msginfo
, MSG_COLORLABEL_TO_FLAGS(labelcolor
), 0,
6043 MSG_CLABEL_FLAG_MASK
, 0);
6044 summary_set_row_marks(summaryview
, row
);
6047 void summary_set_colorlabel(SummaryView
*summaryview
, guint labelcolor
,
6050 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
6052 gboolean froze
= FALSE
;
6054 if (prefs_common
.ask_override_colorlabel
) {
6055 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
6056 gboolean ask
= FALSE
;
6059 gboolean already_this_color_everywhere
= TRUE
;
6061 /* if clearing color labels (applying 'none', 0):
6062 - ask if at least one message has a non-0 color label set
6063 if applying a non-0 color label:
6064 - ask if at least one of the selected messages has a non-0 color label different
6065 from the one we want to apply.
6066 - don't ask if all messages have the same color label as the one we're applying
6068 for (cur
= GTK_CMCLIST(ctree
)->selection
;
6069 !ask
&& cur
!= NULL
&& cur
->data
!= NULL
;
6071 MsgInfo
*msginfo
= gtk_cmctree_node_get_row_data(ctree
, GTK_CMCTREE_NODE(cur
->data
));
6073 color
= MSG_GET_COLORLABEL_VALUE(msginfo
->flags
);
6074 if (labelcolor
== 0) {
6075 /* clearing color labels */
6078 already_this_color_everywhere
&= (color
== labelcolor
);
6079 ask
= ((color
!= 0) && (color
!= labelcolor
)) && !already_this_color_everywhere
;
6087 if (labelcolor
== 0)
6088 msg
= _("Do you really want to reset the color label of all selected messages?");
6090 msg
= _("Do you really want to apply this color label to all selected messages?");
6091 val
= alertpanel_full(labelcolor
== 0? _("Reset color label"): _("Set color label"), msg
,
6092 NULL
, _("_No"), NULL
, _("_Yes"), NULL
, NULL
, ALERTFOCUS_FIRST
,
6093 TRUE
, NULL
, ALERT_QUESTION
);
6095 if ((val
& ~G_ALERTDISABLE
) != G_ALERTALTERNATE
)
6097 else if (val
& G_ALERTDISABLE
)
6098 prefs_common
.ask_override_colorlabel
= FALSE
;
6102 START_LONG_OPERATION(summaryview
, FALSE
);
6103 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
6104 summary_set_row_colorlabel(summaryview
,
6105 GTK_CMCTREE_NODE(cur
->data
), labelcolor
);
6106 END_LONG_OPERATION(summaryview
);
6109 static gboolean
summary_set_row_tag(SummaryView
*summaryview
, GtkCMCTreeNode
*row
, gboolean refresh
, gboolean set
, gint id
)
6111 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
6113 gchar
*tags_str
= NULL
;
6114 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
6115 cm_return_val_if_fail(msginfo
, FALSE
);
6117 procmsg_msginfo_update_tags(msginfo
, set
, id
);
6119 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_TAGS
]].visible
) {
6120 tags_str
= procmsg_msginfo_get_tags_str(msginfo
);
6121 gtk_cmctree_node_set_text(ctree
, row
,
6122 summaryview
->col_pos
[S_COL_TAGS
],
6123 tags_str
?tags_str
:"-");
6127 summary_set_row_marks(summaryview
, row
);
6128 if (row
== summaryview
->displayed
) {
6134 void summary_set_tag(SummaryView
*summaryview
, gint tag_id
,
6137 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
6139 gboolean set
= tag_id
> 0;
6140 gint real_id
= set
? tag_id
:-tag_id
;
6141 gboolean froze
= FALSE
;
6142 gboolean redisplay
= FALSE
;
6144 if (summary_is_locked(summaryview
))
6146 START_LONG_OPERATION(summaryview
, FALSE
);
6147 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
6148 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
6149 redisplay
|= summary_set_row_tag(summaryview
,
6150 GTK_CMCTREE_NODE(cur
->data
), FALSE
, set
, real_id
);
6152 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
6153 END_LONG_OPERATION(summaryview
);
6155 summary_redisplay_msg(summaryview
);
6158 static void summary_tags_menu_item_activate_cb(GtkWidget
*widget
,
6161 gint id
= GPOINTER_TO_INT(data
);
6162 gboolean set
= gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget
));
6163 SummaryView
*summaryview
;
6165 summaryview
= g_object_get_data(G_OBJECT(widget
), "summaryview");
6166 cm_return_if_fail(summaryview
!= NULL
);
6168 /* "dont_toggle" state set? */
6169 if (g_object_get_data(G_OBJECT(summaryview
->tags_menu
),
6175 summary_set_tag(summaryview
, id
, NULL
);
6178 static void summary_colorlabel_menu_item_activate_item_cb(GtkMenuItem
*menu_item
,
6181 SummaryView
*summaryview
;
6183 GtkCheckMenuItem
**items
;
6185 GList
*children
, *cur
, *sel
;
6187 summaryview
= (SummaryView
*)data
;
6188 cm_return_if_fail(summaryview
!= NULL
);
6190 sel
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
6193 menu
= GTK_MENU_SHELL(summaryview
->colorlabel_menu
);
6195 cm_return_if_fail(menu
!= NULL
);
6197 Xalloca(items
, (N_COLOR_LABELS
+ 1) * sizeof(GtkWidget
*), return);
6199 /* NOTE: don't return prematurely because we set the "dont_toggle"
6200 * state for check menu items */
6201 g_object_set_data(G_OBJECT(menu
), "dont_toggle",
6202 GINT_TO_POINTER(1));
6204 /* clear items. get item pointers. */
6205 children
= gtk_container_get_children(GTK_CONTAINER(menu
));
6206 for (n
= 0, cur
= children
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
6207 if (GTK_IS_CHECK_MENU_ITEM(cur
->data
)) {
6208 gtk_check_menu_item_set_active
6209 (GTK_CHECK_MENU_ITEM(cur
->data
), FALSE
);
6210 gtk_check_menu_item_set_draw_as_radio(GTK_CHECK_MENU_ITEM(cur
->data
),
6212 items
[n
] = GTK_CHECK_MENU_ITEM(cur
->data
);
6217 g_list_free(children
);
6219 if (n
== (N_COLOR_LABELS
+ 1)) {
6220 /* iterate all messages and set the state of the appropriate
6222 for (; sel
!= NULL
; sel
= sel
->next
) {
6226 msginfo
= gtk_cmctree_node_get_row_data
6227 (GTK_CMCTREE(summaryview
->ctree
),
6228 GTK_CMCTREE_NODE(sel
->data
));
6230 clabel
= MSG_GET_COLORLABEL_VALUE(msginfo
->flags
);
6231 if (!gtk_check_menu_item_get_active(items
[clabel
]))
6232 gtk_check_menu_item_set_active
6233 (items
[clabel
], TRUE
);
6237 g_warning("invalid number of color elements (%d)", n
);
6239 /* reset "dont_toggle" state */
6240 g_object_set_data(G_OBJECT(menu
), "dont_toggle",
6241 GINT_TO_POINTER(0));
6244 static void summary_colorlabel_menu_create(SummaryView
*summaryview
, gboolean refresh
)
6246 GtkWidget
*label_menuitem
;
6250 gchar
*accel_path
= NULL
;
6252 label_menuitem
= gtk_ui_manager_get_widget(summaryview
->mainwin
->ui_manager
, "/Menus/SummaryViewPopup/ColorLabel");
6253 g_signal_connect(G_OBJECT(label_menuitem
), "activate",
6254 G_CALLBACK(summary_colorlabel_menu_item_activate_item_cb
),
6256 gtk_widget_show(label_menuitem
);
6258 menu
= gtk_menu_new();
6260 gtk_menu_set_accel_group (GTK_MENU (menu
),
6261 gtk_ui_manager_get_accel_group(mainwindow_get_mainwindow()->ui_manager
));
6263 /* create sub items. for the menu item activation callback we pass the
6264 * index of label_colors[] as data parameter. for the None color we
6265 * pass an invalid (high) value. also we attach a data pointer so we
6266 * can always get back the SummaryView pointer. */
6268 item
= gtk_check_menu_item_new_with_label(_("None"));
6269 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6270 g_signal_connect(G_OBJECT(item
), "activate",
6271 G_CALLBACK(summary_colorlabel_menu_item_activate_cb
),
6272 GUINT_TO_POINTER(0));
6273 g_object_set_data(G_OBJECT(item
), "summaryview", summaryview
);
6274 gtk_widget_show(item
);
6276 accel_path
= g_strdup_printf("<ClawsColorLabels>/None");
6277 gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item
), accel_path
);
6279 gtk_accel_map_add_entry("<ClawsColorLabels>/None", GDK_KEY_0
, GDK_CONTROL_MASK
);
6281 /* create pixmap/label menu items */
6282 for (i
= 0; i
< N_COLOR_LABELS
; i
++) {
6283 item
= colorlabel_create_check_color_menu_item(
6284 i
, refresh
, SUMMARY_COLORMENU
);
6285 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6286 g_signal_connect(G_OBJECT(item
), "activate",
6287 G_CALLBACK(summary_colorlabel_menu_item_activate_cb
),
6288 GUINT_TO_POINTER(i
+ 1));
6289 g_object_set_data(G_OBJECT(item
), "summaryview",
6291 gtk_widget_show(item
);
6292 accel_path
= g_strdup_printf("<ClawsColorLabels>/%d", i
+1);
6293 gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item
), accel_path
);
6295 gtk_accel_map_add_entry(accel_path
, GDK_KEY_1
+i
, GDK_CONTROL_MASK
);
6297 g_signal_connect (gtk_ui_manager_get_accel_group(mainwindow_get_mainwindow()->ui_manager
),
6298 "accel-changed", G_CALLBACK (mainwin_accel_changed_cb
), item
);
6301 gtk_widget_show(menu
);
6302 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem
), menu
);
6303 summaryview
->colorlabel_menu
= menu
;
6306 static void summary_tags_menu_item_activate_item_cb(GtkMenuItem
*menu_item
,
6310 GList
*children
, *cur
;
6312 GHashTable
*menu_table
= g_hash_table_new_full(
6316 GHashTable
*menu_allsel_table
= g_hash_table_new_full(
6321 SummaryView
*summaryview
= (SummaryView
*)data
;
6322 cm_return_if_fail(summaryview
!= NULL
);
6324 sel
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
6327 menu
= GTK_MENU_SHELL(summaryview
->tags_menu
);
6328 cm_return_if_fail(menu
!= NULL
);
6330 /* NOTE: don't return prematurely because we set the "dont_toggle"
6331 * state for check menu items */
6332 g_object_set_data(G_OBJECT(menu
), "dont_toggle",
6333 GINT_TO_POINTER(1));
6335 /* clear items. get item pointers. */
6336 children
= gtk_container_get_children(GTK_CONTAINER(menu
));
6337 for (cur
= children
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
6338 if (GTK_IS_CHECK_MENU_ITEM(cur
->data
)) {
6339 gint id
= GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur
->data
),
6341 gtk_check_menu_item_set_active
6342 (GTK_CHECK_MENU_ITEM(cur
->data
), FALSE
);
6344 g_hash_table_insert(menu_table
, GINT_TO_POINTER(id
), GTK_CHECK_MENU_ITEM(cur
->data
));
6345 g_hash_table_insert(menu_allsel_table
, GINT_TO_POINTER(id
), GINT_TO_POINTER(0));
6349 g_list_free(children
);
6351 /* iterate all messages and set the state of the appropriate
6354 for (; sel
!= NULL
; sel
= sel
->next
) {
6356 GSList
*tags
= NULL
;
6357 GtkCheckMenuItem
*item
;
6358 msginfo
= gtk_cmctree_node_get_row_data
6359 (GTK_CMCTREE(summaryview
->ctree
),
6360 GTK_CMCTREE_NODE(sel
->data
));
6363 tags
= msginfo
->tags
;
6367 for (; tags
; tags
= tags
->next
) {
6368 gint num_checked
= GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table
, tags
->data
));
6369 item
= g_hash_table_lookup(menu_table
, GINT_TO_POINTER(tags
->data
));
6370 if (item
&& !gtk_check_menu_item_get_active(item
)) {
6371 gtk_check_menu_item_set_active
6375 g_hash_table_replace(menu_allsel_table
, tags
->data
, GINT_TO_POINTER(num_checked
));
6380 children
= gtk_container_get_children(GTK_CONTAINER(menu
));
6381 for (cur
= children
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
6382 if (GTK_IS_CHECK_MENU_ITEM(cur
->data
)) {
6383 gint id
= GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur
->data
),
6385 gint num_checked
= GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table
, GINT_TO_POINTER(id
)));
6386 if (num_checked
< sel_len
&& num_checked
> 0)
6387 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur
->data
), TRUE
);
6389 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur
->data
), FALSE
);
6392 g_list_free(children
);
6393 g_hash_table_destroy(menu_table
);
6394 g_hash_table_destroy(menu_allsel_table
);
6395 /* reset "dont_toggle" state */
6396 g_object_set_data(G_OBJECT(menu
), "dont_toggle",
6397 GINT_TO_POINTER(0));
6400 void summaryview_destroy(SummaryView
*summaryview
)
6402 if(summaryview
->simplify_subject_preg
) {
6403 regfree(summaryview
->simplify_subject_preg
);
6404 g_free(summaryview
->simplify_subject_preg
);
6405 summaryview
->simplify_subject_preg
= NULL
;
6408 static void summary_tags_menu_item_apply_tags_activate_cb(GtkWidget
*widget
,
6411 SummaryView
*summaryview
;
6413 summaryview
= g_object_get_data(G_OBJECT(widget
), "summaryview");
6414 cm_return_if_fail(summaryview
!= NULL
);
6416 /* "dont_toggle" state set? */
6417 if (g_object_get_data(G_OBJECT(summaryview
->tags_menu
),
6421 tags_window_open(summary_get_selection(summaryview
));
6424 static gint
summary_tag_cmp_list(gconstpointer a
, gconstpointer b
)
6426 gint id_a
= GPOINTER_TO_INT(a
);
6427 gint id_b
= GPOINTER_TO_INT(b
);
6428 const gchar
*tag_a
= tags_get_tag(id_a
);
6429 const gchar
*tag_b
= tags_get_tag(id_b
);
6432 return tag_b
== NULL
? 0:1;
6437 return g_utf8_collate(tag_a
, tag_b
);
6440 static void summary_tags_menu_create(SummaryView
*summaryview
, gboolean refresh
)
6443 GtkWidget
*label_menuitem
;
6446 GSList
*cur
= tags_get_list();
6447 GSList
*orig
= NULL
;
6448 gboolean existing_tags
= FALSE
;
6449 gchar
*accel_path
= NULL
;
6451 cur
= orig
= g_slist_sort(cur
, summary_tag_cmp_list
);
6452 label_menuitem
= gtk_ui_manager_get_widget(summaryview
->mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Tags");
6453 g_signal_connect(G_OBJECT(label_menuitem
), "activate",
6454 G_CALLBACK(summary_tags_menu_item_activate_item_cb
),
6457 gtk_widget_show(label_menuitem
);
6459 menu
= gtk_menu_new();
6461 gtk_menu_set_accel_group (GTK_MENU (menu
),
6462 gtk_ui_manager_get_accel_group(summaryview
->mainwin
->ui_manager
));
6464 /* create tags menu items */
6465 for (; cur
; cur
= cur
->next
) {
6466 gint id
= GPOINTER_TO_INT(cur
->data
);
6467 const gchar
*tag
= tags_get_tag(id
);
6468 item
= gtk_check_menu_item_new_with_label(tag
);
6469 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6470 g_signal_connect(G_OBJECT(item
), "activate",
6471 G_CALLBACK(summary_tags_menu_item_activate_cb
),
6472 GINT_TO_POINTER(id
));
6473 g_object_set_data(G_OBJECT(item
), "summaryview",
6475 g_object_set_data(G_OBJECT(item
), "tag_id",
6476 GINT_TO_POINTER(id
));
6477 gtk_widget_show(item
);
6478 accel_path
= g_strconcat("<ClawsTags>/",tag
, NULL
);
6479 gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item
), accel_path
);
6481 existing_tags
= TRUE
;
6483 if (existing_tags
) {
6485 item
= gtk_separator_menu_item_new();
6486 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6487 gtk_widget_show(item
);
6490 item
= gtk_menu_item_new_with_label(_("Modify tags..."));
6491 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6492 g_signal_connect(G_OBJECT(item
), "activate",
6493 G_CALLBACK(summary_tags_menu_item_apply_tags_activate_cb
),
6495 g_object_set_data(G_OBJECT(item
), "summaryview",
6497 gtk_widget_show(item
);
6498 accel_path
= g_strdup_printf("<ClawsTags>/ModifyTags");
6499 gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item
), accel_path
);
6503 gtk_widget_show(menu
);
6504 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem
), menu
);
6505 summaryview
->tags_menu
= menu
;
6508 static gboolean
summary_popup_menu(GtkWidget
*widget
, gpointer data
)
6510 SummaryView
*summaryview
= (SummaryView
*)data
;
6511 summaryview
->display_msg
= messageview_is_visible(summaryview
->messageview
);
6513 gtk_menu_popup_at_pointer(GTK_MENU(summaryview
->popupmenu
), NULL
);
6519 static gchar
*summaryview_get_tooltip_text(SummaryView
*summaryview
, MsgInfo
*info
, gint column
)
6525 flags
= info
->flags
;
6527 switch(summaryview
->col_state
[column
].type
) {
6529 if (MSG_IS_IGNORE_THREAD(flags
)) {
6530 return _("Ignored thread");
6531 } else if (MSG_IS_WATCH_THREAD(flags
)) {
6532 return _("Watched thread");
6533 } else if (MSG_IS_SPAM(flags
)) {
6535 } else if (MSG_IS_NEW(flags
)) {
6537 } else if (MSG_IS_UNREAD(flags
)) {
6539 } else if (MSG_IS_REPLIED(flags
) && MSG_IS_FORWARDED(flags
)) {
6540 return _("Replied but also forwarded - click to see reply");
6541 } else if (MSG_IS_REPLIED(flags
)) {
6542 return _("Replied - click to see reply");
6543 } else if (MSG_IS_FORWARDED(flags
)) {
6544 return _("Forwarded");
6549 if (MSG_IS_DELETED(flags
)) {
6550 return _("Deleted");
6551 } else if (MSG_IS_MARKED(flags
)) {
6553 } else if (MSG_IS_MOVE(flags
)) {
6554 return _("To be moved");
6555 } else if (MSG_IS_COPY(flags
)) {
6556 return _("To be copied");
6561 if (MSG_IS_LOCKED(flags
)) {
6567 if (MSG_IS_WITH_ATTACHMENT(flags
) && MSG_IS_SIGNED(flags
)) {
6568 return _("Signed, has attachment(s)");
6569 } else if (MSG_IS_SIGNED(flags
)) {
6571 } else if (MSG_IS_WITH_ATTACHMENT(flags
) && MSG_IS_ENCRYPTED(flags
)) {
6572 return _("Encrypted, has attachment(s)");
6573 } else if (MSG_IS_ENCRYPTED(flags
)) {
6574 return _("Encrypted");
6575 } else if (MSG_IS_WITH_ATTACHMENT(flags
)) {
6576 return _("Has attachment(s)");
6584 static gboolean
tooltip_cb (GtkWidget
*widget
,
6587 gboolean keyboard_mode
,
6588 GtkTooltip
*tooltip
,
6591 GtkCMCTree
*ctree
= GTK_CMCTREE(widget
);
6592 SummaryView
*summaryview
= (SummaryView
*)user_data
;
6593 gint row
= -1, column
= -1;
6594 int offset
= prefs_common
.show_col_headers
? 24:0;
6595 GtkCMCTreeNode
*node
= NULL
;
6597 gchar
*formatted
= NULL
;
6598 MsgInfo
*info
= NULL
;
6600 gboolean vert_layout
= (prefs_common
.layout_mode
== VERTICAL_LAYOUT
);
6601 gboolean small_layout
= (prefs_common
.layout_mode
== SMALL_LAYOUT
);
6602 if (!prefs_common
.show_tooltips
)
6608 if (!gtk_cmclist_get_selection_info(GTK_CMCLIST(ctree
), x
, y
- offset
,
6612 if ((node
= gtk_cmctree_node_nth(ctree
, row
)) == NULL
)
6615 if ((info
= gtk_cmctree_node_get_row_data(ctree
, node
)) == NULL
)
6618 switch (gtk_cmctree_node_get_cell_type(ctree
, node
, column
)) {
6619 case GTK_CMCELL_TEXT
:
6620 if (gtk_cmctree_node_get_text(ctree
, node
, column
, &text
) != TRUE
)
6622 if (column
== summaryview
->col_pos
[S_COL_FROM
])
6624 else if (column
== summaryview
->col_pos
[S_COL_TO
])
6627 case GTK_CMCELL_PIXTEXT
:
6628 if (gtk_cmctree_node_get_pixtext(ctree
, node
, column
, &text
,
6629 NULL
, NULL
) != TRUE
)
6633 if ((text
= summaryview_get_tooltip_text(summaryview
, info
, column
)) == NULL
)
6637 if (!text
|| !*text
)
6640 formatted
= g_strdup(text
);
6641 g_strstrip(formatted
);
6643 if ((vert_layout
|| small_layout
) && prefs_common
.two_line_vert
)
6644 gtk_tooltip_set_markup (tooltip
, formatted
);
6646 gtk_tooltip_set_text (tooltip
, formatted
);
6653 gtk_tooltip_set_tip_area(tooltip
, &rect
);
6659 static gboolean
summary_header_button_pressed(GtkWidget
*widget
,
6663 GdkEventButton
*event
= (GdkEventButton
*)_event
;
6664 SummaryView
*summaryview
= (SummaryView
*)user_data
;
6666 cm_return_val_if_fail(summaryview
!= NULL
, FALSE
);
6668 /* Only handle single button presses. */
6669 if (event
->type
== GDK_2BUTTON_PRESS
||
6670 event
->type
== GDK_3BUTTON_PRESS
)
6673 /* Handle right-click for context menu */
6674 if (event
->button
== 3) {
6675 /* Set up any menu items that need setting up. */
6676 summaryview
->header_menu_lock
= TRUE
;
6677 cm_toggle_menu_set_active_full(summaryview
->mainwin
->ui_manager
,
6678 "Menus/SummaryViewHeaderPopup/LockColumnHeaders",
6679 prefs_common_get_prefs()->summary_col_lock
);
6680 summaryview
->header_menu_lock
= FALSE
;
6682 gtk_menu_popup_at_pointer(GTK_MENU(summaryview
->headerpopupmenu
), NULL
);
6689 static GtkWidget
*summary_ctree_create(SummaryView
*summaryview
)
6692 gint
*col_pos
= summaryview
->col_pos
;
6693 SummaryColumnState
*col_state
;
6694 gchar
*titles
[N_SUMMARY_COLS
];
6695 SummaryColumnType type
;
6697 gboolean vert_layout
= (prefs_common
.layout_mode
== VERTICAL_LAYOUT
);
6698 gboolean small_layout
= (prefs_common
.layout_mode
== SMALL_LAYOUT
);
6699 memset(titles
, 0, sizeof(titles
));
6701 col_state
= prefs_summary_column_get_config();
6702 for (pos
= 0; pos
< N_SUMMARY_COLS
; pos
++) {
6703 summaryview
->col_state
[pos
] = col_state
[pos
];
6704 type
= col_state
[pos
].type
;
6705 col_pos
[type
] = pos
;
6706 titles
[pos
] = "dummy";
6708 col_state
= summaryview
->col_state
;
6710 ctree
= gtk_sctree_new_with_titles
6711 (N_SUMMARY_COLS
, col_pos
[S_COL_SUBJECT
], titles
);
6713 gtk_widget_set_name(GTK_WIDGET(ctree
), "summaryview_sctree");
6715 if (prefs_common
.show_col_headers
== FALSE
)
6716 gtk_cmclist_column_titles_hide(GTK_CMCLIST(ctree
));
6718 gtk_cmclist_set_selection_mode(GTK_CMCLIST(ctree
), GTK_SELECTION_MULTIPLE
);
6719 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_MARK
],
6720 GTK_JUSTIFY_CENTER
);
6721 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_STATUS
],
6722 GTK_JUSTIFY_CENTER
);
6723 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_LOCKED
],
6724 GTK_JUSTIFY_CENTER
);
6725 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_MIME
],
6726 GTK_JUSTIFY_CENTER
);
6727 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_SIZE
],
6729 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_NUMBER
],
6731 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_SCORE
],
6733 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_MARK
],
6734 prefs_common
.summary_col_size
[S_COL_MARK
]);
6735 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_STATUS
],
6736 prefs_common
.summary_col_size
[S_COL_STATUS
]);
6737 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_LOCKED
],
6738 prefs_common
.summary_col_size
[S_COL_LOCKED
]);
6739 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_MIME
],
6740 prefs_common
.summary_col_size
[S_COL_MIME
]);
6741 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_SUBJECT
],
6742 prefs_common
.summary_col_size
[S_COL_SUBJECT
]);
6743 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_FROM
],
6744 prefs_common
.summary_col_size
[S_COL_FROM
]);
6745 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_TO
],
6746 prefs_common
.summary_col_size
[S_COL_TO
]);
6747 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_DATE
],
6748 prefs_common
.summary_col_size
[S_COL_DATE
]);
6749 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_SIZE
],
6750 prefs_common
.summary_col_size
[S_COL_SIZE
]);
6751 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_NUMBER
],
6752 prefs_common
.summary_col_size
[S_COL_NUMBER
]);
6753 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_SCORE
],
6754 prefs_common
.summary_col_size
[S_COL_SCORE
]);
6755 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_TAGS
],
6756 prefs_common
.summary_col_size
[S_COL_TAGS
]);
6758 gtk_cmctree_set_expander_style(GTK_CMCTREE(ctree
),
6759 GTK_CMCTREE_EXPANDER_TRIANGLE
);
6761 gtk_sctree_set_stripes(GTK_SCTREE(ctree
), prefs_common
.use_stripes_in_summaries
);
6763 gtk_cmctree_set_indent(GTK_CMCTREE(ctree
), 12);
6764 g_object_set_data(G_OBJECT(ctree
), "summaryview", (gpointer
)summaryview
);
6766 for (pos
= 0; pos
< N_SUMMARY_COLS
; pos
++) {
6767 gtk_widget_set_can_focus(GTK_CMCLIST(ctree
)->column
[pos
].button
,
6769 if (((pos
== summaryview
->col_pos
[S_COL_FROM
] && !FOLDER_SHOWS_TO_HDR(summaryview
->folder_item
)) ||
6770 (pos
== summaryview
->col_pos
[S_COL_TO
] && FOLDER_SHOWS_TO_HDR(summaryview
->folder_item
)) ||
6771 pos
== summaryview
->col_pos
[S_COL_DATE
]) && (vert_layout
|| small_layout
) &&
6772 prefs_common
.two_line_vert
)
6773 gtk_cmclist_set_column_visibility
6774 (GTK_CMCLIST(ctree
), pos
, FALSE
);
6776 gtk_cmclist_set_column_visibility
6777 (GTK_CMCLIST(ctree
), pos
, col_state
[pos
].visible
);
6779 if (prefs_common
.two_line_vert
)
6780 gtk_sctree_set_use_markup(GTK_SCTREE(ctree
), summaryview
->col_pos
[S_COL_SUBJECT
], vert_layout
||small_layout
);
6782 /* connect signal to the buttons for sorting */
6783 #define CLIST_BUTTON_SIGNAL_CONNECT(col, func) \
6785 (G_OBJECT(GTK_CMCLIST(ctree)->column[col_pos[col]].button), \
6786 "button-press-event", \
6787 G_CALLBACK(summary_header_button_pressed), \
6790 (G_OBJECT(GTK_CMCLIST(ctree)->column[col_pos[col]].button), \
6795 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_MARK
, summary_mark_clicked
)
6796 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_STATUS
, summary_status_clicked
)
6797 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_MIME
, summary_mime_clicked
)
6798 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_NUMBER
, summary_num_clicked
)
6799 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_SIZE
, summary_size_clicked
)
6800 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_DATE
, summary_date_clicked
)
6801 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_FROM
, summary_from_clicked
)
6802 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_TO
, summary_to_clicked
)
6803 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_SUBJECT
, summary_subject_clicked
)
6804 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_SCORE
, summary_score_clicked
)
6805 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_LOCKED
, summary_locked_clicked
)
6806 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_TAGS
, summary_tags_clicked
)
6808 #undef CLIST_BUTTON_SIGNAL_CONNECT
6810 g_signal_connect(G_OBJECT(ctree
), "tree_select_row",
6811 G_CALLBACK(summary_selected
), summaryview
);
6812 g_signal_connect(G_OBJECT(ctree
), "tree_unselect_row",
6813 G_CALLBACK(summary_unselected
), summaryview
);
6814 g_signal_connect(G_OBJECT(ctree
), "button_press_event",
6815 G_CALLBACK(summary_button_pressed
),
6817 g_signal_connect(G_OBJECT(ctree
), "popup-menu",
6818 G_CALLBACK(summary_popup_menu
), summaryview
);
6819 g_signal_connect(G_OBJECT(ctree
), "button_release_event",
6820 G_CALLBACK(summary_button_released
),
6822 g_signal_connect(G_OBJECT(ctree
), "key_press_event",
6823 G_CALLBACK(summary_key_pressed
), summaryview
);
6824 g_signal_connect(G_OBJECT(ctree
), "resize_column",
6825 G_CALLBACK(summary_col_resized
), summaryview
);
6826 g_signal_connect(G_OBJECT(ctree
), "open_row",
6827 G_CALLBACK(summary_open_row
), summaryview
);
6829 g_signal_connect_after(G_OBJECT(ctree
), "tree_expand",
6830 G_CALLBACK(summary_tree_expanded
),
6832 g_signal_connect_after(G_OBJECT(ctree
), "tree_collapse",
6833 G_CALLBACK(summary_tree_collapsed
),
6836 g_signal_connect(G_OBJECT(ctree
), "start_drag",
6837 G_CALLBACK(summary_start_drag
),
6839 g_signal_connect(G_OBJECT(ctree
), "drag_data_get",
6840 G_CALLBACK(summary_drag_data_get
),
6842 g_signal_connect(G_OBJECT(ctree
), "drag_end",
6843 G_CALLBACK(summary_drag_end
),
6846 gtk_drag_dest_set(ctree
, GTK_DEST_DEFAULT_ALL
& ~GTK_DEST_DEFAULT_HIGHLIGHT
,
6847 summary_drag_types
, 3,
6848 GDK_ACTION_MOVE
| GDK_ACTION_COPY
| GDK_ACTION_DEFAULT
);
6850 g_signal_connect(G_OBJECT(ctree
), "drag_data_received",
6851 G_CALLBACK(summary_drag_data_received
),
6854 g_signal_connect(G_OBJECT(ctree
), "drag_motion",
6855 G_CALLBACK(summary_drag_motion_cb
),
6859 g_object_set (G_OBJECT(ctree
), "has-tooltip", TRUE
, NULL
);
6860 g_signal_connect(G_OBJECT(ctree
), "query-tooltip",
6861 G_CALLBACK(tooltip_cb
),
6867 void summary_set_column_order(SummaryView
*summaryview
)
6870 GtkWidget
*scrolledwin
= summaryview
->scrolledwin
;
6872 guint selected_msgnum
= summary_get_msgnum(summaryview
, summaryview
->selected
);
6873 guint displayed_msgnum
= summary_get_msgnum(summaryview
, summaryview
->displayed
);
6875 item
= summaryview
->folder_item
;
6877 summary_clear_all(summaryview
);
6878 gtk_widget_destroy(summaryview
->ctree
);
6880 summaryview
->ctree
= ctree
= summary_ctree_create(summaryview
);
6881 summary_set_fonts(summaryview
);
6882 summary_set_column_titles(summaryview
);
6883 gtk_scrolled_window_set_hadjustment(GTK_SCROLLED_WINDOW(scrolledwin
),
6884 GTK_CMCLIST(ctree
)->hadjustment
);
6885 gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(scrolledwin
),
6886 GTK_CMCLIST(ctree
)->vadjustment
);
6887 gtk_container_add(GTK_CONTAINER(scrolledwin
), ctree
);
6888 gtk_widget_show(ctree
);
6890 summary_show(summaryview
, item
, FALSE
);
6892 summary_select_by_msgnum(summaryview
, selected_msgnum
, FALSE
);
6894 summaryview
->selected
= summary_find_msg_by_msgnum(summaryview
, selected_msgnum
);
6895 summaryview
->displayed
= summary_find_msg_by_msgnum(summaryview
, displayed_msgnum
);
6896 if (!summaryview
->displayed
)
6897 messageview_clear(summaryview
->messageview
);
6899 summary_redisplay_msg(summaryview
);
6901 /* get normal row height */
6902 gtk_cmclist_set_row_height(GTK_CMCLIST(ctree
), 0);
6903 normal_row_height
= GTK_CMCLIST(ctree
)->row_height
;
6905 if ((prefs_common
.layout_mode
== SMALL_LAYOUT
|| prefs_common
.layout_mode
== VERTICAL_LAYOUT
) &&
6906 prefs_common
.two_line_vert
) {
6907 gtk_cmclist_set_row_height(GTK_CMCLIST(summaryview
->ctree
), 2*normal_row_height
+ 2);
6912 /* callback functions */
6914 static gint
summary_folder_eventbox_pressed(GtkWidget
*eventbox
, GdkEventButton
*event
,
6915 SummaryView
*summaryview
)
6918 folderview_grab_focus(summaryview
->folderview
);
6919 mainwindow_exit_folder(summaryview
->mainwin
);
6924 static gint
summary_toggle_pressed(GtkWidget
*eventbox
, GdkEventButton
*event
,
6925 SummaryView
*summaryview
)
6928 summary_toggle_view(summaryview
);
6932 static void summary_toggle_multiple_pressed(GtkWidget
*widget
,
6933 SummaryView
*summaryview
)
6935 GTK_SCTREE(summaryview
->ctree
)->force_additive_sel
=
6936 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
6939 static gboolean
summary_button_pressed(GtkWidget
*ctree
, GdkEventButton
*event
,
6940 SummaryView
*summaryview
)
6942 if (!event
) return FALSE
;
6943 if (event
->window
!= GTK_CMCLIST(ctree
)->clist_window
) return FALSE
;
6945 if (event
->button
== 3) {
6947 summary_set_menu_sensitive(summaryview
);
6948 gtk_menu_popup_at_pointer(GTK_MENU(summaryview
->popupmenu
), NULL
);
6949 } else if (event
->button
== 2) {
6950 summaryview
->display_msg
= messageview_is_visible(summaryview
->messageview
);
6951 } else if (event
->button
== 1) {
6952 if (!prefs_common
.emulate_emacs
&&
6953 messageview_is_visible(summaryview
->messageview
))
6954 summaryview
->display_msg
= TRUE
;
6960 static gboolean
summary_button_released(GtkWidget
*ctree
, GdkEventButton
*event
,
6961 SummaryView
*summaryview
)
6966 gboolean
summary_pass_key_press_event(SummaryView
*summaryview
, GdkEventKey
*event
)
6970 if (summary_is_list(summaryview
))
6971 return summary_key_pressed(summaryview
->ctree
, event
, summaryview
);
6976 #define BREAK_ON_MODIFIER_KEY() \
6977 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
6979 /* Copied from gtkcmclist.c, if it changes there, it has to change
6980 * here as well. This is an ugly hack, there must be a better way to
6981 * find out how much to move for page up/down. */
6982 #define CELL_SPACING 1
6983 static gboolean
summary_key_pressed(GtkWidget
*widget
, GdkEventKey
*event
,
6984 SummaryView
*summaryview
)
6986 GtkCMCTree
*ctree
= GTK_CMCTREE(widget
);
6987 GtkCMCTreeNode
*node
;
6988 MessageView
*messageview
;
6990 gboolean mod_pressed
;
6995 if (quicksearch_has_focus(summaryview
->quicksearch
))
6998 messageview
= summaryview
->messageview
;
7001 ((event
->state
& (GDK_SHIFT_MASK
|GDK_MOD1_MASK
)) != 0);
7003 if (summaryview
->selected
) {
7004 gboolean handled
= FALSE
;
7005 switch (event
->keyval
) {
7006 case GDK_KEY_space
: /* Page down or go to the next */
7008 if (event
->state
& GDK_CONTROL_MASK
) {
7012 if (event
->state
& GDK_SHIFT_MASK
)
7013 mimeview_scroll_page(messageview
->mimeview
, TRUE
);
7014 if (summaryview
->displayed
!= summaryview
->selected
) {
7015 summary_display_msg(summaryview
,
7016 summaryview
->selected
);
7019 if (!mimeview_scroll_page(messageview
->mimeview
, TRUE
))
7020 summary_select_prev_unread(summaryview
);
7022 if (!mimeview_scroll_page(messageview
->mimeview
, FALSE
))
7023 summary_select_next_unread(summaryview
);
7027 case GDK_KEY_BackSpace
: /* Page up */
7029 mimeview_scroll_page(messageview
->mimeview
, TRUE
);
7031 case GDK_KEY_Return
: /* Scroll up/down one line */
7032 case GDK_KEY_KP_Enter
:
7034 if (summaryview
->displayed
!= summaryview
->selected
) {
7035 #ifndef GENERIC_UMPC
7036 summary_display_msg(summaryview
,
7037 summaryview
->selected
);
7039 summary_open_row(NULL
, summaryview
);
7043 mimeview_scroll_one_line(messageview
->mimeview
, mod_pressed
);
7050 if (summary_is_locked(summaryview
))
7053 switch (event
->keyval
) {
7054 case GDK_KEY_Left
: /* Move focus */
7055 adj
= gtk_scrolled_window_get_hadjustment
7056 (GTK_SCROLLED_WINDOW(summaryview
->scrolledwin
));
7057 if (gtk_adjustment_get_lower(adj
) != gtk_adjustment_get_value(adj
))
7060 case GDK_KEY_Escape
:
7061 folderview_grab_focus(summaryview
->folderview
);
7062 mainwindow_exit_folder(summaryview
->mainwin
);
7064 case GDK_KEY_Home
: case GDK_KEY_KP_Home
:
7065 case GDK_KEY_End
: case GDK_KEY_KP_End
:
7066 case GDK_KEY_Up
: case GDK_KEY_KP_Up
:
7067 case GDK_KEY_Down
: case GDK_KEY_KP_Down
:
7068 case GDK_KEY_Page_Up
: case GDK_KEY_KP_Page_Up
:
7069 case GDK_KEY_Page_Down
: case GDK_KEY_KP_Page_Down
:
7070 if ((node
= summaryview
->selected
) != NULL
) {
7071 GtkCMCTreeNode
*next
= NULL
;
7072 switch (event
->keyval
) {
7073 case GDK_KEY_Home
: case GDK_KEY_KP_Home
:
7074 next
= gtk_cmctree_node_nth(ctree
, 0);
7076 case GDK_KEY_End
: case GDK_KEY_KP_End
:
7077 next
= gtk_cmctree_node_nth(ctree
,
7078 g_list_length(GTK_CMCLIST(ctree
)->row_list
)-1);
7080 case GDK_KEY_Up
: case GDK_KEY_KP_Up
:
7081 next
= gtk_cmctree_node_nth(ctree
,
7082 MAX(0, GTK_CMCLIST(ctree
)->focus_row
- 1));
7084 case GDK_KEY_Down
: case GDK_KEY_KP_Down
:
7085 next
= gtk_cmctree_node_nth(ctree
,
7086 MIN(GTK_CMCLIST(ctree
)->focus_row
+ 1, GTK_CMCLIST(ctree
)->rows
- 1));
7088 case GDK_KEY_Page_Up
: case GDK_KEY_KP_Page_Up
:
7089 next
= gtk_cmctree_node_nth(ctree
,
7090 MAX(0, GTK_CMCLIST(ctree
)->focus_row
-
7091 (2 * GTK_CMCLIST(ctree
)->clist_window_height
-
7092 GTK_CMCLIST(ctree
)->row_height
- CELL_SPACING
) /
7093 (2 * (GTK_CMCLIST(ctree
)->row_height
+ CELL_SPACING
))));
7095 case GDK_KEY_Page_Down
: case GDK_KEY_KP_Page_Down
:
7096 next
= gtk_cmctree_node_nth(ctree
,
7097 MIN(GTK_CMCLIST(ctree
)->rows
- 1, GTK_CMCLIST(ctree
)->focus_row
+
7098 (2 * GTK_CMCLIST(ctree
)->clist_window_height
-
7099 GTK_CMCLIST(ctree
)->row_height
- CELL_SPACING
) /
7100 (2 * (GTK_CMCLIST(ctree
)->row_height
+ CELL_SPACING
))));
7105 next
!= gtk_cmctree_node_nth(ctree
, GTK_CMCLIST(ctree
)->focus_row
)) {
7106 gtk_sctree_select_with_state
7107 (GTK_SCTREE(ctree
), next
, (event
->state
& ~GDK_CONTROL_MASK
) );
7109 /* Deprecated - what are the non-deprecated equivalents? */
7110 if (gtk_cmctree_node_is_visible(GTK_CMCTREE(ctree
), next
) != GTK_VISIBILITY_FULL
)
7111 gtkut_ctree_node_move_if_on_the_edge(GTK_CMCTREE(ctree
), next
, -1);
7113 summary_select_node(summaryview
, summaryview
->selected
, OPEN_SELECTED_ON_DIRECTIONAL
);
7114 summaryview
->selected
= next
;
7122 if (!summaryview
->selected
) {
7123 node
= gtk_cmctree_node_nth(ctree
, 0);
7125 gtk_sctree_select(GTK_SCTREE(ctree
), node
);
7130 switch (event
->keyval
) {
7131 case GDK_KEY_Delete
:
7132 BREAK_ON_MODIFIER_KEY();
7133 summary_delete_trash(summaryview
);
7142 static void quicksearch_execute_cb(QuickSearch
*quicksearch
, gpointer data
)
7144 SummaryView
*summaryview
= data
;
7146 summaryview_reset_recursive_folder_match(summaryview
);
7147 if (summary_show(summaryview
, summaryview
->folder_item
, FALSE
))
7148 summaryview_quicksearch_recurse(summaryview
);
7150 summaryview_reset_recursive_folder_match(summaryview
);
7153 static void tog_searchbar_cb(GtkWidget
*w
, gpointer data
)
7155 SummaryView
*summaryview
= (SummaryView
*)data
;
7157 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w
))) {
7158 prefs_common
.show_searchbar
= TRUE
;
7159 quicksearch_show(summaryview
->quicksearch
);
7161 prefs_common
.show_searchbar
= FALSE
;
7162 quicksearch_hide(summaryview
->quicksearch
);
7166 void summaryview_activate_quicksearch(SummaryView
*summaryview
, gboolean show
)
7168 prefs_common
.show_searchbar
= show
;
7169 gtk_toggle_button_set_active(
7170 GTK_TOGGLE_BUTTON(summaryview
->toggle_search
),
7173 quicksearch_show(summaryview
->quicksearch
);
7175 quicksearch_hide(summaryview
->quicksearch
);
7176 summary_grab_focus(summaryview
);
7180 void summary_open_row(GtkSCTree
*sctree
, SummaryView
*summaryview
)
7182 if (FOLDER_SHOWS_TO_HDR(summaryview
->folder_item
))
7183 summary_reedit(summaryview
);
7185 summary_open_msg(summaryview
);
7187 summaryview
->display_msg
= FALSE
;
7190 static void summary_tree_expanded(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
7191 SummaryView
*summaryview
)
7193 summary_set_row_marks(summaryview
, node
);
7194 if (prefs_common
.bold_unread
) {
7196 GtkCMCTreeNode
*next
= GTK_CMCTREE_NODE_NEXT(node
);
7197 if (GTK_CMCTREE_ROW(node
)->children
)
7198 summary_set_row_marks(summaryview
, node
);
7204 static void summary_tree_collapsed(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
7205 SummaryView
*summaryview
)
7207 gtk_sctree_select(GTK_SCTREE(ctree
), node
);
7208 summary_set_row_marks(summaryview
, node
);
7211 static void summary_unselected(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
,
7212 gint column
, SummaryView
*summaryview
)
7214 if (summary_is_locked(summaryview
)
7215 || GTK_SCTREE(ctree
)->selecting_range
) {
7219 summary_status_show(summaryview
);
7222 static void summary_selected(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
,
7223 gint column
, SummaryView
*summaryview
)
7225 const GList
*list
, *cur
;
7226 MessageView
*msgview
;
7228 gboolean marked_unread
= FALSE
;
7230 if (summary_is_locked(summaryview
)
7231 && !GTK_SCTREE(ctree
)->selecting_range
7232 && summaryview
->messageview
7233 && summaryview
->messageview
->mimeview
7234 && summaryview
->messageview
->mimeview
->type
== MIMEVIEW_TEXT
7235 && summaryview
->messageview
->mimeview
->textview
->loading
) {
7236 PostponedSelectData
*data
= g_new0(PostponedSelectData
, 1);
7237 summaryview
->messageview
->mimeview
->textview
->stop_loading
= TRUE
;
7239 data
->ctree
= ctree
;
7242 data
->column
= column
;
7243 data
->summaryview
= summaryview
;
7244 debug_print("postponing open of message till end of load\n");
7245 g_timeout_add(100, summary_select_retry
, data
);
7248 if (summary_is_locked(summaryview
)
7249 || GTK_SCTREE(ctree
)->selecting_range
) {
7253 summary_status_show(summaryview
);
7255 if (GTK_CMCLIST(ctree
)->selection
&&
7256 GTK_CMCLIST(ctree
)->selection
->next
) {
7257 summaryview
->display_msg
= FALSE
;
7258 summary_set_menu_sensitive(summaryview
);
7259 toolbar_main_set_sensitive(summaryview
->mainwin
);
7263 summaryview
->selected
= row
;
7265 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
7266 cm_return_if_fail(msginfo
!= NULL
);
7268 main_create_mailing_list_menu (summaryview
->mainwin
, msginfo
);
7269 toolbar_set_learn_button
7270 (summaryview
->mainwin
->toolbar
,
7271 MSG_IS_SPAM(msginfo
->flags
)?LEARN_HAM
:LEARN_SPAM
);
7273 switch (column
< 0 ? column
: summaryview
->col_state
[column
].type
) {
7275 if (!MSG_IS_DELETED(msginfo
->flags
) &&
7276 !MSG_IS_MOVE(msginfo
->flags
) &&
7277 !MSG_IS_COPY(msginfo
->flags
)) {
7278 if (MSG_IS_MARKED(msginfo
->flags
)) {
7279 summary_unmark_row(summaryview
, row
);
7280 summary_status_show(summaryview
);
7282 summary_mark_row(summaryview
, row
);
7283 summary_status_show(summaryview
);
7288 if (MSG_IS_UNREAD(msginfo
->flags
)) {
7289 summary_mark_row_as_read(summaryview
, row
);
7290 summary_status_show(summaryview
);
7291 } else if (MSG_IS_SPAM(msginfo
->flags
)) {
7292 if (procmsg_spam_learner_learn(msginfo
, NULL
, FALSE
) == 0)
7293 summary_msginfo_unset_flags(msginfo
, MSG_SPAM
, 0);
7295 log_error(LOG_PROTOCOL
, _("An error happened while learning.\n"));
7296 } else if (!MSG_IS_REPLIED(msginfo
->flags
) &&
7297 !MSG_IS_FORWARDED(msginfo
->flags
)) {
7298 marked_unread
= TRUE
;
7299 } else if (MSG_IS_REPLIED(msginfo
->flags
)) {
7300 summary_find_answers(summaryview
, msginfo
);
7305 if (MSG_IS_LOCKED(msginfo
->flags
)) {
7306 summary_unlock_row(summaryview
, row
);
7307 summary_status_show(summaryview
);
7310 summary_lock_row(summaryview
, row
);
7311 summary_status_show(summaryview
);
7318 list
= messageview_get_msgview_list();
7319 for (cur
= list
; cur
!= NULL
; cur
= cur
->next
) {
7320 msgview
= (MessageView
*) cur
->data
;
7322 if (msgview
->new_window
&& msgview
->update_needed
) {
7323 MsgInfo
*new_msginfo
= summary_get_selected_msg(summaryview
);
7324 messageview_show(msgview
, new_msginfo
, msgview
->all_headers
);
7325 msgview
->update_needed
= FALSE
;
7329 if (summaryview
->display_msg
) {
7330 summaryview
->display_msg
= FALSE
;
7331 if (summaryview
->displayed
!= row
) {
7332 summary_display_msg(summaryview
, row
);
7333 if (marked_unread
) {
7334 summary_mark_row_as_unread(summaryview
, row
);
7335 summary_status_show(summaryview
);
7341 if (marked_unread
) {
7342 summary_mark_row_as_unread(summaryview
, row
);
7343 summary_status_show(summaryview
);
7346 summary_set_menu_sensitive(summaryview
);
7347 toolbar_main_set_sensitive(summaryview
->mainwin
);
7350 static void summary_col_resized(GtkCMCList
*clist
, gint column
, gint width
,
7351 SummaryView
*summaryview
)
7353 SummaryColumnType type
= summaryview
->col_state
[column
].type
;
7355 prefs_common
.summary_col_size
[type
] = width
;
7360 * \brief get List of msginfo selected in SummaryView
7362 * \param summaryview
7364 * \return GSList holding MsgInfo
7366 GSList
*summary_get_selection(SummaryView
*summaryview
)
7369 GSList
*msginfo_list
= NULL
;
7371 cm_return_val_if_fail(summaryview
!= NULL
, NULL
);
7373 sel
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
7375 cm_return_val_if_fail(sel
!= NULL
, NULL
);
7377 for ( ; sel
!= NULL
; sel
= sel
->next
)
7379 g_slist_prepend(msginfo_list
,
7380 gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview
->ctree
),
7381 GTK_CMCTREE_NODE(sel
->data
)));
7382 return g_slist_reverse(msginfo_list
);
7386 * \brief get number of messages currently selected in SummaryView
7388 * \param summaryview
7390 * \return number of messages currently selected
7392 guint
summary_get_selection_count(SummaryView
*summaryview
)
7394 cm_return_val_if_fail(summaryview
!= NULL
, 0);
7395 return g_list_length(GTK_CMCLIST(summaryview
->ctree
)->selection
);
7398 static void summary_sort_by_column_click(SummaryView
*summaryview
,
7399 FolderSortKey sort_key
)
7401 if (prefs_common
.summary_col_lock
) {
7402 debug_print("summaryview columns locked, ignoring\n");
7406 GtkCMCTreeNode
*node
= NULL
;
7408 if (summaryview
->sort_key
== sort_key
)
7409 summary_sort(summaryview
, sort_key
,
7410 summaryview
->sort_type
== SORT_ASCENDING
7411 ? SORT_DESCENDING
: SORT_ASCENDING
);
7413 summary_sort(summaryview
, sort_key
, summaryview
->sort_type
);
7415 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(summaryview
->ctree
)->row_list
);
7417 summary_freeze(summaryview
);
7418 if (prefs_common
.bold_unread
|| prefs_common
.bold_marked
) {
7420 GtkCMCTreeNode
*next
= GTK_CMCTREE_NODE_NEXT(node
);
7421 if (GTK_CMCTREE_ROW(node
)->children
)
7422 summary_set_row_marks(summaryview
, node
);
7426 summary_thaw(summaryview
);
7430 static void summary_mark_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7432 summary_sort_by_column_click(summaryview
, SORT_BY_MARK
);
7435 static void summary_status_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7437 summary_sort_by_column_click(summaryview
, SORT_BY_STATUS
);
7440 static void summary_mime_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7442 summary_sort_by_column_click(summaryview
, SORT_BY_MIME
);
7445 static void summary_num_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7447 summary_sort_by_column_click(summaryview
, SORT_BY_NUMBER
);
7450 static void summary_size_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7452 summary_sort_by_column_click(summaryview
, SORT_BY_SIZE
);
7455 static void summary_date_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7457 if (summaryview
->sort_key
== SORT_BY_THREAD_DATE
)
7458 summary_sort_by_column_click(summaryview
, SORT_BY_THREAD_DATE
);
7460 summary_sort_by_column_click(summaryview
, SORT_BY_DATE
);
7463 static void summary_from_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7465 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_FROM
]].visible
)
7466 summary_sort_by_column_click(summaryview
, SORT_BY_FROM
);
7468 summary_sort_by_column_click(summaryview
, SORT_BY_TO
);
7471 static void summary_to_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7473 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_TO
]].visible
)
7474 summary_sort_by_column_click(summaryview
, SORT_BY_TO
);
7476 summary_sort_by_column_click(summaryview
, SORT_BY_FROM
);
7479 static void summary_subject_clicked(GtkWidget
*button
,
7480 SummaryView
*summaryview
)
7482 summary_sort_by_column_click(summaryview
, SORT_BY_SUBJECT
);
7485 static void summary_score_clicked(GtkWidget
*button
,
7486 SummaryView
*summaryview
)
7488 summary_sort_by_column_click(summaryview
, SORT_BY_SCORE
);
7491 static void summary_locked_clicked(GtkWidget
*button
,
7492 SummaryView
*summaryview
)
7494 summary_sort_by_column_click(summaryview
, SORT_BY_LOCKED
);
7497 static void summary_tags_clicked(GtkWidget
*button
,
7498 SummaryView
*summaryview
)
7500 summary_sort_by_column_click(summaryview
, SORT_BY_TAGS
);
7503 static void summary_start_drag(GtkWidget
*widget
, gint button
, GdkEvent
*event
,
7504 SummaryView
*summaryview
)
7506 GdkDragContext
*context
;
7508 cm_return_if_fail(summaryview
!= NULL
);
7509 cm_return_if_fail(summaryview
->folder_item
!= NULL
);
7510 cm_return_if_fail(summaryview
->folder_item
->folder
!= NULL
);
7512 if (summaryview
->selected
== NULL
) return;
7514 context
= gtk_drag_begin_with_coordinates(widget
, summaryview
->target_list
,
7515 GDK_ACTION_MOVE
|GDK_ACTION_COPY
|GDK_ACTION_DEFAULT
, button
, event
,
7517 gtk_drag_set_icon_default(context
);
7518 if (prefs_common
.layout_mode
== SMALL_LAYOUT
) {
7519 GtkWidget
*paned
= gtk_widget_get_parent(GTK_WIDGET_PTR(summaryview
));
7520 if (paned
&& GTK_IS_PANED(paned
)) {
7521 mainwindow_reset_paned(GTK_PANED(paned
));
7526 static gboolean
summary_return_to_list(void *data
)
7528 SummaryView
*summaryview
= (SummaryView
*)data
;
7529 mainwindow_enter_folder(summaryview
->mainwin
);
7533 static void summary_drag_end (GtkWidget
*widget
,
7534 GdkDragContext
*drag_context
,
7535 SummaryView
*summaryview
)
7537 if (prefs_common
.layout_mode
== SMALL_LAYOUT
) {
7538 g_timeout_add(250, summary_return_to_list
, summaryview
);
7542 static void summary_drag_data_get(GtkWidget
*widget
,
7543 GdkDragContext
*drag_context
,
7544 GtkSelectionData
*selection_data
,
7547 SummaryView
*summaryview
)
7549 if (info
== TARGET_MAIL_URI_LIST
) {
7550 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
7553 gchar
*mail_list
= NULL
, *tmp1
, *tmp2
;
7555 for (cur
= GTK_CMCLIST(ctree
)->selection
;
7556 cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
7557 msginfo
= gtk_cmctree_node_get_row_data
7558 (ctree
, GTK_CMCTREE_NODE(cur
->data
));
7559 tmp2
= procmsg_get_message_file(msginfo
);
7560 if (!tmp2
) continue;
7561 if (msginfo
->subject
) {
7562 gchar
*san_subject
= g_strdup(msginfo
->subject
);
7564 subst_for_filename(san_subject
);
7565 dest
= g_strdup_printf("%s%s%s.%d.txt",
7568 san_subject
, msginfo
->msgnum
);
7569 g_free(san_subject
);
7570 san_subject
= g_filename_from_utf8(dest
, -1, NULL
, NULL
, NULL
);
7572 g_warning("failed to convert encoding of file name: %s", dest
);
7577 if (copy_file(tmp2
, dest
, TRUE
) < 0) {
7578 g_warning("summary_drag_data_get: can't copy %s to %s",
7584 tmp1
= g_filename_to_uri(tmp2
, NULL
, NULL
);
7586 tmp2
= g_strconcat(tmp1
, "\r\n", NULL
);
7593 tmp2
= g_strconcat(mail_list
, tmp1
, NULL
);
7600 if (mail_list
!= NULL
) {
7601 gtk_selection_data_set(selection_data
,
7602 gtk_selection_data_get_target(selection_data
), 8,
7603 mail_list
, strlen(mail_list
));
7606 } else if (info
== TARGET_DUMMY
) {
7607 if (GTK_CMCLIST(summaryview
->ctree
)->selection
)
7608 gtk_selection_data_set(selection_data
,
7609 gtk_selection_data_get_target(selection_data
), 8,
7610 "Dummy-Summaryview",
7611 strlen("Dummy-Summaryview")+1);
7612 } else if (info
== TARGET_MAIL_CM_PATH_LIST
) {
7613 /* content: folder_item_identifier\nmsgid1\nmsgid2\nmsgid3 */
7615 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
7618 gchar
*path_list
= NULL
;
7621 if(GTK_CMCLIST(ctree
)->selection
!= NULL
) {
7622 msginfo
= gtk_cmctree_node_get_row_data(ctree
, GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->selection
->data
));
7623 if(msginfo
&& msginfo
->folder
)
7624 path_list
= folder_item_get_identifier(msginfo
->folder
);
7627 if (path_list
!= NULL
) {
7628 for (cur
= GTK_CMCLIST(ctree
)->selection
;
7629 cur
!= NULL
&& cur
->data
!= NULL
&& path_list
!= NULL
; cur
= cur
->next
) {
7632 msginfo
= gtk_cmctree_node_get_row_data(ctree
, GTK_CMCTREE_NODE(cur
->data
));
7636 path_list
= g_strconcat(path_list
, "\n", (msginfo
->msgid
? msginfo
->msgid
: "unknown"), NULL
);
7640 if (path_list
!= NULL
) {
7641 gtk_selection_data_set(selection_data
,
7642 gtk_selection_data_get_target(selection_data
), 8,
7643 path_list
, strlen(path_list
));
7647 g_warning("summary_drag_data_get: no folder item identifier");
7652 static gboolean
summary_drag_motion_cb(GtkWidget
*widget
,
7653 GdkDragContext
*context
,
7657 SummaryView
*summaryview
)
7659 FolderItem
*item
= summaryview
->folder_item
;
7660 if (!(item
&& item
->folder
&& folder_item_parent(item
) != NULL
7661 && FOLDER_CLASS(item
->folder
)->add_msg
!= NULL
)) {
7662 gdk_drag_status(context
, 0, time
);
7664 } else if (gtk_drag_get_source_widget(context
) ==
7665 mainwindow_get_mainwindow()->folderview
->ctree
) {
7667 gdk_drag_status(context
, 0, time
);
7669 } else if (gtk_drag_get_source_widget(context
) ==
7670 summaryview
->ctree
) {
7671 /* not from same folder */
7672 gdk_drag_status(context
, 0, time
);
7675 gdk_drag_status(context
, GDK_ACTION_COPY
, time
);
7680 static void summary_drag_data_received(GtkWidget
*widget
,
7681 GdkDragContext
*drag_context
,
7684 GtkSelectionData
*data
,
7687 SummaryView
*summaryview
)
7689 if (info
== TARGET_MAIL_URI_LIST
) {
7690 FolderItem
*item
= summaryview
->folder_item
;
7692 gtk_drag_finish(drag_context
, FALSE
, FALSE
, time
);
7695 folderview_finish_dnd(gtk_selection_data_get_data(data
),
7696 drag_context
, time
, item
);
7702 /* custom compare functions for sorting */
7704 static gint
summary_cmp_by_date(GtkCMCList
*clist
,
7705 gconstpointer ptr1
, gconstpointer ptr2
)
7707 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7708 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7710 if (!msginfo1
|| !msginfo2
)
7713 res
= (msginfo1
->date_t
- msginfo2
->date_t
);
7715 res
= msginfo1
->msgnum
- msginfo2
->msgnum
;
7719 #define CMP_FUNC_DEF(func_name, val) \
7720 static gint func_name(GtkCMCList *clist, \
7721 gconstpointer ptr1, gconstpointer ptr2) \
7723 MsgInfo *msginfo1 = ((GtkCMCListRow *)ptr1)->data; \
7724 MsgInfo *msginfo2 = ((GtkCMCListRow *)ptr2)->data; \
7726 if (!msginfo1 || !msginfo2) \
7730 return (res != 0) ? res:summary_cmp_by_date(clist, ptr1, ptr2); \
7733 CMP_FUNC_DEF(summary_cmp_by_mark
,
7734 MSG_IS_MARKED(msginfo1
->flags
) - MSG_IS_MARKED(msginfo2
->flags
))
7735 CMP_FUNC_DEF(summary_cmp_by_status
,
7736 (-(MSG_IS_SPAM(msginfo1
->flags
))+(MSG_IS_UNREAD(msginfo1
->flags
)<<1)+(MSG_IS_NEW(msginfo1
->flags
)<<2))
7737 - (-(MSG_IS_SPAM(msginfo2
->flags
))+(MSG_IS_UNREAD(msginfo2
->flags
)<<1)+(MSG_IS_NEW(msginfo2
->flags
)<<2)) )
7738 CMP_FUNC_DEF(summary_cmp_by_mime
,
7739 MSG_IS_WITH_ATTACHMENT(msginfo1
->flags
) - MSG_IS_WITH_ATTACHMENT(msginfo2
->flags
))
7740 CMP_FUNC_DEF(summary_cmp_by_label
,
7741 MSG_GET_COLORLABEL(msginfo1
->flags
) -
7742 MSG_GET_COLORLABEL(msginfo2
->flags
))
7743 CMP_FUNC_DEF(summary_cmp_by_locked
,
7744 MSG_IS_LOCKED(msginfo1
->flags
) - MSG_IS_LOCKED(msginfo2
->flags
))
7746 CMP_FUNC_DEF(summary_cmp_by_num
, msginfo1
->msgnum
- msginfo2
->msgnum
)
7747 CMP_FUNC_DEF(summary_cmp_by_size
, msginfo1
->size
- msginfo2
->size
)
7751 static gint
summary_cmp_by_subject(GtkCMCList
*clist
,
7755 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7756 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7759 if (!msginfo1
->subject
)
7760 return (msginfo2
->subject
!= NULL
);
7761 if (!msginfo2
->subject
)
7764 res
= subject_compare_for_sort
7765 (msginfo1
->subject
, msginfo2
->subject
);
7766 return (res
!= 0)? res
: summary_cmp_by_date(clist
, ptr1
, ptr2
);
7769 static gint
summary_cmp_by_thread_date(GtkCMCList
*clist
,
7773 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7774 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7775 gint thread_diff
= msginfo1
->thread_date
- msginfo2
->thread_date
;
7777 if (msginfo1
->thread_date
> 0 && msginfo2
->thread_date
> 0)
7780 return msginfo1
->date_t
- msginfo2
->date_t
;
7783 static gint
summary_cmp_by_from(GtkCMCList
*clist
, gconstpointer ptr1
,
7786 const gchar
*str1
, *str2
;
7787 const GtkCMCListRow
*r1
= (const GtkCMCListRow
*) ptr1
;
7788 const GtkCMCListRow
*r2
= (const GtkCMCListRow
*) ptr2
;
7789 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7790 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7791 const SummaryView
*sv
= g_object_get_data(G_OBJECT(clist
), "summaryview");
7794 cm_return_val_if_fail(sv
, -1);
7795 if (sv
->col_state
[sv
->col_pos
[S_COL_FROM
]].visible
) {
7796 str1
= GTK_CMCELL_TEXT(r1
->cell
[sv
->col_pos
[S_COL_FROM
]])->text
;
7797 str2
= GTK_CMCELL_TEXT(r2
->cell
[sv
->col_pos
[S_COL_FROM
]])->text
;
7799 str1
= msginfo1
->from
;
7800 str2
= msginfo2
->from
;
7804 return str2
!= NULL
;
7809 res
= g_utf8_collate(str1
, str2
);
7810 return (res
!= 0)? res
: summary_cmp_by_date(clist
, ptr1
, ptr2
);
7813 static gint
summary_cmp_by_to(GtkCMCList
*clist
, gconstpointer ptr1
,
7816 const gchar
*str1
, *str2
;
7817 const GtkCMCListRow
*r1
= (const GtkCMCListRow
*) ptr1
;
7818 const GtkCMCListRow
*r2
= (const GtkCMCListRow
*) ptr2
;
7819 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7820 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7821 const SummaryView
*sv
= g_object_get_data(G_OBJECT(clist
), "summaryview");
7823 cm_return_val_if_fail(sv
, -1);
7825 if (sv
->col_state
[sv
->col_pos
[S_COL_TO
]].visible
) {
7826 str1
= GTK_CMCELL_TEXT(r1
->cell
[sv
->col_pos
[S_COL_TO
]])->text
;
7827 str2
= GTK_CMCELL_TEXT(r2
->cell
[sv
->col_pos
[S_COL_TO
]])->text
;
7829 str1
= msginfo1
->to
;
7830 str2
= msginfo2
->to
;
7834 return str2
!= NULL
;
7839 res
= g_utf8_collate(str1
, str2
);
7840 return (res
!= 0)? res
: summary_cmp_by_date(clist
, ptr1
, ptr2
);
7843 static gint
summary_cmp_by_tags(GtkCMCList
*clist
, gconstpointer ptr1
,
7847 const GtkCMCListRow
*r1
= (const GtkCMCListRow
*) ptr1
;
7848 const GtkCMCListRow
*r2
= (const GtkCMCListRow
*) ptr2
;
7849 const SummaryView
*sv
= g_object_get_data(G_OBJECT(clist
), "summaryview");
7850 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7851 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7853 cm_return_val_if_fail(sv
, -1);
7855 if (sv
->col_state
[sv
->col_pos
[S_COL_TAGS
]].visible
) {
7856 str1
= g_strdup(GTK_CMCELL_TEXT(r1
->cell
[sv
->col_pos
[S_COL_TAGS
]])->text
);
7857 str2
= g_strdup(GTK_CMCELL_TEXT(r2
->cell
[sv
->col_pos
[S_COL_TAGS
]])->text
);
7859 str1
= procmsg_msginfo_get_tags_str(msginfo1
);
7860 str2
= procmsg_msginfo_get_tags_str(msginfo2
);
7864 res
= (str2
!= NULL
);
7873 res
= g_utf8_collate(str1
, str2
);
7876 return (res
!= 0)? res
: summary_cmp_by_date(clist
, ptr1
, ptr2
);
7879 static gint summary_cmp_by_simplified_subject
7880 (GtkCMCList
*clist
, gconstpointer ptr1
, gconstpointer ptr2
)
7882 const FolderItemPrefs
*prefs
;
7883 const gchar
*str1
, *str2
;
7884 const GtkCMCListRow
*r1
= (const GtkCMCListRow
*) ptr1
;
7885 const GtkCMCListRow
*r2
= (const GtkCMCListRow
*) ptr2
;
7886 const MsgInfo
*msginfo1
= r1
->data
;
7887 const MsgInfo
*msginfo2
= r2
->data
;
7888 const SummaryView
*sv
= g_object_get_data(G_OBJECT(clist
), "summaryview");
7891 cm_return_val_if_fail(sv
, -1);
7892 cm_return_val_if_fail(msginfo1
!= NULL
&& msginfo2
!= NULL
, -1);
7894 if (sv
->col_state
[sv
->col_pos
[S_COL_SUBJECT
]].visible
) {
7895 str1
= GTK_CMCELL_TEXT(r1
->cell
[sv
->col_pos
[S_COL_SUBJECT
]])->text
;
7896 str2
= GTK_CMCELL_TEXT(r2
->cell
[sv
->col_pos
[S_COL_SUBJECT
]])->text
;
7898 str1
= msginfo1
->subject
;
7899 str2
= msginfo2
->subject
;
7903 return str2
!= NULL
;
7908 prefs
= msginfo1
->folder
->prefs
;
7910 prefs
= msginfo2
->folder
->prefs
;
7914 res
= subject_compare_for_sort(str1
, str2
);
7915 return (res
!= 0)? res
: summary_cmp_by_date(clist
, ptr1
, ptr2
);
7918 static gint
summary_cmp_by_score(GtkCMCList
*clist
,
7919 gconstpointer ptr1
, gconstpointer ptr2
)
7921 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7922 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7925 /* if score are equal, sort by date */
7927 diff
= msginfo1
->score
- msginfo2
->score
;
7931 return summary_cmp_by_date(clist
, ptr1
, ptr2
);
7934 static void summary_ignore_thread_func_mark_unread(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
7938 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
7939 cm_return_if_fail(msginfo
);
7941 summary_msginfo_unset_flags(msginfo
, MSG_WATCH_THREAD
, 0);
7942 summary_msginfo_change_flags(msginfo
, MSG_IGNORE_THREAD
, 0, MSG_NEW
| MSG_UNREAD
, 0);
7944 debug_print("Message %d is marked as ignore thread\n", msginfo
->msgnum
);
7947 static void summary_ignore_thread_func_set_row(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
7949 SummaryView
*summaryview
= (SummaryView
*) data
;
7952 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
7953 cm_return_if_fail(msginfo
);
7955 summary_set_row_marks(summaryview
, row
);
7956 debug_print("Message %d update in row view\n", msginfo
->msgnum
);
7959 void summary_ignore_thread(SummaryView
*summaryview
)
7961 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
7963 gboolean froze
= FALSE
;
7965 START_LONG_OPERATION(summaryview
, FALSE
);
7966 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
7967 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
7968 GTK_CMCTREE_FUNC(summary_ignore_thread_func_mark_unread
),
7971 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
7972 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
7973 GTK_CMCTREE_FUNC(summary_ignore_thread_func_set_row
),
7976 END_LONG_OPERATION(summaryview
);
7978 summary_status_show(summaryview
);
7981 static void summary_unignore_thread_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
7983 SummaryView
*summaryview
= (SummaryView
*) data
;
7986 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
7987 cm_return_if_fail(msginfo
);
7989 summary_msginfo_unset_flags(msginfo
, MSG_IGNORE_THREAD
, 0);
7991 summary_set_row_marks(summaryview
, row
);
7992 debug_print("Message %d is marked as unignore thread\n",
7996 void summary_unignore_thread(SummaryView
*summaryview
)
7998 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
8000 gboolean froze
= FALSE
;
8002 START_LONG_OPERATION(summaryview
, FALSE
);
8003 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
8004 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
8005 GTK_CMCTREE_FUNC(summary_unignore_thread_func
),
8008 END_LONG_OPERATION(summaryview
);
8010 summary_status_show(summaryview
);
8013 static void summary_check_ignore_thread_func
8014 (GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
8017 gint
*found_ignore
= (gint
*) data
;
8019 if (*found_ignore
) return;
8021 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
8022 *found_ignore
= msginfo
&& MSG_IS_IGNORE_THREAD(msginfo
->flags
);
8026 void summary_toggle_ignore_thread(SummaryView
*summaryview
)
8028 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
8030 gint found_ignore
= 0;
8032 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
8033 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
8034 GTK_CMCTREE_FUNC(summary_check_ignore_thread_func
),
8038 summary_unignore_thread(summaryview
);
8040 summary_ignore_thread(summaryview
);
8043 static void summary_watch_thread_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
8045 SummaryView
*summaryview
= (SummaryView
*) data
;
8048 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
8049 cm_return_if_fail(msginfo
);
8051 summary_msginfo_change_flags(msginfo
, MSG_WATCH_THREAD
, 0, MSG_IGNORE_THREAD
, 0);
8053 summary_set_row_marks(summaryview
, row
);
8054 debug_print("Message %d is marked as watch thread\n",
8058 void summary_watch_thread(SummaryView
*summaryview
)
8060 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
8062 gboolean froze
= FALSE
;
8064 START_LONG_OPERATION(summaryview
, FALSE
);
8065 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
8066 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
8067 GTK_CMCTREE_FUNC(summary_watch_thread_func
),
8070 END_LONG_OPERATION(summaryview
);
8072 summary_status_show(summaryview
);
8075 static void summary_unwatch_thread_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
8077 SummaryView
*summaryview
= (SummaryView
*) data
;
8080 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
8081 cm_return_if_fail(msginfo
);
8083 summary_msginfo_unset_flags(msginfo
, MSG_WATCH_THREAD
, 0);
8085 summary_set_row_marks(summaryview
, row
);
8086 debug_print("Message %d is marked as unwatch thread\n",
8090 void summary_unwatch_thread(SummaryView
*summaryview
)
8092 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
8094 gboolean froze
= FALSE
;
8096 START_LONG_OPERATION(summaryview
, FALSE
);
8097 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
8098 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
8099 GTK_CMCTREE_FUNC(summary_unwatch_thread_func
),
8102 END_LONG_OPERATION(summaryview
);
8104 summary_status_show(summaryview
);
8107 static void summary_check_watch_thread_func
8108 (GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
8111 gint
*found_watch
= (gint
*) data
;
8113 if (*found_watch
) return;
8115 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
8116 *found_watch
= msginfo
&& MSG_IS_WATCH_THREAD(msginfo
->flags
);
8120 void summary_toggle_watch_thread(SummaryView
*summaryview
)
8122 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
8124 gint found_watch
= 0;
8126 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
8127 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
8128 GTK_CMCTREE_FUNC(summary_check_watch_thread_func
),
8132 summary_unwatch_thread(summaryview
);
8134 summary_watch_thread(summaryview
);
8138 void summary_toggle_show_read_messages(SummaryView
*summaryview
)
8140 FolderItemUpdateData source
;
8141 if (summaryview
->folder_item
->hide_read_msgs
)
8142 summaryview
->folder_item
->hide_read_msgs
= 0;
8144 summaryview
->folder_item
->hide_read_msgs
= 1;
8146 source
.item
= summaryview
->folder_item
;
8147 source
.update_flags
= F_ITEM_UPDATE_NAME
;
8149 hooks_invoke(FOLDER_ITEM_UPDATE_HOOKLIST
, &source
);
8150 summary_show(summaryview
, summaryview
->folder_item
, FALSE
);
8153 void summary_toggle_show_del_messages(SummaryView
*summaryview
)
8155 FolderItemUpdateData source
;
8156 if (summaryview
->folder_item
->hide_del_msgs
)
8157 summaryview
->folder_item
->hide_del_msgs
= 0;
8159 summaryview
->folder_item
->hide_del_msgs
= 1;
8161 source
.item
= summaryview
->folder_item
;
8162 source
.update_flags
= F_ITEM_UPDATE_NAME
;
8164 hooks_invoke(FOLDER_ITEM_UPDATE_HOOKLIST
, &source
);
8165 summary_show(summaryview
, summaryview
->folder_item
, FALSE
);
8168 void summary_toggle_show_read_threads(SummaryView
*summaryview
)
8170 FolderItemUpdateData source
;
8171 if (summaryview
->folder_item
->hide_read_threads
)
8172 summaryview
->folder_item
->hide_read_threads
= 0;
8174 summaryview
->folder_item
->hide_read_threads
= 1;
8176 source
.item
= summaryview
->folder_item
;
8177 source
.update_flags
= F_ITEM_UPDATE_NAME
;
8179 hooks_invoke(FOLDER_ITEM_UPDATE_HOOKLIST
, &source
);
8180 summary_show(summaryview
, summaryview
->folder_item
, FALSE
);
8183 static void summary_set_hide_menu (SummaryView
*summaryview
,
8184 const gchar
*menu_item
,
8189 widget
= gtk_ui_manager_get_widget(summaryview
->mainwin
->ui_manager
, menu_item
);
8190 cm_return_if_fail(widget
!= NULL
);
8192 g_object_set_data(G_OBJECT(widget
), "dont_toggle",
8193 GINT_TO_POINTER(1));
8194 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(widget
), action
);
8195 g_object_set_data(G_OBJECT(widget
), "dont_toggle",
8196 GINT_TO_POINTER(0));
8199 void summary_reflect_prefs_pixmap_theme(SummaryView
*summaryview
)
8203 stock_pixbuf_gdk(STOCK_PIXMAP_MARK
, &markxpm
);
8204 stock_pixbuf_gdk(STOCK_PIXMAP_DELETED
, &deletedxpm
);
8205 stock_pixbuf_gdk(STOCK_PIXMAP_NEW
, &newxpm
);
8206 stock_pixbuf_gdk(STOCK_PIXMAP_UNREAD
, &unreadxpm
);
8207 stock_pixbuf_gdk(STOCK_PIXMAP_REPLIED
, &repliedxpm
);
8208 stock_pixbuf_gdk(STOCK_PIXMAP_FORWARDED
, &forwardedxpm
);
8209 stock_pixbuf_gdk(STOCK_PIXMAP_REPLIED_AND_FORWARDED
, &repliedandforwardedxpm
);
8210 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP
, &clipxpm
);
8211 stock_pixbuf_gdk(STOCK_PIXMAP_LOCKED
, &lockedxpm
);
8212 stock_pixbuf_gdk(STOCK_PIXMAP_IGNORETHREAD
, &ignorethreadxpm
);
8213 stock_pixbuf_gdk(STOCK_PIXMAP_WATCHTHREAD
, &watchthreadxpm
);
8214 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP_KEY
, &clipkeyxpm
);
8215 stock_pixbuf_gdk(STOCK_PIXMAP_KEY
, &keyxpm
);
8216 stock_pixbuf_gdk(STOCK_PIXMAP_KEY_SIGN
, &keysignxpm
);
8217 stock_pixbuf_gdk(STOCK_PIXMAP_GPG_SIGNED
, &gpgsignedxpm
);
8218 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP_GPG_SIGNED
, &clipgpgsignedxpm
);
8219 stock_pixbuf_gdk(STOCK_PIXMAP_SPAM
, &spamxpm
);
8220 stock_pixbuf_gdk(STOCK_PIXMAP_MOVED
, &movedxpm
);
8221 stock_pixbuf_gdk(STOCK_PIXMAP_COPIED
, &copiedxpm
);
8223 summary_set_folder_pixmap(summaryview
, STOCK_PIXMAP_DIR_OPEN
);
8225 pixmap
= stock_pixmap_widget(STOCK_PIXMAP_QUICKSEARCH
);
8226 gtk_container_remove (GTK_CONTAINER(summaryview
->toggle_search
),
8227 summaryview
->quick_search_pixmap
);
8228 gtk_container_add(GTK_CONTAINER(summaryview
->toggle_search
), pixmap
);
8229 gtk_widget_show(pixmap
);
8230 summaryview
->quick_search_pixmap
= pixmap
;
8233 pixmap
= stock_pixmap_widget(STOCK_PIXMAP_SELECTION
);
8234 gtk_container_remove (GTK_CONTAINER(summaryview
->multiple_sel_togbtn
),
8235 summaryview
->multiple_sel_image
);
8236 gtk_container_add(GTK_CONTAINER(summaryview
->multiple_sel_togbtn
), pixmap
);
8237 gtk_widget_show(pixmap
);
8238 summaryview
->multiple_sel_togbtn
= pixmap
;
8241 folderview_unselect(summaryview
->folderview
);
8242 folderview_select(summaryview
->folderview
, summaryview
->folder_item
);
8243 summary_set_column_titles(summaryview
);
8246 void summary_reflect_prefs_custom_colors(SummaryView
*summaryview
)
8249 GList
*children
, *cur
;
8251 /* re-create colorlabel submenu */
8252 menu
= GTK_MENU_SHELL(summaryview
->colorlabel_menu
);
8253 cm_return_if_fail(menu
!= NULL
);
8255 /* clear items. get item pointers. */
8256 children
= gtk_container_get_children(GTK_CONTAINER(menu
));
8257 for (cur
= children
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
8258 g_signal_handlers_disconnect_matched
8259 (gtk_ui_manager_get_accel_group(summaryview
->mainwin
->ui_manager
),
8260 G_SIGNAL_MATCH_DATA
|G_SIGNAL_MATCH_FUNC
,
8261 0, 0, NULL
, mainwin_accel_changed_cb
, cur
->data
);
8262 gtk_menu_item_set_submenu(GTK_MENU_ITEM(cur
->data
), NULL
);
8264 g_list_free(children
);
8265 summary_colorlabel_menu_create(summaryview
, TRUE
);
8269 * Harvest addresses for selected messages in summary view.
8271 void summary_harvest_address(SummaryView
*summaryview
)
8273 GtkCMCTree
*ctree
= GTK_CMCTREE( summaryview
->ctree
);
8279 for( cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
8280 msginfo
= gtk_cmctree_node_get_row_data( ctree
, GTK_CMCTREE_NODE(cur
->data
) );
8283 msgList
= g_list_append( msgList
, GUINT_TO_POINTER( msginfo
->msgnum
) );
8286 addressbook_harvest( summaryview
->folder_item
, TRUE
, msgList
);
8288 g_list_free( msgList
);
8291 static regex_t
*summary_compile_simplify_regexp(gchar
*simplify_subject_regexp
)
8294 gchar buf
[BUFFSIZE
];
8295 regex_t
*preg
= NULL
;
8297 preg
= g_new0(regex_t
, 1);
8299 err
= regcomp(preg
, simplify_subject_regexp
, REG_EXTENDED
);
8301 regerror(err
, preg
, buf
, BUFFSIZE
);
8302 alertpanel_error(_("Regular expression (regexp) error:\n%s"), buf
);
8310 void summary_set_prefs_from_folderitem(SummaryView
*summaryview
, FolderItem
*item
)
8312 FolderSortKey sort_key
;
8313 FolderSortType sort_type
;
8314 cm_return_if_fail(summaryview
!= NULL
);
8315 cm_return_if_fail(item
!= NULL
);
8317 /* Subject simplification */
8318 if(summaryview
->simplify_subject_preg
) {
8319 regfree(summaryview
->simplify_subject_preg
);
8320 g_free(summaryview
->simplify_subject_preg
);
8321 summaryview
->simplify_subject_preg
= NULL
;
8323 if(item
->prefs
&& item
->prefs
->simplify_subject_regexp
&&
8324 item
->prefs
->simplify_subject_regexp
[0] && item
->prefs
->enable_simplify_subject
)
8325 summaryview
->simplify_subject_preg
= summary_compile_simplify_regexp(item
->prefs
->simplify_subject_regexp
);
8328 sort_key
= item
->sort_key
;
8329 sort_type
= item
->sort_type
;
8331 folder_get_sort_type(item
->folder
, &sort_key
, &sort_type
);
8333 summaryview
->sort_key
= sort_key
;
8334 summaryview
->sort_type
= sort_type
;
8337 summaryview
->threaded
= item
->threaded
;
8338 summaryview
->thread_collapsed
= item
->thread_collapsed
;
8343 void summary_save_prefs_to_folderitem(SummaryView
*summaryview
, FolderItem
*item
)
8346 item
->sort_key
= summaryview
->sort_key
;
8347 item
->sort_type
= summaryview
->sort_type
;
8350 item
->threaded
= summaryview
->threaded
;
8351 item
->thread_collapsed
= summaryview
->thread_collapsed
;
8354 static gboolean
summary_update_msg(gpointer source
, gpointer data
)
8356 MsgInfoUpdate
*msginfo_update
= (MsgInfoUpdate
*) source
;
8357 SummaryView
*summaryview
= (SummaryView
*)data
;
8358 GtkCMCTreeNode
*node
;
8360 cm_return_val_if_fail(msginfo_update
!= NULL
, TRUE
);
8361 cm_return_val_if_fail(summaryview
!= NULL
, FALSE
);
8363 if (msginfo_update
->msginfo
->folder
!= summaryview
->folder_item
)
8366 if (msginfo_update
->flags
& MSGINFO_UPDATE_FLAGS
) {
8367 node
= gtk_cmctree_find_by_row_data(
8368 GTK_CMCTREE(summaryview
->ctree
), NULL
,
8369 msginfo_update
->msginfo
);
8372 summary_set_row_marks(summaryview
, node
);
8378 void summary_update_unread(SummaryView
*summaryview
, FolderItem
*removed_item
)
8380 guint
new, unread
, unreadmarked
, marked
, total
;
8381 guint replied
, forwarded
, locked
, ignored
, watched
;
8382 static gboolean tips_initialized
= FALSE
;
8384 if (prefs_common
.layout_mode
!= SMALL_LAYOUT
) {
8385 if (tips_initialized
) {
8386 summary_set_folder_pixmap(summaryview
, STOCK_PIXMAP_DIR_OPEN
);
8387 CLAWS_SET_TIP(summaryview
->folder_pixmap_eventbox
,
8389 tips_initialized
= FALSE
;
8393 folder_count_total_msgs(&new, &unread
, &unreadmarked
, &marked
, &total
,
8394 &replied
, &forwarded
, &locked
, &ignored
,
8397 total
-= removed_item
->total_msgs
;
8398 new -= removed_item
->new_msgs
;
8399 unread
-= removed_item
->unread_msgs
;
8402 if (new > 0 || unread
> 0) {
8403 tips_initialized
= TRUE
;
8404 summary_set_folder_pixmap(summaryview
, STOCK_PIXMAP_DIR_OPEN_HRM
);
8405 CLAWS_SET_TIP(summaryview
->folder_pixmap_eventbox
,
8406 _("Go back to the folder list (You have unread messages)"));
8408 tips_initialized
= TRUE
;
8409 summary_set_folder_pixmap(summaryview
, STOCK_PIXMAP_DIR_OPEN
);
8410 CLAWS_SET_TIP(summaryview
->folder_pixmap_eventbox
,
8411 _("Go back to the folder list"));
8415 static gboolean
summary_update_folder_item_hook(gpointer source
, gpointer data
)
8417 FolderItemUpdateData
*hookdata
= (FolderItemUpdateData
*)source
;
8418 SummaryView
*summaryview
= (SummaryView
*)data
;
8420 cm_return_val_if_fail(hookdata
!= NULL
, FALSE
);
8421 cm_return_val_if_fail(hookdata
->item
!= NULL
, FALSE
);
8422 cm_return_val_if_fail(summaryview
!= NULL
, FALSE
);
8424 if (hookdata
->item
== summaryview
->folder_item
&&
8425 hookdata
->update_flags
& F_ITEM_UPDATE_NAME
) {
8426 gchar
*name
= folder_item_get_name(hookdata
->item
);
8427 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_folder
), name
);
8430 summary_update_unread(summaryview
, NULL
);
8435 static gboolean
summary_update_folder_hook(gpointer source
, gpointer data
)
8437 FolderUpdateData
*hookdata
;
8438 SummaryView
*summaryview
= (SummaryView
*)data
;
8440 if (hookdata
->update_flags
& FOLDER_REMOVE_FOLDERITEM
) {
8441 summary_update_unread(summaryview
, hookdata
->item
);
8443 summary_update_unread(summaryview
, NULL
);
8449 *\brief change summaryview to display your answer(s) to a message
8451 *\param summaryview The SummaryView ;)
8452 *\param msginfo The message for which answers are searched
8455 static void summary_find_answers (SummaryView
*summaryview
, MsgInfo
*msg
)
8457 FolderItem
*sent_folder
= NULL
;
8458 PrefsAccount
*account
= NULL
;
8459 GtkCMCTreeNode
*node
= NULL
;
8461 if (msg
== NULL
|| msg
->msgid
== NULL
)
8464 account
= account_get_reply_account(msg
, prefs_common
.reply_account_autosel
);
8465 if (account
== NULL
)
8467 sent_folder
= account_get_special_folder
8468 (account
, F_OUTBOX
);
8470 buf
= g_strdup_printf("inreplyto matchcase \"%s\"", msg
->msgid
);
8472 if (sent_folder
!= summaryview
->folder_item
) {
8473 folderview_select(summaryview
->mainwin
->folderview
, sent_folder
);
8476 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(summaryview
->toggle_search
), TRUE
);
8478 quicksearch_set(summaryview
->quicksearch
, ADVANCED_SEARCH_EXTENDED
, buf
);
8481 node
= gtk_cmctree_node_nth(GTK_CMCTREE(summaryview
->ctree
), 0);
8483 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_SEARCH_RESULTS
);
8486 gint
summaryview_export_mbox_list(SummaryView
*summaryview
)
8487 /* return values: -2 skipped, -1 error, 0 OK */
8489 GSList
*list
= summary_get_selected_msg_list(summaryview
);
8490 gchar
*mbox
= filesel_select_file_save(_("Export to mbox file"), NULL
);
8498 ret
= export_list_to_mbox(list
, mbox
);
8506 static void summary_reedit_cb(GtkAction
*gaction
, gpointer data
)
8508 SummaryView
*summaryview
= (SummaryView
*)data
;
8509 summary_reedit(summaryview
);
8512 #define DO_ACTION(name, act) { if (!strcmp(a_name, name)) action = act; }
8513 static void summary_reply_cb(GtkAction
*gaction
, gpointer data
)
8515 SummaryView
*summaryview
= (SummaryView
*)data
;
8516 GSList
*msginfo_list
= NULL
;
8517 gint action
= COMPOSE_REPLY
;
8518 const gchar
*a_name
= gtk_action_get_name(gaction
);
8520 DO_ACTION("SummaryViewPopup/Reply", COMPOSE_REPLY
);
8521 DO_ACTION("SummaryViewPopup/ReplyTo/All", COMPOSE_REPLY_TO_ALL
);
8522 DO_ACTION("SummaryViewPopup/ReplyTo/Sender", COMPOSE_REPLY_TO_SENDER
);
8523 DO_ACTION("SummaryViewPopup/ReplyTo/List", COMPOSE_REPLY_TO_LIST
);
8524 DO_ACTION("SummaryViewPopup/Forward", COMPOSE_FORWARD_INLINE
);
8525 DO_ACTION("SummaryViewPopup/ForwardAtt", COMPOSE_FORWARD_AS_ATTACH
);
8526 DO_ACTION("SummaryViewPopup/Redirect", COMPOSE_REDIRECT
);
8528 msginfo_list
= summary_get_selection(summaryview
);
8529 cm_return_if_fail(msginfo_list
!= NULL
);
8530 compose_reply_from_messageview(NULL
, msginfo_list
, action
);
8531 g_slist_free(msginfo_list
);
8534 gboolean
summary_is_opened_message_selected(SummaryView
*summaryview
)
8538 cm_return_val_if_fail(summaryview
!= NULL
, FALSE
);
8540 sel
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
8542 if (summaryview
->displayed
== NULL
|| sel
== NULL
) {
8546 for ( ; sel
!= NULL
; sel
= sel
->next
) {
8547 if (summaryview
->displayed
== GTK_CMCTREE_NODE(sel
->data
)) {
8554 gboolean
summary_has_opened_message(SummaryView
*summaryview
)
8556 cm_return_val_if_fail(summaryview
!= NULL
, FALSE
);
8558 return (summaryview
->displayed
!= NULL
);
8561 static void summary_header_lock_sorting_cb(GtkAction
*gaction
, gpointer data
)
8563 SummaryView
*summaryview
= (SummaryView
*)data
;
8564 gboolean sorting_lock
= prefs_common_get_prefs()->summary_col_lock
;
8566 if (summaryview
->header_menu_lock
)
8569 debug_print("%slocking summaryview columns\n",
8570 sorting_lock
? "un" : "");
8571 prefs_common_get_prefs()->summary_col_lock
= !sorting_lock
;
8574 static void summary_header_set_displayed_columns_cb(GtkAction
*gaction
,
8577 SummaryView
*summaryview
= (SummaryView
*)data
;
8579 if (summaryview
->header_menu_lock
)
8582 prefs_summary_column_open();