2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team
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/>.
22 #include <glib/gi18n.h>
23 #include <gdk/gdkkeysyms.h>
34 #include "mainwindow.h"
35 #include "folderview.h"
36 #include "summaryview.h"
37 #include "messageview.h"
39 #include "foldersel.h"
41 #include "procheader.h"
42 #include "sourcewindow.h"
43 #include "prefs_common.h"
44 #include "prefs_summary_column.h"
45 #include "prefs_summary_open.h"
46 #include "prefs_filtering.h"
49 #include "file-utils.h"
52 #include "stock_pixmap.h"
54 #include "alertpanel.h"
55 #include "inputdialog.h"
56 #include "statusbar.h"
58 #include "colorlabel.h"
61 #ifndef USE_ALT_ADDRBOOK
62 #include "addressbook.h"
64 #include "addressbook-dbus.h"
65 #include "addressadd.h"
67 #include "addr_compl.h"
68 #include "folder_item_prefs.h"
69 #include "filtering.h"
70 #include "string_match.h"
74 #include "description_window.h"
75 #include "folderutils.h"
76 #include "quicksearch.h"
77 #include "partial_download.h"
83 #include "manage_window.h"
86 #define SUMMARY_COL_MARK_WIDTH 10
87 #define SUMMARY_COL_STATUS_WIDTH 13
88 #define SUMMARY_COL_LOCKED_WIDTH 13
89 #define SUMMARY_COL_MIME_WIDTH 11
91 static int normal_row_height
= -1;
92 static GtkStyle
*bold_style
;
93 static GtkStyle
*bold_marked_style
;
94 static GtkStyle
*bold_deleted_style
;
95 static GtkStyle
*small_style
;
96 static GtkStyle
*small_marked_style
;
97 static GtkStyle
*small_deleted_style
;
99 static GdkPixbuf
*markxpm
;
100 static GdkPixbuf
*deletedxpm
;
101 static GdkPixbuf
*movedxpm
;
102 static GdkPixbuf
*copiedxpm
;
104 static GdkPixbuf
*newxpm
;
105 static GdkPixbuf
*unreadxpm
;
106 static GdkPixbuf
*repliedxpm
;
107 static GdkPixbuf
*forwardedxpm
;
108 static GdkPixbuf
*repliedandforwardedxpm
;
109 static GdkPixbuf
*ignorethreadxpm
;
110 static GdkPixbuf
*watchthreadxpm
;
111 static GdkPixbuf
*lockedxpm
;
112 static GdkPixbuf
*spamxpm
;
114 static GdkPixbuf
*clipxpm
;
115 static GdkPixbuf
*keyxpm
;
116 static GdkPixbuf
*clipkeyxpm
;
117 static GdkPixbuf
*keysignxpm
;
118 static GdkPixbuf
*gpgsignedxpm
;
119 static GdkPixbuf
*clipgpgsignedxpm
;
121 static void summary_free_msginfo_func (GtkCMCTree
*ctree
,
122 GtkCMCTreeNode
*node
,
124 static void summary_set_marks_func (GtkCMCTree
*ctree
,
125 GtkCMCTreeNode
*node
,
128 void summary_set_menu_sensitive (SummaryView
*summaryview
);
129 guint
summary_get_msgnum (SummaryView
*summaryview
,
130 GtkCMCTreeNode
*node
);
133 static void summary_set_hide_menu (SummaryView
*summaryview
,
134 const gchar
*menu_item
,
137 static GtkCMCTreeNode
*summary_find_prev_msg
138 (SummaryView
*summaryview
,
139 GtkCMCTreeNode
*current_node
,
140 gboolean start_from_prev
);
141 static GtkCMCTreeNode
*summary_find_next_msg
142 (SummaryView
*summaryview
,
143 GtkCMCTreeNode
*current_node
,
144 gboolean start_from_next
);
146 static GtkCMCTreeNode
*summary_find_prev_flagged_msg
147 (SummaryView
*summaryview
,
148 GtkCMCTreeNode
*current_node
,
150 gboolean start_from_prev
);
151 static GtkCMCTreeNode
*summary_find_next_flagged_msg
152 (SummaryView
*summaryview
,
153 GtkCMCTreeNode
*current_node
,
155 gboolean start_from_next
);
157 static GtkCMCTreeNode
*summary_find_msg_by_msgnum
158 (SummaryView
*summaryview
,
161 static void summary_update_status (SummaryView
*summaryview
);
163 /* display functions */
164 static void summary_status_show (SummaryView
*summaryview
);
165 static void summary_set_column_titles (SummaryView
*summaryview
);
166 static void summary_set_ctree_from_list (SummaryView
*summaryview
,
168 guint selected_msgnum
);
169 static inline void summary_set_header (SummaryView
*summaryview
,
172 static void summary_display_msg (SummaryView
*summaryview
,
173 GtkCMCTreeNode
*row
);
174 static void summary_display_msg_full (SummaryView
*summaryview
,
177 gboolean all_headers
);
178 static void summary_set_row_marks (SummaryView
*summaryview
,
179 GtkCMCTreeNode
*row
);
181 static gboolean
summary_set_row_tag (SummaryView
*summaryview
,
186 /* message handling */
187 static void summary_mark_row (SummaryView
*summaryview
,
188 GtkCMCTreeNode
*row
);
189 static void summary_lock_row (SummaryView
*summaryview
,
190 GtkCMCTreeNode
*row
);
191 static void summary_unlock_row (SummaryView
*summaryview
,
192 GtkCMCTreeNode
*row
);
193 static void summary_mark_row_as_read (SummaryView
*summaryview
,
194 GtkCMCTreeNode
*row
);
195 static void summary_mark_row_as_unread (SummaryView
*summaryview
,
196 GtkCMCTreeNode
*row
);
197 static gboolean
summary_mark_all_read_confirm(gboolean ask_if_needed
);
198 static gboolean
summary_mark_all_unread_confirm(gboolean ask_if_needed
);
199 static void summary_delete_row (SummaryView
*summaryview
,
200 GtkCMCTreeNode
*row
);
201 static void summary_unmark_row (SummaryView
*summaryview
,
202 GtkCMCTreeNode
*row
);
203 static void summary_move_row_to (SummaryView
*summaryview
,
205 FolderItem
*to_folder
);
206 static void summary_copy_row_to (SummaryView
*summaryview
,
208 FolderItem
*to_folder
);
210 static gint
summary_execute_move (SummaryView
*summaryview
);
211 static void summary_execute_move_func (GtkCMCTree
*ctree
,
212 GtkCMCTreeNode
*node
,
214 static void summary_execute_copy (SummaryView
*summaryview
);
215 static void summary_execute_copy_func (GtkCMCTree
*ctree
,
216 GtkCMCTreeNode
*node
,
218 static void summary_execute_delete (SummaryView
*summaryview
);
219 static void summary_execute_delete_func (GtkCMCTree
*ctree
,
220 GtkCMCTreeNode
*node
,
222 static void summary_execute_expunge (SummaryView
*summaryview
);
224 static void summary_thread_init (SummaryView
*summaryview
);
226 static void summary_unthread_for_exec (SummaryView
*summaryview
);
227 static void summary_unthread_for_exec_func (GtkCMCTree
*ctree
,
228 GtkCMCTreeNode
*node
,
231 void summary_simplify_subject(SummaryView
*summaryview
, gchar
* rexp
,
234 static void summary_filter_func (MsgInfo
*msginfo
);
236 static void summary_colorlabel_menu_item_activate_cb
239 static void summary_colorlabel_menu_item_activate_item_cb
240 (GtkMenuItem
*label_menu_item
,
242 static void summary_colorlabel_menu_create(SummaryView
*summaryview
,
244 static void summary_tags_menu_item_activate_cb
247 static void summary_tags_menu_item_activate_item_cb
248 (GtkMenuItem
*label_menu_item
,
250 static void summary_tags_menu_create(SummaryView
*summaryview
,
253 static GtkWidget
*summary_ctree_create (SummaryView
*summaryview
);
255 /* callback functions */
256 static gint
summary_toggle_pressed (GtkWidget
*eventbox
,
257 GdkEventButton
*event
,
258 SummaryView
*summaryview
);
260 static void summary_toggle_multiple_pressed
262 SummaryView
*summaryview
);
264 static gint summary_folder_eventbox_pressed
265 (GtkWidget
*eventbox
,
266 GdkEventButton
*event
,
267 SummaryView
*summaryview
);
268 static gboolean
summary_button_pressed (GtkWidget
*ctree
,
269 GdkEventButton
*event
,
270 SummaryView
*summaryview
);
271 static gboolean
summary_button_released (GtkWidget
*ctree
,
272 GdkEventButton
*event
,
273 SummaryView
*summaryview
);
274 static gboolean
summary_key_pressed (GtkWidget
*ctree
,
276 SummaryView
*summaryview
);
277 static void summary_tree_expanded (GtkCMCTree
*ctree
,
278 GtkCMCTreeNode
*node
,
279 SummaryView
*summaryview
);
280 static void summary_tree_collapsed (GtkCMCTree
*ctree
,
281 GtkCMCTreeNode
*node
,
282 SummaryView
*summaryview
);
283 static void summary_selected (GtkCMCTree
*ctree
,
286 SummaryView
*summaryview
);
287 static void summary_unselected (GtkCMCTree
*ctree
,
290 SummaryView
*summaryview
);
291 static void summary_col_resized (GtkCMCList
*clist
,
294 SummaryView
*summaryview
);
295 static void summary_mark_clicked (GtkWidget
*button
,
296 SummaryView
*summaryview
);
297 static void summary_status_clicked (GtkWidget
*button
,
298 SummaryView
*summaryview
);
299 static void summary_mime_clicked (GtkWidget
*button
,
300 SummaryView
*summaryview
);
301 static void summary_num_clicked (GtkWidget
*button
,
302 SummaryView
*summaryview
);
303 static void summary_score_clicked (GtkWidget
*button
,
304 SummaryView
*summaryview
);
305 static void summary_size_clicked (GtkWidget
*button
,
306 SummaryView
*summaryview
);
307 static void summary_date_clicked (GtkWidget
*button
,
308 SummaryView
*summaryview
);
309 static void summary_from_clicked (GtkWidget
*button
,
310 SummaryView
*summaryview
);
311 static void summary_to_clicked (GtkWidget
*button
,
312 SummaryView
*summaryview
);
313 static void summary_subject_clicked (GtkWidget
*button
,
314 SummaryView
*summaryview
);
315 static void summary_score_clicked (GtkWidget
*button
,
316 SummaryView
*summaryview
);
317 static void summary_locked_clicked (GtkWidget
*button
,
318 SummaryView
*summaryview
);
319 static void summary_tags_clicked (GtkWidget
*button
,
320 SummaryView
*summaryview
);
322 static void summary_start_drag (GtkWidget
*widget
,
325 SummaryView
*summaryview
);
326 static void summary_drag_data_get (GtkWidget
*widget
,
327 GdkDragContext
*drag_context
,
328 GtkSelectionData
*selection_data
,
331 SummaryView
*summaryview
);
332 static void summary_drag_data_received(GtkWidget
*widget
,
333 GdkDragContext
*drag_context
,
336 GtkSelectionData
*data
,
339 SummaryView
*summaryview
);
340 static gboolean
summary_drag_motion_cb(GtkWidget
*widget
,
341 GdkDragContext
*context
,
345 SummaryView
*summaryview
);
346 static void summary_drag_end(GtkWidget
*widget
,
347 GdkDragContext
*drag_context
,
348 SummaryView
*summaryview
);
350 /* custom compare functions for sorting */
351 static gint
summary_cmp_by_mark (GtkCMCList
*clist
,
354 static gint
summary_cmp_by_status (GtkCMCList
*clist
,
357 static gint
summary_cmp_by_mime (GtkCMCList
*clist
,
360 static gint
summary_cmp_by_num (GtkCMCList
*clist
,
363 static gint
summary_cmp_by_size (GtkCMCList
*clist
,
366 static gint
summary_cmp_by_date (GtkCMCList
*clist
,
369 static gint
summary_cmp_by_thread_date (GtkCMCList
*clist
,
372 static gint
summary_cmp_by_from (GtkCMCList
*clist
,
375 static gint summary_cmp_by_simplified_subject
379 static gint
summary_cmp_by_score (GtkCMCList
*clist
,
382 static gint
summary_cmp_by_label (GtkCMCList
*clist
,
385 static gint
summary_cmp_by_to (GtkCMCList
*clist
,
388 static gint
summary_cmp_by_subject (GtkCMCList
*clist
,
391 static gint
summary_cmp_by_locked (GtkCMCList
*clist
,
394 static gint
summary_cmp_by_tags (GtkCMCList
*clist
,
398 static void quicksearch_execute_cb (QuickSearch
*quicksearch
,
401 static void tog_searchbar_cb (GtkWidget
*w
,
404 static void summary_find_answers (SummaryView
*summaryview
,
407 static gboolean
summary_update_msg (gpointer source
, gpointer data
);
408 static gboolean
summary_update_folder_item_hook(gpointer source
, gpointer data
);
409 static gboolean
summary_update_folder_hook(gpointer source
, gpointer data
);
410 static void summary_set_colorlabel_color (GtkCMCTree
*ctree
,
411 GtkCMCTreeNode
*node
,
413 static void summary_thread_build(SummaryView
*summaryview
);
415 GtkTargetEntry summary_drag_types
[3] =
417 {"text/uri-list", 0, TARGET_MAIL_URI_LIST
},
418 {"claws-mail/internal", GTK_TARGET_SAME_APP
, TARGET_DUMMY
},
419 {"claws-mail/msg-path-list", 0, TARGET_MAIL_CM_PATH_LIST
},
422 static void summary_reply_cb(GtkAction
*gaction
, gpointer data
);
424 /* Only submenus and specifically-handled menu entries here */
425 static GtkActionEntry summary_popup_entries
[] =
427 {"SummaryViewPopup", NULL
, "SummaryViewPopup", NULL
, NULL
, NULL
},
428 {"SummaryViewPopup/Reply", NULL
, N_("_Reply"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_REPLY */
429 {"SummaryViewPopup/ReplyTo", NULL
, N_("Repl_y to"), NULL
, NULL
, NULL
},
430 {"SummaryViewPopup/ReplyTo/All", NULL
, N_("_All"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_REPLY_TO_ALL */
431 {"SummaryViewPopup/ReplyTo/Sender", NULL
, N_("_Sender"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_REPLY_TO_SENDER */
432 {"SummaryViewPopup/ReplyTo/List", NULL
, N_("Mailing _list"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_REPLY_TO_LIST */
434 {"SummaryViewPopup/Forward", NULL
, N_("_Forward"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_FORWARD_INLINE */
435 {"SummaryViewPopup/ForwardAtt", NULL
, N_("For_ward as attachment"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_FORWARD_AS_ATTACH */
436 {"SummaryViewPopup/Redirect", NULL
, N_("Redirec_t"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_REDIRECT */
437 {"SummaryViewPopup/Mark", NULL
, N_("_Mark"), NULL
, NULL
, NULL
},
438 {"SummaryViewPopup/ColorLabel", NULL
, N_("Color la_bel"), NULL
, NULL
, NULL
},
439 {"SummaryViewPopup/Tags", NULL
, N_("Ta_gs"), NULL
, NULL
, NULL
},
440 {"SummaryViewPopup/CreateFilterRule", NULL
, N_("Create _filter rule"), NULL
, NULL
, NULL
},
442 {"SummaryViewPopup/CreateProcessingRule", NULL
, N_("Create processing rule"), NULL
, NULL
, NULL
},
444 {"SummaryViewPopup/View", NULL
, N_("_View"), NULL
, NULL
, NULL
},
447 static const gchar
*const col_label
[N_SUMMARY_COLS
] = {
449 N_("S"), /* S_COL_STATUS */
451 N_("Subject"), /* S_COL_SUBJECT */
452 N_("From"), /* S_COL_FROM */
453 N_("To"), /* S_COL_TO */
454 N_("Date"), /* S_COL_DATE */
455 N_("Size"), /* S_COL_SIZE */
456 N_("#"), /* S_COL_NUMBER */
457 N_("Score"), /* S_COL_SCORE */
458 "", /* S_COL_LOCKED */
459 N_("Tags"), /* S_COL_TAGS */
462 void summary_freeze(SummaryView
*summaryview
)
465 gtk_cmclist_freeze(GTK_CMCLIST(summaryview
->ctree
));
468 void summary_thaw(SummaryView
*summaryview
)
471 gtk_cmclist_thaw(GTK_CMCLIST(summaryview
->ctree
));
474 void summary_thaw_with_status(SummaryView
*summaryview
)
477 summary_status_show(summaryview
);
478 gtk_cmclist_thaw(GTK_CMCLIST(summaryview
->ctree
));
482 void summary_grab_focus(SummaryView
*summaryview
)
485 gtk_widget_grab_focus(summaryview
->ctree
);
488 GtkWidget
*summary_get_main_widget(SummaryView
*summaryview
)
491 return summaryview
->ctree
;
496 #define START_LONG_OPERATION(summaryview,force_freeze) { \
497 summary_lock(summaryview); \
498 main_window_cursor_wait(summaryview->mainwin); \
499 if (force_freeze || sc_g_list_bigger(GTK_CMCLIST(summaryview->ctree)->selection, 1)) {\
501 summary_freeze(summaryview); \
503 folder_item_update_freeze(); \
505 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST, \
506 summaryview->msginfo_update_callback_id); \
508 #define END_LONG_OPERATION(summaryview) { \
510 folder_item_update_thaw(); \
512 summary_thaw(summaryview); \
513 main_window_cursor_normal(summaryview->mainwin); \
514 summary_unlock(summaryview); \
515 summaryview->msginfo_update_callback_id = \
516 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST, \
517 summary_update_msg, (gpointer) summaryview); \
520 SummaryView
*summary_create(MainWindow
*mainwin
)
522 SummaryView
*summaryview
;
524 GtkWidget
*scrolledwin
;
529 GtkWidget
*stat_box2
;
530 GtkWidget
*stat_vbox
;
531 GtkWidget
*statlabel_folder
;
532 GtkWidget
*statlabel_select
;
533 GtkWidget
*statlabel_msgs
;
535 GtkWidget
*toggle_eventbox
;
537 GtkWidget
*multiple_sel_togbtn
;
539 GtkWidget
*toggle_arrow
;
540 GtkWidget
*toggle_search
;
541 QuickSearch
*quicksearch
;
543 debug_print("Creating summary view...\n");
544 summaryview
= g_new0(SummaryView
, 1);
546 #define SUMMARY_VBOX_SPACING 3
547 vbox
= gtk_vbox_new(FALSE
, SUMMARY_VBOX_SPACING
);
549 /* create status label */
550 hbox
= gtk_hbox_new(FALSE
, 0);
551 gtk_widget_show(hbox
);
553 stat_vbox
= gtk_vbox_new(FALSE
, 0);
554 gtk_widget_show(stat_vbox
);
556 stat_box
= gtk_hbox_new(FALSE
, 0);
557 gtk_widget_show(stat_box
);
559 stat_box2
= gtk_hbox_new(FALSE
, 0);
560 gtk_widget_show(stat_box2
);
562 toggle_search
= gtk_toggle_button_new();
563 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle_search
),
564 prefs_common
.show_searchbar
);
565 gtk_widget_set_can_focus(toggle_search
, FALSE
);
566 gtk_widget_show(toggle_search
);
568 CLAWS_SET_TIP(toggle_search
, _("Toggle quick search bar"));
570 gtk_box_pack_start(GTK_BOX(hbox
), toggle_search
, FALSE
, FALSE
, 2);
572 gtk_box_pack_start(GTK_BOX(hbox
), stat_vbox
, TRUE
, TRUE
, 0);
573 gtk_box_pack_start(GTK_BOX(stat_vbox
), stat_box
, TRUE
, TRUE
, 0);
574 gtk_box_pack_start(GTK_BOX(stat_vbox
), stat_box2
, TRUE
, TRUE
, 0);
576 hbox_l
= gtk_hbox_new(FALSE
, 0);
577 gtk_widget_show(hbox_l
);
578 gtk_box_pack_start(GTK_BOX(stat_box
), hbox_l
, TRUE
, TRUE
, 0);
580 statlabel_folder
= gtk_label_new("");
581 gtk_widget_show(statlabel_folder
);
582 gtk_box_pack_start(GTK_BOX(hbox_l
), statlabel_folder
, FALSE
, FALSE
, 2);
583 statlabel_select
= gtk_label_new("");
584 gtk_widget_show(statlabel_select
);
585 gtk_box_pack_start(GTK_BOX(hbox_l
), statlabel_select
, FALSE
, FALSE
, 12);
587 /* toggle view button */
588 toggle_eventbox
= gtk_event_box_new();
589 gtk_widget_show(toggle_eventbox
);
591 gtk_box_pack_end(GTK_BOX(hbox
), toggle_eventbox
, FALSE
, FALSE
, 4);
593 toggle_arrow
= gtk_arrow_new(GTK_ARROW_DOWN
, GTK_SHADOW_OUT
);
594 gtk_widget_show(toggle_arrow
);
595 gtk_container_add(GTK_CONTAINER(toggle_eventbox
), toggle_arrow
);
596 g_signal_connect(G_OBJECT(toggle_eventbox
), "button_press_event",
597 G_CALLBACK(summary_toggle_pressed
),
601 multiple_sel_togbtn
= gtk_toggle_button_new();
602 gtk_widget_show(multiple_sel_togbtn
);
603 gtk_box_pack_end(GTK_BOX(hbox
), multiple_sel_togbtn
, FALSE
, FALSE
, 4);
604 CLAWS_SET_TIP(multiple_sel_togbtn
,
605 _("Toggle multiple selection"));
606 g_signal_connect(G_OBJECT(multiple_sel_togbtn
), "toggled",
607 G_CALLBACK(summary_toggle_multiple_pressed
),
611 statlabel_msgs
= gtk_label_new("");
612 gtk_widget_show(statlabel_msgs
);
613 gtk_box_pack_end(GTK_BOX(stat_box
), statlabel_msgs
, FALSE
, FALSE
, 4);
615 hbox_spc
= gtk_hbox_new(FALSE
, 0);
616 gtk_widget_show(hbox_spc
);
617 gtk_box_pack_end(GTK_BOX(hbox
), hbox_spc
, FALSE
, FALSE
, 6);
619 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
620 gtk_widget_show(scrolledwin
);
621 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
622 GTK_POLICY_AUTOMATIC
,
623 GTK_POLICY_AUTOMATIC
);
624 summaryview
->mainwidget_book
= gtk_notebook_new();
625 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(summaryview
->mainwidget_book
), FALSE
);
626 gtk_notebook_set_show_border(GTK_NOTEBOOK(summaryview
->mainwidget_book
), FALSE
);
628 gtk_container_add(GTK_CONTAINER(summaryview
->mainwidget_book
),
630 gtk_box_pack_start(GTK_BOX(vbox
), summaryview
->mainwidget_book
, TRUE
, TRUE
, 0);
632 gtk_widget_set_size_request(vbox
,
633 prefs_common
.summaryview_width
,
634 prefs_common
.summaryview_height
);
636 ctree
= summary_ctree_create(summaryview
);
637 gtk_widget_show(ctree
);
639 gtk_scrolled_window_set_hadjustment(GTK_SCROLLED_WINDOW(scrolledwin
),
640 GTK_CMCLIST(ctree
)->hadjustment
);
641 gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(scrolledwin
),
642 GTK_CMCLIST(ctree
)->vadjustment
);
643 gtk_container_add(GTK_CONTAINER(scrolledwin
), ctree
);
646 gtk_widget_show_all(stat_vbox
);
647 gtk_box_pack_start(GTK_BOX(vbox
), hbox
, FALSE
, FALSE
, 0);
650 quicksearch
= quicksearch_new();
651 gtk_box_pack_start(GTK_BOX(vbox
), quicksearch_get_widget(quicksearch
), FALSE
, FALSE
, 0);
654 gtk_container_add(GTK_CONTAINER(summaryview
->mainwidget_book
),
656 gtk_box_pack_start(GTK_BOX(vbox
), summaryview
->mainwidget_book
, TRUE
, TRUE
, 0);
658 quicksearch_set_execute_callback(quicksearch
, quicksearch_execute_cb
, summaryview
);
660 g_signal_connect (G_OBJECT(toggle_search
), "toggled",
661 G_CALLBACK(tog_searchbar_cb
), summaryview
);
663 /* create popup menu */
665 gtk_action_group_add_actions(mainwin
->action_group
, summary_popup_entries
,
666 G_N_ELEMENTS(summary_popup_entries
), (gpointer
)summaryview
);
668 summaryview
->ui_manager
= gtk_ui_manager_new();
669 summaryview
->action_group
= cm_menu_create_action_group_full(summaryview
->ui_manager
,"Menu", summary_popup_entries
,
670 G_N_ELEMENTS(summary_popup_entries
), (gpointer
)summaryview
);
672 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/", "Menus", "Menus", GTK_UI_MANAGER_MENUBAR
)
673 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus", "SummaryViewPopup", "SummaryViewPopup", GTK_UI_MANAGER_MENU
)
674 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Reply", "SummaryViewPopup/Reply", GTK_UI_MANAGER_MENUITEM
)
676 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "ReplyTo", "SummaryViewPopup/ReplyTo", GTK_UI_MANAGER_MENU
)
677 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator1", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
679 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Forward", "SummaryViewPopup/Forward", GTK_UI_MANAGER_MENUITEM
)
681 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "ForwardAtt", "SummaryViewPopup/ForwardAtt", GTK_UI_MANAGER_MENUITEM
)
682 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Redirect", "SummaryViewPopup/Redirect", GTK_UI_MANAGER_MENUITEM
)
684 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator2", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
685 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Move", "Message/Move", GTK_UI_MANAGER_MENUITEM
)
686 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Copy", "Message/Copy", GTK_UI_MANAGER_MENUITEM
)
687 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Trash", "Message/Trash", GTK_UI_MANAGER_MENUITEM
)
689 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Delete", "Message/Delete", GTK_UI_MANAGER_MENUITEM
)
691 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator3", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
692 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Mark", "SummaryViewPopup/Mark", GTK_UI_MANAGER_MENU
)
693 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "ColorLabel", "SummaryViewPopup/ColorLabel", GTK_UI_MANAGER_MENU
)
694 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Tags", "SummaryViewPopup/Tags", GTK_UI_MANAGER_MENU
)
696 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator4", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
698 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "AddSenderToAB", "Tools/AddSenderToAB", GTK_UI_MANAGER_MENUITEM
)
700 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "CreateFilterRule", "SummaryViewPopup/CreateFilterRule", GTK_UI_MANAGER_MENU
)
702 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "CreateProcessingRule", "SummaryViewPopup/CreateProcessingRule", GTK_UI_MANAGER_MENU
)
704 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator5", "Tools/---", GTK_UI_MANAGER_SEPARATOR
)
705 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "View", "SummaryViewPopup/View", GTK_UI_MANAGER_MENU
)
706 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "SaveAs", "File/SaveAs", GTK_UI_MANAGER_MENUITEM
)
708 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Print", "File/Print", GTK_UI_MANAGER_MENUITEM
)
710 /* last separator, for plugins */
711 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator6", "File/---", GTK_UI_MANAGER_SEPARATOR
)
713 /* submenus - replyto */
714 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/ReplyTo", "All", "SummaryViewPopup/ReplyTo/All", GTK_UI_MANAGER_MENUITEM
)
715 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/ReplyTo", "Sender", "SummaryViewPopup/ReplyTo/Sender", GTK_UI_MANAGER_MENUITEM
)
716 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/ReplyTo", "MailingList", "SummaryViewPopup/ReplyTo/List", GTK_UI_MANAGER_MENUITEM
)
718 /* submenus - mark */
719 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Mark", "Message/Mark/Mark", GTK_UI_MANAGER_MENUITEM
)
720 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Unmark", "Message/Mark/Unmark", GTK_UI_MANAGER_MENUITEM
)
721 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Separator1", "Message/Mark/---", GTK_UI_MANAGER_SEPARATOR
)
722 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkRead", "Message/Mark/MarkRead", GTK_UI_MANAGER_MENUITEM
)
723 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkUnread", "Message/Mark/MarkUnread", GTK_UI_MANAGER_MENUITEM
)
724 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Separator2", "Message/Mark/---", GTK_UI_MANAGER_SEPARATOR
)
725 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkAllRead", "Message/Mark/MarkAllRead", GTK_UI_MANAGER_MENUITEM
)
726 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkAllUnread", "Message/Mark/MarkAllUnread", GTK_UI_MANAGER_MENUITEM
)
727 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Separator3", "Message/Mark/---", GTK_UI_MANAGER_SEPARATOR
)
728 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "IgnoreThread", "Message/Mark/IgnoreThread", GTK_UI_MANAGER_MENUITEM
)
729 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "UnignoreThread", "Message/Mark/UnignoreThread", GTK_UI_MANAGER_MENUITEM
)
730 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "WatchThread", "Message/Mark/WatchThread", GTK_UI_MANAGER_MENUITEM
)
731 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "UnwatchThread", "Message/Mark/UnwatchThread", GTK_UI_MANAGER_MENUITEM
)
732 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Separator4", "Message/Mark/---", GTK_UI_MANAGER_SEPARATOR
)
733 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkSpam", "Message/Mark/MarkSpam", GTK_UI_MANAGER_MENUITEM
)
734 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkHam", "Message/Mark/MarkHam", GTK_UI_MANAGER_MENUITEM
)
735 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Separator5", "Message/Mark/---", GTK_UI_MANAGER_SEPARATOR
)
736 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Lock", "Message/Mark/Lock", GTK_UI_MANAGER_MENUITEM
)
737 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Unlock", "Message/Mark/Unlock", GTK_UI_MANAGER_MENUITEM
)
739 /* submenus - colorlabel and tags are dynamic */
740 /* submenus - createfilterrule */
741 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateFilterRule", "Automatically", "Tools/CreateFilterRule/Automatically", GTK_UI_MANAGER_MENUITEM
)
742 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateFilterRule", "ByFrom", "Tools/CreateFilterRule/ByFrom", GTK_UI_MANAGER_MENUITEM
)
743 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateFilterRule", "ByTo", "Tools/CreateFilterRule/ByTo", GTK_UI_MANAGER_MENUITEM
)
744 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateFilterRule", "BySubject", "Tools/CreateFilterRule/BySubject", GTK_UI_MANAGER_MENUITEM
)
747 /* submenus - createprocessingrule */
748 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateProcessingRule", "Automatically", "Tools/CreateProcessingRule/Automatically", GTK_UI_MANAGER_MENUITEM
)
749 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateProcessingRule", "ByFrom", "Tools/CreateProcessingRule/ByFrom", GTK_UI_MANAGER_MENUITEM
)
750 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateProcessingRule", "ByTo", "Tools/CreateProcessingRule/ByTo", GTK_UI_MANAGER_MENUITEM
)
751 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateProcessingRule", "BySubject", "Tools/CreateProcessingRule/BySubject", GTK_UI_MANAGER_MENUITEM
)
754 /* submenus - view */
755 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/View", "OpenNewWindow", "View/OpenNewWindow", GTK_UI_MANAGER_MENUITEM
)
756 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/View", "MessageSource", "View/MessageSource", GTK_UI_MANAGER_MENUITEM
)
758 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/View", "AllHeaders", "View/AllHeaders", GTK_UI_MANAGER_MENUITEM
)
760 summaryview
->popupmenu
= gtk_menu_item_get_submenu(GTK_MENU_ITEM(
761 gtk_ui_manager_get_widget(mainwin
->ui_manager
, "/Menus/SummaryViewPopup")) );
764 summaryview
->vbox
= vbox
;
765 summaryview
->scrolledwin
= scrolledwin
;
766 summaryview
->ctree
= ctree
;
767 summaryview
->hbox
= hbox
;
768 summaryview
->hbox_l
= hbox_l
;
769 summaryview
->hbox_spc
= hbox_spc
;
770 summaryview
->stat_box
= stat_box
;
771 summaryview
->stat_box2
= stat_box2
;
772 summaryview
->statlabel_folder
= statlabel_folder
;
773 summaryview
->statlabel_select
= statlabel_select
;
774 summaryview
->statlabel_msgs
= statlabel_msgs
;
775 summaryview
->toggle_eventbox
= toggle_eventbox
;
776 summaryview
->toggle_arrow
= toggle_arrow
;
778 summaryview
->multiple_sel_togbtn
= multiple_sel_togbtn
;
780 summaryview
->toggle_search
= toggle_search
;
781 summaryview
->lock_count
= 0;
782 summaryview
->msginfo_update_callback_id
=
783 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
, summary_update_msg
, (gpointer
) summaryview
);
784 summaryview
->folder_item_update_callback_id
=
785 hooks_register_hook(FOLDER_ITEM_UPDATE_HOOKLIST
,
786 summary_update_folder_item_hook
,
787 (gpointer
) summaryview
);
788 summaryview
->folder_update_callback_id
=
789 hooks_register_hook(FOLDER_UPDATE_HOOKLIST
,
790 summary_update_folder_hook
,
791 (gpointer
) summaryview
);
793 summaryview
->target_list
= gtk_target_list_new(summary_drag_types
, 3);
795 summaryview
->quicksearch
= quicksearch
;
797 /* CLAWS: need this to get the SummaryView * from
799 g_object_set_data(G_OBJECT(ctree
), "summaryview", (gpointer
)summaryview
);
801 gtk_widget_show_all(vbox
);
803 gtk_widget_show(vbox
);
805 if (prefs_common
.show_searchbar
)
806 quicksearch_show(quicksearch
);
808 quicksearch_hide(quicksearch
);
810 if (prefs_common
.layout_mode
== WIDE_MSGLIST_LAYOUT
||
811 prefs_common
.layout_mode
== SMALL_LAYOUT
)
812 gtk_widget_hide(summaryview
->toggle_eventbox
);
817 void summary_relayout(SummaryView
*summaryview
)
819 gtk_widget_realize(summaryview
->stat_box
);
821 g_object_ref(summaryview
->hbox_l
);
822 g_object_ref(summaryview
->statlabel_msgs
);
824 gtkut_container_remove(GTK_CONTAINER(
825 gtk_widget_get_parent(summaryview
->hbox_l
)), summaryview
->hbox_l
);
826 gtkut_container_remove(GTK_CONTAINER(
827 gtk_widget_get_parent(summaryview
->statlabel_msgs
)), summaryview
->statlabel_msgs
);
829 switch (prefs_common
.layout_mode
) {
832 case WIDE_MSGLIST_LAYOUT
:
833 gtk_box_pack_start(GTK_BOX(summaryview
->stat_box
), summaryview
->hbox_l
, TRUE
, TRUE
, 0);
834 gtk_box_pack_end(GTK_BOX(summaryview
->stat_box
), summaryview
->statlabel_msgs
, FALSE
, FALSE
, 4);
835 gtk_widget_show_all(summaryview
->stat_box
);
836 gtk_widget_show_all(summaryview
->stat_box2
);
837 if (prefs_common
.layout_mode
== WIDE_MSGLIST_LAYOUT
||
838 prefs_common
.layout_mode
== SMALL_LAYOUT
)
839 gtk_widget_hide(summaryview
->toggle_eventbox
);
841 gtk_widget_show(summaryview
->toggle_eventbox
);
843 case VERTICAL_LAYOUT
:
845 gtk_box_pack_start(GTK_BOX(summaryview
->stat_box
), summaryview
->hbox_l
, TRUE
, TRUE
, 0);
846 gtk_box_pack_start(GTK_BOX(summaryview
->stat_box2
), summaryview
->statlabel_msgs
, FALSE
, FALSE
, 4);
847 gtk_widget_show_all(summaryview
->stat_box
);
848 gtk_widget_show_all(summaryview
->stat_box2
);
849 if (prefs_common
.layout_mode
== SMALL_LAYOUT
) {
850 gtk_widget_hide(summaryview
->toggle_eventbox
);
851 gtk_widget_hide(summaryview
->statlabel_msgs
);
853 gtk_widget_show(summaryview
->toggle_eventbox
);
854 gtk_widget_show(summaryview
->statlabel_msgs
);
859 summary_set_column_order(summaryview
);
861 g_object_unref(summaryview
->hbox_l
);
862 g_object_unref(summaryview
->statlabel_msgs
);
863 quicksearch_relayout(summaryview
->quicksearch
);
864 if (prefs_common
.show_searchbar
)
865 quicksearch_show(summaryview
->quicksearch
);
867 quicksearch_hide(summaryview
->quicksearch
);
870 static void summary_set_fonts(SummaryView
*summaryview
)
872 PangoFontDescription
*font_desc
;
875 font_desc
= pango_font_description_from_string(NORMAL_FONT
);
877 gtk_widget_modify_font(summaryview
->ctree
, font_desc
);
878 pango_font_description_free(font_desc
);
882 bold_style
= gtk_style_copy
883 (gtk_widget_get_style(summaryview
->ctree
));
885 if (prefs_common
.derive_from_normal_font
|| !BOLD_FONT
) {
886 font_desc
= pango_font_description_from_string(NORMAL_FONT
);
888 pango_font_description_free(bold_style
->font_desc
);
889 bold_style
->font_desc
= font_desc
;
891 pango_font_description_set_weight
892 (bold_style
->font_desc
, PANGO_WEIGHT_BOLD
);
894 font_desc
= pango_font_description_from_string(BOLD_FONT
);
896 pango_font_description_free(bold_style
->font_desc
);
897 bold_style
->font_desc
= font_desc
;
900 bold_marked_style
= gtk_style_copy(bold_style
);
901 bold_marked_style
->text
[GTK_STATE_NORMAL
] =
902 summaryview
->color_marked
;
903 bold_deleted_style
= gtk_style_copy(bold_style
);
904 bold_deleted_style
->text
[GTK_STATE_NORMAL
] =
905 summaryview
->color_dim
;
908 if (prefs_common
.derive_from_normal_font
|| !SMALL_FONT
) {
909 font_desc
= pango_font_description_new();
910 size
= pango_font_description_get_size
911 (gtk_widget_get_style(summaryview
->ctree
)->font_desc
);
912 pango_font_description_set_size(font_desc
, size
* PANGO_SCALE_SMALL
);
914 font_desc
= pango_font_description_from_string(SMALL_FONT
);
917 gtk_widget_modify_font(summaryview
->statlabel_folder
, font_desc
);
918 gtk_widget_modify_font(summaryview
->statlabel_select
, font_desc
);
919 gtk_widget_modify_font(summaryview
->statlabel_msgs
, font_desc
);
920 pango_font_description_free(font_desc
);
925 static void summary_set_folder_pixmap(SummaryView
*summaryview
, StockPixmap icon
)
928 if (!summaryview
->folder_pixmap_eventbox
) {
929 summaryview
->folder_pixmap_eventbox
= gtk_event_box_new();
930 gtk_widget_show(summaryview
->folder_pixmap_eventbox
);
931 gtk_box_pack_start(GTK_BOX(summaryview
->hbox_l
), summaryview
->folder_pixmap_eventbox
, FALSE
, FALSE
, 4);
932 gtk_box_reorder_child(GTK_BOX(summaryview
->hbox_l
), summaryview
->folder_pixmap_eventbox
, 0); /* search_toggle before */
933 g_signal_connect(G_OBJECT(summaryview
->folder_pixmap_eventbox
), "button_press_event",
934 G_CALLBACK(summary_folder_eventbox_pressed
),
937 if (summaryview
->folder_pixmap
)
938 gtk_widget_destroy(summaryview
->folder_pixmap
);
940 pixmap
= stock_pixmap_widget(icon
);
941 gtk_container_add(GTK_CONTAINER(summaryview
->folder_pixmap_eventbox
), pixmap
);
942 gtk_widget_show(pixmap
);
943 summaryview
->folder_pixmap
= pixmap
;
946 void summary_init(SummaryView
*summaryview
)
950 gtk_widget_realize(summaryview
->ctree
);
951 stock_pixbuf_gdk(STOCK_PIXMAP_MARK
, &markxpm
);
952 stock_pixbuf_gdk(STOCK_PIXMAP_DELETED
, &deletedxpm
);
953 stock_pixbuf_gdk(STOCK_PIXMAP_NEW
, &newxpm
);
954 stock_pixbuf_gdk(STOCK_PIXMAP_UNREAD
, &unreadxpm
);
955 stock_pixbuf_gdk(STOCK_PIXMAP_REPLIED
, &repliedxpm
);
956 stock_pixbuf_gdk(STOCK_PIXMAP_FORWARDED
, &forwardedxpm
);
957 stock_pixbuf_gdk(STOCK_PIXMAP_REPLIED_AND_FORWARDED
, &repliedandforwardedxpm
);
958 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP
, &clipxpm
);
959 stock_pixbuf_gdk(STOCK_PIXMAP_LOCKED
, &lockedxpm
);
960 stock_pixbuf_gdk(STOCK_PIXMAP_IGNORETHREAD
, &ignorethreadxpm
);
961 stock_pixbuf_gdk(STOCK_PIXMAP_WATCHTHREAD
, &watchthreadxpm
);
962 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP_KEY
, &clipkeyxpm
);
963 stock_pixbuf_gdk(STOCK_PIXMAP_KEY_SIGN
, &keysignxpm
);
964 stock_pixbuf_gdk(STOCK_PIXMAP_KEY
, &keyxpm
);
965 stock_pixbuf_gdk(STOCK_PIXMAP_GPG_SIGNED
, &gpgsignedxpm
);
966 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP_GPG_SIGNED
, &clipgpgsignedxpm
);
967 stock_pixbuf_gdk(STOCK_PIXMAP_SPAM
, &spamxpm
);
968 stock_pixbuf_gdk(STOCK_PIXMAP_MOVED
, &movedxpm
);
969 stock_pixbuf_gdk(STOCK_PIXMAP_COPIED
, &copiedxpm
);
971 summary_set_fonts(summaryview
);
973 summary_set_folder_pixmap(summaryview
, STOCK_PIXMAP_DIR_OPEN
);
975 pixmap
= stock_pixmap_widget(STOCK_PIXMAP_QUICKSEARCH
);
976 gtk_container_add (GTK_CONTAINER(summaryview
->toggle_search
), pixmap
);
977 gtk_widget_show(pixmap
);
978 summaryview
->quick_search_pixmap
= pixmap
;
981 pixmap
= stock_pixmap_widget(STOCK_PIXMAP_SELECTION
);
982 gtk_container_add(GTK_CONTAINER(summaryview
->multiple_sel_togbtn
), pixmap
);
983 gtk_widget_show(pixmap
);
984 summaryview
->multiple_sel_image
= pixmap
;
987 /* Init summaryview prefs */
988 summaryview
->sort_key
= SORT_BY_NONE
;
989 summaryview
->sort_type
= SORT_ASCENDING
;
991 /* Init summaryview extra data */
992 summaryview
->simplify_subject_preg
= NULL
;
993 summary_clear_list(summaryview
);
994 summary_set_column_titles(summaryview
);
995 summary_colorlabel_menu_create(summaryview
, FALSE
);
996 summary_tags_menu_create(summaryview
, FALSE
);
997 main_create_mailing_list_menu (summaryview
->mainwin
, NULL
);
998 summary_set_menu_sensitive(summaryview
);
1002 #define CURRENTLY_DISPLAYED(m) \
1003 ( (m->msgnum == displayed_msgnum) \
1004 && (!g_ascii_strcasecmp(m->folder->name,item->name)) )
1006 #define FOLDER_SHOWS_TO_HDR(i) \
1007 ( i && (folder_has_parent_of_type(i, F_OUTBOX) \
1008 || folder_has_parent_of_type(i, F_DRAFT) \
1009 || folder_has_parent_of_type(i, F_QUEUE)) )
1011 static void summary_switch_from_to(SummaryView
*summaryview
, FolderItem
*item
)
1013 gboolean show_from
= FALSE
, show_to
= FALSE
;
1014 gboolean showing_from
= FALSE
, showing_to
= FALSE
;
1015 gint from_pos
= 0, to_pos
= 0;
1016 SummaryColumnState
*col_state
= summaryview
->col_state
;
1017 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
1019 if (!item
|| ((prefs_common
.layout_mode
== VERTICAL_LAYOUT
|| prefs_common
.layout_mode
== SMALL_LAYOUT
) && prefs_common
.two_line_vert
) )
1021 if (FOLDER_SHOWS_TO_HDR(item
))
1026 from_pos
= summaryview
->col_pos
[S_COL_FROM
];
1027 to_pos
= summaryview
->col_pos
[S_COL_TO
];
1028 showing_from
= col_state
[from_pos
].visible
;
1029 showing_to
= col_state
[to_pos
].visible
;
1031 if (showing_from
&& showing_to
) {
1032 debug_print("showing both\n");
1036 if (!showing_from
&& !showing_to
) {
1037 debug_print("showing none\n");
1041 debug_print("showing %s %s, must show %s %s\n",
1042 showing_from
?"From":"",
1044 show_from
?"From":"",
1047 if (showing_from
== show_from
&& showing_to
== show_to
)
1049 /* else we'll switch both */
1051 debug_print("switching columns\n");
1052 col_state
[from_pos
].type
= S_COL_TO
;
1053 col_state
[from_pos
].visible
= show_to
;
1055 col_state
[to_pos
].type
= S_COL_FROM
;
1056 col_state
[to_pos
].visible
= show_from
;
1058 summaryview
->col_pos
[S_COL_TO
] = from_pos
;
1059 summaryview
->col_pos
[S_COL_FROM
] = to_pos
;
1061 gtk_cmclist_set_column_visibility
1062 (GTK_CMCLIST(ctree
), from_pos
, col_state
[from_pos
].visible
);
1063 gtk_cmclist_set_column_visibility
1064 (GTK_CMCLIST(ctree
), to_pos
, col_state
[to_pos
].visible
);
1066 summary_set_column_titles(summaryview
);
1069 static void summaryview_reset_recursive_folder_match(SummaryView
*summaryview
)
1073 for (cur
= summaryview
->recursive_matched_folders
; cur
!= NULL
; cur
= cur
->next
) {
1074 folderview_update_search_icon(cur
->data
, FALSE
);
1077 g_slist_free(summaryview
->recursive_matched_folders
);
1078 summaryview
->recursive_matched_folders
= NULL
;
1079 summaryview
->search_root_folder
= NULL
;
1082 static gboolean
summaryview_quicksearch_recursive_progress(gpointer data
, guint at
, guint matched
, guint total
)
1084 QuickSearch
*search
= (QuickSearch
*) data
;
1085 gint interval
= quicksearch_is_fast(search
) ? 5000 : 100;
1087 statusbar_progress_all(at
, total
, interval
);
1088 if (at
% interval
== 0)
1097 static void summaryview_quicksearch_recurse_step(SummaryView
*summaryview
, FolderItem
*item
)
1099 MsgInfoList
*msgs
= NULL
;
1100 gboolean result
= TRUE
;
1102 statusbar_print_all(_("Searching in %s... \n"),
1103 item
->path
? item
->path
: "(null)");
1104 folder_item_update_freeze();
1106 quicksearch_set_on_progress_cb(summaryview
->quicksearch
, summaryview_quicksearch_recursive_progress
, summaryview
->quicksearch
);
1107 if (!quicksearch_run_on_folder(summaryview
->quicksearch
, item
, &msgs
))
1110 result
= result
&& msgs
!= NULL
;
1113 procmsg_msg_list_free(msgs
);
1115 folder_item_update_thaw();
1116 statusbar_progress_all(0, 0, 0);
1117 statusbar_pop_all();
1120 summaryview
->recursive_matched_folders
= g_slist_prepend(
1121 summaryview
->recursive_matched_folders
, item
);
1123 folderview_update_search_icon(item
, TRUE
);
1127 static void summaryview_quicksearch_search_subfolders(SummaryView
*summaryview
, FolderItem
*folder_item
)
1129 FolderItem
*cur
= NULL
;
1130 GNode
*node
= folder_item
->node
->children
;
1132 if (!prefs_common
.summary_quicksearch_recurse
1133 || !quicksearch_has_sat_predicate(summaryview
->quicksearch
)
1134 || quicksearch_is_in_typing(summaryview
->quicksearch
))
1137 for (; node
!= NULL
; node
= node
->next
) {
1138 if (!quicksearch_has_sat_predicate(summaryview
->quicksearch
))
1141 cur
= FOLDER_ITEM(node
->data
);
1142 summaryview_quicksearch_recurse_step(summaryview
, cur
);
1143 if (cur
->node
->children
)
1144 summaryview_quicksearch_search_subfolders(summaryview
, cur
);
1148 static void summaryview_quicksearch_recurse(SummaryView
*summaryview
)
1150 if (!prefs_common
.summary_quicksearch_recurse
1151 || !quicksearch_has_sat_predicate(summaryview
->quicksearch
)
1152 || summaryview
->folder_item
== NULL
) {
1156 main_window_cursor_wait(summaryview
->mainwin
);
1158 summaryview_reset_recursive_folder_match(summaryview
);
1159 summaryview
->search_root_folder
= summaryview
->folder_item
;
1161 summaryview_quicksearch_search_subfolders(summaryview
, summaryview
->folder_item
);
1163 main_window_cursor_normal(summaryview
->mainwin
);
1167 static gboolean
summary_check_consistency(FolderItem
*item
, GSList
*mlist
)
1169 int u
= 0, n
= 0, m
= 0, t
= 0, r
= 0, f
= 0, l
= 0, i
= 0, w
= 0;
1172 for(cur
= mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= g_slist_next(cur
)) {
1173 MsgInfo
* msginfo
= (MsgInfo
*) cur
->data
;
1175 if (MSG_IS_NEW(msginfo
->flags
))
1177 if (MSG_IS_UNREAD(msginfo
->flags
))
1179 if (MSG_IS_MARKED(msginfo
->flags
))
1181 if (MSG_IS_REPLIED(msginfo
->flags
))
1183 if (MSG_IS_FORWARDED(msginfo
->flags
))
1185 if (MSG_IS_LOCKED(msginfo
->flags
))
1187 if (MSG_IS_IGNORE_THREAD(msginfo
->flags
))
1189 if (MSG_IS_WATCH_THREAD(msginfo
->flags
))
1192 if (t
!= item
->total_msgs
1193 || n
!= item
->new_msgs
1194 || u
!= item
->unread_msgs
1195 || m
!= item
->marked_msgs
1196 || r
!= item
->replied_msgs
1197 || f
!= item
->forwarded_msgs
1198 || l
!= item
->locked_msgs
1199 || i
!= item
->ignored_msgs
1200 || w
!= item
->watched_msgs
1201 || (m
== 0 && item
->unreadmarked_msgs
!= 0)
1202 || item
->unreadmarked_msgs
< 0) {
1203 debug_print("Inconsistency\n");
1204 folder_item_scan_full(item
, FALSE
);
1212 gboolean
summaryview_search_root_progress(gpointer data
, guint at
, guint matched
, guint total
)
1214 SummaryView
*summaryview
= (SummaryView
*) data
;
1216 gint interval
= quicksearch_is_fast(summaryview
->quicksearch
) ? 5000 : 100;
1218 statusbar_progress_all(at
, total
, interval
);
1220 if (at
% interval
== 0)
1226 gboolean
summary_show(SummaryView
*summaryview
, FolderItem
*item
)
1228 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
1229 GtkCMCTreeNode
*node
= NULL
;
1230 GSList
*mlist
= NULL
;
1232 gboolean is_refresh
;
1233 guint selected_msgnum
= 0;
1234 guint displayed_msgnum
= 0;
1237 gboolean hidden_removed
= FALSE
;
1239 if (summary_is_locked(summaryview
)) return FALSE
;
1241 if (!summaryview
->mainwin
)
1244 summary_switch_from_to(summaryview
, item
);
1247 summary_lock(summaryview
);
1249 menu_set_sensitive_all(GTK_MENU_SHELL(summaryview
->popupmenu
), TRUE
);
1253 is_refresh
= (item
== summaryview
->folder_item
) ? TRUE
: FALSE
;
1255 if (item
&& item
->folder
->klass
->item_opened
) {
1256 item
->folder
->klass
->item_opened(item
);
1260 main_create_mailing_list_menu (summaryview
->mainwin
, NULL
);
1261 if (prefs_common
.layout_mode
== SMALL_LAYOUT
) {
1263 mainwindow_enter_folder(summaryview
->mainwin
);
1264 gtk_widget_grab_focus(summaryview
->ctree
);
1268 if (!prefs_common
.summary_quicksearch_sticky
1269 && (!prefs_common
.summary_quicksearch_recurse
1270 || !quicksearch_has_sat_predicate(summaryview
->quicksearch
)
1271 || (item
&& !folder_is_child_of(item
, summaryview
->search_root_folder
)))
1272 && !quicksearch_is_running(summaryview
->quicksearch
)
1274 quicksearch_set(summaryview
->quicksearch
, prefs_common
.summary_quicksearch_type
, "");
1277 /* STATUSBAR_POP(summaryview->mainwin); */
1280 selected_msgnum
= summary_get_msgnum(summaryview
,
1281 summaryview
->selected
);
1282 displayed_msgnum
= summary_get_msgnum(summaryview
,
1283 summaryview
->displayed
);
1286 /* process the marks if any */
1288 (summaryview
->mainwin
->lock_count
== 0 &&
1289 (summaryview
->moved
> 0 || summaryview
->copied
> 0))) {
1291 gboolean changed
= FALSE
;
1293 val
= alertpanel(_("Process mark"),
1294 _("Some marks are left. Process them?"),
1295 GTK_STOCK_NO
, GTK_STOCK_YES
, GTK_STOCK_CANCEL
, ALERTFOCUS_FIRST
);
1296 if (G_ALERTALTERNATE
== val
) {
1297 summary_unlock(summaryview
);
1298 summary_execute(summaryview
);
1299 summary_lock(summaryview
);
1301 } else if (G_ALERTDEFAULT
== val
) {
1304 summary_unlock(summaryview
);
1309 if (changed
|| !quicksearch_has_sat_predicate(summaryview
->quicksearch
))
1310 folder_update_op_count();
1313 summary_freeze(summaryview
);
1315 summary_clear_list(summaryview
);
1318 if (!item
|| !item
->path
|| !folder_item_parent(item
) || item
->no_select
) {
1320 debug_print("empty folder (%p %s %p %d)\n",
1322 (item
&& item
->path
)?item
->path
:"(null)",
1323 item
?folder_item_parent(item
):0x0,
1324 item
?item
->no_select
:FALSE
);
1325 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadMessages", FALSE
);
1326 summary_set_hide_menu(summaryview
, "/Menu/View/HideDelMessages", FALSE
);
1327 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadThreads", FALSE
);
1328 summary_clear_all(summaryview
);
1329 summaryview
->folder_item
= item
;
1330 summary_thaw(summaryview
);
1331 summary_unlock(summaryview
);
1339 messageview_clear(summaryview
->messageview
);
1341 summaryview
->folder_item
= item
;
1342 item
->opened
= TRUE
;
1344 buf
= g_strdup_printf(_("Scanning folder (%s)..."), item
->path
);
1345 debug_print("%s\n", buf
);
1346 STATUSBAR_PUSH(summaryview
->mainwin
, buf
);
1349 main_window_cursor_wait(summaryview
->mainwin
);
1351 mlist
= folder_item_get_msg_list(item
);
1353 if (!summary_check_consistency(item
, mlist
)) {
1354 debug_print("reloading due to inconsistency\n");
1355 procmsg_msg_list_free(mlist
);
1356 mlist
= folder_item_get_msg_list(item
);
1359 if (quicksearch_has_sat_predicate(summaryview
->quicksearch
)) {
1360 procmsg_msg_list_free(mlist
);
1363 START_TIMING("quicksearch");
1365 statusbar_print_all(_("Searching in %s... \n"),
1366 summaryview
->folder_item
->path
?
1367 summaryview
->folder_item
->path
: "(null)");
1369 folder_item_update_freeze();
1371 quicksearch_set_on_progress_cb(summaryview
->quicksearch
, summaryview_search_root_progress
, summaryview
);
1372 quicksearch_run_on_folder(summaryview
->quicksearch
, summaryview
->folder_item
, &mlist
);
1374 folder_item_update_thaw();
1375 statusbar_progress_all(0, 0, 0);
1376 statusbar_pop_all();
1378 if (!quicksearch_has_sat_predicate(summaryview
->quicksearch
)) {
1379 debug_print("search cancelled!\n");
1380 summary_thaw(summaryview
);
1381 STATUSBAR_POP(summaryview
->mainwin
);
1382 main_window_cursor_normal(summaryview
->mainwin
);
1383 summary_unlock(summaryview
);
1385 summary_show(summaryview
, summaryview
->folder_item
);
1392 if ((summaryview
->folder_item
->hide_read_msgs
1393 || summaryview
->folder_item
->hide_del_msgs
1394 || summaryview
->folder_item
->hide_read_threads
) &&
1395 quicksearch_has_sat_predicate(summaryview
->quicksearch
) == FALSE
) {
1398 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadMessages",
1399 summaryview
->folder_item
->hide_read_msgs
);
1400 summary_set_hide_menu(summaryview
, "/Menu/View/HideDelMessages",
1401 summaryview
->folder_item
->hide_del_msgs
);
1402 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadThreads",
1403 summaryview
->folder_item
->hide_read_threads
);
1405 for(cur
= mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= g_slist_next(cur
)) {
1406 MsgInfo
* msginfo
= (MsgInfo
*) cur
->data
;
1408 if (!msginfo
->hidden
) {
1409 if (MSG_IS_DELETED(msginfo
->flags
) && summaryview
->folder_item
->hide_del_msgs
) {
1410 procmsg_msginfo_free(&msginfo
);
1413 if (summaryview
->folder_item
->hide_read_msgs
) {
1414 if (MSG_IS_UNREAD(msginfo
->flags
) &&
1415 !MSG_IS_IGNORE_THREAD(msginfo
->flags
))
1416 not_killed
= g_slist_prepend(not_killed
, msginfo
);
1417 else if (MSG_IS_MARKED(msginfo
->flags
) ||
1418 MSG_IS_LOCKED(msginfo
->flags
))
1419 not_killed
= g_slist_prepend(not_killed
, msginfo
);
1420 else if (is_refresh
&&
1421 (msginfo
->msgnum
== selected_msgnum
||
1422 msginfo
->msgnum
== displayed_msgnum
))
1423 not_killed
= g_slist_prepend(not_killed
, msginfo
);
1425 procmsg_msginfo_free(&msginfo
);
1427 not_killed
= g_slist_prepend(not_killed
, msginfo
);
1430 procmsg_msginfo_free(&msginfo
);
1432 hidden_removed
= TRUE
;
1433 g_slist_free(mlist
);
1436 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadMessages",
1438 summary_set_hide_menu(summaryview
, "/Menu/View/HideDelMessages",
1440 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadThreads",
1444 if (!hidden_removed
) {
1445 START_TIMING("removing hidden");
1447 for(cur
= mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= g_slist_next(cur
)) {
1448 MsgInfo
* msginfo
= (MsgInfo
*) cur
->data
;
1450 if (!msginfo
->hidden
)
1451 not_killed
= g_slist_prepend(not_killed
, msginfo
);
1453 procmsg_msginfo_free(&msginfo
);
1455 g_slist_free(mlist
);
1460 STATUSBAR_POP(summaryview
->mainwin
);
1462 /* set ctree and hash table from the msginfo list, and
1463 create the thread */
1464 summary_set_ctree_from_list(summaryview
, mlist
, selected_msgnum
);
1466 g_slist_free(mlist
);
1469 if (!quicksearch_is_in_typing(summaryview
->quicksearch
)) {
1470 summaryview
->displayed
=
1471 summary_find_msg_by_msgnum(summaryview
,
1473 if (!summaryview
->displayed
)
1474 messageview_clear(summaryview
->messageview
);
1475 summary_unlock(summaryview
);
1477 if (quicksearch_is_running(summaryview
->quicksearch
))
1478 summary_select_by_msgnum(summaryview
, selected_msgnum
,
1479 OPEN_SELECTED_ON_SEARCH_RESULTS
);
1481 summary_select_by_msgnum(summaryview
, selected_msgnum
,
1484 summary_lock(summaryview
);
1485 if (!summaryview
->selected
) {
1486 /* no selected message - select first unread
1487 message, but do not display it */
1488 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1490 if (node
== NULL
&& GTK_CMCLIST(ctree
)->row_list
!= NULL
)
1491 node
= gtk_cmctree_node_nth
1493 item
->sort_type
== SORT_DESCENDING
1494 ? 0 : GTK_CMCLIST(ctree
)->rows
- 1);
1495 summary_unlock(summaryview
);
1497 if (quicksearch_is_running(summaryview
->quicksearch
))
1498 summary_select_node(summaryview
, node
,
1499 OPEN_SELECTED_ON_SEARCH_RESULTS
);
1501 summary_select_node(summaryview
, node
,
1502 OPEN_SELECTED_ON_FOLDER_OPEN
);
1504 summary_lock(summaryview
);
1507 /* just select first/last */
1508 if (GTK_CMCLIST(ctree
)->row_list
!= NULL
)
1509 node
= gtk_cmctree_node_nth
1511 item
->sort_type
== SORT_DESCENDING
1512 ? 0 : GTK_CMCLIST(ctree
)->rows
- 1);
1513 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_SEARCH_RESULTS
);
1516 /* backward compat */
1518 gboolean set
= FALSE
, stop
= FALSE
;
1519 for (i
= 0; i
< 6; i
++) {
1520 EntryAction act
= prefs_common
.summary_select_prio
[i
];
1522 if (act
!= ACTION_UNSET
) {
1528 prefs_summary_open_set_defaults();
1530 for (i
= 0; i
< 6 && node
== NULL
; i
++) {
1531 EntryAction act
= prefs_common
.summary_select_prio
[i
];
1534 case ACTION_OLDEST_MARKED
:
1535 if (summaryview
->sort_type
== SORT_ASCENDING
)
1536 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1539 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1542 case ACTION_NEWEST_MARKED
:
1543 if (summaryview
->sort_type
== SORT_ASCENDING
)
1544 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1547 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1550 case ACTION_OLDEST_NEW
:
1551 if (summaryview
->sort_type
== SORT_ASCENDING
)
1552 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1555 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1558 case ACTION_NEWEST_NEW
:
1559 if (summaryview
->sort_type
== SORT_ASCENDING
)
1560 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1563 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1566 case ACTION_OLDEST_UNREAD
:
1567 if (summaryview
->sort_type
== SORT_ASCENDING
)
1568 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1571 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1574 case ACTION_NEWEST_UNREAD
:
1575 if (summaryview
->sort_type
== SORT_ASCENDING
)
1576 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1579 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1582 case ACTION_LAST_OPENED
:
1583 if (summaryview
->folder_item
) {
1584 node
= summary_find_msg_by_msgnum(summaryview
,
1585 summaryview
->folder_item
->last_seen
);
1588 case ACTION_NEWEST_LIST
:
1589 if (GTK_CMCLIST(ctree
)->row_list
!= NULL
) {
1590 node
= gtk_cmctree_node_nth
1592 item
->sort_type
== SORT_DESCENDING
1593 ? 0 : GTK_CMCLIST(ctree
)->rows
- 1);
1596 case ACTION_OLDEST_LIST
:
1597 if (GTK_CMCLIST(ctree
)->row_list
!= NULL
) {
1598 node
= gtk_cmctree_node_nth
1600 item
->sort_type
== SORT_ASCENDING
1601 ? 0 : GTK_CMCLIST(ctree
)->rows
- 1);
1604 case ACTION_NOTHING
:
1615 summary_unlock(summaryview
);
1618 gint open_selected
= -1;
1620 if (OPEN_SELECTED_ON_FOLDER_OPEN
)
1625 summary_select_node(summaryview
, node
, open_selected
);
1628 summary_lock(summaryview
);
1631 summary_status_show(summaryview
);
1632 summary_set_menu_sensitive(summaryview
);
1633 toolbar_main_set_sensitive(summaryview
->mainwin
);
1635 summary_thaw(summaryview
);
1637 STATUSBAR_PUSH(summaryview
->mainwin
, _("Done."));
1638 STATUSBAR_POP(summaryview
->mainwin
);
1639 main_window_cursor_normal(summaryview
->mainwin
);
1640 summary_unlock(summaryview
);
1646 #undef CURRENTLY_DISPLAYED
1648 static void summary_cancel_mark_read_timeout(SummaryView
*summaryview
) {
1649 if (summaryview
->mark_as_read_timeout_tag
!= 0) {
1650 g_source_remove(summaryview
->mark_as_read_timeout_tag
);
1651 summaryview
->mark_as_read_timeout_tag
= 0;
1655 void summary_clear_list(SummaryView
*summaryview
)
1657 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
1660 summary_freeze(summaryview
);
1662 gtk_cmctree_pre_recursive(GTK_CMCTREE(summaryview
->ctree
),
1663 NULL
, summary_free_msginfo_func
, NULL
);
1665 if (summaryview
->folder_item
) {
1666 summaryview
->folder_item
->opened
= FALSE
;
1667 summaryview
->folder_item
= NULL
;
1670 summary_cancel_mark_read_timeout(summaryview
);
1672 summaryview
->display_msg
= FALSE
;
1674 summaryview
->selected
= NULL
;
1675 summaryview
->displayed
= NULL
;
1676 summaryview
->total_size
= 0;
1677 summaryview
->deleted
= summaryview
->moved
= 0;
1678 summaryview
->copied
= 0;
1679 if (summaryview
->msgid_table
) {
1680 g_hash_table_destroy(summaryview
->msgid_table
);
1681 summaryview
->msgid_table
= NULL
;
1683 if (summaryview
->subject_table
) {
1684 g_hash_table_destroy(summaryview
->subject_table
);
1685 summaryview
->subject_table
= NULL
;
1687 summaryview
->mlist
= NULL
;
1689 gtk_cmclist_clear(clist
);
1690 if (summaryview
->col_pos
[S_COL_SUBJECT
] == N_SUMMARY_COLS
- 1) {
1691 optimal_width
= gtk_cmclist_optimal_column_width
1692 (clist
, summaryview
->col_pos
[S_COL_SUBJECT
]);
1693 gtk_cmclist_set_column_width
1694 (clist
, summaryview
->col_pos
[S_COL_SUBJECT
],
1698 summary_thaw(summaryview
);
1701 void summary_clear_all(SummaryView
*summaryview
)
1703 messageview_clear(summaryview
->messageview
);
1704 summary_clear_list(summaryview
);
1705 summary_set_menu_sensitive(summaryview
);
1706 toolbar_main_set_sensitive(summaryview
->mainwin
);
1707 summary_status_show(summaryview
);
1710 void summary_lock(SummaryView
*summaryview
)
1712 summaryview
->lock_count
++;
1715 void summary_unlock(SummaryView
*summaryview
)
1717 if (summaryview
->lock_count
)
1718 summaryview
->lock_count
--;
1721 gboolean
summary_is_locked(SummaryView
*summaryview
)
1723 return summaryview
->lock_count
> 0;
1726 SummarySelection
summary_get_selection_type(SummaryView
*summaryview
)
1728 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
1729 SummarySelection selection
;
1731 if (!clist
->row_list
)
1732 selection
= SUMMARY_NONE
;
1733 else if (!clist
->selection
)
1734 selection
= SUMMARY_SELECTED_NONE
;
1735 else if (!clist
->selection
->next
)
1736 selection
= SUMMARY_SELECTED_SINGLE
;
1738 selection
= SUMMARY_SELECTED_MULTIPLE
;
1744 *\return MsgInfo * Selected message if there's one selected;
1745 * if multiple selected, or none, return NULL.
1747 MsgInfo
*summary_get_selected_msg(SummaryView
*summaryview
)
1749 /* summaryview->selected may be valid when multiple
1750 * messages were selected */
1751 GList
*sellist
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
1753 if (sellist
== NULL
|| sellist
->next
)
1756 return GTKUT_CTREE_NODE_GET_ROW_DATA(sellist
->data
);
1759 GSList
*summary_get_selected_msg_list(SummaryView
*summaryview
)
1761 GSList
*mlist
= NULL
;
1765 for (cur
= GTK_CMCLIST(summaryview
->ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
;
1767 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(cur
->data
);
1768 mlist
= g_slist_prepend(mlist
, msginfo
);
1771 mlist
= g_slist_reverse(mlist
);
1776 void summary_set_menu_sensitive(SummaryView
*summaryview
)
1778 SensitiveCondMask state
;
1782 #ifndef GENERIC_UMPC
1783 #define N_ENTRIES 39
1785 #define N_ENTRIES 28
1789 SensitiveCondMask cond
;
1793 #define FILL_TABLE(entry_str, ...) \
1795 entry[i].entry = (const gchar *) entry_str; entry[i++].cond = main_window_get_mask(__VA_ARGS__, -1); \
1798 FILL_TABLE("Menus/SummaryViewPopup/Reply", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1799 #ifndef GENERIC_UMPC
1800 FILL_TABLE("Menus/SummaryViewPopup/ReplyTo", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1801 FILL_TABLE("Menus/SummaryViewPopup/ReplyTo/All", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1802 FILL_TABLE("Menus/SummaryViewPopup/ReplyTo/Sender", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1803 FILL_TABLE("Menus/SummaryViewPopup/ReplyTo/MailingList", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1806 FILL_TABLE("Menus/SummaryViewPopup/Forward", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1807 #ifndef GENERIC_UMPC
1808 FILL_TABLE("Menus/SummaryViewPopup/ForwardAtt", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1809 FILL_TABLE("Menus/SummaryViewPopup/Redirect", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1812 FILL_TABLE("Menus/SummaryViewPopup/Move", M_TARGET_EXIST
, M_ALLOW_DELETE
, M_NOT_NEWS
);
1813 FILL_TABLE("Menus/SummaryViewPopup/Copy", M_TARGET_EXIST
, M_EXEC
);
1814 FILL_TABLE("Menus/SummaryViewPopup/Trash", M_TARGET_EXIST
, M_ALLOW_DELETE
, M_NOT_NEWS
, M_NOT_TRASH
);
1815 #ifndef GENERIC_UMPC
1816 FILL_TABLE("Menus/SummaryViewPopup/Delete", M_TARGET_EXIST
, M_ALLOW_DELETE
);
1819 FILL_TABLE("Menus/SummaryViewPopup/Mark", M_TARGET_EXIST
);
1820 FILL_TABLE("Menus/SummaryViewPopup/Mark/Mark", M_TARGET_EXIST
);
1821 FILL_TABLE("Menus/SummaryViewPopup/Mark/Unmark", M_TARGET_EXIST
);
1822 FILL_TABLE("Menus/SummaryViewPopup/Mark/MarkRead", M_TARGET_EXIST
);
1823 FILL_TABLE("Menus/SummaryViewPopup/Mark/MarkUnread", M_TARGET_EXIST
);
1824 FILL_TABLE("Menus/SummaryViewPopup/Mark/MarkAllRead", M_TARGET_EXIST
);
1825 FILL_TABLE("Menus/SummaryViewPopup/Mark/MarkAllUnread", M_TARGET_EXIST
);
1826 FILL_TABLE("Menus/SummaryViewPopup/Mark/IgnoreThread", M_TARGET_EXIST
);
1827 FILL_TABLE("Menus/SummaryViewPopup/Mark/UnignoreThread", M_TARGET_EXIST
);
1828 FILL_TABLE("Menus/SummaryViewPopup/Mark/WatchThread", M_TARGET_EXIST
);
1829 FILL_TABLE("Menus/SummaryViewPopup/Mark/UnwatchThread", M_TARGET_EXIST
);
1830 FILL_TABLE("Menus/SummaryViewPopup/Mark/Lock", M_TARGET_EXIST
);
1831 FILL_TABLE("Menus/SummaryViewPopup/Mark/Unlock", M_TARGET_EXIST
);
1832 FILL_TABLE("Menus/SummaryViewPopup/Mark/MarkSpam", M_TARGET_EXIST
, M_CAN_LEARN_SPAM
);
1833 FILL_TABLE("Menus/SummaryViewPopup/Mark/MarkHam", M_TARGET_EXIST
, M_CAN_LEARN_SPAM
);
1834 FILL_TABLE("Menus/SummaryViewPopup/ColorLabel", M_TARGET_EXIST
);
1835 FILL_TABLE("Menus/SummaryViewPopup/Tags", M_TARGET_EXIST
);
1837 #ifndef GENERIC_UMPC
1838 FILL_TABLE("Menus/SummaryViewPopup/AddSenderToAB", M_SINGLE_TARGET_EXIST
);
1840 FILL_TABLE("Menus/SummaryViewPopup/CreateFilterRule", M_SINGLE_TARGET_EXIST
, M_UNLOCKED
);
1841 #ifndef GENERIC_UMPC
1842 FILL_TABLE("Menus/SummaryViewPopup/CreateProcessingRule", M_SINGLE_TARGET_EXIST
, M_UNLOCKED
);
1845 FILL_TABLE("Menus/SummaryViewPopup/View", M_SINGLE_TARGET_EXIST
);
1846 FILL_TABLE("Menus/SummaryViewPopup/View/OpenNewWindow", M_SINGLE_TARGET_EXIST
);
1847 FILL_TABLE("Menus/SummaryViewPopup/View/MessageSource", M_SINGLE_TARGET_EXIST
);
1848 #ifndef GENERIC_UMPC
1849 FILL_TABLE("Menus/SummaryViewPopup/View/AllHeaders", M_SINGLE_TARGET_EXIST
);
1851 FILL_TABLE("Menus/SummaryViewPopup/SaveAs", M_TARGET_EXIST
);
1852 #ifndef GENERIC_UMPC
1853 FILL_TABLE("Menus/SummaryViewPopup/Print", M_TARGET_EXIST
);
1855 FILL_TABLE(NULL
, -1);
1858 g_error("summaryview menu entry table size mismatch (%d/%d)", i
, N_ENTRIES
);
1861 main_window_set_menu_sensitive(summaryview
->mainwin
);
1863 state
= main_window_get_current_state(summaryview
->mainwin
);
1865 for (i
= 0; entry
[i
].entry
!= NULL
; i
++) {
1866 sensitive
= ((entry
[i
].cond
& state
) == entry
[i
].cond
);
1867 cm_menu_set_sensitive_full(summaryview
->mainwin
->ui_manager
, entry
[i
].entry
, sensitive
);
1870 summary_lock(summaryview
);
1871 #ifndef GENERIC_UMPC
1872 if (summaryview
->messageview
1873 && summaryview
->messageview
->mimeview
1874 && summaryview
->messageview
->mimeview
->textview
)
1875 cm_toggle_menu_set_active_full(summaryview
->mainwin
->ui_manager
, "Menus/SummaryViewPopup/View/AllHeaders",
1876 prefs_common
.show_all_headers
);
1878 summary_unlock(summaryview
);
1880 void summary_select_prev(SummaryView
*summaryview
)
1882 GtkCMCTreeNode
*node
= summaryview
->selected
;
1883 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
1885 if (summaryview
->sort_type
== SORT_ASCENDING
)
1886 node
= gtkut_ctree_node_prev(ctree
, node
);
1888 node
= gtkut_ctree_node_next(ctree
, node
);
1890 if (node
&& node
!= summaryview
->selected
)
1891 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
1894 void summary_select_next(SummaryView
*summaryview
)
1896 GtkCMCTreeNode
*node
= summaryview
->selected
;
1897 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
1899 if (summaryview
->sort_type
== SORT_ASCENDING
)
1900 node
= gtkut_ctree_node_next(ctree
, node
);
1902 node
= gtkut_ctree_node_prev(ctree
, node
);
1904 if (node
&& node
!= summaryview
->selected
)
1905 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
1908 void summary_select_prev_unread(SummaryView
*summaryview
)
1910 GtkCMCTreeNode
*node
;
1912 if (summaryview
->sort_type
== SORT_ASCENDING
)
1913 node
= summary_find_prev_flagged_msg
1914 (summaryview
, summaryview
->selected
, MSG_UNREAD
, TRUE
);
1916 node
= summary_find_next_flagged_msg
1917 (summaryview
, summaryview
->selected
, MSG_UNREAD
, TRUE
);
1919 if (!node
|| node
== summaryview
->selected
) {
1922 switch (prefs_common
.next_unread_msg_dialog
) {
1923 case NEXTUNREADMSGDIALOG_ALWAYS
:
1924 val
= alertpanel(_("No more unread messages"),
1925 _("No unread message found. "
1926 "Search from the end?"),
1927 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
1929 case NEXTUNREADMSGDIALOG_ASSUME_YES
:
1930 val
= G_ALERTALTERNATE
;
1932 case NEXTUNREADMSGDIALOG_ASSUME_NO
:
1933 val
= !G_ALERTALTERNATE
;
1937 _("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n"));
1939 if (val
!= G_ALERTALTERNATE
) return;
1940 if (summaryview
->sort_type
== SORT_ASCENDING
)
1941 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1944 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1949 alertpanel_notice(_("No unread messages."));
1951 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
1954 void summary_select_next_unread(SummaryView
*summaryview
)
1956 GtkCMCTreeNode
*node
= summaryview
->selected
;
1958 if (summaryview
->sort_type
== SORT_ASCENDING
)
1959 node
= summary_find_next_flagged_msg
1960 (summaryview
, node
, MSG_UNREAD
, TRUE
);
1962 node
= summary_find_prev_flagged_msg
1963 (summaryview
, node
, MSG_UNREAD
, TRUE
);
1966 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
1970 switch (prefs_common
.next_unread_msg_dialog
) {
1971 case NEXTUNREADMSGDIALOG_ALWAYS
:
1972 val
= alertpanel(_("No more unread messages"),
1973 _("No unread message found. "
1974 "Go to next folder?"),
1975 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
1977 case NEXTUNREADMSGDIALOG_ASSUME_YES
:
1978 val
= G_ALERTALTERNATE
;
1980 case NEXTUNREADMSGDIALOG_ASSUME_NO
:
1985 _("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n"));
1988 if (val
== G_ALERTALTERNATE
)
1989 folderview_select_next_with_flag(summaryview
->folderview
, MSG_UNREAD
);
1993 void summary_select_prev_new(SummaryView
*summaryview
)
1995 GtkCMCTreeNode
*node
;
1997 if (summaryview
->sort_type
== SORT_ASCENDING
)
1998 node
= summary_find_prev_flagged_msg
1999 (summaryview
, summaryview
->selected
, MSG_NEW
, TRUE
);
2001 node
= summary_find_next_flagged_msg
2002 (summaryview
, summaryview
->selected
, MSG_NEW
, TRUE
);
2004 if (!node
|| node
== summaryview
->selected
) {
2007 switch (prefs_common
.next_unread_msg_dialog
) {
2008 case NEXTUNREADMSGDIALOG_ALWAYS
:
2009 val
= alertpanel(_("No more new messages"),
2010 _("No new message found. "
2011 "Search from the end?"),
2012 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
2014 case NEXTUNREADMSGDIALOG_ASSUME_YES
:
2015 val
= G_ALERTALTERNATE
;
2017 case NEXTUNREADMSGDIALOG_ASSUME_NO
:
2018 val
= !G_ALERTALTERNATE
;
2022 _("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n"));
2024 if (val
!= G_ALERTALTERNATE
) return;
2025 if (summaryview
->sort_type
== SORT_ASCENDING
)
2026 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
2029 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
2034 alertpanel_notice(_("No new messages."));
2036 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2039 void summary_select_next_new(SummaryView
*summaryview
)
2041 GtkCMCTreeNode
*node
= summaryview
->selected
;
2043 if (summaryview
->sort_type
== SORT_ASCENDING
)
2044 node
= summary_find_next_flagged_msg
2045 (summaryview
, node
, MSG_NEW
, TRUE
);
2047 node
= summary_find_prev_flagged_msg
2048 (summaryview
, node
, MSG_NEW
, TRUE
);
2051 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2055 switch (prefs_common
.next_unread_msg_dialog
) {
2056 case NEXTUNREADMSGDIALOG_ALWAYS
:
2057 val
= alertpanel(_("No more new messages"),
2058 _("No new message found. "
2059 "Go to next folder?"),
2060 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
2062 case NEXTUNREADMSGDIALOG_ASSUME_YES
:
2063 val
= G_ALERTALTERNATE
;
2065 case NEXTUNREADMSGDIALOG_ASSUME_NO
:
2070 _("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n"));
2072 if (val
== G_ALERTALTERNATE
)
2073 folderview_select_next_with_flag(summaryview
->folderview
, MSG_NEW
);
2077 void summary_select_prev_marked(SummaryView
*summaryview
)
2079 GtkCMCTreeNode
*node
;
2081 if (summaryview
->sort_type
== SORT_ASCENDING
)
2082 node
= summary_find_prev_flagged_msg
2083 (summaryview
, summaryview
->selected
, MSG_MARKED
, TRUE
);
2085 node
= summary_find_next_flagged_msg
2086 (summaryview
, summaryview
->selected
, MSG_MARKED
, TRUE
);
2091 val
= alertpanel(_("No more marked messages"),
2092 _("No marked message found. "
2093 "Search from the end?"),
2094 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
2095 if (val
!= G_ALERTALTERNATE
) return;
2096 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
2101 alertpanel_notice(_("No marked messages."));
2103 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2106 void summary_select_next_marked(SummaryView
*summaryview
)
2108 GtkCMCTreeNode
*node
= summaryview
->selected
;
2110 if (summaryview
->sort_type
== SORT_ASCENDING
)
2111 node
= summary_find_next_flagged_msg
2112 (summaryview
, node
, MSG_MARKED
, TRUE
);
2114 node
= summary_find_prev_flagged_msg
2115 (summaryview
, node
, MSG_MARKED
, TRUE
);
2118 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2122 switch (prefs_common
.next_unread_msg_dialog
) {
2123 case NEXTUNREADMSGDIALOG_ALWAYS
:
2124 val
= alertpanel(_("No more marked messages"),
2125 _("No marked message found. "
2126 "Go to next folder?"),
2127 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
2129 case NEXTUNREADMSGDIALOG_ASSUME_YES
:
2130 val
= G_ALERTALTERNATE
;
2132 case NEXTUNREADMSGDIALOG_ASSUME_NO
:
2137 _("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n"));
2139 if (val
== G_ALERTALTERNATE
)
2140 folderview_select_next_with_flag(summaryview
->folderview
, MSG_MARKED
);
2144 void summary_select_prev_labeled(SummaryView
*summaryview
)
2146 GtkCMCTreeNode
*node
;
2148 if (summaryview
->sort_type
== SORT_ASCENDING
)
2149 node
= summary_find_prev_flagged_msg
2150 (summaryview
, summaryview
->selected
, MSG_CLABEL_FLAG_MASK
, TRUE
);
2152 node
= summary_find_next_flagged_msg
2153 (summaryview
, summaryview
->selected
, MSG_CLABEL_FLAG_MASK
, TRUE
);
2158 val
= alertpanel(_("No more labeled messages"),
2159 _("No labeled message found. "
2160 "Search from the end?"),
2161 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
2162 if (val
!= G_ALERTALTERNATE
) return;
2163 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
2164 MSG_CLABEL_FLAG_MASK
, TRUE
);
2168 alertpanel_notice(_("No labeled messages."));
2170 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2173 void summary_select_next_labeled(SummaryView
*summaryview
)
2175 GtkCMCTreeNode
*node
;
2177 if (summaryview
->sort_type
== SORT_ASCENDING
)
2178 node
= summary_find_next_flagged_msg
2179 (summaryview
, summaryview
->selected
, MSG_CLABEL_FLAG_MASK
, TRUE
);
2181 node
= summary_find_prev_flagged_msg
2182 (summaryview
, summaryview
->selected
, MSG_CLABEL_FLAG_MASK
, TRUE
);
2187 val
= alertpanel(_("No more labeled messages"),
2188 _("No labeled message found. "
2189 "Search from the beginning?"),
2190 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
2191 if (val
!= G_ALERTALTERNATE
) return;
2192 if (summaryview
->sort_type
== SORT_ASCENDING
)
2193 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
2194 MSG_CLABEL_FLAG_MASK
, TRUE
);
2196 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
2197 MSG_CLABEL_FLAG_MASK
, TRUE
);
2201 alertpanel_notice(_("No labeled messages."));
2203 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2206 void summary_select_parent(SummaryView
*summaryview
)
2208 GtkCMCTreeNode
*node
= NULL
;
2210 if (summaryview
->selected
)
2211 node
= GTK_CMCTREE_ROW(summaryview
->selected
)->parent
;
2213 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2216 void summary_select_by_msgnum(SummaryView
*summaryview
, guint msgnum
,
2219 GtkCMCTreeNode
*node
;
2221 node
= summary_find_msg_by_msgnum(summaryview
, msgnum
);
2222 summary_select_node(summaryview
, node
, show
);
2225 void summary_select_by_msg_list(SummaryView
*summaryview
, GSList
*msginfos
)
2228 GSList
*msgnum_list
, *walk
;
2229 gboolean froze
= FALSE
;
2231 ctree
= GTK_CMCTREE(summaryview
->ctree
);
2233 msgnum_list
= procmsg_get_number_list_for_msgs(msginfos
);
2235 START_LONG_OPERATION(summaryview
, FALSE
);
2236 for(walk
= msgnum_list
; walk
; walk
= walk
->next
) {
2237 GtkCMCTreeNode
*node
;
2238 node
= summary_find_msg_by_msgnum(summaryview
, GPOINTER_TO_UINT(walk
->data
));
2240 gtk_cmctree_select(ctree
, node
);
2242 END_LONG_OPERATION(summaryview
);
2243 g_slist_free(msgnum_list
);
2246 typedef struct _PostponedSelectData
2249 GtkCMCTreeNode
*row
;
2250 GtkCMCTreeNode
*node
;
2253 SummaryView
*summaryview
;
2254 gboolean display_msg
;
2255 } PostponedSelectData
;
2257 static gboolean
summary_select_retry(void *data
)
2259 PostponedSelectData
*psdata
= (PostponedSelectData
*)data
;
2260 debug_print("trying again\n");
2262 summary_selected(psdata
->ctree
, psdata
->row
,
2263 psdata
->column
, psdata
->summaryview
);
2264 else if (psdata
->node
)
2265 summary_select_node(psdata
->summaryview
, psdata
->node
,
2266 psdata
->display_msg
);
2272 * summary_select_node:
2273 * @summaryview: Summary view.
2274 * @node: Summary tree node.
2275 * @display_msg: whether to also display the message
2277 * Select @node (bringing it into view by scrolling and expanding its
2278 * thread, if necessary) and unselect all others.
2281 void summary_select_node(SummaryView
*summaryview
, GtkCMCTreeNode
*node
,
2282 gboolean display_msg
)
2284 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2286 /* If msgview is hidden, we never want to automatically display
2287 * a selected message, since that would unhide the msgview. */
2288 if (!messageview_is_visible(summaryview
->messageview
))
2289 display_msg
= FALSE
;
2291 if (summary_is_locked(summaryview
)
2292 && !GTK_SCTREE(ctree
)->selecting_range
2293 && summaryview
->messageview
->mimeview
2294 && summaryview
->messageview
->mimeview
->type
== MIMEVIEW_TEXT
2295 && summaryview
->messageview
->mimeview
->textview
->loading
) {
2296 PostponedSelectData
*data
= g_new0(PostponedSelectData
, 1);
2297 summaryview
->messageview
->mimeview
->textview
->stop_loading
= TRUE
;
2299 data
->ctree
= ctree
;
2302 data
->summaryview
= summaryview
;
2303 data
->display_msg
= display_msg
;
2304 debug_print("postponing open of message till end of load\n");
2305 g_timeout_add(100, summary_select_retry
, data
);
2308 if (summary_is_locked(summaryview
)) {
2311 if (!summaryview
->folder_item
)
2314 gtkut_ctree_expand_parent_all(ctree
, node
);
2316 summary_lock(summaryview
);
2318 summary_unlock(summaryview
);
2319 gtk_widget_grab_focus(GTK_WIDGET(ctree
));
2320 gtkut_ctree_node_move_if_on_the_edge(ctree
, node
, -1);
2322 if (display_msg
&& summaryview
->displayed
== node
)
2323 summaryview
->displayed
= NULL
;
2324 summaryview
->display_msg
= display_msg
;
2325 gtk_sctree_select(GTK_SCTREE(ctree
), node
);
2326 if (summaryview
->selected
== NULL
)
2327 summaryview
->selected
= node
;
2331 guint
summary_get_msgnum(SummaryView
*summaryview
, GtkCMCTreeNode
*node
)
2333 GtkCMCTree
*ctree
=NULL
;
2338 ctree
= GTK_CMCTREE(summaryview
->ctree
);
2341 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2343 return msginfo
->msgnum
;
2348 static GtkCMCTreeNode
*summary_find_prev_msg(SummaryView
*summaryview
,
2349 GtkCMCTreeNode
*current_node
,
2350 gboolean start_from_prev
)
2352 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2353 GtkCMCTreeNode
*node
;
2357 if (start_from_prev
)
2358 node
= gtkut_ctree_node_prev(ctree
, current_node
);
2360 node
= current_node
;
2362 node
= gtk_cmctree_node_nth(ctree
, GTK_CMCLIST(ctree
)->rows
- 1);
2364 for (; node
!= NULL
; node
= gtkut_ctree_node_prev(ctree
, node
)) {
2365 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2366 if (msginfo
&& !MSG_IS_DELETED(msginfo
->flags
)) break;
2372 static GtkCMCTreeNode
*summary_find_next_msg(SummaryView
*summaryview
,
2373 GtkCMCTreeNode
*current_node
,
2374 gboolean start_from_next
)
2376 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2377 GtkCMCTreeNode
*node
;
2381 if (start_from_next
)
2382 node
= gtkut_ctree_node_next(ctree
, current_node
);
2384 node
= current_node
;
2386 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
2388 for (; node
!= NULL
; node
= gtkut_ctree_node_next(ctree
, node
)) {
2389 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2390 if (msginfo
&& !MSG_IS_DELETED(msginfo
->flags
)
2391 && !MSG_IS_MOVE(msginfo
->flags
)) break;
2397 static GtkCMCTreeNode
*summary_find_prev_flagged_msg(SummaryView
*summaryview
,
2398 GtkCMCTreeNode
*current_node
,
2400 gboolean start_from_prev
)
2402 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2403 GtkCMCTreeNode
*node
;
2407 if (start_from_prev
)
2408 node
= gtkut_ctree_node_prev(ctree
, current_node
);
2410 node
= current_node
;
2412 node
= gtk_cmctree_node_nth(ctree
, GTK_CMCLIST(ctree
)->rows
- 1);
2414 for (; node
!= NULL
; node
= gtkut_ctree_node_prev(ctree
, node
)) {
2415 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2416 if (msginfo
&& (msginfo
->flags
.perm_flags
& flags
) != 0) break;
2422 static GtkCMCTreeNode
*summary_find_next_flagged_msg(SummaryView
*summaryview
,
2423 GtkCMCTreeNode
*current_node
,
2425 gboolean start_from_next
)
2427 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2428 GtkCMCTreeNode
*node
;
2432 if (start_from_next
)
2433 node
= gtkut_ctree_node_next(ctree
, current_node
);
2435 node
= current_node
;
2437 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
2439 for (; node
!= NULL
; node
= gtkut_ctree_node_next(ctree
, node
)) {
2440 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2441 /* Find msg with matching flags but ignore messages with
2442 ignore flags, if searching for new or unread messages */
2443 if ((msginfo
&& (msginfo
->flags
.perm_flags
& flags
) != 0) &&
2444 !(((flags
& (MSG_NEW
| MSG_UNREAD
)) != 0) && MSG_IS_IGNORE_THREAD(msginfo
->flags
))
2452 static GtkCMCTreeNode
*summary_find_msg_by_msgnum(SummaryView
*summaryview
,
2455 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2456 GtkCMCTreeNode
*node
;
2459 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
2461 for (; node
!= NULL
; node
= gtkut_ctree_node_next(ctree
, node
)) {
2462 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2463 if (msginfo
&& msginfo
->msgnum
== msgnum
) break;
2469 static guint
attract_hash_func(gconstpointer key
)
2475 Xstrdup_a(str
, (const gchar
*)key
, return 0);
2482 for (p
+= 1; *p
!= '\0'; p
++)
2483 h
= (h
<< 5) - h
+ *p
;
2489 static gint
attract_compare_func(gconstpointer a
, gconstpointer b
)
2491 return subject_compare((const gchar
*)a
, (const gchar
*)b
) == 0;
2494 void summary_attract_by_subject(SummaryView
*summaryview
)
2496 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2497 GtkCMCList
*clist
= GTK_CMCLIST(ctree
);
2498 GtkCMCTreeNode
*src_node
;
2499 GtkCMCTreeNode
*dst_node
, *sibling
;
2500 GtkCMCTreeNode
*tmp
;
2501 MsgInfo
*src_msginfo
, *dst_msginfo
;
2502 GHashTable
*subject_table
;
2504 debug_print("Attracting messages by subject...\n");
2505 STATUSBAR_PUSH(summaryview
->mainwin
,
2506 _("Attracting messages by subject..."));
2508 main_window_cursor_wait(summaryview
->mainwin
);
2509 summary_freeze(summaryview
);
2511 subject_table
= g_hash_table_new(attract_hash_func
,
2512 attract_compare_func
);
2514 for (src_node
= GTK_CMCTREE_NODE(clist
->row_list
);
2517 tmp
= GTK_CMCTREE_ROW(src_node
)->sibling
;
2518 src_msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(src_node
);
2519 if (!src_msginfo
) continue;
2520 if (!src_msginfo
->subject
) continue;
2522 /* find attracting node */
2523 dst_node
= g_hash_table_lookup(subject_table
,
2524 src_msginfo
->subject
);
2527 dst_msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(dst_node
);
2529 /* if the time difference is more than 20 days,
2531 if (ABS(src_msginfo
->date_t
- dst_msginfo
->date_t
)
2532 > 60 * 60 * 24 * 20)
2535 sibling
= GTK_CMCTREE_ROW(dst_node
)->sibling
;
2536 if (src_node
!= sibling
)
2537 gtk_cmctree_move(ctree
, src_node
, NULL
, sibling
);
2540 g_hash_table_insert(subject_table
,
2541 src_msginfo
->subject
, src_node
);
2544 g_hash_table_destroy(subject_table
);
2546 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
2548 summary_thaw(summaryview
);
2550 debug_print("Attracting messages by subject done.\n");
2551 STATUSBAR_POP(summaryview
->mainwin
);
2553 main_window_cursor_normal(summaryview
->mainwin
);
2556 static void summary_free_msginfo_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
2559 MsgInfo
*msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2562 procmsg_msginfo_free(&msginfo
);
2565 static void summary_set_marks_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
2568 SummaryView
*summaryview
= data
;
2571 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2573 cm_return_if_fail(msginfo
!= NULL
);
2575 if (MSG_IS_DELETED(msginfo
->flags
))
2576 summaryview
->deleted
++;
2578 summaryview
->total_size
+= msginfo
->size
;
2580 summary_set_row_marks(summaryview
, node
);
2583 static void summary_update_status(SummaryView
*summaryview
)
2585 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2586 GtkCMCTreeNode
*node
;
2589 summaryview
->total_size
=
2590 summaryview
->deleted
= summaryview
->moved
= summaryview
->copied
= 0;
2592 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
2593 node
!= NULL
; node
= gtkut_ctree_node_next(ctree
, node
)) {
2594 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
2599 if (MSG_IS_DELETED(msginfo
->flags
))
2600 summaryview
->deleted
++;
2601 if (MSG_IS_MOVE(msginfo
->flags
))
2602 summaryview
->moved
++;
2603 if (MSG_IS_COPY(msginfo
->flags
))
2604 summaryview
->copied
++;
2605 summaryview
->total_size
+= msginfo
->size
;
2609 static void summary_status_show(SummaryView
*summaryview
)
2612 gchar
*del
, *mv
, *cp
;
2616 GList
*rowlist
, *cur
;
2617 guint n_selected
= 0, n_new
= 0, n_unread
= 0, n_total
= 0;
2618 guint n_marked
= 0, n_replied
= 0, n_forwarded
= 0, n_locked
= 0, n_ignored
= 0, n_watched
= 0;
2619 goffset sel_size
= 0, n_size
= 0;
2624 if (!summaryview
->folder_item
) {
2625 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_folder
), "");
2626 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_select
), "");
2627 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_msgs
), "");
2628 toolbar_main_set_sensitive(summaryview
->mainwin
);
2632 rowlist
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
2633 for (cur
= rowlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
2634 msginfo
= gtk_cmctree_node_get_row_data
2635 (GTK_CMCTREE(summaryview
->ctree
),
2636 GTK_CMCTREE_NODE(cur
->data
));
2638 sel_size
+= msginfo
->size
;
2643 if (summaryview
->folder_item
->hide_read_msgs
2644 || summaryview
->folder_item
->hide_del_msgs
2645 || summaryview
->folder_item
->hide_read_threads
2646 || quicksearch_has_sat_predicate(summaryview
->quicksearch
)) {
2647 rowlist
= GTK_CMCLIST(summaryview
->ctree
)->row_list
;
2648 for (cur
= rowlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
2649 msginfo
= gtk_cmctree_node_get_row_data
2650 (GTK_CMCTREE(summaryview
->ctree
),
2651 GTK_CMCTREE_NODE(cur
));
2653 n_size
+= msginfo
->size
;
2655 if (MSG_IS_NEW(msginfo
->flags
))
2657 if (MSG_IS_UNREAD(msginfo
->flags
))
2659 if (MSG_IS_MARKED(msginfo
->flags
))
2661 if (MSG_IS_REPLIED(msginfo
->flags
))
2663 if (MSG_IS_FORWARDED(msginfo
->flags
))
2665 if (MSG_IS_LOCKED(msginfo
->flags
))
2667 if (MSG_IS_IGNORE_THREAD(msginfo
->flags
))
2669 if (MSG_IS_WATCH_THREAD(msginfo
->flags
))
2674 n_new
= summaryview
->folder_item
->new_msgs
;
2675 n_unread
= summaryview
->folder_item
->unread_msgs
;
2676 n_marked
= summaryview
->folder_item
->marked_msgs
;
2677 n_replied
= summaryview
->folder_item
->replied_msgs
;
2678 n_forwarded
= summaryview
->folder_item
->forwarded_msgs
;
2679 n_locked
= summaryview
->folder_item
->locked_msgs
;
2680 n_ignored
= summaryview
->folder_item
->ignored_msgs
;
2681 n_watched
= summaryview
->folder_item
->watched_msgs
;
2682 n_total
= summaryview
->folder_item
->total_msgs
;
2683 n_size
= summaryview
->total_size
;
2686 name
= folder_item_get_name(summaryview
->folder_item
);
2687 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_folder
), name
);
2690 if (summaryview
->deleted
)
2691 del
= g_strdup_printf(_("%d deleted"), summaryview
->deleted
);
2694 if (summaryview
->moved
)
2695 mv
= g_strdup_printf(_("%s%d moved"),
2696 summaryview
->deleted
? _(", ") : "",
2697 summaryview
->moved
);
2700 if (summaryview
->copied
)
2701 cp
= g_strdup_printf(_("%s%d copied"),
2702 summaryview
->deleted
||
2703 summaryview
->moved
? _(", ") : "",
2704 summaryview
->copied
);
2708 if (summaryview
->deleted
|| summaryview
->moved
|| summaryview
->copied
)
2714 sel
= g_strdup_printf(" (%s)", to_human_readable((goffset
)sel_size
));
2715 itstr
= g_strdup_printf(ngettext(" item selected"," items selected", n_selected
));
2718 itstr
= g_strdup("");
2721 if (prefs_common
.layout_mode
!= SMALL_LAYOUT
) {
2722 str
= g_strconcat(n_selected
? itos(n_selected
) : "",
2723 itstr
, sel
, spc
, del
, mv
, cp
, NULL
);
2730 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_select
), str
);
2733 str
= g_strdup_printf(_("%d new, %d unread, %d total (%s)"),
2734 n_new
, n_unread
, n_total
,
2735 to_human_readable((goffset
)n_size
));
2738 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_msgs
), str
);
2740 tooltip
= g_strdup_printf("<b>%s</b>\n"
2751 _("Message summary"),
2753 _("Unread:"), n_unread
,
2754 _("Total:"), n_total
,
2755 _("Size:"), to_human_readable((goffset
)n_size
),
2756 _("Marked:"), n_marked
,
2757 _("Replied:"), n_replied
,
2758 _("Forwarded:"), n_forwarded
,
2759 _("Locked:"), n_locked
,
2760 _("Ignored:"), n_ignored
,
2761 _("Watched:"), n_watched
);
2763 gtk_widget_set_tooltip_markup(GTK_WIDGET(summaryview
->statlabel_msgs
),
2767 gchar
*ssize
, *tsize
;
2769 ssize
= g_strdup(to_human_readable((goffset
)sel_size
));
2770 tsize
= g_strdup(to_human_readable((goffset
)n_size
));
2771 str
= g_strdup_printf(_("%d/%d selected (%s/%s), %d unread"),
2772 n_selected
, n_total
, ssize
, tsize
, n_unread
);
2776 str
= g_strdup_printf(_("%d new, %d unread, %d total (%s)"),
2777 n_new
, n_unread
, n_total
, to_human_readable((goffset
)n_size
));
2784 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_select
), str
);
2788 summary_set_menu_sensitive(summaryview
);
2789 toolbar_main_set_sensitive(summaryview
->mainwin
);
2792 static void summary_set_column_titles(SummaryView
*summaryview
)
2794 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
2795 FolderItem
*item
= summaryview
->folder_item
;
2801 SummaryColumnType type
;
2802 GtkJustification justify
;
2804 static FolderSortKey sort_by
[N_SUMMARY_COLS
] = {
2819 for (pos
= 0; pos
< N_SUMMARY_COLS
; pos
++) {
2820 type
= summaryview
->col_state
[pos
].type
;
2822 /* CLAWS: mime and unread are single char headers */
2823 justify
= (type
== S_COL_NUMBER
|| type
== S_COL_SIZE
)
2824 ? GTK_JUSTIFY_RIGHT
: GTK_JUSTIFY_LEFT
;
2832 if(type
== S_COL_FROM
&& item
!= NULL
&&
2833 FOLDER_SHOWS_TO_HDR(item
) &&
2834 !summaryview
->col_state
[summaryview
->col_pos
[S_COL_TO
]].visible
)
2836 if(type
== S_COL_NUMBER
)
2837 title
= gettext(col_label
[type
]);
2839 title
= prefs_common_translated_header_name(col_label
[type
]);
2842 title
= gettext(col_label
[type
]);
2845 if (type
== S_COL_MIME
) {
2846 label
= gtk_image_new_from_pixbuf(clipxpm
);
2847 gtk_widget_show(label
);
2848 gtk_cmclist_set_column_widget(clist
, pos
, label
);
2849 gtk_sctree_set_column_tooltip(GTK_SCTREE(clist
), pos
, _("Attachment"));
2851 } else if (type
== S_COL_MARK
) {
2852 label
= gtk_image_new_from_pixbuf(markxpm
);
2853 gtk_widget_show(label
);
2854 gtk_cmclist_set_column_widget(clist
, pos
, label
);
2855 gtk_sctree_set_column_tooltip(GTK_SCTREE(clist
), pos
, _("Mark"));
2857 } else if (type
== S_COL_LOCKED
) {
2858 label
= gtk_image_new_from_pixbuf(lockedxpm
);
2859 gtk_widget_show(label
);
2860 gtk_cmclist_set_column_widget(clist
, pos
, label
);
2861 gtk_sctree_set_column_tooltip(GTK_SCTREE(clist
), pos
, _("Locked"));
2863 } else if (type
== S_COL_STATUS
) {
2864 gtk_cmclist_set_column_title(clist
, pos
, title
);
2865 gtk_sctree_set_column_tooltip(GTK_SCTREE(clist
), pos
, _("Status"));
2869 hbox
= gtk_hbox_new(FALSE
, 4);
2870 label
= gtk_label_new(title
);
2872 gtk_widget_set_size_request(hbox
, -1, 20);
2875 if (justify
== GTK_JUSTIFY_RIGHT
)
2876 gtk_box_pack_end(GTK_BOX(hbox
), label
,
2879 gtk_box_pack_start(GTK_BOX(hbox
), label
,
2882 if (summaryview
->sort_key
== sort_by
[type
] ||
2883 (summaryview
->sort_key
== SORT_BY_THREAD_DATE
&&
2884 sort_by
[SORT_BY_DATE
] && type
== S_COL_DATE
)) {
2885 arrow
= gtk_arrow_new
2886 (summaryview
->sort_type
== SORT_ASCENDING
2887 ? GTK_ARROW_DOWN
: GTK_ARROW_UP
,
2889 gtk_widget_set_size_request(GTK_WIDGET(arrow
), 10, 10);
2890 if (justify
== GTK_JUSTIFY_RIGHT
)
2891 gtk_box_pack_start(GTK_BOX(hbox
), arrow
,
2894 gtk_box_pack_end(GTK_BOX(hbox
), arrow
,
2898 gtk_widget_show_all(hbox
);
2899 gtk_cmclist_set_column_widget(clist
, pos
, hbox
);
2903 void summary_reflect_tags_changes(SummaryView
*summaryview
)
2906 GList
*children
, *cur
;
2907 GtkCMCTreeNode
*node
;
2908 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2909 gboolean froze
= FALSE
;
2910 gboolean redisplay
= FALSE
;
2912 /* re-create colorlabel submenu */
2913 menu
= GTK_MENU_SHELL(summaryview
->tags_menu
);
2914 cm_return_if_fail(menu
!= NULL
);
2916 /* clear items. get item pointers. */
2917 children
= gtk_container_get_children(GTK_CONTAINER(menu
));
2918 for (cur
= children
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
2919 gtk_menu_item_set_submenu(GTK_MENU_ITEM(cur
->data
), NULL
);
2921 g_list_free(children
);
2922 summary_tags_menu_create(summaryview
, TRUE
);
2924 START_LONG_OPERATION(summaryview
, TRUE
);
2925 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
); node
!= NULL
;
2926 node
= gtkut_ctree_node_next(ctree
, node
)) {
2927 redisplay
|= summary_set_row_tag(summaryview
,
2928 node
, TRUE
, FALSE
, 0);
2930 END_LONG_OPERATION(summaryview
);
2932 summary_redisplay_msg(summaryview
);
2936 void summary_reflect_prefs(void)
2938 static gchar
*last_smallfont
= NULL
;
2939 static gchar
*last_normalfont
= NULL
;
2940 static gchar
*last_boldfont
= NULL
;
2941 static gboolean last_derive
= 0;
2942 gboolean update_font
= FALSE
;
2943 SummaryView
*summaryview
= NULL
;
2945 if (!mainwindow_get_mainwindow())
2947 summaryview
= mainwindow_get_mainwindow()->summaryview
;
2949 if (!last_smallfont
|| strcmp(last_smallfont
, SMALL_FONT
) ||
2950 !last_normalfont
|| strcmp(last_normalfont
, NORMAL_FONT
) ||
2951 !last_boldfont
|| strcmp(last_boldfont
, BOLD_FONT
) ||
2952 last_derive
!= prefs_common
.derive_from_normal_font
)
2955 g_free(last_smallfont
);
2956 last_smallfont
= g_strdup(SMALL_FONT
);
2957 g_free(last_normalfont
);
2958 last_normalfont
= g_strdup(NORMAL_FONT
);
2959 g_free(last_boldfont
);
2960 last_boldfont
= g_strdup(BOLD_FONT
);
2961 last_derive
= prefs_common
.derive_from_normal_font
;
2963 #define STYLE_FREE(s) \
2965 g_object_unref(s); \
2970 STYLE_FREE(bold_style
);
2971 STYLE_FREE(bold_style
);
2972 STYLE_FREE(bold_marked_style
);
2973 STYLE_FREE(bold_deleted_style
);
2974 STYLE_FREE(small_style
);
2975 STYLE_FREE(small_marked_style
);
2976 STYLE_FREE(small_deleted_style
);
2977 summary_set_fonts(summaryview
);
2982 summary_set_column_titles(summaryview
);
2983 summary_relayout(summaryview
);
2985 if (summaryview
->folder_item
)
2986 summary_show(summaryview
, summaryview
->folder_item
);
2989 void summary_sort(SummaryView
*summaryview
,
2990 FolderSortKey sort_key
, FolderSortType sort_type
)
2992 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2993 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
2994 GtkCMCListCompareFunc cmp_func
= NULL
;
2996 g_signal_handlers_block_by_func(G_OBJECT(summaryview
->ctree
),
2997 G_CALLBACK(summary_tree_expanded
), summaryview
);
2998 summary_freeze(summaryview
);
3002 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_mark
;
3004 case SORT_BY_STATUS
:
3005 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_status
;
3008 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_mime
;
3010 case SORT_BY_NUMBER
:
3011 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_num
;
3014 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_size
;
3017 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_date
;
3019 case SORT_BY_THREAD_DATE
:
3020 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_thread_date
;
3023 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_from
;
3025 case SORT_BY_SUBJECT
:
3026 if (summaryview
->simplify_subject_preg
)
3027 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_simplified_subject
;
3029 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_subject
;
3032 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_score
;
3035 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_label
;
3038 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_to
;
3040 case SORT_BY_LOCKED
:
3041 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_locked
;
3044 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_tags
;
3052 summaryview
->sort_key
= sort_key
;
3053 summaryview
->sort_type
= sort_type
;
3055 summary_set_column_titles(summaryview
);
3056 summary_set_menu_sensitive(summaryview
);
3058 /* allow fallback to don't sort */
3059 if (summaryview
->sort_key
== SORT_BY_NONE
)
3062 if (cmp_func
!= NULL
) {
3063 debug_print("Sorting summary...\n");
3064 STATUSBAR_PUSH(summaryview
->mainwin
, _("Sorting summary..."));
3066 main_window_cursor_wait(summaryview
->mainwin
);
3068 gtk_cmclist_set_compare_func(clist
, cmp_func
);
3070 gtk_cmclist_set_sort_type(clist
, (GtkSortType
)sort_type
);
3071 gtk_sctree_sort_recursive(ctree
, NULL
);
3073 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
3075 main_window_cursor_normal(summaryview
->mainwin
);
3077 debug_print("Sorting summary done.\n");
3078 STATUSBAR_POP(summaryview
->mainwin
);
3081 summary_thaw(summaryview
);
3082 g_signal_handlers_unblock_by_func(G_OBJECT(summaryview
->ctree
),
3083 G_CALLBACK(summary_tree_expanded
), summaryview
);
3087 static gboolean
summary_update_thread_age(GNode
*node
, gpointer data
)
3089 MsgInfo
*msginfo
= node
->data
;
3090 time_t *most_recent
= (time_t *)data
;
3092 if (msginfo
->date_t
> *most_recent
) {
3093 *most_recent
= msginfo
->date_t
;
3098 static void summary_find_thread_age(GNode
*gnode
)
3100 MsgInfo
*msginfo
= (MsgInfo
*)gnode
->data
;
3105 most_recent
= msginfo
->thread_date
= msginfo
->date_t
;
3107 g_node_traverse(gnode
, G_IN_ORDER
, G_TRAVERSE_ALL
, -1, summary_update_thread_age
, &most_recent
);
3109 msginfo
->thread_date
= most_recent
;
3112 static gboolean
summary_update_is_read(GNode
*node
, gpointer data
)
3114 MsgInfo
*msginfo
= node
->data
;
3115 gboolean
*all_read
= (gboolean
*)data
;
3117 if (MSG_IS_UNREAD(msginfo
->flags
)) {
3124 static gboolean
summary_thread_is_read(GNode
*gnode
)
3126 MsgInfo
*msginfo
= (MsgInfo
*)gnode
->data
;
3127 gboolean all_read
= TRUE
;
3132 g_node_traverse(gnode
, G_IN_ORDER
, G_TRAVERSE_ALL
, -1, summary_update_is_read
, &all_read
);
3136 typedef struct _ThreadSelectedData
{
3138 gboolean is_selected
;
3139 } ThreadSelectedData
;
3141 static gboolean
summary_update_is_selected(GNode
*gnode
, gpointer data
)
3143 ThreadSelectedData
*selected
= (ThreadSelectedData
*)data
;
3144 MsgInfo
*msginfo
= (MsgInfo
*)gnode
->data
;
3146 if (msginfo
->msgnum
== selected
->msgnum
) {
3147 selected
->is_selected
= TRUE
;
3154 static gboolean
summary_thread_is_selected(GNode
*gnode
, guint selected_msgnum
)
3156 ThreadSelectedData selected
;
3158 selected
.msgnum
= selected_msgnum
;
3159 selected
.is_selected
= FALSE
;
3160 g_node_traverse(gnode
, G_IN_ORDER
, G_TRAVERSE_ALL
, -1,
3161 summary_update_is_selected
, &selected
);
3162 return selected
.is_selected
;
3165 static gboolean
summary_insert_gnode_func(GtkCMCTree
*ctree
, guint depth
, GNode
*gnode
,
3166 GtkCMCTreeNode
*cnode
, gpointer data
)
3168 SummaryView
*summaryview
= (SummaryView
*)data
;
3169 MsgInfo
*msginfo
= (MsgInfo
*)gnode
->data
;
3170 gchar
*text
[N_SUMMARY_COLS
];
3171 gint
*col_pos
= summaryview
->col_pos
;
3172 const gchar
*msgid
= msginfo
->msgid
;
3173 GHashTable
*msgid_table
= summaryview
->msgid_table
;
3174 gboolean vert_layout
= (prefs_common
.layout_mode
== VERTICAL_LAYOUT
);
3175 gboolean small_layout
= (prefs_common
.layout_mode
== SMALL_LAYOUT
);
3177 summary_set_header(summaryview
, text
, msginfo
);
3179 gtk_cmctree_set_node_info(ctree
, cnode
, text
[col_pos
[S_COL_SUBJECT
]], 2,
3180 NULL
, NULL
, FALSE
, summaryview
->threaded
&& !summaryview
->thread_collapsed
);
3181 #define SET_TEXT(col) { \
3182 gtk_cmctree_node_set_text(ctree, cnode, col_pos[col], \
3183 text[col_pos[col]]); \
3186 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_NUMBER
]].visible
)
3187 SET_TEXT(S_COL_NUMBER
);
3188 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_SCORE
]].visible
)
3189 SET_TEXT(S_COL_SCORE
);
3190 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_SIZE
]].visible
)
3191 SET_TEXT(S_COL_SIZE
);
3192 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_DATE
]].visible
)
3193 SET_TEXT(S_COL_DATE
);
3194 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_FROM
]].visible
)
3195 SET_TEXT(S_COL_FROM
);
3196 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_TO
]].visible
)
3198 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_TAGS
]].visible
)
3199 SET_TEXT(S_COL_TAGS
);
3201 if ((vert_layout
|| small_layout
) && prefs_common
.two_line_vert
)
3202 g_free(text
[summaryview
->col_pos
[S_COL_SUBJECT
]]);
3206 GTKUT_CTREE_NODE_SET_ROW_DATA(cnode
, msginfo
);
3207 summary_set_marks_func(ctree
, cnode
, summaryview
);
3209 if (msgid
&& msgid
[0] != '\0')
3210 g_hash_table_insert(msgid_table
, (gchar
*)msgid
, cnode
);
3215 static void summary_set_ctree_from_list(SummaryView
*summaryview
,
3216 GSList
*mlist
, guint selected_msgnum
)
3218 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3220 GtkCMCTreeNode
*node
= NULL
;
3221 GHashTable
*msgid_table
;
3222 GHashTable
*subject_table
= NULL
;
3224 gboolean vert_layout
= (prefs_common
.layout_mode
== VERTICAL_LAYOUT
);
3225 gboolean small_layout
= (prefs_common
.layout_mode
== SMALL_LAYOUT
);
3230 debug_print("Setting summary from message data...\n");
3231 STATUSBAR_PUSH(summaryview
->mainwin
,
3232 _("Setting summary from message data..."));
3235 g_signal_handlers_block_by_func(G_OBJECT(ctree
),
3236 G_CALLBACK(summary_tree_expanded
), summaryview
);
3238 msgid_table
= g_hash_table_new(g_str_hash
, g_str_equal
);
3239 summaryview
->msgid_table
= msgid_table
;
3241 if (prefs_common
.thread_by_subject
) {
3242 subject_table
= g_hash_table_new(g_str_hash
, g_str_equal
);
3243 summaryview
->subject_table
= subject_table
;
3245 summaryview
->subject_table
= NULL
;
3248 if (prefs_common
.use_addr_book
)
3249 start_address_completion(NULL
);
3251 if (summaryview
->threaded
) {
3252 GNode
*root
, *gnode
;
3253 START_TIMING("threaded");
3254 root
= procmsg_get_thread_tree(mlist
);
3257 for (gnode
= root
->children
; gnode
!= NULL
;
3258 gnode
= gnode
->next
) {
3259 if (!summaryview
->folder_item
->hide_read_threads
||
3260 !summary_thread_is_read(gnode
) ||
3261 summary_thread_is_selected(gnode
, selected_msgnum
)) {
3262 summary_find_thread_age(gnode
);
3263 node
= gtk_sctree_insert_gnode
3264 (ctree
, NULL
, node
, gnode
,
3265 summary_insert_gnode_func
, summaryview
);
3269 g_node_destroy(root
);
3273 gchar
*text
[N_SUMMARY_COLS
];
3274 START_TIMING("unthreaded");
3276 for (; mlist
!= NULL
; mlist
= mlist
->next
) {
3277 msginfo
= (MsgInfo
*)mlist
->data
;
3279 summary_set_header(summaryview
, text
, msginfo
);
3281 node
= gtk_sctree_insert_node
3282 (ctree
, NULL
, node
, text
, 2,
3285 if ((vert_layout
|| small_layout
) && prefs_common
.two_line_vert
)
3286 g_free(text
[summaryview
->col_pos
[S_COL_SUBJECT
]]);
3288 GTKUT_CTREE_NODE_SET_ROW_DATA(node
, msginfo
);
3289 summary_set_marks_func(ctree
, node
, summaryview
);
3291 if (msginfo
->msgid
&& msginfo
->msgid
[0] != '\0')
3292 g_hash_table_insert(msgid_table
,
3293 msginfo
->msgid
, node
);
3295 if (prefs_common
.thread_by_subject
)
3296 subject_table_insert(subject_table
,
3304 if (prefs_common
.enable_hscrollbar
&&
3305 summaryview
->col_pos
[S_COL_SUBJECT
] == N_SUMMARY_COLS
- 1) {
3308 optimal_width
= gtk_cmclist_optimal_column_width
3309 (GTK_CMCLIST(ctree
), summaryview
->col_pos
[S_COL_SUBJECT
]);
3310 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
),
3311 summaryview
->col_pos
[S_COL_SUBJECT
],
3315 if (prefs_common
.use_addr_book
)
3316 end_address_completion();
3318 debug_print("Setting summary from message data done.\n");
3319 STATUSBAR_POP(summaryview
->mainwin
);
3320 if (debug_get_mode()) {
3321 debug_print("\tmsgid hash table size = %d\n",
3322 g_hash_table_size(msgid_table
));
3323 if (prefs_common
.thread_by_subject
)
3324 debug_print("\tsubject hash table size = %d\n",
3325 g_hash_table_size(subject_table
));
3328 summary_sort(summaryview
, summaryview
->sort_key
, summaryview
->sort_type
);
3330 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
3332 if (prefs_common
.bold_unread
) {
3333 START_TIMING("bold_unread");
3335 GtkCMCTreeNode
*next
= GTK_CMCTREE_NODE_NEXT(node
);
3336 if (GTK_CMCTREE_ROW(node
)->children
)
3337 summary_set_row_marks(summaryview
, node
);
3343 g_signal_handlers_unblock_by_func(G_OBJECT(ctree
),
3344 G_CALLBACK(summary_tree_expanded
), summaryview
);
3348 static gchar
*summary_complete_address(const gchar
*addr
)
3351 gchar
*res
, *tmp
, *email_addr
;
3353 if (addr
== NULL
|| !strchr(addr
, '@'))
3356 Xstrdup_a(email_addr
, addr
, return NULL
);
3357 extract_address(email_addr
);
3362 * completion stuff must be already initialized
3365 if (1 < (count
= complete_address(email_addr
))) {
3366 tmp
= get_complete_address(1);
3367 res
= procheader_get_fromname(tmp
);
3374 static inline void summary_set_header(SummaryView
*summaryview
, gchar
*text
[],
3377 static gchar date_modified
[80];
3378 static gchar col_score
[11];
3379 static gchar from_buf
[BUFFSIZE
], to_buf
[BUFFSIZE
];
3380 static gchar tmp1
[BUFFSIZE
], tmp2
[BUFFSIZE
], tmp3
[BUFFSIZE
];
3381 gint
*col_pos
= summaryview
->col_pos
;
3382 gchar
*from_text
= NULL
, *to_text
= NULL
, *tags_text
= NULL
;
3383 gboolean should_swap
= FALSE
;
3384 gboolean vert_layout
= (prefs_common
.layout_mode
== VERTICAL_LAYOUT
);
3385 gboolean small_layout
= (prefs_common
.layout_mode
== SMALL_LAYOUT
);
3386 static const gchar
*color_dim_rgb
= NULL
;
3388 color_dim_rgb
= gdk_color_to_string(&summaryview
->color_dim
);
3389 text
[col_pos
[S_COL_FROM
]] = "";
3390 text
[col_pos
[S_COL_TO
]] = "";
3391 text
[col_pos
[S_COL_SUBJECT
]]= "";
3392 text
[col_pos
[S_COL_MARK
]] = "";
3393 text
[col_pos
[S_COL_STATUS
]] = "";
3394 text
[col_pos
[S_COL_MIME
]] = "";
3395 text
[col_pos
[S_COL_LOCKED
]] = "";
3396 text
[col_pos
[S_COL_DATE
]] = "";
3397 text
[col_pos
[S_COL_TAGS
]] = "";
3398 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_NUMBER
]].visible
)
3399 text
[col_pos
[S_COL_NUMBER
]] = itos(msginfo
->msgnum
);
3401 text
[col_pos
[S_COL_NUMBER
]] = "";
3404 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_SIZE
]].visible
)
3405 text
[col_pos
[S_COL_SIZE
]] = to_human_readable(msginfo
->size
);
3407 text
[col_pos
[S_COL_SIZE
]] = "";
3409 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_SCORE
]].visible
)
3410 text
[col_pos
[S_COL_SCORE
]] = itos_buf(col_score
, msginfo
->score
);
3412 text
[col_pos
[S_COL_SCORE
]] = "";
3414 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_TAGS
]].visible
) {
3415 tags_text
= procmsg_msginfo_get_tags_str(msginfo
);
3417 text
[col_pos
[S_COL_TAGS
]] = "-";
3419 strncpy2(tmp1
, tags_text
, sizeof(tmp1
));
3420 tmp1
[sizeof(tmp1
)-1]='\0';
3422 text
[col_pos
[S_COL_TAGS
]] = tmp1
;
3425 text
[col_pos
[S_COL_TAGS
]] = "";
3428 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_DATE
]].visible
||
3429 ((vert_layout
|| small_layout
) && prefs_common
.two_line_vert
)) {
3430 if (msginfo
->date_t
&& msginfo
->date_t
> 0) {
3431 procheader_date_get_localtime(date_modified
,
3432 sizeof(date_modified
),
3434 text
[col_pos
[S_COL_DATE
]] = date_modified
;
3435 } else if (msginfo
->date
)
3436 text
[col_pos
[S_COL_DATE
]] = msginfo
->date
;
3438 text
[col_pos
[S_COL_DATE
]] = _("(No Date)");
3441 if (prefs_common
.swap_from
&& msginfo
->from
&& msginfo
->to
3442 && !summaryview
->col_state
[summaryview
->col_pos
[S_COL_TO
]].visible
) {
3445 addr
= g_strdup(msginfo
->from
);
3448 extract_address(addr
);
3449 if (account_find_from_address(addr
, FALSE
)) {
3456 if (!prefs_common
.use_addr_book
) {
3457 if (prefs_common
.summary_from_show
== SHOW_NAME
)
3458 from_text
= msginfo
->fromname
;
3459 else if (prefs_common
.summary_from_show
== SHOW_BOTH
)
3460 from_text
= msginfo
->from
;
3462 from_text
= msginfo
->from
;
3463 extract_address(from_text
);
3466 from_text
= _("(No From)");
3468 gchar
*tmp
= summary_complete_address(msginfo
->from
);
3470 strncpy2(from_buf
, tmp
, sizeof(from_buf
));
3472 from_text
= from_buf
;
3474 if (prefs_common
.summary_from_show
== SHOW_NAME
)
3475 from_text
= msginfo
->fromname
;
3476 else if (prefs_common
.summary_from_show
== SHOW_BOTH
)
3477 from_text
= msginfo
->from
;
3479 from_text
= msginfo
->from
;
3481 extract_address(from_text
);
3484 from_text
= _("(No From)");
3488 to_text
= msginfo
->to
? msginfo
->to
:
3489 (msginfo
->cc
? msginfo
->cc
:
3490 (msginfo
->newsgroups
? msginfo
->newsgroups
: NULL
3495 to_text
= _("(No Recipient)");
3497 if (prefs_common
.summary_from_show
== SHOW_NAME
) {
3498 gchar
*tmp
= procheader_get_fromname(to_text
);
3499 /* need to keep to_text pointing to stack, so heap-allocated
3500 * string from procheader_get_fromname() will be copied to to_buf */
3502 strncpy2(to_buf
, tmp
, sizeof(to_buf
));
3506 } else if (prefs_common
.summary_from_show
== SHOW_ADDR
)
3507 extract_address(to_text
);
3510 text
[col_pos
[S_COL_TO
]] = to_text
;
3512 text
[col_pos
[S_COL_FROM
]] = from_text
;
3514 if (prefs_common
.use_addr_book
) {
3515 gchar
*tmp
= summary_complete_address(to_text
);
3516 /* need to keep to_text pointing to stack, so heap-allocated
3517 * string from summary_complete_address() will be copied to to_buf */
3519 strncpy2(to_buf
, tmp
, sizeof(to_buf
));
3523 to_text
= to_text
? to_text
: _("(No From)");
3526 snprintf(tmp2
, BUFFSIZE
-1, "➜ %s", to_text
);
3527 tmp2
[BUFFSIZE
-1]='\0';
3528 text
[col_pos
[S_COL_FROM
]] = tmp2
;
3531 if (summaryview
->simplify_subject_preg
!= NULL
)
3532 text
[col_pos
[S_COL_SUBJECT
]] = msginfo
->subject
?
3533 string_remove_match(tmp3
, BUFFSIZE
, msginfo
->subject
,
3534 summaryview
->simplify_subject_preg
) :
3537 text
[col_pos
[S_COL_SUBJECT
]] = msginfo
->subject
? msginfo
->subject
:
3539 if ((vert_layout
|| small_layout
) && prefs_common
.two_line_vert
) {
3540 if (!FOLDER_SHOWS_TO_HDR(summaryview
->folder_item
)) {
3541 gchar
*tmp
= g_markup_printf_escaped(g_strconcat("%s\n",
3542 "<span color='%s' style='italic'>",
3543 _("From: %s, on %s"), "</span>", NULL
),
3544 text
[col_pos
[S_COL_SUBJECT
]],
3546 text
[col_pos
[S_COL_FROM
]],
3547 text
[col_pos
[S_COL_DATE
]]);
3548 text
[col_pos
[S_COL_SUBJECT
]] = tmp
;
3550 gchar
*tmp
= g_markup_printf_escaped(g_strconcat("%s\n",
3551 "<span color='%s' style='italic'>",
3552 _("To: %s, on %s"), "</span>", NULL
),
3553 text
[col_pos
[S_COL_SUBJECT
]],
3555 text
[col_pos
[S_COL_TO
]],
3556 text
[col_pos
[S_COL_DATE
]]);
3557 text
[col_pos
[S_COL_SUBJECT
]] = tmp
;
3562 static void summary_display_msg(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
3564 summary_display_msg_full(summaryview
, row
, FALSE
, FALSE
);
3567 static gboolean
defer_change(gpointer data
);
3568 typedef struct _ChangeData
{
3570 gint op
; /* 0, 1, 2 for unset, set, change */
3571 MsgPermFlags set_flags
;
3572 MsgTmpFlags set_tmp_flags
;
3573 MsgPermFlags unset_flags
;
3574 MsgTmpFlags unset_tmp_flags
;
3577 static void summary_msginfo_unset_flags(MsgInfo
*msginfo
, MsgPermFlags flags
, MsgTmpFlags tmp_flags
)
3579 if (!msginfo
->folder
|| !msginfo
->folder
->processing_pending
) {
3580 debug_print("flags: doing unset now\n");
3581 procmsg_msginfo_unset_flags(msginfo
, flags
, tmp_flags
);
3583 ChangeData
*unset_data
= g_new0(ChangeData
, 1);
3584 unset_data
->info
= msginfo
;
3586 unset_data
->unset_flags
= flags
;
3587 unset_data
->unset_tmp_flags
= tmp_flags
;
3588 debug_print("flags: deferring unset\n");
3589 g_timeout_add(100, defer_change
, unset_data
);
3593 static void summary_msginfo_set_flags(MsgInfo
*msginfo
, MsgPermFlags flags
, MsgTmpFlags tmp_flags
)
3595 if (!msginfo
->folder
|| !msginfo
->folder
->processing_pending
) {
3596 debug_print("flags: doing set now\n");
3597 procmsg_msginfo_set_flags(msginfo
, flags
, tmp_flags
);
3599 ChangeData
*set_data
= g_new0(ChangeData
, 1);
3600 set_data
->info
= msginfo
;
3602 set_data
->set_flags
= flags
;
3603 set_data
->set_tmp_flags
= tmp_flags
;
3604 debug_print("flags: deferring set\n");
3605 g_timeout_add(100, defer_change
, set_data
);
3609 static void summary_msginfo_change_flags(MsgInfo
*msginfo
,
3610 MsgPermFlags add_flags
, MsgTmpFlags add_tmp_flags
,
3611 MsgPermFlags rem_flags
, MsgTmpFlags rem_tmp_flags
)
3613 if (!msginfo
->folder
|| !msginfo
->folder
->processing_pending
) {
3614 debug_print("flags: doing change now\n");
3615 procmsg_msginfo_change_flags(msginfo
, add_flags
, add_tmp_flags
,
3616 rem_flags
, rem_tmp_flags
);
3618 ChangeData
*change_data
= g_new0(ChangeData
, 1);
3619 change_data
->info
= msginfo
;
3620 change_data
->op
= 2;
3621 change_data
->set_flags
= add_flags
;
3622 change_data
->set_tmp_flags
= add_tmp_flags
;
3623 change_data
->unset_flags
= rem_flags
;
3624 change_data
->unset_tmp_flags
= rem_tmp_flags
;
3625 debug_print("flags: deferring change\n");
3626 g_timeout_add(100, defer_change
, change_data
);
3630 gboolean
defer_change(gpointer data
)
3632 ChangeData
*chg
= (ChangeData
*)data
;
3633 if (chg
->info
->folder
&& chg
->info
->folder
->processing_pending
) {
3634 debug_print("flags: trying later\n");
3635 return TRUE
; /* try again */
3637 debug_print("flags: finally doing it\n");
3640 procmsg_msginfo_unset_flags(chg
->info
, chg
->unset_flags
, chg
->unset_tmp_flags
);
3643 procmsg_msginfo_set_flags(chg
->info
, chg
->set_flags
, chg
->set_tmp_flags
);
3646 procmsg_msginfo_change_flags(chg
->info
, chg
->set_flags
, chg
->set_tmp_flags
,
3647 chg
->unset_flags
, chg
->unset_tmp_flags
);
3650 g_warning("unknown change op");
3657 static void msginfo_mark_as_read (SummaryView
*summaryview
, MsgInfo
*msginfo
,
3658 GtkCMCTreeNode
*row
)
3660 cm_return_if_fail(summaryview
!= NULL
);
3661 cm_return_if_fail(msginfo
!= NULL
);
3662 cm_return_if_fail(row
!= NULL
);
3664 if (MSG_IS_NEW(msginfo
->flags
) || MSG_IS_UNREAD(msginfo
->flags
)) {
3665 summary_msginfo_unset_flags
3666 (msginfo
, MSG_NEW
| MSG_UNREAD
, 0);
3667 summary_set_row_marks(summaryview
, row
);
3668 summary_status_show(summaryview
);
3674 SummaryView
*summaryview
;
3677 static int msginfo_mark_as_read_timeout(void *data
)
3679 MarkAsReadData
*mdata
= (MarkAsReadData
*)data
;
3683 summary_lock(mdata
->summaryview
);
3684 if (mdata
->msginfo
== summary_get_selected_msg(mdata
->summaryview
))
3685 msginfo_mark_as_read(mdata
->summaryview
, mdata
->msginfo
,
3686 mdata
->summaryview
->selected
);
3687 procmsg_msginfo_free(&(mdata
->msginfo
));
3689 mdata
->summaryview
->mark_as_read_timeout_tag
= 0;
3690 summary_unlock(mdata
->summaryview
);
3696 static void summary_display_msg_full(SummaryView
*summaryview
,
3697 GtkCMCTreeNode
*row
,
3698 gboolean new_window
, gboolean all_headers
)
3700 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3705 if (summaryview
->displayed
== row
&&
3706 messageview_is_visible(summaryview
->messageview
))
3708 else if (summaryview
->messageview
)
3709 summaryview
->messageview
->filtered
= FALSE
;
3711 cm_return_if_fail(row
!= NULL
);
3713 if (summary_is_locked(summaryview
)) return;
3714 summary_lock(summaryview
);
3716 STATUSBAR_POP(summaryview
->mainwin
);
3719 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
3722 debug_print("NULL msginfo\n");
3723 summary_unlock(summaryview
);
3728 if (new_window
&& prefs_common
.layout_mode
!= SMALL_LAYOUT
) {
3729 MessageView
*msgview
;
3731 msgview
= messageview_create_with_new_window(summaryview
->mainwin
);
3732 val
= messageview_show(msgview
, msginfo
, all_headers
);
3734 MessageView
*msgview
;
3736 if (prefs_common
.layout_mode
== SMALL_LAYOUT
) {
3737 if (summaryview
->ext_messageview
== NULL
)
3738 summaryview
->ext_messageview
= messageview_create_with_new_window(summaryview
->mainwin
);
3740 gtkut_window_popup(summaryview
->ext_messageview
->window
);
3741 msgview
= summaryview
->ext_messageview
;
3742 summaryview
->displayed
= row
;
3743 val
= messageview_show(msgview
, msginfo
, all_headers
);
3744 if (mimeview_tree_is_empty(msgview
->mimeview
))
3745 gtk_widget_grab_focus(summaryview
->ctree
);
3746 gtkut_ctree_node_move_if_on_the_edge(ctree
, row
,
3747 GTK_CMCLIST(summaryview
->ctree
)->focus_row
);
3749 msgview
= summaryview
->messageview
;
3750 summaryview
->displayed
= row
;
3751 if (!messageview_is_visible(msgview
) &&
3752 gtk_window_is_active(GTK_WINDOW(summaryview
->mainwin
->window
))) {
3753 main_window_toggle_message_view(summaryview
->mainwin
);
3756 val
= messageview_show(msgview
, msginfo
, all_headers
);
3757 if (mimeview_tree_is_empty(msgview
->mimeview
))
3758 gtk_widget_grab_focus(summaryview
->ctree
);
3759 gtkut_ctree_node_move_if_on_the_edge(ctree
, row
,
3760 GTK_CMCLIST(summaryview
->ctree
)->focus_row
);
3764 if (val
== 0 && MSG_IS_UNREAD(msginfo
->flags
)) {
3765 if (!prefs_common
.mark_as_read_on_new_window
&&
3766 prefs_common
.mark_as_read_delay
) {
3767 MarkAsReadData
*data
= g_new0(MarkAsReadData
, 1);
3768 data
->summaryview
= summaryview
;
3769 data
->msginfo
= procmsg_msginfo_new_ref(msginfo
);
3770 if (summaryview
->mark_as_read_timeout_tag
!= 0)
3771 g_source_remove(summaryview
->mark_as_read_timeout_tag
);
3772 summaryview
->mark_as_read_timeout_tag
=
3773 g_timeout_add_seconds(prefs_common
.mark_as_read_delay
,
3774 msginfo_mark_as_read_timeout
, data
);
3775 } else if (new_window
|| !prefs_common
.mark_as_read_on_new_window
) {
3776 msginfo_mark_as_read(summaryview
, msginfo
, row
);
3780 summary_set_menu_sensitive(summaryview
);
3781 toolbar_main_set_sensitive(summaryview
->mainwin
);
3782 messageview_set_menu_sensitive(summaryview
->messageview
);
3784 summary_unlock(summaryview
);
3788 void summary_display_msg_selected(SummaryView
*summaryview
,
3789 gboolean all_headers
)
3791 if (summary_is_locked(summaryview
)) return;
3792 summaryview
->displayed
= NULL
;
3793 summary_display_msg_full(summaryview
, summaryview
->selected
, FALSE
,
3797 void summary_redisplay_msg(SummaryView
*summaryview
)
3799 GtkCMCTreeNode
*node
;
3801 if (summaryview
->displayed
) {
3802 node
= summaryview
->displayed
;
3803 summaryview
->displayed
= NULL
;
3804 summary_display_msg(summaryview
, node
);
3808 void summary_open_msg(SummaryView
*summaryview
)
3810 if (!summaryview
->selected
) return;
3812 /* CLAWS: if separate message view, don't open a new window
3813 * but rather use the current separated message view */
3814 summary_display_msg_full(summaryview
, summaryview
->selected
,
3818 void summary_view_source(SummaryView
* summaryview
)
3820 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3822 SourceWindow
*srcwin
;
3824 if (!summaryview
->selected
) return;
3826 srcwin
= source_window_create();
3827 msginfo
= gtk_cmctree_node_get_row_data(ctree
, summaryview
->selected
);
3828 source_window_show_msg(srcwin
, msginfo
);
3829 source_window_show(srcwin
);
3832 void summary_reedit(SummaryView
*summaryview
)
3836 if (!summaryview
->selected
) return;
3837 if (!summaryview
->folder_item
) return;
3838 if (!FOLDER_SHOWS_TO_HDR(summaryview
->folder_item
))
3841 msginfo
= gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview
->ctree
),
3842 summaryview
->selected
);
3843 if (!msginfo
) return;
3845 compose_reedit(msginfo
, FALSE
);
3848 gboolean
summary_is_list(SummaryView
*summaryview
)
3850 return (gtk_notebook_get_current_page(
3851 GTK_NOTEBOOK(summaryview
->mainwidget_book
)) == 0);
3854 void summary_toggle_view(SummaryView
*summaryview
)
3856 if (prefs_common
.layout_mode
== SMALL_LAYOUT
)
3858 if (summary_is_locked(summaryview
))
3860 if (!messageview_is_visible(summaryview
->messageview
) &&
3861 summaryview
->selected
&& summary_is_list(summaryview
))
3862 summary_display_msg(summaryview
,
3863 summaryview
->selected
);
3865 main_window_toggle_message_view(summaryview
->mainwin
);
3868 static gboolean
summary_search_unread_recursive(GtkCMCTree
*ctree
,
3869 GtkCMCTreeNode
*node
)
3874 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
3875 if (msginfo
&& MSG_IS_UNREAD(msginfo
->flags
) && !MSG_IS_IGNORE_THREAD(msginfo
->flags
))
3877 node
= GTK_CMCTREE_ROW(node
)->children
;
3879 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
3882 if (summary_search_unread_recursive(ctree
, node
) == TRUE
)
3884 node
= GTK_CMCTREE_ROW(node
)->sibling
;
3890 static gboolean
summary_have_unread_children(SummaryView
*summaryview
,
3891 GtkCMCTreeNode
*node
)
3893 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3895 if (!node
) return FALSE
;
3897 node
= GTK_CMCTREE_ROW(node
)->children
;
3900 if (summary_search_unread_recursive(ctree
, node
) == TRUE
)
3902 node
= GTK_CMCTREE_ROW(node
)->sibling
;
3907 static void summary_set_row_marks(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
3909 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3910 GtkStyle
*style
= NULL
;
3913 gint
*col_pos
= summaryview
->col_pos
;
3915 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
3916 if (!msginfo
) return;
3918 flags
= msginfo
->flags
;
3920 gtk_cmctree_node_set_foreground(ctree
, row
, NULL
);
3922 /* set new/unread column */
3923 if (MSG_IS_IGNORE_THREAD(flags
)) {
3924 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3926 } else if (MSG_IS_WATCH_THREAD(flags
)) {
3927 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3929 } else if (MSG_IS_SPAM(flags
)) {
3930 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3932 } else if (MSG_IS_NEW(flags
)) {
3933 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3935 } else if (MSG_IS_UNREAD(flags
)) {
3936 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3938 } else if (MSG_IS_REPLIED(flags
) && MSG_IS_FORWARDED(flags
)) {
3939 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3940 repliedandforwardedxpm
);
3941 } else if (MSG_IS_REPLIED(flags
)) {
3942 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3944 } else if (MSG_IS_FORWARDED(flags
)) {
3945 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3948 gtk_cmctree_node_set_text(ctree
, row
, col_pos
[S_COL_STATUS
],
3952 if (prefs_common
.bold_unread
&&
3953 ((MSG_IS_UNREAD(flags
) && !MSG_IS_IGNORE_THREAD(flags
)) ||
3954 (!GTK_CMCTREE_ROW(row
)->expanded
&&
3955 GTK_CMCTREE_ROW(row
)->children
&&
3956 summary_have_unread_children(summaryview
, row
))))
3959 /* set mark column */
3960 if (MSG_IS_DELETED(flags
)) {
3961 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MARK
],
3964 style
= bold_deleted_style
;
3966 style
= small_deleted_style
;
3968 gtk_cmctree_node_set_foreground
3969 (ctree
, row
, &summaryview
->color_dim
);
3970 } else if (MSG_IS_MARKED(flags
)) {
3971 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MARK
],
3973 } else if (MSG_IS_MOVE(flags
)) {
3974 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MARK
],
3976 if (!msginfo
->to_folder
||
3977 !folder_has_parent_of_type(msginfo
->to_folder
, F_TRASH
)) {
3979 style
= bold_marked_style
;
3981 style
= small_marked_style
;
3983 gtk_cmctree_node_set_foreground
3984 (ctree
, row
, &summaryview
->color_marked
);
3987 style
= bold_deleted_style
;
3989 style
= small_deleted_style
;
3991 gtk_cmctree_node_set_foreground
3992 (ctree
, row
, &summaryview
->color_dim
);
3994 } else if (MSG_IS_COPY(flags
)) {
3995 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MARK
],
3998 style
= bold_marked_style
;
4000 style
= small_marked_style
;
4002 gtk_cmctree_node_set_foreground
4003 (ctree
, row
, &summaryview
->color_marked
);
4005 gtk_cmctree_node_set_text(ctree
, row
, col_pos
[S_COL_MARK
], "");
4008 if (MSG_IS_LOCKED(flags
)) {
4009 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_LOCKED
],
4013 gtk_cmctree_node_set_text(ctree
, row
, col_pos
[S_COL_LOCKED
], "");
4016 if (MSG_IS_WITH_ATTACHMENT(flags
) && MSG_IS_SIGNED(flags
)) {
4017 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4019 } else if (MSG_IS_SIGNED(flags
)) {
4020 if (MSG_IS_ENCRYPTED(flags
)) {
4021 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4024 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4027 } else if (MSG_IS_WITH_ATTACHMENT(flags
) && MSG_IS_ENCRYPTED(flags
)) {
4028 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4030 } else if (MSG_IS_ENCRYPTED(flags
)) {
4031 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4033 } else if (MSG_IS_WITH_ATTACHMENT(flags
)) {
4034 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4037 gtk_cmctree_node_set_text(ctree
, row
, col_pos
[S_COL_MIME
], "");
4040 style
= small_style
;
4042 gtk_cmctree_node_set_row_style(ctree
, row
, style
);
4044 if (MSG_GET_COLORLABEL(flags
))
4045 summary_set_colorlabel_color(ctree
, row
, MSG_GET_COLORLABEL_VALUE(flags
));
4048 static void summary_mark_row(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
4050 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4053 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4054 cm_return_if_fail(msginfo
);
4055 if (MSG_IS_DELETED(msginfo
->flags
))
4056 summaryview
->deleted
--;
4057 if (MSG_IS_MOVE(msginfo
->flags
))
4058 summaryview
->moved
--;
4059 if (MSG_IS_COPY(msginfo
->flags
))
4060 summaryview
->copied
--;
4062 procmsg_msginfo_set_to_folder(msginfo
, NULL
);
4063 summary_msginfo_change_flags(msginfo
, MSG_MARKED
, 0, MSG_DELETED
,
4064 MSG_MOVE
| MSG_COPY
| MSG_MOVE_DONE
);
4065 summary_set_row_marks(summaryview
, row
);
4066 debug_print("Message %s/%d is marked\n", msginfo
->folder
->path
, msginfo
->msgnum
);
4069 static void summary_lock_row(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
4071 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4074 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4075 cm_return_if_fail(msginfo
);
4076 if (MSG_IS_DELETED(msginfo
->flags
))
4077 summaryview
->deleted
--;
4078 if (MSG_IS_MOVE(msginfo
->flags
)) {
4079 summaryview
->moved
--;
4081 if (MSG_IS_COPY(msginfo
->flags
)) {
4082 summaryview
->copied
--;
4084 procmsg_msginfo_set_to_folder(msginfo
, NULL
);
4085 summary_msginfo_change_flags(msginfo
, MSG_LOCKED
, 0, MSG_DELETED
,
4086 MSG_MOVE
| MSG_COPY
| MSG_MOVE_DONE
);
4088 summary_set_row_marks(summaryview
, row
);
4089 debug_print("Message %d is locked\n", msginfo
->msgnum
);
4092 static void summary_unlock_row(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
4094 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4097 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4098 cm_return_if_fail(msginfo
);
4099 if (!MSG_IS_LOCKED(msginfo
->flags
))
4101 procmsg_msginfo_set_to_folder(msginfo
, NULL
);
4102 summary_msginfo_unset_flags(msginfo
, MSG_LOCKED
, 0);
4103 summary_set_row_marks(summaryview
, row
);
4104 debug_print("Message %d is unlocked\n", msginfo
->msgnum
);
4107 void summary_mark(SummaryView
*summaryview
)
4109 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4111 gboolean froze
= FALSE
;
4113 if (summary_is_locked(summaryview
))
4115 START_LONG_OPERATION(summaryview
, FALSE
);
4116 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4117 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4118 summary_mark_row(summaryview
, GTK_CMCTREE_NODE(cur
->data
));
4119 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4120 END_LONG_OPERATION(summaryview
);
4122 summary_status_show(summaryview
);
4125 static void summary_mark_row_as_read(SummaryView
*summaryview
,
4126 GtkCMCTreeNode
*row
)
4128 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4131 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4132 cm_return_if_fail(msginfo
);
4134 if(!(MSG_IS_NEW(msginfo
->flags
) || MSG_IS_UNREAD(msginfo
->flags
)))
4137 summary_msginfo_unset_flags(msginfo
, MSG_NEW
| MSG_UNREAD
, 0);
4138 summary_set_row_marks(summaryview
, row
);
4139 debug_print("Message %d is marked as read\n",
4143 static void summary_mark_row_as_unread(SummaryView
*summaryview
,
4144 GtkCMCTreeNode
*row
)
4146 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4149 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4150 cm_return_if_fail(msginfo
);
4152 if(MSG_IS_NEW(msginfo
->flags
) || MSG_IS_UNREAD(msginfo
->flags
))
4155 summary_msginfo_set_flags(msginfo
, MSG_UNREAD
, 0);
4156 summary_set_row_marks(summaryview
, row
);
4157 debug_print("Message %d is marked as unread\n",
4161 void summary_mark_as_read(SummaryView
*summaryview
)
4163 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4165 gboolean froze
= FALSE
;
4167 if (summary_is_locked(summaryview
))
4170 if ((summaryview
->folder_item
->total_msgs
== (gint
)g_list_length(GTK_CMCLIST(ctree
)->selection
))
4171 && !summary_mark_all_read_confirm(TRUE
))
4174 START_LONG_OPERATION(summaryview
, FALSE
);
4175 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4176 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4177 summary_mark_row_as_read(summaryview
,
4178 GTK_CMCTREE_NODE(cur
->data
));
4179 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4180 END_LONG_OPERATION(summaryview
);
4182 summary_status_show(summaryview
);
4185 void summary_mark_as_unread(SummaryView
*summaryview
)
4187 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4189 gboolean froze
= FALSE
;
4191 if (summary_is_locked(summaryview
))
4194 if ((summaryview
->folder_item
->total_msgs
== (gint
)g_list_length(GTK_CMCLIST(ctree
)->selection
))
4195 && !summary_mark_all_unread_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_unread(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_msgs_lock(SummaryView
*summaryview
)
4211 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4213 gboolean froze
= FALSE
;
4215 if (summary_is_locked(summaryview
))
4217 START_LONG_OPERATION(summaryview
, FALSE
);
4218 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4219 summary_lock_row(summaryview
,
4220 GTK_CMCTREE_NODE(cur
->data
));
4221 END_LONG_OPERATION(summaryview
);
4223 summary_status_show(summaryview
);
4226 void summary_msgs_unlock(SummaryView
*summaryview
)
4228 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4230 gboolean froze
= FALSE
;
4232 if (summary_is_locked(summaryview
))
4234 START_LONG_OPERATION(summaryview
, FALSE
);
4235 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4236 summary_unlock_row(summaryview
,
4237 GTK_CMCTREE_NODE(cur
->data
));
4238 END_LONG_OPERATION(summaryview
);
4240 summary_status_show(summaryview
);
4243 static gboolean
summary_mark_all_read_confirm(gboolean ask_if_needed
)
4245 /* ask_if_needed is FALSE when user-asking is performed by caller,
4246 commonly when the caller is a mark-as-read-recursive func */
4247 if (ask_if_needed
&& prefs_common
.ask_mark_all_read
) {
4248 AlertValue val
= alertpanel_full(_("Mark all as read"),
4249 _("Do you really want to mark all mails in this folder as read?"),
4250 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_FIRST
,
4251 TRUE
, NULL
, ALERT_QUESTION
);
4253 if ((val
& ~G_ALERTDISABLE
) != G_ALERTALTERNATE
)
4255 else if (val
& G_ALERTDISABLE
)
4256 prefs_common
.ask_mark_all_read
= FALSE
;
4261 void summary_mark_all_read(SummaryView
*summaryview
, gboolean ask_if_needed
)
4263 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4264 GtkCMCTreeNode
*node
;
4265 gboolean froze
= FALSE
;
4267 if (summary_is_locked(summaryview
))
4270 if (!summary_mark_all_read_confirm(ask_if_needed
))
4273 START_LONG_OPERATION(summaryview
, TRUE
);
4274 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4275 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
); node
!= NULL
;
4276 node
= gtkut_ctree_node_next(ctree
, node
))
4277 summary_mark_row_as_read(summaryview
, node
);
4278 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4279 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
); node
!= NULL
;
4280 node
= gtkut_ctree_node_next(ctree
, node
)) {
4281 if (!GTK_CMCTREE_ROW(node
)->expanded
)
4282 summary_set_row_marks(summaryview
, node
);
4284 END_LONG_OPERATION(summaryview
);
4286 summary_status_show(summaryview
);
4289 static gboolean
summary_mark_all_unread_confirm(gboolean ask_if_needed
)
4291 /* ask_if_needed is FALSE when user-asking is performed by caller,
4292 commonly when the caller is a mark-as-unread-recursive func */
4293 if (ask_if_needed
&& prefs_common
.ask_mark_all_read
) {
4294 AlertValue val
= alertpanel_full(_("Mark all as unread"),
4295 _("Do you really want to mark all mails in this folder as unread?"),
4296 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_FIRST
,
4297 TRUE
, NULL
, ALERT_QUESTION
);
4299 if ((val
& ~G_ALERTDISABLE
) != G_ALERTALTERNATE
)
4301 else if (val
& G_ALERTDISABLE
)
4302 prefs_common
.ask_mark_all_read
= FALSE
;
4307 void summary_mark_all_unread(SummaryView
*summaryview
, gboolean ask_if_needed
)
4309 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4310 GtkCMCTreeNode
*node
;
4311 gboolean froze
= FALSE
;
4313 if (summary_is_locked(summaryview
))
4316 if (!summary_mark_all_unread_confirm(ask_if_needed
))
4319 START_LONG_OPERATION(summaryview
, TRUE
);
4320 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4321 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
); node
!= NULL
;
4322 node
= gtkut_ctree_node_next(ctree
, node
))
4323 summary_mark_row_as_unread(summaryview
, node
);
4324 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4325 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
); node
!= NULL
;
4326 node
= gtkut_ctree_node_next(ctree
, node
)) {
4327 if (!GTK_CMCTREE_ROW(node
)->expanded
)
4328 summary_set_row_marks(summaryview
, node
);
4330 END_LONG_OPERATION(summaryview
);
4332 summary_status_show(summaryview
);
4335 void summary_mark_as_spam(SummaryView
*summaryview
, guint action
, GtkWidget
*widget
)
4337 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4339 gboolean is_spam
= action
;
4340 GSList
*msgs
= NULL
;
4341 gboolean immediate_exec
= prefs_common
.immediate_exec
;
4342 gboolean moved
= FALSE
;
4343 gboolean froze
= FALSE
;
4346 if (summary_is_locked(summaryview
))
4349 prefs_common
.immediate_exec
= FALSE
;
4350 START_LONG_OPERATION(summaryview
, FALSE
);
4351 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4352 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
4353 GtkCMCTreeNode
*row
= GTK_CMCTREE_NODE(cur
->data
);
4354 MsgInfo
*msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4356 msgs
= g_slist_prepend(msgs
, msginfo
);
4359 if (procmsg_spam_learner_learn(NULL
, msgs
, is_spam
) == 0) {
4360 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
4361 GtkCMCTreeNode
*row
= GTK_CMCTREE_NODE(cur
->data
);
4362 MsgInfo
*msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4366 summary_msginfo_change_flags(msginfo
, MSG_SPAM
, 0, MSG_NEW
|MSG_UNREAD
, 0);
4367 if (procmsg_spam_get_folder(msginfo
) != summaryview
->folder_item
) {
4368 summary_move_row_to(summaryview
, row
,
4369 procmsg_spam_get_folder(msginfo
));
4373 summary_msginfo_unset_flags(msginfo
, MSG_SPAM
, 0);
4375 summaryview
->display_msg
= prefs_common
.always_show_msg
;
4377 summary_set_row_marks(summaryview
, row
);
4380 log_error(LOG_PROTOCOL
, _("An error happened while learning.\n"));
4383 prefs_common
.immediate_exec
= immediate_exec
;
4384 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4385 END_LONG_OPERATION(summaryview
);
4387 if (prefs_common
.immediate_exec
&& moved
) {
4388 summary_execute(summaryview
);
4391 if (!moved
&& msgs
) {
4392 MsgInfo
*msginfo
= (MsgInfo
*)msgs
->data
;
4393 toolbar_set_learn_button
4394 (summaryview
->mainwin
->toolbar
,
4395 MSG_IS_SPAM(msginfo
->flags
)?LEARN_HAM
:LEARN_SPAM
);
4399 summary_status_show(summaryview
);
4402 static gboolean
check_permission(SummaryView
*summaryview
, MsgInfo
* msginfo
)
4407 switch (FOLDER_TYPE(summaryview
->folder_item
->folder
)) {
4412 security : checks if one the accounts correspond to
4413 the author of the post
4417 for(cur
= account_get_list() ; cur
!= NULL
; cur
= cur
->next
) {
4418 PrefsAccount
* account
;
4421 account
= cur
->data
;
4422 if (account
->name
&& *account
->name
)
4424 g_strdup_printf("%s <%s>",
4429 g_strdup_printf("%s",
4432 if (g_utf8_collate(from_name
, msginfo
->from
) == 0) {
4441 alertpanel_error(_("You're not the author of the article."));
4451 static void summary_delete_row(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
4453 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4456 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4457 cm_return_if_fail(msginfo
);
4459 if (MSG_IS_LOCKED(msginfo
->flags
)) return;
4461 if (MSG_IS_DELETED(msginfo
->flags
)) return;
4463 if (MSG_IS_MOVE(msginfo
->flags
))
4464 summaryview
->moved
--;
4465 if (MSG_IS_COPY(msginfo
->flags
))
4466 summaryview
->copied
--;
4468 procmsg_msginfo_set_to_folder(msginfo
, NULL
);
4469 summary_msginfo_change_flags(msginfo
, MSG_DELETED
, 0, MSG_MARKED
,
4470 MSG_MOVE
| MSG_COPY
| MSG_MOVE_DONE
);
4471 summaryview
->deleted
++;
4473 if (!prefs_common
.immediate_exec
&&
4474 !folder_has_parent_of_type(summaryview
->folder_item
, F_TRASH
)) {
4475 summary_set_row_marks(summaryview
, row
);
4477 debug_print("Message %s/%d is set to delete\n",
4478 msginfo
->folder
->path
, msginfo
->msgnum
);
4481 void summary_cancel(SummaryView
*summaryview
)
4485 msginfo
= gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview
->ctree
),
4486 summaryview
->selected
);
4487 if (!msginfo
) return;
4489 if (!check_permission(summaryview
, msginfo
))
4492 news_cancel_article(summaryview
->folder_item
->folder
, msginfo
);
4494 if (summary_is_locked(summaryview
)) return;
4496 summary_lock(summaryview
);
4498 summary_freeze(summaryview
);
4500 summary_update_status(summaryview
);
4501 summary_status_show(summaryview
);
4503 summary_thaw(summaryview
);
4505 summary_unlock(summaryview
);
4508 void summary_delete(SummaryView
*summaryview
)
4510 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4511 FolderItem
*item
= summaryview
->folder_item
;
4513 GtkCMCTreeNode
*sel_last
= NULL
;
4514 GtkCMCTreeNode
*node
;
4517 gboolean froze
= FALSE
;
4521 if (summary_is_locked(summaryview
)) return;
4523 if (!summaryview
->folder_item
) return;
4525 START_LONG_OPERATION(summaryview
, FALSE
);
4527 if (!prefs_common
.live_dangerously
) {
4529 guint num
= g_list_length(GTK_CMCLIST(summaryview
->ctree
)->selection
);
4530 buf
= g_strdup_printf(ngettext(
4531 "Do you really want to delete the selected message?",
4532 "Do you really want to delete the %d selected messages?", num
),
4534 aval
= alertpanel(ngettext("Delete message", "Delete messages", num
),
4536 GTK_STOCK_CANCEL
, GTK_STOCK_DELETE
, NULL
, ALERTFOCUS_SECOND
);
4538 if (aval
!= G_ALERTALTERNATE
) {
4539 END_LONG_OPERATION(summaryview
);
4544 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
;
4546 GtkCMCTreeNode
*row
= GTK_CMCTREE_NODE(cur
->data
);
4547 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4548 if (msginfo
&& msginfo
->total_size
!= 0 &&
4549 msginfo
->size
!= (goffset
)msginfo
->total_size
)
4550 partial_mark_for_delete(msginfo
);
4553 main_window_cursor_wait(summaryview
->mainwin
);
4555 /* next code sets current row focus right. We need to find a row
4556 * that is not deleted. */
4557 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4558 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
4559 sel_last
= GTK_CMCTREE_NODE(cur
->data
);
4560 summary_delete_row(summaryview
, sel_last
);
4562 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4563 END_LONG_OPERATION(summaryview
);
4565 if (summaryview
->sort_type
== SORT_ASCENDING
) {
4566 node
= summary_find_next_msg(summaryview
, sel_last
, TRUE
);
4567 if (!node
|| prefs_common
.next_on_delete
== FALSE
)
4568 node
= summary_find_prev_msg(summaryview
, sel_last
,TRUE
);
4570 node
= summary_find_prev_msg(summaryview
, sel_last
,TRUE
);
4571 if (!node
|| prefs_common
.next_on_delete
== FALSE
)
4572 node
= summary_find_next_msg(summaryview
, sel_last
,TRUE
);
4574 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_DELETEMOVE
);
4576 if (prefs_common
.immediate_exec
|| folder_has_parent_of_type(item
, F_TRASH
)) {
4577 summary_execute(summaryview
);
4578 /* after deleting, the anchor may be at an invalid row
4579 * so reset it to the node we found earlier */
4580 gtk_sctree_set_anchor_row(GTK_SCTREE(ctree
), node
);
4582 summary_status_show(summaryview
);
4585 main_window_cursor_normal(summaryview
->mainwin
);
4588 void summary_delete_trash(SummaryView
*summaryview
)
4590 FolderItem
*to_folder
= NULL
;
4592 if (!summaryview
->folder_item
||
4593 FOLDER_TYPE(summaryview
->folder_item
->folder
) == F_NEWS
) return;
4595 if (NULL
!= (ac
= account_find_from_item(summaryview
->folder_item
)))
4596 to_folder
= account_get_special_folder(ac
, F_TRASH
);
4598 if (to_folder
== NULL
)
4599 to_folder
= summaryview
->folder_item
->folder
->trash
;
4601 if (to_folder
== NULL
|| to_folder
== summaryview
->folder_item
4602 || folder_has_parent_of_type(summaryview
->folder_item
, F_TRASH
))
4603 summary_delete(summaryview
);
4605 summary_move_selected_to(summaryview
, to_folder
);
4609 static void summary_unmark_row(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
4611 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4614 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4615 cm_return_if_fail(msginfo
);
4616 if (MSG_IS_DELETED(msginfo
->flags
))
4617 summaryview
->deleted
--;
4618 if (MSG_IS_MOVE(msginfo
->flags
))
4619 summaryview
->moved
--;
4620 if (MSG_IS_COPY(msginfo
->flags
))
4621 summaryview
->copied
--;
4623 procmsg_msginfo_set_to_folder(msginfo
, NULL
);
4624 summary_msginfo_unset_flags(msginfo
, MSG_MARKED
| MSG_DELETED
,
4625 MSG_MOVE
| MSG_COPY
| MSG_MOVE_DONE
);
4626 summary_set_row_marks(summaryview
, row
);
4628 debug_print("Message %s/%d is unmarked\n",
4629 msginfo
->folder
->path
, msginfo
->msgnum
);
4632 void summary_unmark(SummaryView
*summaryview
)
4634 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4636 gboolean froze
= FALSE
;
4638 if (summary_is_locked(summaryview
))
4640 START_LONG_OPERATION(summaryview
, FALSE
);
4641 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4642 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4643 summary_unmark_row(summaryview
, GTK_CMCTREE_NODE(cur
->data
));
4644 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4645 END_LONG_OPERATION(summaryview
);
4647 summary_status_show(summaryview
);
4650 static void summary_move_row_to(SummaryView
*summaryview
, GtkCMCTreeNode
*row
,
4651 FolderItem
*to_folder
)
4653 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4656 cm_return_if_fail(to_folder
!= NULL
);
4658 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4659 cm_return_if_fail(msginfo
);
4660 if (MSG_IS_LOCKED(msginfo
->flags
))
4663 procmsg_msginfo_set_to_folder(msginfo
, to_folder
);
4664 if (MSG_IS_DELETED(msginfo
->flags
))
4665 summaryview
->deleted
--;
4666 if (MSG_IS_COPY(msginfo
->flags
)) {
4667 summaryview
->copied
--;
4669 if (!MSG_IS_MOVE(msginfo
->flags
)) {
4670 summary_msginfo_change_flags(msginfo
, 0, MSG_MOVE
, MSG_DELETED
,
4671 MSG_COPY
| MSG_MOVE_DONE
);
4672 summaryview
->moved
++;
4674 summary_msginfo_unset_flags(msginfo
, MSG_DELETED
, MSG_COPY
);
4677 if (!prefs_common
.immediate_exec
) {
4678 summary_set_row_marks(summaryview
, row
);
4681 debug_print("Message %d is set to move to %s\n",
4682 msginfo
->msgnum
, to_folder
->path
);
4685 void summary_move_selected_to(SummaryView
*summaryview
, FolderItem
*to_folder
)
4688 GtkCMCTreeNode
*sel_last
= NULL
;
4689 gboolean froze
= FALSE
;
4691 if (!to_folder
) return;
4692 if (!summaryview
->folder_item
||
4693 FOLDER_TYPE(summaryview
->folder_item
->folder
) == F_NEWS
) return;
4695 if (summary_is_locked(summaryview
)) return;
4697 if (summaryview
->folder_item
== to_folder
) {
4698 alertpanel_error(_("Destination is same as current folder."));
4702 if (to_folder
->no_select
) {
4703 alertpanel_error(_("The destination folder can only be used to "
4704 "store subfolders."));
4708 START_LONG_OPERATION(summaryview
, FALSE
);
4710 for (cur
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
4711 cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
4712 sel_last
= GTK_CMCTREE_NODE(cur
->data
);
4714 (summaryview
, GTK_CMCTREE_NODE(cur
->data
), to_folder
);
4716 END_LONG_OPERATION(summaryview
);
4718 if (prefs_common
.immediate_exec
) {
4719 summary_execute(summaryview
);
4721 GtkCMCTreeNode
*node
= NULL
;
4722 if (summaryview
->sort_type
== SORT_ASCENDING
) {
4723 node
= summary_find_next_msg(summaryview
, sel_last
,TRUE
);
4724 if (!node
|| prefs_common
.next_on_delete
== FALSE
)
4725 node
= summary_find_prev_msg(summaryview
, sel_last
,TRUE
);
4727 node
= summary_find_prev_msg(summaryview
, sel_last
,TRUE
);
4728 if (!node
|| prefs_common
.next_on_delete
== FALSE
)
4729 node
= summary_find_next_msg(summaryview
, sel_last
,TRUE
);
4731 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_DELETEMOVE
);
4732 summary_status_show(summaryview
);
4735 if (!summaryview
->selected
) { /* this was the last message */
4736 GtkCMCTreeNode
*node
= gtk_cmctree_node_nth (GTK_CMCTREE(summaryview
->ctree
),
4737 GTK_CMCLIST(summaryview
->ctree
)->rows
- 1);
4739 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_DELETEMOVE
);
4744 void summary_move_to(SummaryView
*summaryview
)
4746 FolderItem
*to_folder
;
4748 if (!summaryview
->folder_item
||
4749 FOLDER_TYPE(summaryview
->folder_item
->folder
) == F_NEWS
) return;
4751 to_folder
= foldersel_folder_sel(NULL
, FOLDER_SEL_MOVE
, NULL
, FALSE
,
4753 "Select folder to move selected message to",
4754 "Select folder to move selected messages to",
4755 g_list_length(GTK_CMCLIST(summaryview
->ctree
)->selection
))
4757 summary_move_selected_to(summaryview
, to_folder
);
4760 static void summary_copy_row_to(SummaryView
*summaryview
, GtkCMCTreeNode
*row
,
4761 FolderItem
*to_folder
)
4763 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4766 cm_return_if_fail(to_folder
!= NULL
);
4768 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4769 cm_return_if_fail(msginfo
);
4770 procmsg_msginfo_set_to_folder(msginfo
, to_folder
);
4771 if (MSG_IS_DELETED(msginfo
->flags
))
4772 summaryview
->deleted
--;
4773 if (MSG_IS_MOVE(msginfo
->flags
)) {
4774 summaryview
->moved
--;
4777 if (!MSG_IS_COPY(msginfo
->flags
)) {
4778 summary_msginfo_change_flags(msginfo
, 0, MSG_COPY
, MSG_DELETED
,
4779 MSG_MOVE
| MSG_MOVE_DONE
);
4780 summaryview
->copied
++;
4782 summary_msginfo_unset_flags(msginfo
, MSG_DELETED
, MSG_MOVE
);
4784 if (!prefs_common
.immediate_exec
) {
4785 summary_set_row_marks(summaryview
, row
);
4788 debug_print("Message %d is set to copy to %s\n",
4789 msginfo
->msgnum
, to_folder
->path
);
4792 void summary_copy_selected_to(SummaryView
*summaryview
, FolderItem
*to_folder
)
4795 gboolean froze
= FALSE
;
4797 if (!to_folder
) return;
4798 if (!summaryview
->folder_item
) return;
4800 if (summary_is_locked(summaryview
)) return;
4802 if (summaryview
->folder_item
== to_folder
) {
4804 (_("Destination to copy is same as current folder."));
4808 if (to_folder
->no_select
) {
4809 alertpanel_error(_("The destination folder can only be used to "
4810 "store subfolders."));
4814 START_LONG_OPERATION(summaryview
, FALSE
);
4816 for (cur
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
4817 cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4819 (summaryview
, GTK_CMCTREE_NODE(cur
->data
), to_folder
);
4821 END_LONG_OPERATION(summaryview
);
4823 if (prefs_common
.immediate_exec
)
4824 summary_execute(summaryview
);
4826 summary_status_show(summaryview
);
4830 void summary_copy_to(SummaryView
*summaryview
)
4832 FolderItem
*to_folder
;
4834 if (!summaryview
->folder_item
) return;
4836 to_folder
= foldersel_folder_sel(NULL
, FOLDER_SEL_COPY
, NULL
, FALSE
,
4838 "Select folder to copy selected message to",
4839 "Select folder to copy selected messages to",
4840 g_list_length(GTK_CMCLIST(summaryview
->ctree
)->selection
))
4842 summary_copy_selected_to(summaryview
, to_folder
);
4845 void summary_add_address(SummaryView
*summaryview
)
4847 MsgInfo
*msginfo
, *full_msginfo
;
4849 GdkPixbuf
*picture
= NULL
;
4850 AvatarRender
*avatarr
;
4852 msginfo
= gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview
->ctree
),
4853 summaryview
->selected
);
4854 if (!msginfo
|| !msginfo
->from
)
4857 Xstrdup_a(from
, msginfo
->from
, return);
4858 eliminate_address_comment(from
);
4859 extract_address(from
);
4861 full_msginfo
= procmsg_msginfo_get_full_info(msginfo
);
4863 avatarr
= avatars_avatarrender_new(full_msginfo
);
4864 hooks_invoke(AVATAR_IMAGE_RENDER_HOOKLIST
, avatarr
);
4866 procmsg_msginfo_free(&full_msginfo
);
4869 picture
= gtk_image_get_pixbuf(GTK_IMAGE(avatarr
->image
));
4871 #ifndef USE_ALT_ADDRBOOK
4872 addressbook_add_contact(msginfo
->fromname
, from
, NULL
, picture
);
4874 if (addressadd_selection(msginfo
->fromname
, from
, NULL
, picture
)) {
4875 debug_print( "addressbook_add_contact - added\n" );
4878 avatars_avatarrender_free(avatarr
);
4881 void summary_select_all(SummaryView
*summaryview
)
4883 GtkCMCTreeNode
*node
;
4885 if (!summaryview
->folder_item
) return;
4887 if (GTK_CMCLIST(summaryview
->ctree
)->focus_row
< 0) {
4888 /* If no row is selected, select (but do not open) the first
4889 * row, to get summaryview into correct state for selecting all. */
4890 debug_print("summary_select_all: no row selected, selecting first one\n");
4891 if (GTK_CMCLIST(summaryview
->ctree
)->row_list
!= NULL
) {
4892 node
= gtk_cmctree_node_nth(GTK_CMCTREE(summaryview
->ctree
), 0);
4893 summary_select_node(summaryview
, node
, FALSE
);
4897 /* Now select all rows while locking the summaryview for
4898 * faster performance. */
4899 summary_lock(summaryview
);
4900 gtk_cmclist_select_all(GTK_CMCLIST(summaryview
->ctree
));
4901 summary_unlock(summaryview
);
4903 summary_status_show(summaryview
);
4906 void summary_unselect_all(SummaryView
*summaryview
)
4908 summary_lock(summaryview
);
4909 gtk_sctree_unselect_all(GTK_SCTREE(summaryview
->ctree
));
4910 summary_unlock(summaryview
);
4911 summary_status_show(summaryview
);
4914 void summary_select_thread(SummaryView
*summaryview
, gboolean delete_thread
,
4915 gboolean trash_thread
)
4917 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4918 GtkCMCTreeNode
*node
= NULL
;
4919 gboolean froze
= FALSE
;
4922 if (!GTK_CMCLIST(summaryview
->ctree
)->selection
)
4926 START_LONG_OPERATION(summaryview
, FALSE
);
4927 copy
= g_list_copy(GTK_CMCLIST(summaryview
->ctree
)->selection
);
4928 for (cur
= copy
; cur
!= NULL
&& cur
->data
!= NULL
;
4930 node
= GTK_CMCTREE_NODE(cur
->data
);
4933 while (GTK_CMCTREE_ROW(node
)->parent
!= NULL
)
4934 node
= GTK_CMCTREE_ROW(node
)->parent
;
4936 gtk_cmctree_select_recursive(ctree
, node
);
4939 END_LONG_OPERATION(summaryview
);
4942 if (FOLDER_TYPE(summaryview
->folder_item
->folder
) == F_NEWS
)
4943 summary_delete(summaryview
);
4945 summary_delete_trash(summaryview
);
4946 } else if (delete_thread
)
4947 summary_delete(summaryview
);
4949 summary_status_show(summaryview
);
4952 void summary_save_as(SummaryView
*summaryview
)
4954 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4956 gchar
*filename
= NULL
;
4960 AlertValue aval
= 0;
4962 if (!summaryview
->selected
) return;
4963 msginfo
= gtk_cmctree_node_get_row_data(ctree
, summaryview
->selected
);
4964 if (!msginfo
) return;
4966 if (msginfo
->subject
) {
4967 Xstrdup_a(filename
, msginfo
->subject
, return);
4968 subst_for_filename(filename
);
4971 manage_window_focus_in(summaryview
->window
, NULL
, NULL
);
4973 if (filename
&& !g_utf8_validate(filename
, -1, NULL
)) {
4974 gchar
*oldstr
= filename
;
4975 filename
= conv_codeset_strdup(filename
,
4976 conv_get_locale_charset_str(),
4979 g_warning("summary_save_as(): failed to convert character set.");
4980 filename
= g_strdup(oldstr
);
4982 dest
= filesel_select_file_save(_("Save as"), filename
);
4985 dest
= filesel_select_file_save(_("Save as"), filename
);
4988 if (is_file_exist(dest
)) {
4989 aval
= alertpanel(_("Append or Overwrite"),
4990 _("Append or overwrite existing file?"),
4991 _("_Append"), _("_Overwrite"), GTK_STOCK_CANCEL
,
4993 if (aval
!= 0 && aval
!= 1)
4997 src
= procmsg_get_message_file(msginfo
);
4998 tmp
= g_path_get_basename(dest
);
5000 if ( aval
==0 ) { /* append */
5001 if (append_file(src
, dest
, TRUE
) < 0)
5002 alertpanel_error(_("Couldn't save the file '%s'."), tmp
);
5003 } else { /* overwrite */
5004 if (copy_file(src
, dest
, TRUE
) < 0)
5005 alertpanel_error(_("Couldn't save the file '%s'."), tmp
);
5010 * If two or more msgs are selected,
5011 * append them to the output file.
5013 if (GTK_CMCLIST(ctree
)->selection
->next
) {
5015 for (item
= GTK_CMCLIST(ctree
)->selection
->next
; item
!= NULL
; item
=item
->next
) {
5016 msginfo
= gtk_cmctree_node_get_row_data(ctree
, GTK_CMCTREE_NODE(item
->data
));
5017 if (!msginfo
) break;
5018 src
= procmsg_get_message_file(msginfo
);
5019 if (append_file(src
, dest
, TRUE
) < 0)
5020 alertpanel_error(_("Couldn't save the file '%s'."), tmp
);
5028 void summary_print(SummaryView
*summaryview
)
5030 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
5032 gchar
*msg
= g_strdup_printf(_("You are about to print %d "
5033 "messages, one by one. Do you "
5034 "want to continue?"),
5035 g_list_length(clist
->selection
));
5036 if (g_list_length(clist
->selection
) > 9
5037 && alertpanel(_("Warning"), msg
, GTK_STOCK_CANCEL
, GTK_STOCK_YES
,
5038 NULL
, ALERTFOCUS_SECOND
) != G_ALERTALTERNATE
) {
5044 if (clist
->selection
== NULL
) return;
5045 for (cur
= clist
->selection
;
5046 cur
!= NULL
&& cur
->data
!= NULL
;
5048 GtkCMCTreeNode
*node
= GTK_CMCTREE_NODE(cur
->data
);
5049 MsgInfo
*msginfo
= gtk_cmctree_node_get_row_data(
5050 GTK_CMCTREE(summaryview
->ctree
),
5052 gint sel_start
= -1, sel_end
= -1, partnum
= 0;
5054 if (node
== summaryview
->displayed
) {
5055 partnum
= mimeview_get_selected_part_num(summaryview
->messageview
->mimeview
);
5056 textview_get_selection_offsets(summaryview
->messageview
->mimeview
->textview
,
5057 &sel_start
, &sel_end
);
5059 messageview_print(msginfo
, summaryview
->messageview
->all_headers
,
5060 sel_start
, sel_end
, partnum
);
5064 gboolean
summary_execute(SummaryView
*summaryview
)
5066 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5067 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
5068 GtkCMCTreeNode
*node
, *next
;
5069 GtkCMCTreeNode
*new_selected
= NULL
;
5072 if (!summaryview
->folder_item
) return FALSE
;
5074 if (summary_is_locked(summaryview
)) return FALSE
;
5075 summary_lock(summaryview
);
5077 summary_freeze(summaryview
);
5079 main_window_cursor_wait(summaryview
->mainwin
);
5081 if (summaryview
->threaded
)
5082 summary_unthread_for_exec(summaryview
);
5084 folder_item_update_freeze();
5085 move_val
= summary_execute_move(summaryview
);
5086 summary_execute_copy(summaryview
);
5087 summary_execute_delete(summaryview
);
5089 node
= GTK_CMCTREE_NODE(clist
->row_list
);
5090 for (; node
!= NULL
; node
= next
) {
5091 next
= gtkut_ctree_node_next(ctree
, node
);
5092 if (gtk_cmctree_node_get_row_data(ctree
, node
) != NULL
) continue;
5094 if (node
== summaryview
->displayed
) {
5095 messageview_clear(summaryview
->messageview
);
5096 summary_cancel_mark_read_timeout(summaryview
);
5097 summaryview
->displayed
= NULL
;
5099 if (GTK_CMCTREE_ROW(node
)->children
!= NULL
) {
5101 if (GTK_CMCTREE_ROW(node
)->sibling
) {
5102 next
= GTK_CMCTREE_ROW(node
)->sibling
;
5104 GtkCMCTreeNode
*parent
= NULL
;
5105 for (parent
= GTK_CMCTREE_ROW(node
)->parent
; parent
!= NULL
;
5106 parent
= GTK_CMCTREE_ROW(parent
)->parent
) {
5107 if (GTK_CMCTREE_ROW(parent
)->sibling
) {
5108 next
= GTK_CMCTREE_ROW(parent
)->sibling
;
5114 if (!new_selected
&&
5115 gtkut_ctree_node_is_selected(ctree
, node
)) {
5116 summary_unselect_all(summaryview
);
5117 if (summaryview
->sort_type
== SORT_ASCENDING
) {
5118 new_selected
= summary_find_next_msg(summaryview
, node
,TRUE
);
5119 if (!new_selected
|| prefs_common
.next_on_delete
== FALSE
)
5120 new_selected
= summary_find_prev_msg(summaryview
, node
,TRUE
);
5122 new_selected
= summary_find_prev_msg(summaryview
, node
,TRUE
);
5123 if (!new_selected
|| prefs_common
.next_on_delete
== FALSE
)
5124 new_selected
= summary_find_next_msg(summaryview
, node
,TRUE
);
5128 gtk_sctree_remove_node((GtkSCTree
*)ctree
, node
);
5131 folder_item_update_thaw();
5134 summary_unlock(summaryview
);
5135 summary_select_node(summaryview
, new_selected
, OPEN_SELECTED_ON_DELETEMOVE
);
5136 summary_lock(summaryview
);
5139 if (summaryview
->threaded
) {
5140 summary_thread_build(summaryview
);
5141 summary_thread_init(summaryview
);
5144 summary_thaw(summaryview
);
5146 summaryview
->selected
= clist
->selection
?
5147 GTK_CMCTREE_NODE(clist
->selection
->data
) : NULL
;
5149 if (!GTK_CMCLIST(summaryview
->ctree
)->row_list
) {
5150 menu_set_insensitive_all
5151 (GTK_MENU_SHELL(summaryview
->popupmenu
));
5152 folderview_grab_focus(summaryview
->folderview
);
5154 menu_set_sensitive_all(GTK_MENU_SHELL(summaryview
->popupmenu
), TRUE
);
5155 gtk_widget_grab_focus(summaryview
->ctree
);
5157 summary_update_status(summaryview
);
5158 summary_status_show(summaryview
);
5160 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
5162 summary_unlock(summaryview
);
5164 main_window_cursor_normal(summaryview
->mainwin
);
5167 summary_show(summaryview
, summaryview
->folder_item
);
5171 gboolean
summary_expunge(SummaryView
*summaryview
)
5173 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5174 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
5175 GtkCMCTreeNode
*node
, *next
;
5176 GtkCMCTreeNode
*new_selected
= NULL
;
5178 if (!summaryview
->folder_item
) return FALSE
;
5180 if (summary_is_locked(summaryview
)) return FALSE
;
5182 summary_lock(summaryview
);
5184 summary_freeze(summaryview
);
5186 main_window_cursor_wait(summaryview
->mainwin
);
5188 if (summaryview
->threaded
)
5189 summary_unthread_for_exec(summaryview
);
5191 folder_item_update_freeze();
5192 summary_execute_expunge(summaryview
);
5194 node
= GTK_CMCTREE_NODE(clist
->row_list
);
5195 for (; node
!= NULL
; node
= next
) {
5196 next
= gtkut_ctree_node_next(ctree
, node
);
5197 if (gtk_cmctree_node_get_row_data(ctree
, node
) != NULL
) continue;
5199 if (node
== summaryview
->displayed
) {
5200 messageview_clear(summaryview
->messageview
);
5201 summary_cancel_mark_read_timeout(summaryview
);
5202 summaryview
->displayed
= NULL
;
5204 if (GTK_CMCTREE_ROW(node
)->children
!= NULL
) {
5206 if (GTK_CMCTREE_ROW(node
)->sibling
) {
5207 next
= GTK_CMCTREE_ROW(node
)->sibling
;
5209 GtkCMCTreeNode
*parent
= NULL
;
5210 for (parent
= GTK_CMCTREE_ROW(node
)->parent
; parent
!= NULL
;
5211 parent
= GTK_CMCTREE_ROW(parent
)->parent
) {
5212 if (GTK_CMCTREE_ROW(parent
)->sibling
) {
5213 next
= GTK_CMCTREE_ROW(parent
)->sibling
;
5219 if (!new_selected
&&
5220 gtkut_ctree_node_is_selected(ctree
, node
)) {
5221 summary_unselect_all(summaryview
);
5222 new_selected
= summary_find_next_msg(summaryview
, node
,TRUE
);
5224 new_selected
= summary_find_prev_msg
5225 (summaryview
, node
,TRUE
);
5228 gtk_sctree_remove_node((GtkSCTree
*)ctree
, node
);
5231 folder_item_update_thaw();
5234 summary_unlock(summaryview
);
5235 summary_select_node(summaryview
, new_selected
, OPEN_SELECTED_ON_DELETEMOVE
);
5236 summary_lock(summaryview
);
5239 if (summaryview
->threaded
) {
5240 summary_thread_build(summaryview
);
5241 summary_thread_init(summaryview
);
5244 summary_thaw(summaryview
);
5246 summaryview
->selected
= clist
->selection
?
5247 GTK_CMCTREE_NODE(clist
->selection
->data
) : NULL
;
5249 if (!GTK_CMCLIST(summaryview
->ctree
)->row_list
) {
5250 menu_set_insensitive_all
5251 (GTK_MENU_SHELL(summaryview
->popupmenu
));
5252 folderview_grab_focus(summaryview
->folderview
);
5254 menu_set_sensitive_all(GTK_MENU_SHELL(summaryview
->popupmenu
), TRUE
);
5255 gtk_widget_grab_focus(summaryview
->ctree
);
5258 summary_update_status(summaryview
);
5259 summary_status_show(summaryview
);
5261 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
5263 summary_unlock(summaryview
);
5265 main_window_cursor_normal(summaryview
->mainwin
);
5270 static gint
summary_execute_move(SummaryView
*summaryview
)
5272 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5275 /* search moving messages and execute */
5277 gtk_cmctree_pre_recursive(ctree
, NULL
, summary_execute_move_func
,
5280 if (summaryview
->mlist
) {
5281 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST
,
5282 summaryview
->msginfo_update_callback_id
);
5283 val
= procmsg_move_messages(summaryview
->mlist
);
5284 summaryview
->msginfo_update_callback_id
=
5285 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
,
5286 summary_update_msg
, (gpointer
) summaryview
);
5288 for (cur
= summaryview
->mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
5289 procmsg_msginfo_free((MsgInfo
**)&(cur
->data
));
5292 g_slist_free(summaryview
->mlist
);
5293 summaryview
->mlist
= NULL
;
5299 static void summary_execute_move_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5302 SummaryView
*summaryview
= data
;
5305 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5307 if (msginfo
&& MSG_IS_MOVE(msginfo
->flags
) && msginfo
->to_folder
) {
5308 summaryview
->mlist
=
5309 g_slist_prepend(summaryview
->mlist
, msginfo
);
5310 gtk_cmctree_node_set_row_data(ctree
, node
, NULL
);
5312 if (msginfo
->msgid
&& *msginfo
->msgid
&&
5313 node
== g_hash_table_lookup(summaryview
->msgid_table
,
5315 g_hash_table_remove(summaryview
->msgid_table
,
5317 if (prefs_common
.thread_by_subject
&&
5318 msginfo
->subject
&& *msginfo
->subject
&&
5319 node
== subject_table_lookup(summaryview
->subject_table
,
5320 msginfo
->subject
)) {
5321 subject_table_remove(summaryview
->subject_table
,
5327 static void summary_execute_copy(SummaryView
*summaryview
)
5329 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5331 /* search copying messages and execute */
5332 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST
,
5333 summaryview
->msginfo_update_callback_id
);
5334 gtk_cmctree_pre_recursive(ctree
, NULL
, summary_execute_copy_func
,
5337 if (summaryview
->mlist
) {
5338 summaryview
->mlist
= g_slist_reverse(summaryview
->mlist
);
5339 procmsg_copy_messages(summaryview
->mlist
);
5341 g_slist_free(summaryview
->mlist
);
5342 summaryview
->mlist
= NULL
;
5344 summaryview
->msginfo_update_callback_id
=
5345 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
,
5346 summary_update_msg
, (gpointer
) summaryview
);
5349 static void summary_execute_copy_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5352 SummaryView
*summaryview
= data
;
5355 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5357 if (msginfo
&& MSG_IS_COPY(msginfo
->flags
) && msginfo
->to_folder
) {
5358 summaryview
->mlist
=
5359 g_slist_prepend(summaryview
->mlist
, msginfo
);
5361 summary_msginfo_unset_flags(msginfo
, 0, MSG_COPY
);
5362 summary_set_row_marks(summaryview
, node
);
5366 static void summary_execute_delete(SummaryView
*summaryview
)
5368 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5371 /* search deleting messages and execute */
5372 gtk_cmctree_pre_recursive
5373 (ctree
, NULL
, summary_execute_delete_func
, summaryview
);
5375 if (!summaryview
->mlist
) return;
5377 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST
,
5378 summaryview
->msginfo_update_callback_id
);
5380 folder_item_remove_msgs(summaryview
->folder_item
,
5381 summaryview
->mlist
);
5383 summaryview
->msginfo_update_callback_id
=
5384 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
,
5385 summary_update_msg
, (gpointer
) summaryview
);
5387 for (cur
= summaryview
->mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
5388 procmsg_msginfo_free((MsgInfo
**)&(cur
->data
));
5391 g_slist_free(summaryview
->mlist
);
5392 summaryview
->mlist
= NULL
;
5395 static void summary_execute_delete_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5398 SummaryView
*summaryview
= data
;
5401 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5403 if (msginfo
&& MSG_IS_DELETED(msginfo
->flags
)) {
5404 summaryview
->mlist
=
5405 g_slist_prepend(summaryview
->mlist
, msginfo
);
5406 gtk_cmctree_node_set_row_data(ctree
, node
, NULL
);
5408 if (msginfo
->msgid
&& *msginfo
->msgid
&&
5409 node
== g_hash_table_lookup(summaryview
->msgid_table
,
5411 g_hash_table_remove(summaryview
->msgid_table
,
5414 if (prefs_common
.thread_by_subject
&&
5415 msginfo
->subject
&& *msginfo
->subject
&&
5416 node
== subject_table_lookup(summaryview
->subject_table
,
5417 msginfo
->subject
)) {
5418 subject_table_remove(summaryview
->subject_table
,
5424 static void summary_execute_expunge_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5427 SummaryView
*summaryview
= data
;
5430 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5432 if (msginfo
&& MSG_IS_DELETED(msginfo
->flags
)) {
5433 summaryview
->mlist
=
5434 g_slist_prepend(summaryview
->mlist
, msginfo
);
5435 gtk_cmctree_node_set_row_data(ctree
, node
, NULL
);
5437 if (msginfo
->msgid
&& *msginfo
->msgid
&&
5438 node
== g_hash_table_lookup(summaryview
->msgid_table
,
5440 g_hash_table_remove(summaryview
->msgid_table
,
5443 if (prefs_common
.thread_by_subject
&&
5444 msginfo
->subject
&& *msginfo
->subject
&&
5445 node
== subject_table_lookup(summaryview
->subject_table
,
5446 msginfo
->subject
)) {
5447 subject_table_remove(summaryview
->subject_table
,
5453 static void summary_execute_expunge(SummaryView
*summaryview
)
5455 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5458 gtk_cmctree_pre_recursive
5459 (ctree
, NULL
, summary_execute_expunge_func
, summaryview
);
5461 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST
,
5462 summaryview
->msginfo_update_callback_id
);
5464 folder_item_expunge(summaryview
->folder_item
);
5466 summaryview
->msginfo_update_callback_id
=
5467 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
,
5468 summary_update_msg
, (gpointer
) summaryview
);
5469 for (cur
= summaryview
->mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
5470 procmsg_msginfo_free((MsgInfo
**)&(cur
->data
));
5472 g_slist_free(summaryview
->mlist
);
5473 summaryview
->mlist
= NULL
;
5476 /* thread functions */
5478 static void summary_thread_build(SummaryView
*summaryview
)
5480 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5481 GtkCMCTreeNode
*node
;
5482 GtkCMCTreeNode
*next
;
5483 GtkCMCTreeNode
*parent
;
5487 summary_lock(summaryview
);
5489 debug_print("Building threads...\n");
5490 STATUSBAR_PUSH(summaryview
->mainwin
, _("Building threads..."));
5491 main_window_cursor_wait(summaryview
->mainwin
);
5493 g_signal_handlers_block_by_func(G_OBJECT(ctree
),
5494 G_CALLBACK(summary_tree_expanded
), summaryview
);
5495 summary_freeze(summaryview
);
5497 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
5499 next
= GTK_CMCTREE_ROW(node
)->sibling
;
5501 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5505 if (msginfo
&& msginfo
->inreplyto
) {
5506 parent
= g_hash_table_lookup(summaryview
->msgid_table
,
5507 msginfo
->inreplyto
);
5509 if (!parent
&& msginfo
->references
) {
5510 for (reflist
= msginfo
->references
;
5511 reflist
!= NULL
; reflist
= reflist
->next
)
5512 if ((parent
= g_hash_table_lookup
5513 (summaryview
->msgid_table
,
5519 if (msginfo
&& prefs_common
.thread_by_subject
&& parent
== NULL
) {
5520 parent
= subject_table_lookup
5521 (summaryview
->subject_table
,
5525 if (parent
&& parent
!= node
&& parent
!= GTK_CMCTREE_ROW(node
)->parent
) {
5526 gtk_cmctree_move(ctree
, node
, parent
, NULL
);
5532 gtkut_ctree_set_focus_row(ctree
, summaryview
->selected
);
5534 summary_thaw(summaryview
);
5535 g_signal_handlers_unblock_by_func(G_OBJECT(ctree
),
5536 G_CALLBACK(summary_tree_expanded
), summaryview
);
5538 debug_print("Building threads done.\n");
5539 STATUSBAR_POP(summaryview
->mainwin
);
5540 main_window_cursor_normal(summaryview
->mainwin
);
5542 summaryview
->threaded
= TRUE
;
5544 summary_unlock(summaryview
);
5547 static void summary_thread_init(SummaryView
*summaryview
)
5549 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5550 GtkCMCTreeNode
*node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
5551 GtkCMCTreeNode
*next
;
5553 if (!summaryview
->thread_collapsed
) {
5554 g_signal_handlers_block_by_func(G_OBJECT(ctree
),
5555 G_CALLBACK(summary_tree_expanded
), summaryview
);
5557 next
= GTK_CMCTREE_ROW(node
)->sibling
;
5558 if (GTK_CMCTREE_ROW(node
)->children
)
5559 gtk_cmctree_expand_recursive(ctree
, node
);
5562 g_signal_handlers_unblock_by_func(G_OBJECT(ctree
),
5563 G_CALLBACK(summary_tree_expanded
), summaryview
);
5568 static void summary_unthread_for_exec(SummaryView
*summaryview
)
5570 GtkCMCTreeNode
*node
;
5571 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5572 gboolean froze
= FALSE
;
5574 debug_print("Unthreading for execution...\n");
5576 START_LONG_OPERATION(summaryview
, TRUE
);
5577 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
5578 node
!= NULL
; node
= GTK_CMCTREE_NODE_NEXT(node
)) {
5579 summary_unthread_for_exec_func(ctree
, node
, summaryview
);
5582 END_LONG_OPERATION(summaryview
);
5584 debug_print("Unthreading for execution done.\n");
5587 static void summary_unthread_for_exec_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5591 GtkCMCTreeNode
*top_parent
;
5592 GtkCMCTreeNode
*child
;
5593 GtkCMCTreeNode
*sibling
;
5594 SummaryView
* summaryview
= (SummaryView
*)data
;
5595 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5598 (!MSG_IS_MOVE(msginfo
->flags
) &&
5599 !MSG_IS_DELETED(msginfo
->flags
)))
5601 child
= GTK_CMCTREE_ROW(node
)->children
;
5604 if (node
== summaryview
->selected
)
5605 summaryview
->selected
= NULL
;
5606 if (node
== summaryview
->displayed
)
5607 summaryview
->displayed
= NULL
;
5609 summary_cancel_mark_read_timeout(summaryview
);
5611 for (top_parent
= node
;
5612 GTK_CMCTREE_ROW(top_parent
)->parent
!= NULL
;
5613 top_parent
= GTK_CMCTREE_ROW(top_parent
)->parent
)
5615 sibling
= GTK_CMCTREE_ROW(top_parent
)->sibling
;
5617 GTK_SCTREE(ctree
)->sorting
= TRUE
;
5618 while (child
!= NULL
) {
5619 GtkCMCTreeNode
*next_child
;
5620 MsgInfo
*cinfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(child
);
5622 next_child
= GTK_CMCTREE_ROW(child
)->sibling
;
5624 if (!MSG_IS_MOVE(cinfo
->flags
) && !MSG_IS_DELETED(cinfo
->flags
)) {
5625 gtk_cmctree_move(ctree
, child
,
5629 if (child
== summaryview
->displayed
) {
5630 messageview_clear(summaryview
->messageview
);
5631 summaryview
->displayed
= NULL
;
5633 if (child
== summaryview
->selected
) {
5634 messageview_clear(summaryview
->messageview
);
5635 summaryview
->selected
= NULL
;
5640 GTK_SCTREE(ctree
)->sorting
= FALSE
;
5643 void summary_expand_threads(SummaryView
*summaryview
)
5645 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5646 GtkCMCTreeNode
*node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
5647 GtkCMCTreeNode
*focus_node
= GTK_CMCTREE_NODE (g_list_nth (GTK_CMCLIST(ctree
)->row_list
, GTK_CMCLIST(ctree
)->focus_row
));
5649 g_signal_handlers_block_by_func(G_OBJECT(ctree
),
5650 G_CALLBACK(summary_tree_expanded
), summaryview
);
5651 summary_freeze(summaryview
);
5652 GTK_SCTREE(ctree
)->sorting
= TRUE
;
5655 if (GTK_CMCTREE_ROW(node
)->children
) {
5656 gtk_cmctree_expand(ctree
, node
);
5657 summary_set_row_marks(summaryview
, node
);
5659 node
= GTK_CMCTREE_NODE_NEXT(node
);
5662 GTK_SCTREE(ctree
)->sorting
= FALSE
;
5664 GTK_CMCLIST(ctree
)->focus_row
= g_list_position (GTK_CMCLIST(ctree
)->row_list
,(GList
*)focus_node
);
5666 summary_thaw(summaryview
);
5668 g_signal_handlers_unblock_by_func(G_OBJECT(ctree
),
5669 G_CALLBACK(summary_tree_expanded
), summaryview
);
5671 summaryview
->thread_collapsed
= FALSE
;
5673 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
5676 void summary_collapse_threads(SummaryView
*summaryview
)
5678 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5679 GtkCMCTreeNode
*node
= NULL
;
5680 GtkCMCTreeNode
*focus_node
= GTK_CMCTREE_NODE (g_list_nth (GTK_CMCLIST(ctree
)->row_list
, GTK_CMCLIST(ctree
)->focus_row
));
5682 g_signal_handlers_block_by_func(G_OBJECT(ctree
),
5683 G_CALLBACK(summary_tree_collapsed
), summaryview
);
5684 summary_freeze(summaryview
);
5685 GTK_SCTREE(ctree
)->sorting
= TRUE
;
5688 while (node
&& GTK_CMCTREE_ROW(node
)->parent
) {
5689 focus_node
= node
= GTK_CMCTREE_ROW(node
)->parent
;
5691 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_DIRECTIONAL
);
5692 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
5694 if (GTK_CMCTREE_ROW(node
)->children
) {
5695 gtk_cmctree_collapse(ctree
, node
);
5696 summary_set_row_marks(summaryview
, node
);
5698 node
= GTK_CMCTREE_ROW(node
)->sibling
;
5701 GTK_SCTREE(ctree
)->sorting
= FALSE
;
5703 GTK_CMCLIST(ctree
)->focus_row
= g_list_position (GTK_CMCLIST(ctree
)->row_list
,(GList
*)focus_node
);
5705 GTK_SCTREE(ctree
)->anchor_row
=
5706 gtk_cmctree_node_nth(ctree
, GTK_CMCLIST(ctree
)->focus_row
);
5707 summary_thaw(summaryview
);
5708 g_signal_handlers_unblock_by_func(G_OBJECT(ctree
),
5709 G_CALLBACK(summary_tree_collapsed
), summaryview
);
5711 summaryview
->thread_collapsed
= TRUE
;
5713 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
5716 static void account_rules_radio_button_toggled_cb(GtkToggleButton
*btn
, gpointer data
)
5718 prefs_common
.apply_per_account_filtering_rules
= GPOINTER_TO_INT(data
);
5721 static gboolean
summary_filter_get_mode(void)
5722 /* ask what to do w/ them: skip them, apply them regardless to the account,
5723 use the current account */
5725 /* TODO: eventually also propose to use the current folder's default account,
5727 /* TODO: eventually allow to select the account to use from a optmenu */
5730 GtkWidget
*account_rules_skip
;
5731 GtkWidget
*account_rules_force
;
5732 GtkWidget
*account_rules_user_current
;
5735 vbox
= gtk_vbox_new (FALSE
, 0);
5737 account_rules_skip
= gtk_radio_button_new_with_label
5738 (NULL
, _("Skip these rules"));
5739 account_rules_force
= gtk_radio_button_new_with_label_from_widget
5740 (GTK_RADIO_BUTTON(account_rules_skip
),
5741 _("Apply these rules regardless of the account they belong to"));
5742 account_rules_user_current
= gtk_radio_button_new_with_label_from_widget
5743 (GTK_RADIO_BUTTON(account_rules_skip
),
5744 _("Apply these rules if they apply to the current account"));
5745 gtk_box_pack_start (GTK_BOX (vbox
), account_rules_skip
, FALSE
, FALSE
, 0);
5746 gtk_box_pack_start (GTK_BOX (vbox
), account_rules_force
, FALSE
, FALSE
, 0);
5747 gtk_box_pack_start (GTK_BOX (vbox
), account_rules_user_current
, FALSE
, FALSE
, 0);
5748 g_signal_connect(G_OBJECT(account_rules_skip
), "toggled",
5749 G_CALLBACK(account_rules_radio_button_toggled_cb
),
5750 GINT_TO_POINTER(FILTERING_ACCOUNT_RULES_SKIP
));
5751 g_signal_connect(G_OBJECT(account_rules_force
), "toggled",
5752 G_CALLBACK(account_rules_radio_button_toggled_cb
),
5753 GINT_TO_POINTER(FILTERING_ACCOUNT_RULES_FORCE
));
5754 g_signal_connect(G_OBJECT(account_rules_user_current
), "toggled",
5755 G_CALLBACK(account_rules_radio_button_toggled_cb
),
5756 GINT_TO_POINTER(FILTERING_ACCOUNT_RULES_USE_CURRENT
));
5757 switch (prefs_common
.apply_per_account_filtering_rules
) {
5758 case FILTERING_ACCOUNT_RULES_SKIP
:
5759 gtk_toggle_button_set_active(
5760 GTK_TOGGLE_BUTTON(account_rules_skip
), TRUE
);
5762 case FILTERING_ACCOUNT_RULES_FORCE
:
5763 gtk_toggle_button_set_active(
5764 GTK_TOGGLE_BUTTON(account_rules_force
), TRUE
);
5766 case FILTERING_ACCOUNT_RULES_USE_CURRENT
:
5767 gtk_toggle_button_set_active(
5768 GTK_TOGGLE_BUTTON(account_rules_user_current
), TRUE
);
5772 val
= alertpanel_with_widget(
5774 _("There are some filtering rules that belong to an account.\n"
5775 "Please choose what to do with these rules:"),
5776 GTK_STOCK_CANCEL
, _("_Filter"), NULL
, ALERTFOCUS_SECOND
,
5779 if ((val
& ~G_ALERTDISABLE
) != G_ALERTALTERNATE
) {
5781 } else if (val
& G_ALERTDISABLE
)
5782 prefs_common
.ask_apply_per_account_filtering_rules
= FALSE
;
5787 void summary_filter(SummaryView
*summaryview
, gboolean selected_only
)
5789 GSList
*mlist
= NULL
, *cur_list
;
5790 summary_lock(summaryview
);
5792 /* are there any per-account filtering rules? */
5793 if (prefs_common
.ask_apply_per_account_filtering_rules
== TRUE
&&
5794 filtering_peek_per_account_rules(filtering_rules
)) {
5796 if (summary_filter_get_mode() == FALSE
) {
5797 summary_unlock(summaryview
);
5802 folder_item_update_freeze();
5804 debug_print("filtering...\n");
5805 STATUSBAR_PUSH(summaryview
->mainwin
, _("Filtering..."));
5806 main_window_cursor_wait(summaryview
->mainwin
);
5808 summary_freeze(summaryview
);
5810 if (selected_only
) {
5813 for (cur
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
5814 cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
5815 mlist
= g_slist_prepend(mlist
,
5816 procmsg_msginfo_new_ref(
5817 GTKUT_CTREE_NODE_GET_ROW_DATA(cur
->data
)));
5819 mlist
= g_slist_reverse(mlist
);
5821 mlist
= folder_item_get_msg_list(summaryview
->folder_item
);
5824 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
5825 for (cur_list
= mlist
; cur_list
; cur_list
= cur_list
->next
) {
5826 summary_filter_func((MsgInfo
*)cur_list
->data
);
5828 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
5830 filtering_move_and_copy_msgs(mlist
);
5832 for (cur_list
= mlist
; cur_list
; cur_list
= cur_list
->next
) {
5833 procmsg_msginfo_free((MsgInfo
**)&(cur_list
->data
));
5835 g_slist_free(mlist
);
5837 summary_thaw(summaryview
);
5839 folder_item_update_thaw();
5840 debug_print("filtering done.\n");
5841 STATUSBAR_POP(summaryview
->mainwin
);
5842 main_window_cursor_normal(summaryview
->mainwin
);
5844 summary_unlock(summaryview
);
5847 * CLAWS: summary_show() only valid after having a lock. ideally
5848 * we want the lock to be context aware...
5850 summary_show(summaryview
, summaryview
->folder_item
);
5853 static void summary_filter_func(MsgInfo
*msginfo
)
5855 MailFilteringData mail_filtering_data
;
5857 mail_filtering_data
.msginfo
= msginfo
;
5858 mail_filtering_data
.msglist
= NULL
;
5859 mail_filtering_data
.filtered
= NULL
;
5860 mail_filtering_data
.unfiltered
= NULL
;
5861 if (hooks_invoke(MAIL_MANUAL_FILTERING_HOOKLIST
, &mail_filtering_data
))
5864 filter_message_by_msginfo(filtering_rules
, msginfo
, NULL
,
5865 FILTERING_MANUALLY
, NULL
);
5868 void summary_msginfo_filter_open(FolderItem
* item
, MsgInfo
*msginfo
,
5869 PrefsFilterType type
, gint processing_rule
)
5871 gchar
*header
= NULL
;
5874 procmsg_get_filter_keyword(msginfo
, &header
, &key
, type
);
5876 if (processing_rule
) {
5878 prefs_filtering_open(&pre_global_processing
,
5879 _("Processing rules to apply before folder rules"),
5880 MANUAL_ANCHOR_PROCESSING
,
5881 header
, key
, FALSE
);
5883 prefs_filtering_open(&item
->prefs
->processing
,
5884 _("Processing configuration"),
5885 MANUAL_ANCHOR_PROCESSING
,
5886 header
, key
, FALSE
);
5889 prefs_filtering_open(&filtering_rules
,
5890 _("Filtering configuration"),
5891 MANUAL_ANCHOR_FILTERING
,
5899 void summary_filter_open(SummaryView
*summaryview
, PrefsFilterType type
,
5900 gint processing_rule
)
5905 if (!summaryview
->selected
) return;
5907 msginfo
= gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview
->ctree
),
5908 summaryview
->selected
);
5909 if (!msginfo
) return;
5911 item
= summaryview
->folder_item
;
5912 summary_msginfo_filter_open(item
, msginfo
, type
, processing_rule
);
5917 #define N_COLOR_LABELS colorlabel_get_color_count()
5919 static void summary_colorlabel_menu_item_activate_cb(GtkWidget
*widget
,
5922 guint color
= GPOINTER_TO_UINT(data
);
5923 SummaryView
*summaryview
;
5925 summaryview
= g_object_get_data(G_OBJECT(widget
), "summaryview");
5926 cm_return_if_fail(summaryview
!= NULL
);
5928 /* "dont_toggle" state set? */
5929 if (g_object_get_data(G_OBJECT(summaryview
->colorlabel_menu
),
5933 summary_set_colorlabel(summaryview
, color
, NULL
);
5936 /* summary_set_colorlabel_color() - labelcolor parameter is the color *flag*
5937 * for the message; not the color index */
5938 void summary_set_colorlabel_color(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5942 GtkStyle
*style
, *prev_style
, *ctree_style
;
5946 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
5947 cm_return_if_fail(msginfo
);
5949 color_index
= labelcolor
== 0 ? -1 : (gint
)labelcolor
- 1;
5950 ctree_style
= gtk_widget_get_style(GTK_WIDGET(ctree
));
5951 prev_style
= gtk_cmctree_node_get_row_style(ctree
, node
);
5953 if (color_index
< 0 || color_index
>= N_COLOR_LABELS
) {
5954 if (!prev_style
) return;
5955 style
= gtk_style_copy(prev_style
);
5956 color
= ctree_style
->text
[GTK_STATE_NORMAL
];
5957 style
->text
[GTK_STATE_NORMAL
] = color
;
5958 color
= ctree_style
->text
[GTK_STATE_SELECTED
];
5959 style
->text
[GTK_STATE_SELECTED
] = color
;
5962 style
= gtk_style_copy(prev_style
);
5964 style
= gtk_style_copy(ctree_style
);
5965 color
= colorlabel_get_color(color_index
);
5966 style
->text
[GTK_STATE_NORMAL
] = color
;
5967 /* get the average of label color and selected fg color
5969 style
->text
[GTK_STATE_SELECTED
].red
= (color
.red
+ 3*ctree_style
->text
[GTK_STATE_SELECTED
].red
) / 4;
5970 style
->text
[GTK_STATE_SELECTED
].green
= (color
.green
+ 3*ctree_style
->text
[GTK_STATE_SELECTED
].green
) / 4;
5971 style
->text
[GTK_STATE_SELECTED
].blue
= (color
.blue
+ 3*ctree_style
->text
[GTK_STATE_SELECTED
].blue
) / 4;
5974 gtk_cmctree_node_set_row_style(ctree
, node
, style
);
5975 g_object_unref(style
);
5978 static void summary_set_row_colorlabel(SummaryView
*summaryview
, GtkCMCTreeNode
*row
, guint labelcolor
)
5980 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5983 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
5984 cm_return_if_fail(msginfo
);
5986 summary_msginfo_change_flags(msginfo
, MSG_COLORLABEL_TO_FLAGS(labelcolor
), 0,
5987 MSG_CLABEL_FLAG_MASK
, 0);
5988 summary_set_row_marks(summaryview
, row
);
5991 void summary_set_colorlabel(SummaryView
*summaryview
, guint labelcolor
,
5994 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5996 gboolean froze
= FALSE
;
5998 if (prefs_common
.ask_override_colorlabel
) {
5999 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
6000 gboolean ask
= FALSE
;
6003 gboolean already_this_color_everywhere
= TRUE
;
6005 /* if clearing color labels (applying 'none', 0):
6006 - ask if at least one message has a non-0 color label set
6007 if applying a non-0 color label:
6008 - ask if at least one of the selected messages has a non-0 color label different
6009 from the one we want to apply.
6010 - don't ask if all messages have the same color label as the one we're applying
6012 for (cur
= GTK_CMCLIST(ctree
)->selection
;
6013 !ask
&& cur
!= NULL
&& cur
->data
!= NULL
;
6015 MsgInfo
*msginfo
= gtk_cmctree_node_get_row_data(ctree
, GTK_CMCTREE_NODE(cur
->data
));
6017 color
= MSG_GET_COLORLABEL_VALUE(msginfo
->flags
);
6018 if (labelcolor
== 0) {
6019 /* clearing color labels */
6022 already_this_color_everywhere
&= (color
== labelcolor
);
6023 ask
= ((color
!= 0) && (color
!= labelcolor
)) && !already_this_color_everywhere
;
6031 if (labelcolor
== 0)
6032 msg
= _("Do you really want to reset the color label of all selected messages?");
6034 msg
= _("Do you really want to apply this color label to all selected messages?");
6035 val
= alertpanel_full(_("Set color label"), msg
,
6036 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_FIRST
,
6037 TRUE
, NULL
, ALERT_QUESTION
);
6039 if ((val
& ~G_ALERTDISABLE
) != G_ALERTALTERNATE
)
6041 else if (val
& G_ALERTDISABLE
)
6042 prefs_common
.ask_override_colorlabel
= FALSE
;
6046 START_LONG_OPERATION(summaryview
, FALSE
);
6047 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
6048 summary_set_row_colorlabel(summaryview
,
6049 GTK_CMCTREE_NODE(cur
->data
), labelcolor
);
6050 END_LONG_OPERATION(summaryview
);
6053 static gboolean
summary_set_row_tag(SummaryView
*summaryview
, GtkCMCTreeNode
*row
, gboolean refresh
, gboolean set
, gint id
)
6055 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
6057 gchar
*tags_str
= NULL
;
6058 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
6059 cm_return_val_if_fail(msginfo
, FALSE
);
6061 procmsg_msginfo_update_tags(msginfo
, set
, id
);
6063 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_TAGS
]].visible
) {
6064 tags_str
= procmsg_msginfo_get_tags_str(msginfo
);
6065 gtk_cmctree_node_set_text(ctree
, row
,
6066 summaryview
->col_pos
[S_COL_TAGS
],
6067 tags_str
?tags_str
:"-");
6071 summary_set_row_marks(summaryview
, row
);
6072 if (row
== summaryview
->displayed
) {
6078 void summary_set_tag(SummaryView
*summaryview
, gint tag_id
,
6081 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
6083 gboolean set
= tag_id
> 0;
6084 gint real_id
= set
? tag_id
:-tag_id
;
6085 gboolean froze
= FALSE
;
6086 gboolean redisplay
= FALSE
;
6088 if (summary_is_locked(summaryview
))
6090 START_LONG_OPERATION(summaryview
, FALSE
);
6091 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
6092 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
6093 redisplay
|= summary_set_row_tag(summaryview
,
6094 GTK_CMCTREE_NODE(cur
->data
), FALSE
, set
, real_id
);
6096 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
6097 END_LONG_OPERATION(summaryview
);
6099 summary_redisplay_msg(summaryview
);
6102 static void summary_tags_menu_item_activate_cb(GtkWidget
*widget
,
6105 gint id
= GPOINTER_TO_INT(data
);
6106 gboolean set
= gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget
));
6107 SummaryView
*summaryview
;
6109 summaryview
= g_object_get_data(G_OBJECT(widget
), "summaryview");
6110 cm_return_if_fail(summaryview
!= NULL
);
6112 /* "dont_toggle" state set? */
6113 if (g_object_get_data(G_OBJECT(summaryview
->tags_menu
),
6119 summary_set_tag(summaryview
, id
, NULL
);
6122 static void summary_colorlabel_menu_item_activate_item_cb(GtkMenuItem
*menu_item
,
6125 SummaryView
*summaryview
;
6127 GtkCheckMenuItem
**items
;
6129 GList
*children
, *cur
, *sel
;
6131 summaryview
= (SummaryView
*)data
;
6132 cm_return_if_fail(summaryview
!= NULL
);
6134 sel
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
6137 menu
= GTK_MENU_SHELL(summaryview
->colorlabel_menu
);
6139 cm_return_if_fail(menu
!= NULL
);
6141 Xalloca(items
, (N_COLOR_LABELS
+ 1) * sizeof(GtkWidget
*), return);
6143 /* NOTE: don't return prematurely because we set the "dont_toggle"
6144 * state for check menu items */
6145 g_object_set_data(G_OBJECT(menu
), "dont_toggle",
6146 GINT_TO_POINTER(1));
6148 /* clear items. get item pointers. */
6149 children
= gtk_container_get_children(GTK_CONTAINER(menu
));
6150 for (n
= 0, cur
= children
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
6151 if (GTK_IS_CHECK_MENU_ITEM(cur
->data
)) {
6152 gtk_check_menu_item_set_active
6153 (GTK_CHECK_MENU_ITEM(cur
->data
), FALSE
);
6154 items
[n
] = GTK_CHECK_MENU_ITEM(cur
->data
);
6159 g_list_free(children
);
6161 if (n
== (N_COLOR_LABELS
+ 1)) {
6162 /* iterate all messages and set the state of the appropriate
6164 for (; sel
!= NULL
; sel
= sel
->next
) {
6168 msginfo
= gtk_cmctree_node_get_row_data
6169 (GTK_CMCTREE(summaryview
->ctree
),
6170 GTK_CMCTREE_NODE(sel
->data
));
6172 clabel
= MSG_GET_COLORLABEL_VALUE(msginfo
->flags
);
6173 if (!gtk_check_menu_item_get_active(items
[clabel
]))
6174 gtk_check_menu_item_set_active
6175 (items
[clabel
], TRUE
);
6179 g_warning("invalid number of color elements (%d)", n
);
6181 /* reset "dont_toggle" state */
6182 g_object_set_data(G_OBJECT(menu
), "dont_toggle",
6183 GINT_TO_POINTER(0));
6186 static void summary_colorlabel_menu_create(SummaryView
*summaryview
, gboolean refresh
)
6188 GtkWidget
*label_menuitem
;
6192 gchar
*accel_path
= NULL
;
6194 label_menuitem
= gtk_ui_manager_get_widget(summaryview
->mainwin
->ui_manager
, "/Menus/SummaryViewPopup/ColorLabel");
6195 g_signal_connect(G_OBJECT(label_menuitem
), "activate",
6196 G_CALLBACK(summary_colorlabel_menu_item_activate_item_cb
),
6198 gtk_widget_show(label_menuitem
);
6200 menu
= gtk_menu_new();
6202 gtk_menu_set_accel_group (GTK_MENU (menu
),
6203 gtk_ui_manager_get_accel_group(mainwindow_get_mainwindow()->ui_manager
));
6205 /* create sub items. for the menu item activation callback we pass the
6206 * index of label_colors[] as data parameter. for the None color we
6207 * pass an invalid (high) value. also we attach a data pointer so we
6208 * can always get back the SummaryView pointer. */
6210 item
= gtk_check_menu_item_new_with_label(_("None"));
6211 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6212 g_signal_connect(G_OBJECT(item
), "activate",
6213 G_CALLBACK(summary_colorlabel_menu_item_activate_cb
),
6214 GUINT_TO_POINTER(0));
6215 g_object_set_data(G_OBJECT(item
), "summaryview", summaryview
);
6216 gtk_widget_show(item
);
6218 accel_path
= g_strdup_printf("<ClawsColorLabels>/None");
6219 gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item
), accel_path
);
6221 gtk_accel_map_add_entry("<ClawsColorLabels>/None", GDK_KEY_0
, GDK_CONTROL_MASK
);
6223 item
= gtk_menu_item_new();
6224 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6225 gtk_widget_show(item
);
6227 /* create pixmap/label menu items */
6228 for (i
= 0; i
< N_COLOR_LABELS
; i
++) {
6229 item
= colorlabel_create_check_color_menu_item(
6230 i
, refresh
, SUMMARY_COLORMENU
);
6231 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6232 g_signal_connect(G_OBJECT(item
), "activate",
6233 G_CALLBACK(summary_colorlabel_menu_item_activate_cb
),
6234 GUINT_TO_POINTER(i
+ 1));
6235 g_object_set_data(G_OBJECT(item
), "summaryview",
6237 gtk_widget_show(item
);
6238 accel_path
= g_strdup_printf("<ClawsColorLabels>/%d", i
+1);
6239 gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item
), accel_path
);
6241 gtk_accel_map_add_entry(accel_path
, GDK_KEY_1
+i
, GDK_CONTROL_MASK
);
6243 g_signal_connect (gtk_ui_manager_get_accel_group(mainwindow_get_mainwindow()->ui_manager
),
6244 "accel-changed", G_CALLBACK (mainwin_accel_changed_cb
), item
);
6247 gtk_widget_show(menu
);
6248 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem
), menu
);
6249 summaryview
->colorlabel_menu
= menu
;
6252 static void summary_tags_menu_item_activate_item_cb(GtkMenuItem
*menu_item
,
6256 GList
*children
, *cur
;
6258 GHashTable
*menu_table
= g_hash_table_new_full(
6262 GHashTable
*menu_allsel_table
= g_hash_table_new_full(
6267 SummaryView
*summaryview
= (SummaryView
*)data
;
6268 cm_return_if_fail(summaryview
!= NULL
);
6270 sel
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
6273 menu
= GTK_MENU_SHELL(summaryview
->tags_menu
);
6274 cm_return_if_fail(menu
!= NULL
);
6276 /* NOTE: don't return prematurely because we set the "dont_toggle"
6277 * state for check menu items */
6278 g_object_set_data(G_OBJECT(menu
), "dont_toggle",
6279 GINT_TO_POINTER(1));
6281 /* clear items. get item pointers. */
6282 children
= gtk_container_get_children(GTK_CONTAINER(menu
));
6283 for (cur
= children
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
6284 if (GTK_IS_CHECK_MENU_ITEM(cur
->data
)) {
6285 gint id
= GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur
->data
),
6287 gtk_check_menu_item_set_active
6288 (GTK_CHECK_MENU_ITEM(cur
->data
), FALSE
);
6290 g_hash_table_insert(menu_table
, GINT_TO_POINTER(id
), GTK_CHECK_MENU_ITEM(cur
->data
));
6291 g_hash_table_insert(menu_allsel_table
, GINT_TO_POINTER(id
), GINT_TO_POINTER(0));
6295 g_list_free(children
);
6297 /* iterate all messages and set the state of the appropriate
6300 for (; sel
!= NULL
; sel
= sel
->next
) {
6302 GSList
*tags
= NULL
;
6303 GtkCheckMenuItem
*item
;
6304 msginfo
= gtk_cmctree_node_get_row_data
6305 (GTK_CMCTREE(summaryview
->ctree
),
6306 GTK_CMCTREE_NODE(sel
->data
));
6309 tags
= msginfo
->tags
;
6313 for (; tags
; tags
= tags
->next
) {
6314 gint num_checked
= GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table
, tags
->data
));
6315 item
= g_hash_table_lookup(menu_table
, GINT_TO_POINTER(tags
->data
));
6316 if (item
&& !gtk_check_menu_item_get_active(item
)) {
6317 gtk_check_menu_item_set_active
6321 g_hash_table_replace(menu_allsel_table
, tags
->data
, GINT_TO_POINTER(num_checked
));
6326 children
= gtk_container_get_children(GTK_CONTAINER(menu
));
6327 for (cur
= children
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
6328 if (GTK_IS_CHECK_MENU_ITEM(cur
->data
)) {
6329 gint id
= GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur
->data
),
6331 gint num_checked
= GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table
, GINT_TO_POINTER(id
)));
6332 if (num_checked
< sel_len
&& num_checked
> 0)
6333 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur
->data
), TRUE
);
6335 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur
->data
), FALSE
);
6338 g_list_free(children
);
6339 g_hash_table_destroy(menu_table
);
6340 g_hash_table_destroy(menu_allsel_table
);
6341 /* reset "dont_toggle" state */
6342 g_object_set_data(G_OBJECT(menu
), "dont_toggle",
6343 GINT_TO_POINTER(0));
6346 void summaryview_destroy(SummaryView
*summaryview
)
6348 if(summaryview
->simplify_subject_preg
) {
6349 regfree(summaryview
->simplify_subject_preg
);
6350 g_free(summaryview
->simplify_subject_preg
);
6351 summaryview
->simplify_subject_preg
= NULL
;
6354 static void summary_tags_menu_item_apply_tags_activate_cb(GtkWidget
*widget
,
6357 SummaryView
*summaryview
;
6359 summaryview
= g_object_get_data(G_OBJECT(widget
), "summaryview");
6360 cm_return_if_fail(summaryview
!= NULL
);
6362 /* "dont_toggle" state set? */
6363 if (g_object_get_data(G_OBJECT(summaryview
->tags_menu
),
6367 tag_apply_open(summary_get_selection(summaryview
));
6370 static gint
summary_tag_cmp_list(gconstpointer a
, gconstpointer b
)
6372 gint id_a
= GPOINTER_TO_INT(a
);
6373 gint id_b
= GPOINTER_TO_INT(b
);
6374 const gchar
*tag_a
= tags_get_tag(id_a
);
6375 const gchar
*tag_b
= tags_get_tag(id_b
);
6378 return tag_b
== NULL
? 0:1;
6383 return g_utf8_collate(tag_a
, tag_b
);
6386 static void summary_tags_menu_create(SummaryView
*summaryview
, gboolean refresh
)
6389 GtkWidget
*label_menuitem
;
6392 GSList
*cur
= tags_get_list();
6393 GSList
*orig
= NULL
;
6394 gboolean existing_tags
= FALSE
;
6395 gchar
*accel_path
= NULL
;
6397 cur
= orig
= g_slist_sort(cur
, summary_tag_cmp_list
);
6398 label_menuitem
= gtk_ui_manager_get_widget(summaryview
->mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Tags");
6399 g_signal_connect(G_OBJECT(label_menuitem
), "activate",
6400 G_CALLBACK(summary_tags_menu_item_activate_item_cb
),
6403 gtk_widget_show(label_menuitem
);
6405 menu
= gtk_menu_new();
6407 gtk_menu_set_accel_group (GTK_MENU (menu
),
6408 gtk_ui_manager_get_accel_group(summaryview
->mainwin
->ui_manager
));
6410 /* create tags menu items */
6411 for (; cur
; cur
= cur
->next
) {
6412 gint id
= GPOINTER_TO_INT(cur
->data
);
6413 const gchar
*tag
= tags_get_tag(id
);
6414 item
= gtk_check_menu_item_new_with_label(tag
);
6415 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6416 g_signal_connect(G_OBJECT(item
), "activate",
6417 G_CALLBACK(summary_tags_menu_item_activate_cb
),
6418 GINT_TO_POINTER(id
));
6419 g_object_set_data(G_OBJECT(item
), "summaryview",
6421 g_object_set_data(G_OBJECT(item
), "tag_id",
6422 GINT_TO_POINTER(id
));
6423 gtk_widget_show(item
);
6424 accel_path
= g_strconcat("<ClawsTags>/",tag
, NULL
);
6425 gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item
), accel_path
);
6427 existing_tags
= TRUE
;
6429 if (existing_tags
) {
6431 item
= gtk_menu_item_new();
6432 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6433 gtk_widget_show(item
);
6436 item
= gtk_menu_item_new_with_label(_("Apply tags..."));
6437 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6438 g_signal_connect(G_OBJECT(item
), "activate",
6439 G_CALLBACK(summary_tags_menu_item_apply_tags_activate_cb
),
6441 g_object_set_data(G_OBJECT(item
), "summaryview",
6443 gtk_widget_show(item
);
6444 accel_path
= g_strdup_printf("<ClawsTags>/ApplyTags");
6445 gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item
), accel_path
);
6449 gtk_widget_show(menu
);
6450 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem
), menu
);
6451 summaryview
->tags_menu
= menu
;
6454 static gboolean
summary_popup_menu(GtkWidget
*widget
, gpointer data
)
6456 SummaryView
*summaryview
= (SummaryView
*)data
;
6457 summaryview
->display_msg
= messageview_is_visible(summaryview
->messageview
);
6459 gtk_menu_popup(GTK_MENU(summaryview
->popupmenu
),
6460 NULL
, NULL
, NULL
, NULL
,
6461 3, gtk_get_current_event_time());
6467 static gchar
*summaryview_get_tooltip_text(SummaryView
*summaryview
, MsgInfo
*info
, gint column
)
6473 flags
= info
->flags
;
6475 switch(summaryview
->col_state
[column
].type
) {
6477 if (MSG_IS_IGNORE_THREAD(flags
)) {
6478 return _("Ignored thread");
6479 } else if (MSG_IS_WATCH_THREAD(flags
)) {
6480 return _("Watched thread");
6481 } else if (MSG_IS_SPAM(flags
)) {
6483 } else if (MSG_IS_NEW(flags
)) {
6485 } else if (MSG_IS_UNREAD(flags
)) {
6487 } else if (MSG_IS_REPLIED(flags
) && MSG_IS_FORWARDED(flags
)) {
6488 return _("Replied but also forwarded - click to see reply");
6489 } else if (MSG_IS_REPLIED(flags
)) {
6490 return _("Replied - click to see reply");
6491 } else if (MSG_IS_FORWARDED(flags
)) {
6492 return _("Forwarded");
6497 if (MSG_IS_DELETED(flags
)) {
6498 return _("Deleted");
6499 } else if (MSG_IS_MARKED(flags
)) {
6501 } else if (MSG_IS_MOVE(flags
)) {
6502 return _("To be moved");
6503 } else if (MSG_IS_COPY(flags
)) {
6504 return _("To be copied");
6509 if (MSG_IS_LOCKED(flags
)) {
6515 if (MSG_IS_WITH_ATTACHMENT(flags
) && MSG_IS_SIGNED(flags
)) {
6516 return _("Signed, has attachment(s)");
6517 } else if (MSG_IS_SIGNED(flags
)) {
6519 } else if (MSG_IS_WITH_ATTACHMENT(flags
) && MSG_IS_ENCRYPTED(flags
)) {
6520 return _("Encrypted, has attachment(s)");
6521 } else if (MSG_IS_ENCRYPTED(flags
)) {
6522 return _("Encrypted");
6523 } else if (MSG_IS_WITH_ATTACHMENT(flags
)) {
6524 return _("Has attachment(s)");
6532 static gboolean
tooltip_cb (GtkWidget
*widget
,
6535 gboolean keyboard_mode
,
6536 GtkTooltip
*tooltip
,
6539 GtkCMCTree
*ctree
= GTK_CMCTREE(widget
);
6540 SummaryView
*summaryview
= (SummaryView
*)user_data
;
6541 gint row
= -1, column
= -1;
6542 int offset
= prefs_common
.show_col_headers
? 24:0;
6543 GtkCMCTreeNode
*node
= NULL
;
6545 gchar
*formatted
= NULL
;
6546 MsgInfo
*info
= NULL
;
6548 gboolean vert_layout
= (prefs_common
.layout_mode
== VERTICAL_LAYOUT
);
6549 gboolean small_layout
= (prefs_common
.layout_mode
== SMALL_LAYOUT
);
6550 if (!prefs_common
.show_tooltips
)
6556 if (!gtk_cmclist_get_selection_info(GTK_CMCLIST(ctree
), x
, y
- offset
,
6560 if ((node
= gtk_cmctree_node_nth(ctree
, row
)) == NULL
)
6563 if ((info
= gtk_cmctree_node_get_row_data(ctree
, node
)) == NULL
)
6566 switch (gtk_cmctree_node_get_cell_type(ctree
, node
, column
)) {
6567 case GTK_CMCELL_TEXT
:
6568 if (gtk_cmctree_node_get_text(ctree
, node
, column
, &text
) != TRUE
)
6571 case GTK_CMCELL_PIXTEXT
:
6572 if (gtk_cmctree_node_get_pixtext(ctree
, node
, column
, &text
,
6573 NULL
, NULL
) != TRUE
)
6577 if ((text
= summaryview_get_tooltip_text(summaryview
, info
, column
)) == NULL
)
6581 if (!text
|| !*text
)
6584 formatted
= g_strdup(text
);
6585 g_strstrip(formatted
);
6587 if ((vert_layout
|| small_layout
) && prefs_common
.two_line_vert
)
6588 gtk_tooltip_set_markup (tooltip
, formatted
);
6590 gtk_tooltip_set_text (tooltip
, formatted
);
6597 gtk_tooltip_set_tip_area(tooltip
, &rect
);
6602 static GtkWidget
*summary_ctree_create(SummaryView
*summaryview
)
6605 gint
*col_pos
= summaryview
->col_pos
;
6606 SummaryColumnState
*col_state
;
6607 gchar
*titles
[N_SUMMARY_COLS
];
6608 SummaryColumnType type
;
6610 gboolean vert_layout
= (prefs_common
.layout_mode
== VERTICAL_LAYOUT
);
6611 gboolean small_layout
= (prefs_common
.layout_mode
== SMALL_LAYOUT
);
6612 memset(titles
, 0, sizeof(titles
));
6614 col_state
= prefs_summary_column_get_config();
6615 for (pos
= 0; pos
< N_SUMMARY_COLS
; pos
++) {
6616 summaryview
->col_state
[pos
] = col_state
[pos
];
6617 type
= col_state
[pos
].type
;
6618 col_pos
[type
] = pos
;
6619 titles
[pos
] = "dummy";
6621 col_state
= summaryview
->col_state
;
6623 ctree
= gtk_sctree_new_with_titles
6624 (N_SUMMARY_COLS
, col_pos
[S_COL_SUBJECT
], titles
);
6626 if (prefs_common
.show_col_headers
== FALSE
)
6627 gtk_cmclist_column_titles_hide(GTK_CMCLIST(ctree
));
6629 gtk_cmclist_set_selection_mode(GTK_CMCLIST(ctree
), GTK_SELECTION_MULTIPLE
);
6630 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_MARK
],
6631 GTK_JUSTIFY_CENTER
);
6632 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_STATUS
],
6633 GTK_JUSTIFY_CENTER
);
6634 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_LOCKED
],
6635 GTK_JUSTIFY_CENTER
);
6636 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_MIME
],
6637 GTK_JUSTIFY_CENTER
);
6638 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_SIZE
],
6640 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_NUMBER
],
6642 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_SCORE
],
6644 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_MARK
],
6645 prefs_common
.summary_col_size
[S_COL_MARK
]);
6646 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_STATUS
],
6647 prefs_common
.summary_col_size
[S_COL_STATUS
]);
6648 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_LOCKED
],
6649 prefs_common
.summary_col_size
[S_COL_LOCKED
]);
6650 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_MIME
],
6651 prefs_common
.summary_col_size
[S_COL_MIME
]);
6652 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_SUBJECT
],
6653 prefs_common
.summary_col_size
[S_COL_SUBJECT
]);
6654 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_FROM
],
6655 prefs_common
.summary_col_size
[S_COL_FROM
]);
6656 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_TO
],
6657 prefs_common
.summary_col_size
[S_COL_TO
]);
6658 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_DATE
],
6659 prefs_common
.summary_col_size
[S_COL_DATE
]);
6660 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_SIZE
],
6661 prefs_common
.summary_col_size
[S_COL_SIZE
]);
6662 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_NUMBER
],
6663 prefs_common
.summary_col_size
[S_COL_NUMBER
]);
6664 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_SCORE
],
6665 prefs_common
.summary_col_size
[S_COL_SCORE
]);
6666 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_TAGS
],
6667 prefs_common
.summary_col_size
[S_COL_TAGS
]);
6669 gtk_cmctree_set_expander_style(GTK_CMCTREE(ctree
),
6670 GTK_CMCTREE_EXPANDER_TRIANGLE
);
6672 gtk_sctree_set_stripes(GTK_SCTREE(ctree
), prefs_common
.use_stripes_in_summaries
);
6674 gtk_cmctree_set_indent(GTK_CMCTREE(ctree
), 12);
6675 g_object_set_data(G_OBJECT(ctree
), "summaryview", (gpointer
)summaryview
);
6677 for (pos
= 0; pos
< N_SUMMARY_COLS
; pos
++) {
6678 gtk_widget_set_can_focus(GTK_CMCLIST(ctree
)->column
[pos
].button
,
6680 if (((pos
== summaryview
->col_pos
[S_COL_FROM
] && !FOLDER_SHOWS_TO_HDR(summaryview
->folder_item
)) ||
6681 (pos
== summaryview
->col_pos
[S_COL_TO
] && FOLDER_SHOWS_TO_HDR(summaryview
->folder_item
)) ||
6682 pos
== summaryview
->col_pos
[S_COL_DATE
]) && (vert_layout
|| small_layout
) &&
6683 prefs_common
.two_line_vert
)
6684 gtk_cmclist_set_column_visibility
6685 (GTK_CMCLIST(ctree
), pos
, FALSE
);
6687 gtk_cmclist_set_column_visibility
6688 (GTK_CMCLIST(ctree
), pos
, col_state
[pos
].visible
);
6690 if (prefs_common
.two_line_vert
)
6691 gtk_sctree_set_use_markup(GTK_SCTREE(ctree
), summaryview
->col_pos
[S_COL_SUBJECT
], vert_layout
||small_layout
);
6693 /* connect signal to the buttons for sorting */
6694 #define CLIST_BUTTON_SIGNAL_CONNECT(col, func) \
6696 (G_OBJECT(GTK_CMCLIST(ctree)->column[col_pos[col]].button), \
6701 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_MARK
, summary_mark_clicked
);
6702 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_STATUS
, summary_status_clicked
);
6703 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_MIME
, summary_mime_clicked
);
6704 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_NUMBER
, summary_num_clicked
);
6705 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_SIZE
, summary_size_clicked
);
6706 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_DATE
, summary_date_clicked
);
6707 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_FROM
, summary_from_clicked
);
6708 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_TO
, summary_to_clicked
);
6709 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_SUBJECT
, summary_subject_clicked
);
6710 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_SCORE
, summary_score_clicked
);
6711 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_LOCKED
, summary_locked_clicked
);
6712 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_TAGS
, summary_tags_clicked
);
6714 #undef CLIST_BUTTON_SIGNAL_CONNECT
6716 g_signal_connect(G_OBJECT(ctree
), "tree_select_row",
6717 G_CALLBACK(summary_selected
), summaryview
);
6718 g_signal_connect(G_OBJECT(ctree
), "tree_unselect_row",
6719 G_CALLBACK(summary_unselected
), summaryview
);
6720 g_signal_connect(G_OBJECT(ctree
), "button_press_event",
6721 G_CALLBACK(summary_button_pressed
),
6723 g_signal_connect(G_OBJECT(ctree
), "popup-menu",
6724 G_CALLBACK(summary_popup_menu
), summaryview
);
6725 g_signal_connect(G_OBJECT(ctree
), "button_release_event",
6726 G_CALLBACK(summary_button_released
),
6728 g_signal_connect(G_OBJECT(ctree
), "key_press_event",
6729 G_CALLBACK(summary_key_pressed
), summaryview
);
6730 g_signal_connect(G_OBJECT(ctree
), "resize_column",
6731 G_CALLBACK(summary_col_resized
), summaryview
);
6732 g_signal_connect(G_OBJECT(ctree
), "open_row",
6733 G_CALLBACK(summary_open_row
), summaryview
);
6735 g_signal_connect_after(G_OBJECT(ctree
), "tree_expand",
6736 G_CALLBACK(summary_tree_expanded
),
6738 g_signal_connect_after(G_OBJECT(ctree
), "tree_collapse",
6739 G_CALLBACK(summary_tree_collapsed
),
6742 g_signal_connect(G_OBJECT(ctree
), "start_drag",
6743 G_CALLBACK(summary_start_drag
),
6745 g_signal_connect(G_OBJECT(ctree
), "drag_data_get",
6746 G_CALLBACK(summary_drag_data_get
),
6748 g_signal_connect(G_OBJECT(ctree
), "drag_end",
6749 G_CALLBACK(summary_drag_end
),
6752 gtk_drag_dest_set(ctree
, GTK_DEST_DEFAULT_ALL
& ~GTK_DEST_DEFAULT_HIGHLIGHT
,
6753 summary_drag_types
, 3,
6754 GDK_ACTION_MOVE
| GDK_ACTION_COPY
| GDK_ACTION_DEFAULT
);
6756 g_signal_connect(G_OBJECT(ctree
), "drag_data_received",
6757 G_CALLBACK(summary_drag_data_received
),
6760 g_signal_connect(G_OBJECT(ctree
), "drag_motion",
6761 G_CALLBACK(summary_drag_motion_cb
),
6765 g_object_set (G_OBJECT(ctree
), "has-tooltip", TRUE
, NULL
);
6766 g_signal_connect(G_OBJECT(ctree
), "query-tooltip",
6767 G_CALLBACK(tooltip_cb
),
6773 void summary_set_column_order(SummaryView
*summaryview
)
6776 GtkWidget
*scrolledwin
= summaryview
->scrolledwin
;
6778 guint selected_msgnum
= summary_get_msgnum(summaryview
, summaryview
->selected
);
6779 guint displayed_msgnum
= summary_get_msgnum(summaryview
, summaryview
->displayed
);
6781 item
= summaryview
->folder_item
;
6783 summary_clear_all(summaryview
);
6784 gtk_widget_destroy(summaryview
->ctree
);
6786 summaryview
->ctree
= ctree
= summary_ctree_create(summaryview
);
6787 summary_set_fonts(summaryview
);
6788 summary_set_column_titles(summaryview
);
6789 gtk_scrolled_window_set_hadjustment(GTK_SCROLLED_WINDOW(scrolledwin
),
6790 GTK_CMCLIST(ctree
)->hadjustment
);
6791 gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(scrolledwin
),
6792 GTK_CMCLIST(ctree
)->vadjustment
);
6793 gtk_container_add(GTK_CONTAINER(scrolledwin
), ctree
);
6794 gtk_widget_show(ctree
);
6796 summary_show(summaryview
, item
);
6798 summary_select_by_msgnum(summaryview
, selected_msgnum
, FALSE
);
6800 summaryview
->selected
= summary_find_msg_by_msgnum(summaryview
, selected_msgnum
);
6801 summaryview
->displayed
= summary_find_msg_by_msgnum(summaryview
, displayed_msgnum
);
6802 if (!summaryview
->displayed
)
6803 messageview_clear(summaryview
->messageview
);
6805 summary_redisplay_msg(summaryview
);
6807 /* get normal row height */
6808 gtk_cmclist_set_row_height(GTK_CMCLIST(ctree
), 0);
6809 normal_row_height
= GTK_CMCLIST(ctree
)->row_height
;
6811 if ((prefs_common
.layout_mode
== SMALL_LAYOUT
|| prefs_common
.layout_mode
== VERTICAL_LAYOUT
) &&
6812 prefs_common
.two_line_vert
) {
6813 gtk_cmclist_set_row_height(GTK_CMCLIST(summaryview
->ctree
), 2*normal_row_height
+ 2);
6818 /* callback functions */
6820 static gint
summary_folder_eventbox_pressed(GtkWidget
*eventbox
, GdkEventButton
*event
,
6821 SummaryView
*summaryview
)
6824 folderview_grab_focus(summaryview
->folderview
);
6825 mainwindow_exit_folder(summaryview
->mainwin
);
6830 static gint
summary_toggle_pressed(GtkWidget
*eventbox
, GdkEventButton
*event
,
6831 SummaryView
*summaryview
)
6834 summary_toggle_view(summaryview
);
6838 static void summary_toggle_multiple_pressed(GtkWidget
*widget
,
6839 SummaryView
*summaryview
)
6841 GTK_SCTREE(summaryview
->ctree
)->force_additive_sel
=
6842 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
6845 static gboolean
summary_button_pressed(GtkWidget
*ctree
, GdkEventButton
*event
,
6846 SummaryView
*summaryview
)
6848 if (!event
) return FALSE
;
6850 if (event
->button
== 3) {
6852 summary_set_menu_sensitive(summaryview
);
6853 gtk_menu_popup(GTK_MENU(summaryview
->popupmenu
), NULL
, NULL
,
6854 NULL
, NULL
, event
->button
, event
->time
);
6855 } else if (event
->button
== 2) {
6856 summaryview
->display_msg
= messageview_is_visible(summaryview
->messageview
);
6857 } else if (event
->button
== 1) {
6858 if (!prefs_common
.emulate_emacs
&&
6859 messageview_is_visible(summaryview
->messageview
))
6860 summaryview
->display_msg
= TRUE
;
6866 static gboolean
summary_button_released(GtkWidget
*ctree
, GdkEventButton
*event
,
6867 SummaryView
*summaryview
)
6872 gboolean
summary_pass_key_press_event(SummaryView
*summaryview
, GdkEventKey
*event
)
6876 if (summary_is_list(summaryview
))
6877 return summary_key_pressed(summaryview
->ctree
, event
, summaryview
);
6882 #define BREAK_ON_MODIFIER_KEY() \
6883 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
6885 /* Copied from gtkcmclist.c, if it changes there, it has to change
6886 * here as well. This is an ugly hack, there must be a better way to
6887 * find out how much to move for page up/down. */
6888 #define CELL_SPACING 1
6889 static gboolean
summary_key_pressed(GtkWidget
*widget
, GdkEventKey
*event
,
6890 SummaryView
*summaryview
)
6892 GtkCMCTree
*ctree
= GTK_CMCTREE(widget
);
6893 GtkCMCTreeNode
*node
;
6894 MessageView
*messageview
;
6896 gboolean mod_pressed
;
6901 if (quicksearch_has_focus(summaryview
->quicksearch
))
6904 messageview
= summaryview
->messageview
;
6907 ((event
->state
& (GDK_SHIFT_MASK
|GDK_MOD1_MASK
)) != 0);
6909 if (summaryview
->selected
) {
6910 gboolean handled
= FALSE
;
6911 switch (event
->keyval
) {
6912 case GDK_KEY_space
: /* Page down or go to the next */
6914 if (event
->state
& GDK_CONTROL_MASK
) {
6918 if (event
->state
& GDK_SHIFT_MASK
)
6919 mimeview_scroll_page(messageview
->mimeview
, TRUE
);
6921 if (summaryview
->displayed
!= summaryview
->selected
) {
6922 summary_display_msg(summaryview
,
6923 summaryview
->selected
);
6927 if (!mimeview_scroll_page(messageview
->mimeview
, TRUE
))
6928 summary_select_prev_unread(summaryview
);
6930 if (!mimeview_scroll_page(messageview
->mimeview
, FALSE
))
6931 summary_select_next_unread(summaryview
);
6935 case GDK_KEY_BackSpace
: /* Page up */
6937 mimeview_scroll_page(messageview
->mimeview
, TRUE
);
6939 case GDK_KEY_Return
: /* Scroll up/down one line */
6940 case GDK_KEY_KP_Enter
:
6942 if (summaryview
->displayed
!= summaryview
->selected
) {
6943 #ifndef GENERIC_UMPC
6944 summary_display_msg(summaryview
,
6945 summaryview
->selected
);
6947 summary_open_row(NULL
, summaryview
);
6951 mimeview_scroll_one_line(messageview
->mimeview
, mod_pressed
);
6958 if (summary_is_locked(summaryview
))
6961 switch (event
->keyval
) {
6962 case GDK_KEY_Left
: /* Move focus */
6963 adj
= gtk_scrolled_window_get_hadjustment
6964 (GTK_SCROLLED_WINDOW(summaryview
->scrolledwin
));
6965 if (gtk_adjustment_get_lower(adj
) != gtk_adjustment_get_value(adj
))
6968 case GDK_KEY_Escape
:
6969 folderview_grab_focus(summaryview
->folderview
);
6970 mainwindow_exit_folder(summaryview
->mainwin
);
6972 case GDK_KEY_Home
: case GDK_KEY_KP_Home
:
6973 case GDK_KEY_End
: case GDK_KEY_KP_End
:
6974 case GDK_KEY_Up
: case GDK_KEY_KP_Up
:
6975 case GDK_KEY_Down
: case GDK_KEY_KP_Down
:
6976 case GDK_KEY_Page_Up
: case GDK_KEY_KP_Page_Up
:
6977 case GDK_KEY_Page_Down
: case GDK_KEY_KP_Page_Down
:
6978 if ((node
= summaryview
->selected
) != NULL
) {
6979 GtkCMCTreeNode
*next
= NULL
;
6980 switch (event
->keyval
) {
6981 case GDK_KEY_Home
: case GDK_KEY_KP_Home
:
6982 next
= gtk_cmctree_node_nth(ctree
, 0);
6984 case GDK_KEY_End
: case GDK_KEY_KP_End
:
6985 next
= gtk_cmctree_node_nth(ctree
,
6986 g_list_length(GTK_CMCLIST(ctree
)->row_list
)-1);
6988 case GDK_KEY_Up
: case GDK_KEY_KP_Up
:
6989 next
= gtk_cmctree_node_nth(ctree
,
6990 MAX(0, GTK_CMCLIST(ctree
)->focus_row
- 1));
6992 case GDK_KEY_Down
: case GDK_KEY_KP_Down
:
6993 next
= gtk_cmctree_node_nth(ctree
,
6994 MIN(GTK_CMCLIST(ctree
)->focus_row
+ 1, GTK_CMCLIST(ctree
)->rows
- 1));
6996 case GDK_KEY_Page_Up
: case GDK_KEY_KP_Page_Up
:
6997 next
= gtk_cmctree_node_nth(ctree
,
6998 MAX(0, GTK_CMCLIST(ctree
)->focus_row
-
6999 (2 * GTK_CMCLIST(ctree
)->clist_window_height
-
7000 GTK_CMCLIST(ctree
)->row_height
- CELL_SPACING
) /
7001 (2 * (GTK_CMCLIST(ctree
)->row_height
+ CELL_SPACING
))));
7003 case GDK_KEY_Page_Down
: case GDK_KEY_KP_Page_Down
:
7004 next
= gtk_cmctree_node_nth(ctree
,
7005 MIN(GTK_CMCLIST(ctree
)->rows
- 1, GTK_CMCLIST(ctree
)->focus_row
+
7006 (2 * GTK_CMCLIST(ctree
)->clist_window_height
-
7007 GTK_CMCLIST(ctree
)->row_height
- CELL_SPACING
) /
7008 (2 * (GTK_CMCLIST(ctree
)->row_height
+ CELL_SPACING
))));
7013 next
!= gtk_cmctree_node_nth(ctree
, GTK_CMCLIST(ctree
)->focus_row
)) {
7014 gtk_sctree_select_with_state
7015 (GTK_SCTREE(ctree
), next
, (event
->state
& ~GDK_CONTROL_MASK
) );
7017 /* Deprecated - what are the non-deprecated equivalents? */
7018 if (gtk_cmctree_node_is_visible(GTK_CMCTREE(ctree
), next
) != GTK_VISIBILITY_FULL
)
7019 gtkut_ctree_node_move_if_on_the_edge(GTK_CMCTREE(ctree
), next
, -1);
7021 summary_select_node(summaryview
, summaryview
->selected
, OPEN_SELECTED_ON_DIRECTIONAL
);
7022 summaryview
->selected
= next
;
7030 if (!summaryview
->selected
) {
7031 node
= gtk_cmctree_node_nth(ctree
, 0);
7033 gtk_sctree_select(GTK_SCTREE(ctree
), node
);
7038 switch (event
->keyval
) {
7039 case GDK_KEY_Delete
:
7040 BREAK_ON_MODIFIER_KEY();
7041 summary_delete_trash(summaryview
);
7050 static void quicksearch_execute_cb(QuickSearch
*quicksearch
, gpointer data
)
7052 SummaryView
*summaryview
= data
;
7054 summaryview_reset_recursive_folder_match(summaryview
);
7055 if (summary_show(summaryview
, summaryview
->folder_item
))
7056 summaryview_quicksearch_recurse(summaryview
);
7058 summaryview_reset_recursive_folder_match(summaryview
);
7061 static void tog_searchbar_cb(GtkWidget
*w
, gpointer data
)
7063 SummaryView
*summaryview
= (SummaryView
*)data
;
7065 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w
))) {
7066 prefs_common
.show_searchbar
= TRUE
;
7067 quicksearch_show(summaryview
->quicksearch
);
7069 prefs_common
.show_searchbar
= FALSE
;
7070 quicksearch_hide(summaryview
->quicksearch
);
7074 void summaryview_activate_quicksearch(SummaryView
*summaryview
, gboolean show
)
7076 prefs_common
.show_searchbar
= show
;
7077 gtk_toggle_button_set_active(
7078 GTK_TOGGLE_BUTTON(summaryview
->toggle_search
),
7081 quicksearch_show(summaryview
->quicksearch
);
7083 quicksearch_hide(summaryview
->quicksearch
);
7084 summary_grab_focus(summaryview
);
7088 void summary_open_row(GtkSCTree
*sctree
, SummaryView
*summaryview
)
7090 if (FOLDER_SHOWS_TO_HDR(summaryview
->folder_item
))
7091 summary_reedit(summaryview
);
7093 summary_open_msg(summaryview
);
7095 summaryview
->display_msg
= FALSE
;
7098 static void summary_tree_expanded(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
7099 SummaryView
*summaryview
)
7101 summary_set_row_marks(summaryview
, node
);
7102 if (prefs_common
.bold_unread
) {
7104 GtkCMCTreeNode
*next
= GTK_CMCTREE_NODE_NEXT(node
);
7105 if (GTK_CMCTREE_ROW(node
)->children
)
7106 summary_set_row_marks(summaryview
, node
);
7112 static void summary_tree_collapsed(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
7113 SummaryView
*summaryview
)
7115 gtk_sctree_select(GTK_SCTREE(ctree
), node
);
7116 summary_set_row_marks(summaryview
, node
);
7119 static void summary_unselected(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
,
7120 gint column
, SummaryView
*summaryview
)
7122 if (summary_is_locked(summaryview
)
7123 || GTK_SCTREE(ctree
)->selecting_range
) {
7127 summary_status_show(summaryview
);
7130 static void summary_selected(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
,
7131 gint column
, SummaryView
*summaryview
)
7133 const GList
*list
, *cur
;
7134 MessageView
*msgview
;
7136 gboolean marked_unread
= FALSE
;
7138 if (summary_is_locked(summaryview
)
7139 && !GTK_SCTREE(ctree
)->selecting_range
7140 && summaryview
->messageview
7141 && summaryview
->messageview
->mimeview
7142 && summaryview
->messageview
->mimeview
->type
== MIMEVIEW_TEXT
7143 && summaryview
->messageview
->mimeview
->textview
->loading
) {
7144 PostponedSelectData
*data
= g_new0(PostponedSelectData
, 1);
7145 summaryview
->messageview
->mimeview
->textview
->stop_loading
= TRUE
;
7147 data
->ctree
= ctree
;
7150 data
->column
= column
;
7151 data
->summaryview
= summaryview
;
7152 debug_print("postponing open of message till end of load\n");
7153 g_timeout_add(100, summary_select_retry
, data
);
7156 if (summary_is_locked(summaryview
)
7157 || GTK_SCTREE(ctree
)->selecting_range
) {
7161 summary_status_show(summaryview
);
7163 if (GTK_CMCLIST(ctree
)->selection
&&
7164 GTK_CMCLIST(ctree
)->selection
->next
) {
7165 summaryview
->display_msg
= FALSE
;
7166 summary_set_menu_sensitive(summaryview
);
7167 toolbar_main_set_sensitive(summaryview
->mainwin
);
7171 summaryview
->selected
= row
;
7173 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
7174 cm_return_if_fail(msginfo
!= NULL
);
7176 main_create_mailing_list_menu (summaryview
->mainwin
, msginfo
);
7177 toolbar_set_learn_button
7178 (summaryview
->mainwin
->toolbar
,
7179 MSG_IS_SPAM(msginfo
->flags
)?LEARN_HAM
:LEARN_SPAM
);
7181 switch (column
< 0 ? column
: summaryview
->col_state
[column
].type
) {
7183 if (!MSG_IS_DELETED(msginfo
->flags
) &&
7184 !MSG_IS_MOVE(msginfo
->flags
) &&
7185 !MSG_IS_COPY(msginfo
->flags
)) {
7186 if (MSG_IS_MARKED(msginfo
->flags
)) {
7187 summary_unmark_row(summaryview
, row
);
7188 summary_status_show(summaryview
);
7190 summary_mark_row(summaryview
, row
);
7191 summary_status_show(summaryview
);
7196 if (MSG_IS_UNREAD(msginfo
->flags
)) {
7197 summary_mark_row_as_read(summaryview
, row
);
7198 summary_status_show(summaryview
);
7199 } else if (MSG_IS_SPAM(msginfo
->flags
)) {
7200 if (procmsg_spam_learner_learn(msginfo
, NULL
, FALSE
) == 0)
7201 summary_msginfo_unset_flags(msginfo
, MSG_SPAM
, 0);
7203 log_error(LOG_PROTOCOL
, _("An error happened while learning.\n"));
7204 } else if (!MSG_IS_REPLIED(msginfo
->flags
) &&
7205 !MSG_IS_FORWARDED(msginfo
->flags
)) {
7206 marked_unread
= TRUE
;
7207 } else if (MSG_IS_REPLIED(msginfo
->flags
)) {
7208 summary_find_answers(summaryview
, msginfo
);
7213 if (MSG_IS_LOCKED(msginfo
->flags
)) {
7214 summary_unlock_row(summaryview
, row
);
7215 summary_status_show(summaryview
);
7218 summary_lock_row(summaryview
, row
);
7219 summary_status_show(summaryview
);
7226 list
= messageview_get_msgview_list();
7227 for (cur
= list
; cur
!= NULL
; cur
= cur
->next
) {
7228 msgview
= (MessageView
*) cur
->data
;
7230 if (msgview
->new_window
&& msgview
->update_needed
) {
7231 MsgInfo
*new_msginfo
= summary_get_selected_msg(summaryview
);
7232 messageview_show(msgview
, new_msginfo
, msgview
->all_headers
);
7233 msgview
->update_needed
= FALSE
;
7237 if (summaryview
->display_msg
) {
7238 summaryview
->display_msg
= FALSE
;
7239 if (summaryview
->displayed
!= row
) {
7240 summary_display_msg(summaryview
, row
);
7241 if (marked_unread
) {
7242 summary_mark_row_as_unread(summaryview
, row
);
7243 summary_status_show(summaryview
);
7249 if (marked_unread
) {
7250 summary_mark_row_as_unread(summaryview
, row
);
7251 summary_status_show(summaryview
);
7254 summary_set_menu_sensitive(summaryview
);
7255 toolbar_main_set_sensitive(summaryview
->mainwin
);
7258 static void summary_col_resized(GtkCMCList
*clist
, gint column
, gint width
,
7259 SummaryView
*summaryview
)
7261 SummaryColumnType type
= summaryview
->col_state
[column
].type
;
7263 prefs_common
.summary_col_size
[type
] = width
;
7268 * \brief get List of msginfo selected in SummaryView
7270 * \param summaryview
7272 * \return GSList holding MsgInfo
7274 GSList
*summary_get_selection(SummaryView
*summaryview
)
7277 GSList
*msginfo_list
= NULL
;
7279 cm_return_val_if_fail(summaryview
!= NULL
, NULL
);
7281 sel
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
7283 cm_return_val_if_fail(sel
!= NULL
, NULL
);
7285 for ( ; sel
!= NULL
; sel
= sel
->next
)
7287 g_slist_prepend(msginfo_list
,
7288 gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview
->ctree
),
7289 GTK_CMCTREE_NODE(sel
->data
)));
7290 return g_slist_reverse(msginfo_list
);
7294 * \brief get number of messages currently selected in SummaryView
7296 * \param summaryview
7298 * \return number of messages currently selected
7300 guint
summary_get_selection_count(SummaryView
*summaryview
)
7302 cm_return_val_if_fail(summaryview
!= NULL
, 0);
7303 return g_list_length(GTK_CMCLIST(summaryview
->ctree
)->selection
);
7306 static void summary_sort_by_column_click(SummaryView
*summaryview
,
7307 FolderSortKey sort_key
)
7309 GtkCMCTreeNode
*node
= NULL
;
7311 if (summaryview
->sort_key
== sort_key
)
7312 summary_sort(summaryview
, sort_key
,
7313 summaryview
->sort_type
== SORT_ASCENDING
7314 ? SORT_DESCENDING
: SORT_ASCENDING
);
7316 summary_sort(summaryview
, sort_key
, summaryview
->sort_type
);
7318 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(summaryview
->ctree
)->row_list
);
7320 summary_freeze(summaryview
);
7321 if (prefs_common
.bold_unread
) {
7323 GtkCMCTreeNode
*next
= GTK_CMCTREE_NODE_NEXT(node
);
7324 if (GTK_CMCTREE_ROW(node
)->children
)
7325 summary_set_row_marks(summaryview
, node
);
7329 summary_thaw(summaryview
);
7333 static void summary_mark_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7335 summary_sort_by_column_click(summaryview
, SORT_BY_MARK
);
7338 static void summary_status_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7340 summary_sort_by_column_click(summaryview
, SORT_BY_STATUS
);
7343 static void summary_mime_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7345 summary_sort_by_column_click(summaryview
, SORT_BY_MIME
);
7348 static void summary_num_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7350 summary_sort_by_column_click(summaryview
, SORT_BY_NUMBER
);
7353 static void summary_size_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7355 summary_sort_by_column_click(summaryview
, SORT_BY_SIZE
);
7358 static void summary_date_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7360 if (summaryview
->sort_key
== SORT_BY_THREAD_DATE
)
7361 summary_sort_by_column_click(summaryview
, SORT_BY_THREAD_DATE
);
7363 summary_sort_by_column_click(summaryview
, SORT_BY_DATE
);
7366 static void summary_from_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7368 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_FROM
]].visible
)
7369 summary_sort_by_column_click(summaryview
, SORT_BY_FROM
);
7371 summary_sort_by_column_click(summaryview
, SORT_BY_TO
);
7374 static void summary_to_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7376 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_TO
]].visible
)
7377 summary_sort_by_column_click(summaryview
, SORT_BY_TO
);
7379 summary_sort_by_column_click(summaryview
, SORT_BY_FROM
);
7382 static void summary_subject_clicked(GtkWidget
*button
,
7383 SummaryView
*summaryview
)
7385 summary_sort_by_column_click(summaryview
, SORT_BY_SUBJECT
);
7388 static void summary_score_clicked(GtkWidget
*button
,
7389 SummaryView
*summaryview
)
7391 summary_sort_by_column_click(summaryview
, SORT_BY_SCORE
);
7394 static void summary_locked_clicked(GtkWidget
*button
,
7395 SummaryView
*summaryview
)
7397 summary_sort_by_column_click(summaryview
, SORT_BY_LOCKED
);
7400 static void summary_tags_clicked(GtkWidget
*button
,
7401 SummaryView
*summaryview
)
7403 summary_sort_by_column_click(summaryview
, SORT_BY_TAGS
);
7406 static void summary_start_drag(GtkWidget
*widget
, gint button
, GdkEvent
*event
,
7407 SummaryView
*summaryview
)
7409 GdkDragContext
*context
;
7411 cm_return_if_fail(summaryview
!= NULL
);
7412 cm_return_if_fail(summaryview
->folder_item
!= NULL
);
7413 cm_return_if_fail(summaryview
->folder_item
->folder
!= NULL
);
7415 if (summaryview
->selected
== NULL
) return;
7417 context
= gtk_drag_begin(widget
, summaryview
->target_list
,
7418 GDK_ACTION_MOVE
|GDK_ACTION_COPY
|GDK_ACTION_DEFAULT
, button
, event
);
7419 gtk_drag_set_icon_default(context
);
7420 if (prefs_common
.layout_mode
== SMALL_LAYOUT
) {
7421 GtkWidget
*paned
= gtk_widget_get_parent(GTK_WIDGET_PTR(summaryview
));
7422 if (paned
&& GTK_IS_PANED(paned
)) {
7423 mainwindow_reset_paned(GTK_PANED(paned
));
7428 static gboolean
summary_return_to_list(void *data
)
7430 SummaryView
*summaryview
= (SummaryView
*)data
;
7431 mainwindow_enter_folder(summaryview
->mainwin
);
7435 static void summary_drag_end (GtkWidget
*widget
,
7436 GdkDragContext
*drag_context
,
7437 SummaryView
*summaryview
)
7439 if (prefs_common
.layout_mode
== SMALL_LAYOUT
) {
7440 g_timeout_add(250, summary_return_to_list
, summaryview
);
7444 static void summary_drag_data_get(GtkWidget
*widget
,
7445 GdkDragContext
*drag_context
,
7446 GtkSelectionData
*selection_data
,
7449 SummaryView
*summaryview
)
7451 if (info
== TARGET_MAIL_URI_LIST
) {
7452 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
7455 gchar
*mail_list
= NULL
, *tmp1
, *tmp2
;
7457 for (cur
= GTK_CMCLIST(ctree
)->selection
;
7458 cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
7459 msginfo
= gtk_cmctree_node_get_row_data
7460 (ctree
, GTK_CMCTREE_NODE(cur
->data
));
7461 tmp2
= procmsg_get_message_file(msginfo
);
7462 if (!tmp2
) continue;
7463 if (msginfo
->subject
) {
7464 gchar
*san_subject
= g_strdup(msginfo
->subject
);
7466 subst_for_filename(san_subject
);
7467 dest
= g_strdup_printf("%s%s%s.%d.txt",
7470 san_subject
, msginfo
->msgnum
);
7471 g_free(san_subject
);
7472 san_subject
= g_filename_from_utf8(dest
, -1, NULL
, NULL
, NULL
);
7475 if (copy_file(tmp2
, dest
, TRUE
) == 0) {
7480 tmp1
= g_filename_to_uri(tmp2
, NULL
, NULL
);
7482 tmp2
= g_strconcat(tmp1
, "\r\n", NULL
);
7489 tmp2
= g_strconcat(mail_list
, tmp1
, NULL
);
7496 if (mail_list
!= NULL
) {
7497 gtk_selection_data_set(selection_data
,
7498 gtk_selection_data_get_target(selection_data
), 8,
7499 mail_list
, strlen(mail_list
));
7502 } else if (info
== TARGET_DUMMY
) {
7503 if (GTK_CMCLIST(summaryview
->ctree
)->selection
)
7504 gtk_selection_data_set(selection_data
,
7505 gtk_selection_data_get_target(selection_data
), 8,
7506 "Dummy-Summaryview",
7507 strlen("Dummy-Summaryview")+1);
7508 } else if (info
== TARGET_MAIL_CM_PATH_LIST
) {
7509 /* content: folder_item_identifier\nmsgid1\nmsgid2\nmsgid3 */
7511 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
7514 gchar
*path_list
= NULL
;
7517 if(GTK_CMCLIST(ctree
)->selection
!= NULL
) {
7518 msginfo
= gtk_cmctree_node_get_row_data(ctree
, GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->selection
->data
));
7519 if(msginfo
&& msginfo
->folder
)
7520 path_list
= folder_item_get_identifier(msginfo
->folder
);
7523 for (cur
= GTK_CMCLIST(ctree
)->selection
;
7524 cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
7527 msginfo
= gtk_cmctree_node_get_row_data(ctree
, GTK_CMCTREE_NODE(cur
->data
));
7531 path_list
= g_strconcat(path_list
, "\n", (msginfo
->msgid
? msginfo
->msgid
: "unknown"), NULL
);
7535 if (path_list
!= NULL
) {
7536 gtk_selection_data_set(selection_data
,
7537 gtk_selection_data_get_target(selection_data
), 8,
7538 path_list
, strlen(path_list
));
7544 static gboolean
summary_drag_motion_cb(GtkWidget
*widget
,
7545 GdkDragContext
*context
,
7549 SummaryView
*summaryview
)
7551 FolderItem
*item
= summaryview
->folder_item
;
7552 if (!(item
&& item
->folder
&& folder_item_parent(item
) != NULL
7553 && FOLDER_CLASS(item
->folder
)->add_msg
!= NULL
)) {
7554 gdk_drag_status(context
, 0, time
);
7556 } else if (gtk_drag_get_source_widget(context
) ==
7557 mainwindow_get_mainwindow()->folderview
->ctree
) {
7559 gdk_drag_status(context
, 0, time
);
7561 } else if (gtk_drag_get_source_widget(context
) ==
7562 summaryview
->ctree
) {
7563 /* not from same folder */
7564 gdk_drag_status(context
, 0, time
);
7567 gdk_drag_status(context
, GDK_ACTION_COPY
, time
);
7572 static void summary_drag_data_received(GtkWidget
*widget
,
7573 GdkDragContext
*drag_context
,
7576 GtkSelectionData
*data
,
7579 SummaryView
*summaryview
)
7581 if (info
== TARGET_MAIL_URI_LIST
) {
7582 FolderItem
*item
= summaryview
->folder_item
;
7584 gtk_drag_finish(drag_context
, FALSE
, FALSE
, time
);
7587 folderview_finish_dnd(gtk_selection_data_get_data(data
),
7588 drag_context
, time
, item
);
7594 /* custom compare functions for sorting */
7596 static gint
summary_cmp_by_date(GtkCMCList
*clist
,
7597 gconstpointer ptr1
, gconstpointer ptr2
)
7599 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7600 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7602 if (!msginfo1
|| !msginfo2
)
7605 res
= (msginfo1
->date_t
- msginfo2
->date_t
);
7607 res
= msginfo1
->msgnum
- msginfo2
->msgnum
;
7611 #define CMP_FUNC_DEF(func_name, val) \
7612 static gint func_name(GtkCMCList *clist, \
7613 gconstpointer ptr1, gconstpointer ptr2) \
7615 MsgInfo *msginfo1 = ((GtkCMCListRow *)ptr1)->data; \
7616 MsgInfo *msginfo2 = ((GtkCMCListRow *)ptr2)->data; \
7618 if (!msginfo1 || !msginfo2) \
7622 return (res != 0) ? res:summary_cmp_by_date(clist, ptr1, ptr2); \
7625 CMP_FUNC_DEF(summary_cmp_by_mark
,
7626 MSG_IS_MARKED(msginfo1
->flags
) - MSG_IS_MARKED(msginfo2
->flags
))
7627 CMP_FUNC_DEF(summary_cmp_by_status
,
7628 (-(MSG_IS_SPAM(msginfo1
->flags
))+(MSG_IS_UNREAD(msginfo1
->flags
)<<1)+(MSG_IS_NEW(msginfo1
->flags
)<<2))
7629 - (-(MSG_IS_SPAM(msginfo2
->flags
))+(MSG_IS_UNREAD(msginfo2
->flags
)<<1)+(MSG_IS_NEW(msginfo2
->flags
)<<2)) )
7630 CMP_FUNC_DEF(summary_cmp_by_mime
,
7631 MSG_IS_WITH_ATTACHMENT(msginfo1
->flags
) - MSG_IS_WITH_ATTACHMENT(msginfo2
->flags
))
7632 CMP_FUNC_DEF(summary_cmp_by_label
,
7633 MSG_GET_COLORLABEL(msginfo1
->flags
) -
7634 MSG_GET_COLORLABEL(msginfo2
->flags
))
7635 CMP_FUNC_DEF(summary_cmp_by_locked
,
7636 MSG_IS_LOCKED(msginfo1
->flags
) - MSG_IS_LOCKED(msginfo2
->flags
))
7638 CMP_FUNC_DEF(summary_cmp_by_num
, msginfo1
->msgnum
- msginfo2
->msgnum
)
7639 CMP_FUNC_DEF(summary_cmp_by_size
, msginfo1
->size
- msginfo2
->size
)
7643 static gint
summary_cmp_by_subject(GtkCMCList
*clist
,
7647 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7648 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7651 if (!msginfo1
->subject
)
7652 return (msginfo2
->subject
!= NULL
);
7653 if (!msginfo2
->subject
)
7656 res
= subject_compare_for_sort
7657 (msginfo1
->subject
, msginfo2
->subject
);
7658 return (res
!= 0)? res
: summary_cmp_by_date(clist
, ptr1
, ptr2
);
7661 static gint
summary_cmp_by_thread_date(GtkCMCList
*clist
,
7665 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7666 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7667 gint thread_diff
= msginfo1
->thread_date
- msginfo2
->thread_date
;
7669 if (msginfo1
->thread_date
> 0 && msginfo2
->thread_date
> 0)
7672 return msginfo1
->date_t
- msginfo2
->date_t
;
7675 static gint
summary_cmp_by_from(GtkCMCList
*clist
, gconstpointer ptr1
,
7678 const gchar
*str1
, *str2
;
7679 const GtkCMCListRow
*r1
= (const GtkCMCListRow
*) ptr1
;
7680 const GtkCMCListRow
*r2
= (const GtkCMCListRow
*) ptr2
;
7681 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7682 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7683 const SummaryView
*sv
= g_object_get_data(G_OBJECT(clist
), "summaryview");
7686 cm_return_val_if_fail(sv
, -1);
7687 if (sv
->col_state
[sv
->col_pos
[S_COL_FROM
]].visible
) {
7688 str1
= GTK_CMCELL_TEXT(r1
->cell
[sv
->col_pos
[S_COL_FROM
]])->text
;
7689 str2
= GTK_CMCELL_TEXT(r2
->cell
[sv
->col_pos
[S_COL_FROM
]])->text
;
7691 str1
= msginfo1
->from
;
7692 str2
= msginfo2
->from
;
7696 return str2
!= NULL
;
7701 res
= g_utf8_collate(str1
, str2
);
7702 return (res
!= 0)? res
: summary_cmp_by_date(clist
, ptr1
, ptr2
);
7705 static gint
summary_cmp_by_to(GtkCMCList
*clist
, gconstpointer ptr1
,
7708 const gchar
*str1
, *str2
;
7709 const GtkCMCListRow
*r1
= (const GtkCMCListRow
*) ptr1
;
7710 const GtkCMCListRow
*r2
= (const GtkCMCListRow
*) ptr2
;
7711 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7712 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7713 const SummaryView
*sv
= g_object_get_data(G_OBJECT(clist
), "summaryview");
7715 cm_return_val_if_fail(sv
, -1);
7717 if (sv
->col_state
[sv
->col_pos
[S_COL_TO
]].visible
) {
7718 str1
= GTK_CMCELL_TEXT(r1
->cell
[sv
->col_pos
[S_COL_TO
]])->text
;
7719 str2
= GTK_CMCELL_TEXT(r2
->cell
[sv
->col_pos
[S_COL_TO
]])->text
;
7721 str1
= msginfo1
->to
;
7722 str2
= msginfo2
->to
;
7726 return str2
!= NULL
;
7731 res
= g_utf8_collate(str1
, str2
);
7732 return (res
!= 0)? res
: summary_cmp_by_date(clist
, ptr1
, ptr2
);
7735 static gint
summary_cmp_by_tags(GtkCMCList
*clist
, gconstpointer ptr1
,
7739 const GtkCMCListRow
*r1
= (const GtkCMCListRow
*) ptr1
;
7740 const GtkCMCListRow
*r2
= (const GtkCMCListRow
*) ptr2
;
7741 const SummaryView
*sv
= g_object_get_data(G_OBJECT(clist
), "summaryview");
7742 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7743 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7745 cm_return_val_if_fail(sv
, -1);
7747 if (sv
->col_state
[sv
->col_pos
[S_COL_TAGS
]].visible
) {
7748 str1
= g_strdup(GTK_CMCELL_TEXT(r1
->cell
[sv
->col_pos
[S_COL_TAGS
]])->text
);
7749 str2
= g_strdup(GTK_CMCELL_TEXT(r2
->cell
[sv
->col_pos
[S_COL_TAGS
]])->text
);
7751 str1
= procmsg_msginfo_get_tags_str(msginfo1
);
7752 str2
= procmsg_msginfo_get_tags_str(msginfo2
);
7756 res
= (str2
!= NULL
);
7765 res
= g_utf8_collate(str1
, str2
);
7768 return (res
!= 0)? res
: summary_cmp_by_date(clist
, ptr1
, ptr2
);
7771 static gint summary_cmp_by_simplified_subject
7772 (GtkCMCList
*clist
, gconstpointer ptr1
, gconstpointer ptr2
)
7774 const FolderItemPrefs
*prefs
;
7775 const gchar
*str1
, *str2
;
7776 const GtkCMCListRow
*r1
= (const GtkCMCListRow
*) ptr1
;
7777 const GtkCMCListRow
*r2
= (const GtkCMCListRow
*) ptr2
;
7778 const MsgInfo
*msginfo1
= r1
->data
;
7779 const MsgInfo
*msginfo2
= r2
->data
;
7780 const SummaryView
*sv
= g_object_get_data(G_OBJECT(clist
), "summaryview");
7783 cm_return_val_if_fail(sv
, -1);
7784 cm_return_val_if_fail(msginfo1
!= NULL
&& msginfo2
!= NULL
, -1);
7786 if (sv
->col_state
[sv
->col_pos
[S_COL_SUBJECT
]].visible
) {
7787 str1
= GTK_CMCELL_TEXT(r1
->cell
[sv
->col_pos
[S_COL_SUBJECT
]])->text
;
7788 str2
= GTK_CMCELL_TEXT(r2
->cell
[sv
->col_pos
[S_COL_SUBJECT
]])->text
;
7790 str1
= msginfo1
->subject
;
7791 str2
= msginfo2
->subject
;
7795 return str2
!= NULL
;
7800 prefs
= msginfo1
->folder
->prefs
;
7802 prefs
= msginfo2
->folder
->prefs
;
7806 res
= subject_compare_for_sort(str1
, str2
);
7807 return (res
!= 0)? res
: summary_cmp_by_date(clist
, ptr1
, ptr2
);
7810 static gint
summary_cmp_by_score(GtkCMCList
*clist
,
7811 gconstpointer ptr1
, gconstpointer ptr2
)
7813 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7814 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7817 /* if score are equal, sort by date */
7819 diff
= msginfo1
->score
- msginfo2
->score
;
7823 return summary_cmp_by_date(clist
, ptr1
, ptr2
);
7826 static void summary_ignore_thread_func_mark_unread(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
7830 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
7831 cm_return_if_fail(msginfo
);
7833 summary_msginfo_unset_flags(msginfo
, MSG_WATCH_THREAD
, 0);
7834 summary_msginfo_change_flags(msginfo
, MSG_IGNORE_THREAD
, 0, MSG_NEW
| MSG_UNREAD
, 0);
7836 debug_print("Message %d is marked as ignore thread\n", msginfo
->msgnum
);
7839 static void summary_ignore_thread_func_set_row(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
7841 SummaryView
*summaryview
= (SummaryView
*) data
;
7844 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
7845 cm_return_if_fail(msginfo
);
7847 summary_set_row_marks(summaryview
, row
);
7848 debug_print("Message %d update in row view\n", msginfo
->msgnum
);
7851 void summary_ignore_thread(SummaryView
*summaryview
)
7853 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
7855 gboolean froze
= FALSE
;
7857 START_LONG_OPERATION(summaryview
, FALSE
);
7858 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
7859 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
7860 GTK_CMCTREE_FUNC(summary_ignore_thread_func_mark_unread
),
7863 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
7864 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
7865 GTK_CMCTREE_FUNC(summary_ignore_thread_func_set_row
),
7868 END_LONG_OPERATION(summaryview
);
7870 summary_status_show(summaryview
);
7873 static void summary_unignore_thread_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
7875 SummaryView
*summaryview
= (SummaryView
*) data
;
7878 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
7879 cm_return_if_fail(msginfo
);
7881 summary_msginfo_unset_flags(msginfo
, MSG_IGNORE_THREAD
, 0);
7883 summary_set_row_marks(summaryview
, row
);
7884 debug_print("Message %d is marked as unignore thread\n",
7888 void summary_unignore_thread(SummaryView
*summaryview
)
7890 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
7892 gboolean froze
= FALSE
;
7894 START_LONG_OPERATION(summaryview
, FALSE
);
7895 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
7896 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
7897 GTK_CMCTREE_FUNC(summary_unignore_thread_func
),
7900 END_LONG_OPERATION(summaryview
);
7902 summary_status_show(summaryview
);
7905 static void summary_check_ignore_thread_func
7906 (GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
7909 gint
*found_ignore
= (gint
*) data
;
7911 if (*found_ignore
) return;
7913 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
7914 *found_ignore
= msginfo
&& MSG_IS_IGNORE_THREAD(msginfo
->flags
);
7918 void summary_toggle_ignore_thread(SummaryView
*summaryview
)
7920 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
7922 gint found_ignore
= 0;
7924 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
7925 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
7926 GTK_CMCTREE_FUNC(summary_check_ignore_thread_func
),
7930 summary_unignore_thread(summaryview
);
7932 summary_ignore_thread(summaryview
);
7935 static void summary_watch_thread_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
7937 SummaryView
*summaryview
= (SummaryView
*) data
;
7940 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
7941 cm_return_if_fail(msginfo
);
7943 summary_msginfo_change_flags(msginfo
, MSG_WATCH_THREAD
, 0, MSG_IGNORE_THREAD
, 0);
7945 summary_set_row_marks(summaryview
, row
);
7946 debug_print("Message %d is marked as watch thread\n",
7950 void summary_watch_thread(SummaryView
*summaryview
)
7952 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
7954 gboolean froze
= FALSE
;
7956 START_LONG_OPERATION(summaryview
, FALSE
);
7957 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
7958 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
7959 GTK_CMCTREE_FUNC(summary_watch_thread_func
),
7962 END_LONG_OPERATION(summaryview
);
7964 summary_status_show(summaryview
);
7967 static void summary_unwatch_thread_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
7969 SummaryView
*summaryview
= (SummaryView
*) data
;
7972 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
7973 cm_return_if_fail(msginfo
);
7975 summary_msginfo_unset_flags(msginfo
, MSG_WATCH_THREAD
, 0);
7977 summary_set_row_marks(summaryview
, row
);
7978 debug_print("Message %d is marked as unwatch thread\n",
7982 void summary_unwatch_thread(SummaryView
*summaryview
)
7984 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
7986 gboolean froze
= FALSE
;
7988 START_LONG_OPERATION(summaryview
, FALSE
);
7989 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
7990 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
7991 GTK_CMCTREE_FUNC(summary_unwatch_thread_func
),
7994 END_LONG_OPERATION(summaryview
);
7996 summary_status_show(summaryview
);
7999 static void summary_check_watch_thread_func
8000 (GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
8003 gint
*found_watch
= (gint
*) data
;
8005 if (*found_watch
) return;
8007 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
8008 *found_watch
= msginfo
&& MSG_IS_WATCH_THREAD(msginfo
->flags
);
8012 void summary_toggle_watch_thread(SummaryView
*summaryview
)
8014 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
8016 gint found_watch
= 0;
8018 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
8019 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
8020 GTK_CMCTREE_FUNC(summary_check_watch_thread_func
),
8024 summary_unwatch_thread(summaryview
);
8026 summary_watch_thread(summaryview
);
8030 void summary_toggle_show_read_messages(SummaryView
*summaryview
)
8032 FolderItemUpdateData source
;
8033 if (summaryview
->folder_item
->hide_read_msgs
)
8034 summaryview
->folder_item
->hide_read_msgs
= 0;
8036 summaryview
->folder_item
->hide_read_msgs
= 1;
8038 source
.item
= summaryview
->folder_item
;
8039 source
.update_flags
= F_ITEM_UPDATE_NAME
;
8041 hooks_invoke(FOLDER_ITEM_UPDATE_HOOKLIST
, &source
);
8042 summary_show(summaryview
, summaryview
->folder_item
);
8045 void summary_toggle_show_del_messages(SummaryView
*summaryview
)
8047 FolderItemUpdateData source
;
8048 if (summaryview
->folder_item
->hide_del_msgs
)
8049 summaryview
->folder_item
->hide_del_msgs
= 0;
8051 summaryview
->folder_item
->hide_del_msgs
= 1;
8053 source
.item
= summaryview
->folder_item
;
8054 source
.update_flags
= F_ITEM_UPDATE_NAME
;
8056 hooks_invoke(FOLDER_ITEM_UPDATE_HOOKLIST
, &source
);
8057 summary_show(summaryview
, summaryview
->folder_item
);
8060 void summary_toggle_show_read_threads(SummaryView
*summaryview
)
8062 FolderItemUpdateData source
;
8063 if (summaryview
->folder_item
->hide_read_threads
)
8064 summaryview
->folder_item
->hide_read_threads
= 0;
8066 summaryview
->folder_item
->hide_read_threads
= 1;
8068 source
.item
= summaryview
->folder_item
;
8069 source
.update_flags
= F_ITEM_UPDATE_NAME
;
8071 hooks_invoke(FOLDER_ITEM_UPDATE_HOOKLIST
, &source
);
8072 summary_show(summaryview
, summaryview
->folder_item
);
8075 static void summary_set_hide_menu (SummaryView
*summaryview
,
8076 const gchar
*menu_item
,
8081 widget
= gtk_ui_manager_get_widget(summaryview
->mainwin
->ui_manager
, menu_item
);
8082 cm_return_if_fail(widget
!= NULL
);
8084 g_object_set_data(G_OBJECT(widget
), "dont_toggle",
8085 GINT_TO_POINTER(1));
8086 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(widget
), action
);
8087 g_object_set_data(G_OBJECT(widget
), "dont_toggle",
8088 GINT_TO_POINTER(0));
8091 void summary_reflect_prefs_pixmap_theme(SummaryView
*summaryview
)
8095 stock_pixbuf_gdk(STOCK_PIXMAP_MARK
, &markxpm
);
8096 stock_pixbuf_gdk(STOCK_PIXMAP_DELETED
, &deletedxpm
);
8097 stock_pixbuf_gdk(STOCK_PIXMAP_NEW
, &newxpm
);
8098 stock_pixbuf_gdk(STOCK_PIXMAP_UNREAD
, &unreadxpm
);
8099 stock_pixbuf_gdk(STOCK_PIXMAP_REPLIED
, &repliedxpm
);
8100 stock_pixbuf_gdk(STOCK_PIXMAP_FORWARDED
, &forwardedxpm
);
8101 stock_pixbuf_gdk(STOCK_PIXMAP_REPLIED_AND_FORWARDED
, &repliedandforwardedxpm
);
8102 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP
, &clipxpm
);
8103 stock_pixbuf_gdk(STOCK_PIXMAP_LOCKED
, &lockedxpm
);
8104 stock_pixbuf_gdk(STOCK_PIXMAP_IGNORETHREAD
, &ignorethreadxpm
);
8105 stock_pixbuf_gdk(STOCK_PIXMAP_WATCHTHREAD
, &watchthreadxpm
);
8106 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP_KEY
, &clipkeyxpm
);
8107 stock_pixbuf_gdk(STOCK_PIXMAP_KEY
, &keyxpm
);
8108 stock_pixbuf_gdk(STOCK_PIXMAP_KEY_SIGN
, &keysignxpm
);
8109 stock_pixbuf_gdk(STOCK_PIXMAP_GPG_SIGNED
, &gpgsignedxpm
);
8110 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP_GPG_SIGNED
, &clipgpgsignedxpm
);
8111 stock_pixbuf_gdk(STOCK_PIXMAP_SPAM
, &spamxpm
);
8112 stock_pixbuf_gdk(STOCK_PIXMAP_MOVED
, &movedxpm
);
8113 stock_pixbuf_gdk(STOCK_PIXMAP_COPIED
, &copiedxpm
);
8115 summary_set_folder_pixmap(summaryview
, STOCK_PIXMAP_DIR_OPEN
);
8117 pixmap
= stock_pixmap_widget(STOCK_PIXMAP_QUICKSEARCH
);
8118 gtk_container_remove (GTK_CONTAINER(summaryview
->toggle_search
),
8119 summaryview
->quick_search_pixmap
);
8120 gtk_container_add(GTK_CONTAINER(summaryview
->toggle_search
), pixmap
);
8121 gtk_widget_show(pixmap
);
8122 summaryview
->quick_search_pixmap
= pixmap
;
8125 pixmap
= stock_pixmap_widget(STOCK_PIXMAP_SELECTION
);
8126 gtk_container_remove (GTK_CONTAINER(summaryview
->multiple_sel_togbtn
),
8127 summaryview
->multiple_sel_image
);
8128 gtk_container_add(GTK_CONTAINER(summaryview
->multiple_sel_togbtn
), pixmap
);
8129 gtk_widget_show(pixmap
);
8130 summaryview
->multiple_sel_togbtn
= pixmap
;
8133 folderview_unselect(summaryview
->folderview
);
8134 folderview_select(summaryview
->folderview
, summaryview
->folder_item
);
8135 summary_set_column_titles(summaryview
);
8138 void summary_reflect_prefs_custom_colors(SummaryView
*summaryview
)
8141 GList
*children
, *cur
;
8143 /* re-create colorlabel submenu */
8144 menu
= GTK_MENU_SHELL(summaryview
->colorlabel_menu
);
8145 cm_return_if_fail(menu
!= NULL
);
8147 /* clear items. get item pointers. */
8148 children
= gtk_container_get_children(GTK_CONTAINER(menu
));
8149 for (cur
= children
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
8150 g_signal_handlers_disconnect_matched
8151 (gtk_ui_manager_get_accel_group(summaryview
->mainwin
->ui_manager
),
8152 G_SIGNAL_MATCH_DATA
|G_SIGNAL_MATCH_FUNC
,
8153 0, 0, NULL
, mainwin_accel_changed_cb
, cur
->data
);
8154 gtk_menu_item_set_submenu(GTK_MENU_ITEM(cur
->data
), NULL
);
8156 g_list_free(children
);
8157 summary_colorlabel_menu_create(summaryview
, TRUE
);
8161 * Harvest addresses for selected messages in summary view.
8163 void summary_harvest_address(SummaryView
*summaryview
)
8165 GtkCMCTree
*ctree
= GTK_CMCTREE( summaryview
->ctree
);
8171 for( cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
8172 msginfo
= gtk_cmctree_node_get_row_data( ctree
, GTK_CMCTREE_NODE(cur
->data
) );
8175 msgList
= g_list_append( msgList
, GUINT_TO_POINTER( msginfo
->msgnum
) );
8178 addressbook_harvest( summaryview
->folder_item
, TRUE
, msgList
);
8180 g_list_free( msgList
);
8183 static regex_t
*summary_compile_simplify_regexp(gchar
*simplify_subject_regexp
)
8186 gchar buf
[BUFFSIZE
];
8187 regex_t
*preg
= NULL
;
8189 preg
= g_new0(regex_t
, 1);
8191 err
= string_match_precompile(simplify_subject_regexp
,
8192 preg
, REG_EXTENDED
);
8194 regerror(err
, preg
, buf
, BUFFSIZE
);
8195 alertpanel_error(_("Regular expression (regexp) error:\n%s"), buf
);
8202 void summary_set_prefs_from_folderitem(SummaryView
*summaryview
, FolderItem
*item
)
8204 FolderSortKey sort_key
;
8205 FolderSortType sort_type
;
8206 cm_return_if_fail(summaryview
!= NULL
);
8207 cm_return_if_fail(item
!= NULL
);
8209 /* Subject simplification */
8210 if(summaryview
->simplify_subject_preg
) {
8211 regfree(summaryview
->simplify_subject_preg
);
8212 g_free(summaryview
->simplify_subject_preg
);
8213 summaryview
->simplify_subject_preg
= NULL
;
8215 if(item
->prefs
&& item
->prefs
->simplify_subject_regexp
&&
8216 item
->prefs
->simplify_subject_regexp
[0] && item
->prefs
->enable_simplify_subject
)
8217 summaryview
->simplify_subject_preg
= summary_compile_simplify_regexp(item
->prefs
->simplify_subject_regexp
);
8220 sort_key
= item
->sort_key
;
8221 sort_type
= item
->sort_type
;
8223 folder_get_sort_type(item
->folder
, &sort_key
, &sort_type
);
8225 summaryview
->sort_key
= sort_key
;
8226 summaryview
->sort_type
= sort_type
;
8229 summaryview
->threaded
= item
->threaded
;
8230 summaryview
->thread_collapsed
= item
->thread_collapsed
;
8235 void summary_save_prefs_to_folderitem(SummaryView
*summaryview
, FolderItem
*item
)
8238 item
->sort_key
= summaryview
->sort_key
;
8239 item
->sort_type
= summaryview
->sort_type
;
8242 item
->threaded
= summaryview
->threaded
;
8243 item
->thread_collapsed
= summaryview
->thread_collapsed
;
8246 static gboolean
summary_update_msg(gpointer source
, gpointer data
)
8248 MsgInfoUpdate
*msginfo_update
= (MsgInfoUpdate
*) source
;
8249 SummaryView
*summaryview
= (SummaryView
*)data
;
8250 GtkCMCTreeNode
*node
;
8252 cm_return_val_if_fail(msginfo_update
!= NULL
, TRUE
);
8253 cm_return_val_if_fail(summaryview
!= NULL
, FALSE
);
8255 if (msginfo_update
->msginfo
->folder
!= summaryview
->folder_item
)
8258 if (msginfo_update
->flags
& MSGINFO_UPDATE_FLAGS
) {
8259 node
= gtk_cmctree_find_by_row_data(
8260 GTK_CMCTREE(summaryview
->ctree
), NULL
,
8261 msginfo_update
->msginfo
);
8264 summary_set_row_marks(summaryview
, node
);
8270 void summary_update_unread(SummaryView
*summaryview
, FolderItem
*removed_item
)
8272 guint
new, unread
, unreadmarked
, marked
, total
;
8273 guint replied
, forwarded
, locked
, ignored
, watched
;
8274 static gboolean tips_initialized
= FALSE
;
8276 if (prefs_common
.layout_mode
!= SMALL_LAYOUT
) {
8277 if (tips_initialized
) {
8278 summary_set_folder_pixmap(summaryview
, STOCK_PIXMAP_DIR_OPEN
);
8279 CLAWS_SET_TIP(summaryview
->folder_pixmap_eventbox
,
8281 tips_initialized
= FALSE
;
8285 folder_count_total_msgs(&new, &unread
, &unreadmarked
, &marked
, &total
,
8286 &replied
, &forwarded
, &locked
, &ignored
,
8289 total
-= removed_item
->total_msgs
;
8290 new -= removed_item
->new_msgs
;
8291 unread
-= removed_item
->unread_msgs
;
8294 if (new > 0 || unread
> 0) {
8295 tips_initialized
= TRUE
;
8296 summary_set_folder_pixmap(summaryview
, STOCK_PIXMAP_DIR_OPEN_HRM
);
8297 CLAWS_SET_TIP(summaryview
->folder_pixmap_eventbox
,
8298 _("Go back to the folder list (You have unread messages)"));
8300 tips_initialized
= TRUE
;
8301 summary_set_folder_pixmap(summaryview
, STOCK_PIXMAP_DIR_OPEN
);
8302 CLAWS_SET_TIP(summaryview
->folder_pixmap_eventbox
,
8303 _("Go back to the folder list"));
8307 static gboolean
summary_update_folder_item_hook(gpointer source
, gpointer data
)
8309 FolderItemUpdateData
*hookdata
= (FolderItemUpdateData
*)source
;
8310 SummaryView
*summaryview
= (SummaryView
*)data
;
8312 cm_return_val_if_fail(hookdata
!= NULL
, FALSE
);
8313 cm_return_val_if_fail(hookdata
->item
!= NULL
, FALSE
);
8314 cm_return_val_if_fail(summaryview
!= NULL
, FALSE
);
8316 if (hookdata
->item
== summaryview
->folder_item
&&
8317 hookdata
->update_flags
& F_ITEM_UPDATE_NAME
) {
8318 gchar
*name
= folder_item_get_name(hookdata
->item
);
8319 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_folder
), name
);
8322 summary_update_unread(summaryview
, NULL
);
8327 static gboolean
summary_update_folder_hook(gpointer source
, gpointer data
)
8329 FolderUpdateData
*hookdata
;
8330 SummaryView
*summaryview
= (SummaryView
*)data
;
8332 if (hookdata
->update_flags
& FOLDER_REMOVE_FOLDERITEM
) {
8333 summary_update_unread(summaryview
, hookdata
->item
);
8335 summary_update_unread(summaryview
, NULL
);
8341 *\brief change summaryview to display your answer(s) to a message
8343 *\param summaryview The SummaryView ;)
8344 *\param msginfo The message for which answers are searched
8347 static void summary_find_answers (SummaryView
*summaryview
, MsgInfo
*msg
)
8349 FolderItem
*sent_folder
= NULL
;
8350 PrefsAccount
*account
= NULL
;
8351 GtkCMCTreeNode
*node
= NULL
;
8353 if (msg
== NULL
|| msg
->msgid
== NULL
)
8356 account
= account_get_reply_account(msg
, prefs_common
.reply_account_autosel
);
8357 if (account
== NULL
)
8359 sent_folder
= account_get_special_folder
8360 (account
, F_OUTBOX
);
8362 buf
= g_strdup_printf("inreplyto matchcase \"%s\"", msg
->msgid
);
8364 if (sent_folder
!= summaryview
->folder_item
) {
8365 folderview_select(summaryview
->mainwin
->folderview
, sent_folder
);
8368 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(summaryview
->toggle_search
), TRUE
);
8370 quicksearch_set(summaryview
->quicksearch
, ADVANCED_SEARCH_EXTENDED
, buf
);
8373 node
= gtk_cmctree_node_nth(GTK_CMCTREE(summaryview
->ctree
), 0);
8375 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_SEARCH_RESULTS
);
8378 gint
summaryview_export_mbox_list(SummaryView
*summaryview
)
8379 /* return values: -2 skipped, -1 error, 0 OK */
8381 GSList
*list
= summary_get_selected_msg_list(summaryview
);
8382 gchar
*mbox
= filesel_select_file_save(_("Export to mbox file"), NULL
);
8390 ret
= export_list_to_mbox(list
, mbox
);
8398 void summaryview_lock(SummaryView
*summaryview
, FolderItem
*item
)
8400 if (!summaryview
|| !summaryview
->folder_item
|| !item
) {
8404 if (summaryview
->folder_item
->folder
== item
->folder
) {
8405 gtk_widget_set_sensitive(summaryview
->ctree
, FALSE
);
8408 void summaryview_unlock(SummaryView
*summaryview
, FolderItem
*item
)
8410 gtk_widget_set_sensitive(summaryview
->ctree
, TRUE
);
8413 #define DO_ACTION(name, act) { if (!strcmp(a_name, name)) action = act; }
8414 static void summary_reply_cb(GtkAction
*gaction
, gpointer data
)
8416 SummaryView
*summaryview
= (SummaryView
*)data
;
8417 GSList
*msginfo_list
= NULL
;
8418 gint action
= COMPOSE_REPLY
;
8419 const gchar
*a_name
= gtk_action_get_name(gaction
);
8421 DO_ACTION("SummaryViewPopup/Reply", COMPOSE_REPLY
);
8422 DO_ACTION("SummaryViewPopup/ReplyTo/All", COMPOSE_REPLY_TO_ALL
);
8423 DO_ACTION("SummaryViewPopup/ReplyTo/Sender", COMPOSE_REPLY_TO_SENDER
);
8424 DO_ACTION("SummaryViewPopup/ReplyTo/List", COMPOSE_REPLY_TO_LIST
);
8425 DO_ACTION("SummaryViewPopup/Forward", COMPOSE_FORWARD_INLINE
);
8426 DO_ACTION("SummaryViewPopup/ForwardAtt", COMPOSE_FORWARD_AS_ATTACH
);
8427 DO_ACTION("SummaryViewPopup/Redirect", COMPOSE_REDIRECT
);
8429 msginfo_list
= summary_get_selection(summaryview
);
8430 cm_return_if_fail(msginfo_list
!= NULL
);
8431 compose_reply_from_messageview(NULL
, msginfo_list
, action
);
8432 g_slist_free(msginfo_list
);
8435 gboolean
summary_is_opened_message_selected(SummaryView
*summaryview
)
8439 cm_return_val_if_fail(summaryview
!= NULL
, FALSE
);
8441 sel
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
8443 if (summaryview
->displayed
== NULL
|| sel
== NULL
) {
8447 for ( ; sel
!= NULL
; sel
= sel
->next
) {
8448 if (summaryview
->displayed
== GTK_CMCTREE_NODE(sel
->data
)) {
8455 gboolean
summary_has_opened_message(SummaryView
*summaryview
)
8457 cm_return_val_if_fail(summaryview
!= NULL
, FALSE
);
8459 return (summaryview
->displayed
!= NULL
);