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/>.
23 #include <glib/gi18n.h>
24 #include <gdk/gdkkeysyms.h>
35 #include "mainwindow.h"
36 #include "folderview.h"
37 #include "summaryview.h"
38 #include "messageview.h"
40 #include "foldersel.h"
42 #include "procheader.h"
43 #include "sourcewindow.h"
44 #include "prefs_common.h"
45 #include "prefs_summary_column.h"
46 #include "prefs_summary_open.h"
47 #include "prefs_filtering.h"
50 #include "file-utils.h"
53 #include "stock_pixmap.h"
55 #include "alertpanel.h"
56 #include "inputdialog.h"
57 #include "statusbar.h"
59 #include "colorlabel.h"
62 #ifndef USE_ALT_ADDRBOOK
63 #include "addressbook.h"
65 #include "addressbook-dbus.h"
66 #include "addressadd.h"
68 #include "addr_compl.h"
69 #include "folder_item_prefs.h"
70 #include "filtering.h"
71 #include "string_match.h"
75 #include "description_window.h"
76 #include "folderutils.h"
77 #include "quicksearch.h"
78 #include "partial_download.h"
84 #include "manage_window.h"
87 #define SUMMARY_COL_MARK_WIDTH 10
88 #define SUMMARY_COL_STATUS_WIDTH 13
89 #define SUMMARY_COL_LOCKED_WIDTH 13
90 #define SUMMARY_COL_MIME_WIDTH 11
92 static int normal_row_height
= -1;
93 static GtkStyle
*bold_style
;
94 static GtkStyle
*bold_marked_style
;
95 static GtkStyle
*bold_deleted_style
;
96 static GtkStyle
*small_style
;
97 static GtkStyle
*small_marked_style
;
98 static GtkStyle
*small_deleted_style
;
100 static GdkPixbuf
*markxpm
;
101 static GdkPixbuf
*deletedxpm
;
102 static GdkPixbuf
*movedxpm
;
103 static GdkPixbuf
*copiedxpm
;
105 static GdkPixbuf
*newxpm
;
106 static GdkPixbuf
*unreadxpm
;
107 static GdkPixbuf
*repliedxpm
;
108 static GdkPixbuf
*forwardedxpm
;
109 static GdkPixbuf
*repliedandforwardedxpm
;
110 static GdkPixbuf
*ignorethreadxpm
;
111 static GdkPixbuf
*watchthreadxpm
;
112 static GdkPixbuf
*lockedxpm
;
113 static GdkPixbuf
*spamxpm
;
115 static GdkPixbuf
*clipxpm
;
116 static GdkPixbuf
*keyxpm
;
117 static GdkPixbuf
*clipkeyxpm
;
118 static GdkPixbuf
*keysignxpm
;
119 static GdkPixbuf
*gpgsignedxpm
;
120 static GdkPixbuf
*clipgpgsignedxpm
;
122 static void summary_free_msginfo_func (GtkCMCTree
*ctree
,
123 GtkCMCTreeNode
*node
,
125 static void summary_set_marks_func (GtkCMCTree
*ctree
,
126 GtkCMCTreeNode
*node
,
129 void summary_set_menu_sensitive (SummaryView
*summaryview
);
130 guint
summary_get_msgnum (SummaryView
*summaryview
,
131 GtkCMCTreeNode
*node
);
134 static void summary_set_hide_menu (SummaryView
*summaryview
,
135 const gchar
*menu_item
,
138 static GtkCMCTreeNode
*summary_find_prev_msg
139 (SummaryView
*summaryview
,
140 GtkCMCTreeNode
*current_node
,
141 gboolean start_from_prev
);
142 static GtkCMCTreeNode
*summary_find_next_msg
143 (SummaryView
*summaryview
,
144 GtkCMCTreeNode
*current_node
,
145 gboolean start_from_next
);
147 static GtkCMCTreeNode
*summary_find_prev_flagged_msg
148 (SummaryView
*summaryview
,
149 GtkCMCTreeNode
*current_node
,
151 gboolean start_from_prev
);
152 static GtkCMCTreeNode
*summary_find_next_flagged_msg
153 (SummaryView
*summaryview
,
154 GtkCMCTreeNode
*current_node
,
156 gboolean start_from_next
);
158 static GtkCMCTreeNode
*summary_find_msg_by_msgnum
159 (SummaryView
*summaryview
,
162 static void summary_update_status (SummaryView
*summaryview
);
164 /* display functions */
165 static void summary_status_show (SummaryView
*summaryview
);
166 static void summary_set_column_titles (SummaryView
*summaryview
);
167 static void summary_set_ctree_from_list (SummaryView
*summaryview
,
169 guint selected_msgnum
);
170 static inline void summary_set_header (SummaryView
*summaryview
,
173 static void summary_display_msg (SummaryView
*summaryview
,
174 GtkCMCTreeNode
*row
);
175 static void summary_display_msg_full (SummaryView
*summaryview
,
178 gboolean all_headers
);
179 static void summary_set_row_marks (SummaryView
*summaryview
,
180 GtkCMCTreeNode
*row
);
182 static gboolean
summary_set_row_tag (SummaryView
*summaryview
,
187 /* message handling */
188 static void summary_mark_row (SummaryView
*summaryview
,
189 GtkCMCTreeNode
*row
);
190 static void summary_lock_row (SummaryView
*summaryview
,
191 GtkCMCTreeNode
*row
);
192 static void summary_unlock_row (SummaryView
*summaryview
,
193 GtkCMCTreeNode
*row
);
194 static void summary_mark_row_as_read (SummaryView
*summaryview
,
195 GtkCMCTreeNode
*row
);
196 static void summary_mark_row_as_unread (SummaryView
*summaryview
,
197 GtkCMCTreeNode
*row
);
198 static gboolean
summary_mark_all_read_confirm(gboolean ask_if_needed
);
199 static gboolean
summary_mark_all_unread_confirm(gboolean ask_if_needed
);
200 static void summary_delete_row (SummaryView
*summaryview
,
201 GtkCMCTreeNode
*row
);
202 static void summary_unmark_row (SummaryView
*summaryview
,
203 GtkCMCTreeNode
*row
);
204 static void summary_move_row_to (SummaryView
*summaryview
,
206 FolderItem
*to_folder
);
207 static void summary_copy_row_to (SummaryView
*summaryview
,
209 FolderItem
*to_folder
);
211 static gint
summary_execute_move (SummaryView
*summaryview
);
212 static void summary_execute_move_func (GtkCMCTree
*ctree
,
213 GtkCMCTreeNode
*node
,
215 static void summary_execute_copy (SummaryView
*summaryview
);
216 static void summary_execute_copy_func (GtkCMCTree
*ctree
,
217 GtkCMCTreeNode
*node
,
219 static void summary_execute_delete (SummaryView
*summaryview
);
220 static void summary_execute_delete_func (GtkCMCTree
*ctree
,
221 GtkCMCTreeNode
*node
,
223 static void summary_execute_expunge (SummaryView
*summaryview
);
225 static void summary_thread_init (SummaryView
*summaryview
);
227 static void summary_unthread_for_exec (SummaryView
*summaryview
);
228 static void summary_unthread_for_exec_func (GtkCMCTree
*ctree
,
229 GtkCMCTreeNode
*node
,
232 void summary_simplify_subject(SummaryView
*summaryview
, gchar
* rexp
,
235 static void summary_filter_func (MsgInfo
*msginfo
,
236 PrefsAccount
*ac_prefs
);
238 static void summary_colorlabel_menu_item_activate_cb
241 static void summary_colorlabel_menu_item_activate_item_cb
242 (GtkMenuItem
*label_menu_item
,
244 static void summary_colorlabel_menu_create(SummaryView
*summaryview
,
246 static void summary_tags_menu_item_activate_cb
249 static void summary_tags_menu_item_activate_item_cb
250 (GtkMenuItem
*label_menu_item
,
252 static void summary_tags_menu_create(SummaryView
*summaryview
,
255 static GtkWidget
*summary_ctree_create (SummaryView
*summaryview
);
257 /* callback functions */
258 static gint
summary_toggle_pressed (GtkWidget
*eventbox
,
259 GdkEventButton
*event
,
260 SummaryView
*summaryview
);
262 static void summary_toggle_multiple_pressed
264 SummaryView
*summaryview
);
266 static gint summary_folder_eventbox_pressed
267 (GtkWidget
*eventbox
,
268 GdkEventButton
*event
,
269 SummaryView
*summaryview
);
270 static gboolean
summary_button_pressed (GtkWidget
*ctree
,
271 GdkEventButton
*event
,
272 SummaryView
*summaryview
);
273 static gboolean
summary_button_released (GtkWidget
*ctree
,
274 GdkEventButton
*event
,
275 SummaryView
*summaryview
);
276 static gboolean
summary_key_pressed (GtkWidget
*ctree
,
278 SummaryView
*summaryview
);
279 static void summary_tree_expanded (GtkCMCTree
*ctree
,
280 GtkCMCTreeNode
*node
,
281 SummaryView
*summaryview
);
282 static void summary_tree_collapsed (GtkCMCTree
*ctree
,
283 GtkCMCTreeNode
*node
,
284 SummaryView
*summaryview
);
285 static void summary_selected (GtkCMCTree
*ctree
,
288 SummaryView
*summaryview
);
289 static void summary_unselected (GtkCMCTree
*ctree
,
292 SummaryView
*summaryview
);
293 static void summary_col_resized (GtkCMCList
*clist
,
296 SummaryView
*summaryview
);
297 static void summary_mark_clicked (GtkWidget
*button
,
298 SummaryView
*summaryview
);
299 static void summary_status_clicked (GtkWidget
*button
,
300 SummaryView
*summaryview
);
301 static void summary_mime_clicked (GtkWidget
*button
,
302 SummaryView
*summaryview
);
303 static void summary_num_clicked (GtkWidget
*button
,
304 SummaryView
*summaryview
);
305 static void summary_score_clicked (GtkWidget
*button
,
306 SummaryView
*summaryview
);
307 static void summary_size_clicked (GtkWidget
*button
,
308 SummaryView
*summaryview
);
309 static void summary_date_clicked (GtkWidget
*button
,
310 SummaryView
*summaryview
);
311 static void summary_from_clicked (GtkWidget
*button
,
312 SummaryView
*summaryview
);
313 static void summary_to_clicked (GtkWidget
*button
,
314 SummaryView
*summaryview
);
315 static void summary_subject_clicked (GtkWidget
*button
,
316 SummaryView
*summaryview
);
317 static void summary_score_clicked (GtkWidget
*button
,
318 SummaryView
*summaryview
);
319 static void summary_locked_clicked (GtkWidget
*button
,
320 SummaryView
*summaryview
);
321 static void summary_tags_clicked (GtkWidget
*button
,
322 SummaryView
*summaryview
);
324 static void summary_start_drag (GtkWidget
*widget
,
327 SummaryView
*summaryview
);
328 static void summary_drag_data_get (GtkWidget
*widget
,
329 GdkDragContext
*drag_context
,
330 GtkSelectionData
*selection_data
,
333 SummaryView
*summaryview
);
334 static void summary_drag_data_received(GtkWidget
*widget
,
335 GdkDragContext
*drag_context
,
338 GtkSelectionData
*data
,
341 SummaryView
*summaryview
);
342 static gboolean
summary_drag_motion_cb(GtkWidget
*widget
,
343 GdkDragContext
*context
,
347 SummaryView
*summaryview
);
348 static void summary_drag_end(GtkWidget
*widget
,
349 GdkDragContext
*drag_context
,
350 SummaryView
*summaryview
);
352 /* custom compare functions for sorting */
353 static gint
summary_cmp_by_mark (GtkCMCList
*clist
,
356 static gint
summary_cmp_by_status (GtkCMCList
*clist
,
359 static gint
summary_cmp_by_mime (GtkCMCList
*clist
,
362 static gint
summary_cmp_by_num (GtkCMCList
*clist
,
365 static gint
summary_cmp_by_size (GtkCMCList
*clist
,
368 static gint
summary_cmp_by_date (GtkCMCList
*clist
,
371 static gint
summary_cmp_by_thread_date (GtkCMCList
*clist
,
374 static gint
summary_cmp_by_from (GtkCMCList
*clist
,
377 static gint summary_cmp_by_simplified_subject
381 static gint
summary_cmp_by_score (GtkCMCList
*clist
,
384 static gint
summary_cmp_by_label (GtkCMCList
*clist
,
387 static gint
summary_cmp_by_to (GtkCMCList
*clist
,
390 static gint
summary_cmp_by_subject (GtkCMCList
*clist
,
393 static gint
summary_cmp_by_locked (GtkCMCList
*clist
,
396 static gint
summary_cmp_by_tags (GtkCMCList
*clist
,
400 static void quicksearch_execute_cb (QuickSearch
*quicksearch
,
403 static void tog_searchbar_cb (GtkWidget
*w
,
406 static void summary_find_answers (SummaryView
*summaryview
,
409 static gboolean
summary_update_msg (gpointer source
, gpointer data
);
410 static gboolean
summary_update_folder_item_hook(gpointer source
, gpointer data
);
411 static gboolean
summary_update_folder_hook(gpointer source
, gpointer data
);
412 static void summary_set_colorlabel_color (GtkCMCTree
*ctree
,
413 GtkCMCTreeNode
*node
,
415 static void summary_thread_build(SummaryView
*summaryview
);
417 GtkTargetEntry summary_drag_types
[3] =
419 {"text/uri-list", 0, TARGET_MAIL_URI_LIST
},
420 {"claws-mail/internal", GTK_TARGET_SAME_APP
, TARGET_DUMMY
},
421 {"claws-mail/msg-path-list", 0, TARGET_MAIL_CM_PATH_LIST
},
424 static void summary_reedit_cb(GtkAction
*gaction
, gpointer data
);
425 static void summary_reply_cb(GtkAction
*gaction
, gpointer data
);
427 /* Only submenus and specifically-handled menu entries here */
428 static GtkActionEntry summary_popup_entries
[] =
430 {"SummaryViewPopup", NULL
, "SummaryViewPopup", NULL
, NULL
, NULL
},
431 {"SummaryViewPopup/Reedit", NULL
, N_("Re-edit"), NULL
, NULL
, G_CALLBACK(summary_reedit_cb
) },
432 {"SummaryViewPopup/Reply", NULL
, N_("_Reply"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_REPLY */
433 {"SummaryViewPopup/ReplyTo", NULL
, N_("Repl_y to"), NULL
, NULL
, NULL
},
434 {"SummaryViewPopup/ReplyTo/All", NULL
, N_("_All"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_REPLY_TO_ALL */
435 {"SummaryViewPopup/ReplyTo/Sender", NULL
, N_("_Sender"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_REPLY_TO_SENDER */
436 {"SummaryViewPopup/ReplyTo/List", NULL
, N_("Mailing _list"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_REPLY_TO_LIST */
438 {"SummaryViewPopup/Forward", NULL
, N_("_Forward"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_FORWARD_INLINE */
439 {"SummaryViewPopup/ForwardAtt", NULL
, N_("For_ward as attachment"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_FORWARD_AS_ATTACH */
440 {"SummaryViewPopup/Redirect", NULL
, N_("Redirec_t"), NULL
, NULL
, G_CALLBACK(summary_reply_cb
) }, /* COMPOSE_REDIRECT */
441 {"SummaryViewPopup/Mark", NULL
, N_("_Mark"), NULL
, NULL
, NULL
},
442 {"SummaryViewPopup/ColorLabel", NULL
, N_("Color la_bel"), NULL
, NULL
, NULL
},
443 {"SummaryViewPopup/Tags", NULL
, N_("Ta_gs"), NULL
, NULL
, NULL
},
444 {"SummaryViewPopup/CreateFilterRule", NULL
, N_("Create _filter rule"), NULL
, NULL
, NULL
},
446 {"SummaryViewPopup/CreateProcessingRule", NULL
, N_("Create processing rule"), NULL
, NULL
, NULL
},
448 {"SummaryViewPopup/View", NULL
, N_("_View"), NULL
, NULL
, NULL
},
451 static void summary_header_lock_sorting_cb(GtkAction
*gaction
, gpointer data
);
452 static void summary_header_set_displayed_columns_cb(GtkAction
*gaction
, gpointer data
);
454 static GtkActionEntry summary_header_popup_entries
[] =
456 {"SummaryViewHeaderPopup", NULL
, "SummaryViewHeaderPopup", NULL
, NULL
, NULL
},
457 {"SummaryViewHeaderPopup/SetDisplayedColumns", NULL
, N_("_Set displayed columns"), NULL
, NULL
, G_CALLBACK(summary_header_set_displayed_columns_cb
) }
460 static GtkToggleActionEntry summary_header_popup_toggle_entries
[] =
462 {"SummaryViewHeaderPopup/LockColumnHeaders", NULL
, N_("_Lock column headers"), NULL
, NULL
, G_CALLBACK(summary_header_lock_sorting_cb
), FALSE
}
465 static const gchar
*const col_label
[N_SUMMARY_COLS
] = {
467 N_("S"), /* S_COL_STATUS */
469 N_("Subject"), /* S_COL_SUBJECT */
470 N_("From"), /* S_COL_FROM */
471 N_("To"), /* S_COL_TO */
472 N_("Date"), /* S_COL_DATE */
473 N_("Size"), /* S_COL_SIZE */
474 N_("#"), /* S_COL_NUMBER */
475 N_("Score"), /* S_COL_SCORE */
476 "", /* S_COL_LOCKED */
477 N_("Tags"), /* S_COL_TAGS */
480 void summary_freeze(SummaryView
*summaryview
)
483 gtk_cmclist_freeze(GTK_CMCLIST(summaryview
->ctree
));
486 void summary_thaw(SummaryView
*summaryview
)
489 gtk_cmclist_thaw(GTK_CMCLIST(summaryview
->ctree
));
492 void summary_thaw_with_status(SummaryView
*summaryview
)
495 summary_status_show(summaryview
);
496 gtk_cmclist_thaw(GTK_CMCLIST(summaryview
->ctree
));
500 void summary_grab_focus(SummaryView
*summaryview
)
503 gtk_widget_grab_focus(summaryview
->ctree
);
506 GtkWidget
*summary_get_main_widget(SummaryView
*summaryview
)
509 return summaryview
->ctree
;
514 #define START_LONG_OPERATION(summaryview,force_freeze) { \
515 summary_lock(summaryview); \
516 main_window_cursor_wait(summaryview->mainwin); \
517 if (force_freeze || sc_g_list_bigger(GTK_CMCLIST(summaryview->ctree)->selection, 1)) {\
519 summary_freeze(summaryview); \
521 folder_item_update_freeze(); \
523 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST, \
524 summaryview->msginfo_update_callback_id); \
526 #define END_LONG_OPERATION(summaryview) { \
528 folder_item_update_thaw(); \
530 summary_thaw(summaryview); \
531 main_window_cursor_normal(summaryview->mainwin); \
532 summary_unlock(summaryview); \
533 summaryview->msginfo_update_callback_id = \
534 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST, \
535 summary_update_msg, (gpointer) summaryview); \
538 static void popup_menu_selection_done(GtkMenuShell
*shell
, gpointer user_data
)
540 SummaryView
*summaryview
= (SummaryView
*)user_data
;
542 cm_return_if_fail(summaryview
!= NULL
);
544 /* If a message is displayed, place cursor back on the message. */
545 if (summaryview
->displayed
!= NULL
&&
546 summaryview
->displayed
!= summaryview
->selected
) {
547 gtk_sctree_select(GTK_SCTREE(summaryview
->ctree
), summaryview
->displayed
);
551 SummaryView
*summary_create(MainWindow
*mainwin
)
553 SummaryView
*summaryview
;
555 GtkWidget
*scrolledwin
;
560 GtkWidget
*stat_box2
;
561 GtkWidget
*stat_vbox
;
562 GtkWidget
*statlabel_folder
;
563 GtkWidget
*statlabel_select
;
564 GtkWidget
*statlabel_msgs
;
566 GtkWidget
*toggle_eventbox
;
568 GtkWidget
*multiple_sel_togbtn
;
570 GtkWidget
*toggle_arrow
;
571 GtkWidget
*toggle_search
;
572 QuickSearch
*quicksearch
;
574 debug_print("Creating summary view...\n");
575 summaryview
= g_new0(SummaryView
, 1);
577 #define SUMMARY_VBOX_SPACING 3
578 vbox
= gtk_vbox_new(FALSE
, SUMMARY_VBOX_SPACING
);
580 /* create status label */
581 hbox
= gtk_hbox_new(FALSE
, 0);
582 gtk_widget_show(hbox
);
584 stat_vbox
= gtk_vbox_new(FALSE
, 0);
585 gtk_widget_show(stat_vbox
);
587 stat_box
= gtk_hbox_new(FALSE
, 0);
588 gtk_widget_show(stat_box
);
590 stat_box2
= gtk_hbox_new(FALSE
, 0);
591 gtk_widget_show(stat_box2
);
593 toggle_search
= gtk_toggle_button_new();
594 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle_search
),
595 prefs_common
.show_searchbar
);
596 gtk_widget_set_can_focus(toggle_search
, FALSE
);
597 gtk_widget_show(toggle_search
);
599 CLAWS_SET_TIP(toggle_search
, _("Toggle quick search bar"));
601 gtk_box_pack_start(GTK_BOX(hbox
), toggle_search
, FALSE
, FALSE
, 2);
603 gtk_box_pack_start(GTK_BOX(hbox
), stat_vbox
, TRUE
, TRUE
, 0);
604 gtk_box_pack_start(GTK_BOX(stat_vbox
), stat_box
, TRUE
, TRUE
, 0);
605 gtk_box_pack_start(GTK_BOX(stat_vbox
), stat_box2
, TRUE
, TRUE
, 0);
607 hbox_l
= gtk_hbox_new(FALSE
, 0);
608 gtk_widget_show(hbox_l
);
609 gtk_box_pack_start(GTK_BOX(stat_box
), hbox_l
, TRUE
, TRUE
, 0);
611 statlabel_folder
= gtk_label_new("");
612 gtk_widget_show(statlabel_folder
);
613 gtk_box_pack_start(GTK_BOX(hbox_l
), statlabel_folder
, FALSE
, FALSE
, 2);
614 statlabel_select
= gtk_label_new("");
615 gtk_widget_show(statlabel_select
);
616 gtk_box_pack_start(GTK_BOX(hbox_l
), statlabel_select
, FALSE
, FALSE
, 12);
618 /* toggle view button */
619 toggle_eventbox
= gtk_event_box_new();
620 gtk_widget_show(toggle_eventbox
);
622 gtk_box_pack_end(GTK_BOX(hbox
), toggle_eventbox
, FALSE
, FALSE
, 4);
624 toggle_arrow
= gtk_arrow_new(GTK_ARROW_DOWN
, GTK_SHADOW_OUT
);
625 gtk_widget_show(toggle_arrow
);
626 gtk_container_add(GTK_CONTAINER(toggle_eventbox
), toggle_arrow
);
627 g_signal_connect(G_OBJECT(toggle_eventbox
), "button_press_event",
628 G_CALLBACK(summary_toggle_pressed
),
632 multiple_sel_togbtn
= gtk_toggle_button_new();
633 gtk_widget_show(multiple_sel_togbtn
);
634 gtk_box_pack_end(GTK_BOX(hbox
), multiple_sel_togbtn
, FALSE
, FALSE
, 4);
635 CLAWS_SET_TIP(multiple_sel_togbtn
,
636 _("Toggle multiple selection"));
637 g_signal_connect(G_OBJECT(multiple_sel_togbtn
), "toggled",
638 G_CALLBACK(summary_toggle_multiple_pressed
),
642 statlabel_msgs
= gtk_label_new("");
643 gtk_widget_show(statlabel_msgs
);
644 gtk_box_pack_end(GTK_BOX(stat_box
), statlabel_msgs
, FALSE
, FALSE
, 4);
646 hbox_spc
= gtk_hbox_new(FALSE
, 0);
647 gtk_widget_show(hbox_spc
);
648 gtk_box_pack_end(GTK_BOX(hbox
), hbox_spc
, FALSE
, FALSE
, 6);
650 scrolledwin
= gtk_scrolled_window_new(NULL
, NULL
);
651 gtk_widget_show(scrolledwin
);
652 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin
),
653 GTK_POLICY_AUTOMATIC
,
654 GTK_POLICY_AUTOMATIC
);
655 summaryview
->mainwidget_book
= gtk_notebook_new();
656 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(summaryview
->mainwidget_book
), FALSE
);
657 gtk_notebook_set_show_border(GTK_NOTEBOOK(summaryview
->mainwidget_book
), FALSE
);
659 gtk_container_add(GTK_CONTAINER(summaryview
->mainwidget_book
),
661 gtk_box_pack_start(GTK_BOX(vbox
), summaryview
->mainwidget_book
, TRUE
, TRUE
, 0);
663 gtk_widget_set_size_request(vbox
,
664 prefs_common
.summaryview_width
,
665 prefs_common
.summaryview_height
);
667 ctree
= summary_ctree_create(summaryview
);
668 gtk_widget_show(ctree
);
670 gtk_scrolled_window_set_hadjustment(GTK_SCROLLED_WINDOW(scrolledwin
),
671 GTK_CMCLIST(ctree
)->hadjustment
);
672 gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(scrolledwin
),
673 GTK_CMCLIST(ctree
)->vadjustment
);
674 gtk_container_add(GTK_CONTAINER(scrolledwin
), ctree
);
677 gtk_widget_show_all(stat_vbox
);
678 gtk_box_pack_start(GTK_BOX(vbox
), hbox
, FALSE
, FALSE
, 0);
681 quicksearch
= quicksearch_new();
682 gtk_box_pack_start(GTK_BOX(vbox
), quicksearch_get_widget(quicksearch
), FALSE
, FALSE
, 0);
685 gtk_container_add(GTK_CONTAINER(summaryview
->mainwidget_book
),
687 gtk_box_pack_start(GTK_BOX(vbox
), summaryview
->mainwidget_book
, TRUE
, TRUE
, 0);
689 quicksearch_set_execute_callback(quicksearch
, quicksearch_execute_cb
, summaryview
);
691 g_signal_connect (G_OBJECT(toggle_search
), "toggled",
692 G_CALLBACK(tog_searchbar_cb
), summaryview
);
694 /* create popup menu */
696 gtk_action_group_add_actions(mainwin
->action_group
,
697 summary_popup_entries
,
698 G_N_ELEMENTS(summary_popup_entries
),
699 (gpointer
)summaryview
);
701 gtk_action_group_add_actions(mainwin
->action_group
,
702 summary_header_popup_entries
,
703 G_N_ELEMENTS(summary_header_popup_entries
),
704 (gpointer
)summaryview
);
706 gtk_action_group_add_toggle_actions(mainwin
->action_group
,
707 summary_header_popup_toggle_entries
,
708 G_N_ELEMENTS(summary_header_popup_toggle_entries
),
709 (gpointer
)summaryview
);
711 summaryview
->ui_manager
= gtk_ui_manager_new();
712 summaryview
->action_group
= cm_menu_create_action_group_full(summaryview
->ui_manager
,"Menu", summary_popup_entries
,
713 G_N_ELEMENTS(summary_popup_entries
), (gpointer
)summaryview
);
715 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus", "SummaryViewPopup", "SummaryViewPopup", GTK_UI_MANAGER_MENU
)
716 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Reedit", "SummaryViewPopup/Reedit", GTK_UI_MANAGER_MENUITEM
)
717 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Reply", "SummaryViewPopup/Reply", GTK_UI_MANAGER_MENUITEM
)
719 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "ReplyTo", "SummaryViewPopup/ReplyTo", GTK_UI_MANAGER_MENU
)
720 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator1", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
722 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Forward", "SummaryViewPopup/Forward", GTK_UI_MANAGER_MENUITEM
)
724 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "ForwardAtt", "SummaryViewPopup/ForwardAtt", GTK_UI_MANAGER_MENUITEM
)
725 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Redirect", "SummaryViewPopup/Redirect", GTK_UI_MANAGER_MENUITEM
)
727 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator2", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
728 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Move", "Message/Move", GTK_UI_MANAGER_MENUITEM
)
729 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Copy", "Message/Copy", GTK_UI_MANAGER_MENUITEM
)
730 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Trash", "Message/Trash", GTK_UI_MANAGER_MENUITEM
)
732 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Delete", "Message/Delete", GTK_UI_MANAGER_MENUITEM
)
734 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator3", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
735 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Mark", "SummaryViewPopup/Mark", GTK_UI_MANAGER_MENU
)
736 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "ColorLabel", "SummaryViewPopup/ColorLabel", GTK_UI_MANAGER_MENU
)
737 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Tags", "SummaryViewPopup/Tags", GTK_UI_MANAGER_MENU
)
739 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator4", "Message/---", GTK_UI_MANAGER_SEPARATOR
)
741 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "AddSenderToAB", "Tools/AddSenderToAB", GTK_UI_MANAGER_MENUITEM
)
743 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "CreateFilterRule", "SummaryViewPopup/CreateFilterRule", GTK_UI_MANAGER_MENU
)
745 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "CreateProcessingRule", "SummaryViewPopup/CreateProcessingRule", GTK_UI_MANAGER_MENU
)
747 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator5", "Tools/---", GTK_UI_MANAGER_SEPARATOR
)
748 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "View", "SummaryViewPopup/View", GTK_UI_MANAGER_MENU
)
749 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "SaveAs", "File/SaveAs", GTK_UI_MANAGER_MENUITEM
)
751 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Print", "File/Print", GTK_UI_MANAGER_MENUITEM
)
753 /* last separator, for plugins */
754 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup", "Separator6", "File/---", GTK_UI_MANAGER_SEPARATOR
)
756 /* submenus - replyto */
757 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/ReplyTo", "All", "SummaryViewPopup/ReplyTo/All", GTK_UI_MANAGER_MENUITEM
)
758 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/ReplyTo", "Sender", "SummaryViewPopup/ReplyTo/Sender", GTK_UI_MANAGER_MENUITEM
)
759 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/ReplyTo", "MailingList", "SummaryViewPopup/ReplyTo/List", GTK_UI_MANAGER_MENUITEM
)
761 /* submenus - mark */
762 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Mark", "Message/Mark/Mark", GTK_UI_MANAGER_MENUITEM
)
763 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Unmark", "Message/Mark/Unmark", GTK_UI_MANAGER_MENUITEM
)
764 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Separator1", "Message/Mark/---", GTK_UI_MANAGER_SEPARATOR
)
765 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkRead", "Message/Mark/MarkRead", GTK_UI_MANAGER_MENUITEM
)
766 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkUnread", "Message/Mark/MarkUnread", GTK_UI_MANAGER_MENUITEM
)
767 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Separator2", "Message/Mark/---", GTK_UI_MANAGER_SEPARATOR
)
768 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkAllRead", "Message/Mark/MarkAllRead", GTK_UI_MANAGER_MENUITEM
)
769 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkAllUnread", "Message/Mark/MarkAllUnread", GTK_UI_MANAGER_MENUITEM
)
770 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Separator3", "Message/Mark/---", GTK_UI_MANAGER_SEPARATOR
)
771 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "IgnoreThread", "Message/Mark/IgnoreThread", GTK_UI_MANAGER_MENUITEM
)
772 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "UnignoreThread", "Message/Mark/UnignoreThread", GTK_UI_MANAGER_MENUITEM
)
773 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "WatchThread", "Message/Mark/WatchThread", GTK_UI_MANAGER_MENUITEM
)
774 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "UnwatchThread", "Message/Mark/UnwatchThread", GTK_UI_MANAGER_MENUITEM
)
775 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Separator4", "Message/Mark/---", GTK_UI_MANAGER_SEPARATOR
)
776 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkSpam", "Message/Mark/MarkSpam", GTK_UI_MANAGER_MENUITEM
)
777 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "MarkHam", "Message/Mark/MarkHam", GTK_UI_MANAGER_MENUITEM
)
778 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Separator5", "Message/Mark/---", GTK_UI_MANAGER_SEPARATOR
)
779 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Lock", "Message/Mark/Lock", GTK_UI_MANAGER_MENUITEM
)
780 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Mark", "Unlock", "Message/Mark/Unlock", GTK_UI_MANAGER_MENUITEM
)
782 /* submenus - colorlabel and tags are dynamic */
783 /* submenus - createfilterrule */
784 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateFilterRule", "Automatically", "Tools/CreateFilterRule/Automatically", GTK_UI_MANAGER_MENUITEM
)
785 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateFilterRule", "ByFrom", "Tools/CreateFilterRule/ByFrom", GTK_UI_MANAGER_MENUITEM
)
786 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateFilterRule", "ByTo", "Tools/CreateFilterRule/ByTo", GTK_UI_MANAGER_MENUITEM
)
787 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateFilterRule", "BySubject", "Tools/CreateFilterRule/BySubject", GTK_UI_MANAGER_MENUITEM
)
788 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateFilterRule", "BySender", "Tools/CreateFilterRule/BySender", GTK_UI_MANAGER_MENUITEM
)
791 /* submenus - createprocessingrule */
792 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateProcessingRule", "Automatically", "Tools/CreateProcessingRule/Automatically", GTK_UI_MANAGER_MENUITEM
)
793 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateProcessingRule", "ByFrom", "Tools/CreateProcessingRule/ByFrom", GTK_UI_MANAGER_MENUITEM
)
794 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateProcessingRule", "ByTo", "Tools/CreateProcessingRule/ByTo", GTK_UI_MANAGER_MENUITEM
)
795 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateProcessingRule", "BySubject", "Tools/CreateProcessingRule/BySubject", GTK_UI_MANAGER_MENUITEM
)
796 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/CreateProcessingRule", "BySender", "Tools/CreateProcessingRule/BySender", GTK_UI_MANAGER_MENUITEM
)
799 /* submenus - view */
800 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/View", "OpenNewWindow", "View/OpenNewWindow", GTK_UI_MANAGER_MENUITEM
)
801 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/View", "MessageSource", "View/MessageSource", GTK_UI_MANAGER_MENUITEM
)
803 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewPopup/View", "AllHeaders", "View/AllHeaders", GTK_UI_MANAGER_MENUITEM
)
806 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus", "SummaryViewHeaderPopup", "SummaryViewHeaderPopup", GTK_UI_MANAGER_MENU
)
807 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewHeaderPopup", "LockColumnHeaders", "SummaryViewHeaderPopup/LockColumnHeaders", GTK_UI_MANAGER_MENUITEM
)
808 MENUITEM_ADDUI_MANAGER(mainwin
->ui_manager
, "/Menus/SummaryViewHeaderPopup", "SetDisplayedColumns", "SummaryViewHeaderPopup/SetDisplayedColumns", GTK_UI_MANAGER_MENUITEM
)
810 summaryview
->popupmenu
= gtk_menu_item_get_submenu(GTK_MENU_ITEM(
811 gtk_ui_manager_get_widget(mainwin
->ui_manager
, "/Menus/SummaryViewPopup")) );
812 summaryview
->headerpopupmenu
= gtk_menu_item_get_submenu(GTK_MENU_ITEM(
813 gtk_ui_manager_get_widget(mainwin
->ui_manager
, "/Menus/SummaryViewHeaderPopup")) );
815 summaryview
->vbox
= vbox
;
816 summaryview
->scrolledwin
= scrolledwin
;
817 summaryview
->ctree
= ctree
;
818 summaryview
->hbox
= hbox
;
819 summaryview
->hbox_l
= hbox_l
;
820 summaryview
->hbox_spc
= hbox_spc
;
821 summaryview
->stat_box
= stat_box
;
822 summaryview
->stat_box2
= stat_box2
;
823 summaryview
->statlabel_folder
= statlabel_folder
;
824 summaryview
->statlabel_select
= statlabel_select
;
825 summaryview
->statlabel_msgs
= statlabel_msgs
;
826 summaryview
->toggle_eventbox
= toggle_eventbox
;
827 summaryview
->toggle_arrow
= toggle_arrow
;
829 summaryview
->multiple_sel_togbtn
= multiple_sel_togbtn
;
831 summaryview
->toggle_search
= toggle_search
;
832 summaryview
->lock_count
= 0;
833 summaryview
->msginfo_update_callback_id
=
834 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
, summary_update_msg
, (gpointer
) summaryview
);
835 summaryview
->folder_item_update_callback_id
=
836 hooks_register_hook(FOLDER_ITEM_UPDATE_HOOKLIST
,
837 summary_update_folder_item_hook
,
838 (gpointer
) summaryview
);
839 summaryview
->folder_update_callback_id
=
840 hooks_register_hook(FOLDER_UPDATE_HOOKLIST
,
841 summary_update_folder_hook
,
842 (gpointer
) summaryview
);
844 summaryview
->target_list
= gtk_target_list_new(summary_drag_types
, 3);
846 summaryview
->quicksearch
= quicksearch
;
848 /* CLAWS: need this to get the SummaryView * from
850 g_object_set_data(G_OBJECT(ctree
), "summaryview", (gpointer
)summaryview
);
852 gtk_widget_show_all(vbox
);
854 gtk_widget_show(vbox
);
856 if (prefs_common
.show_searchbar
)
857 quicksearch_show(quicksearch
);
859 quicksearch_hide(quicksearch
);
861 if (prefs_common
.layout_mode
== WIDE_MSGLIST_LAYOUT
||
862 prefs_common
.layout_mode
== SMALL_LAYOUT
)
863 gtk_widget_hide(summaryview
->toggle_eventbox
);
868 void summary_relayout(SummaryView
*summaryview
)
870 gtk_widget_realize(summaryview
->stat_box
);
872 g_object_ref(summaryview
->hbox_l
);
873 g_object_ref(summaryview
->statlabel_msgs
);
875 gtkut_container_remove(GTK_CONTAINER(
876 gtk_widget_get_parent(summaryview
->hbox_l
)), summaryview
->hbox_l
);
877 gtkut_container_remove(GTK_CONTAINER(
878 gtk_widget_get_parent(summaryview
->statlabel_msgs
)), summaryview
->statlabel_msgs
);
880 switch (prefs_common
.layout_mode
) {
883 case WIDE_MSGLIST_LAYOUT
:
884 gtk_box_pack_start(GTK_BOX(summaryview
->stat_box
), summaryview
->hbox_l
, TRUE
, TRUE
, 0);
885 gtk_box_pack_end(GTK_BOX(summaryview
->stat_box
), summaryview
->statlabel_msgs
, FALSE
, FALSE
, 4);
886 gtk_widget_show_all(summaryview
->stat_box
);
887 gtk_widget_show_all(summaryview
->stat_box2
);
888 if (prefs_common
.layout_mode
== WIDE_MSGLIST_LAYOUT
||
889 prefs_common
.layout_mode
== SMALL_LAYOUT
)
890 gtk_widget_hide(summaryview
->toggle_eventbox
);
892 gtk_widget_show(summaryview
->toggle_eventbox
);
894 case VERTICAL_LAYOUT
:
896 gtk_box_pack_start(GTK_BOX(summaryview
->stat_box
), summaryview
->hbox_l
, TRUE
, TRUE
, 0);
897 gtk_box_pack_start(GTK_BOX(summaryview
->stat_box2
), summaryview
->statlabel_msgs
, FALSE
, FALSE
, 4);
898 gtk_widget_show_all(summaryview
->stat_box
);
899 gtk_widget_show_all(summaryview
->stat_box2
);
900 if (prefs_common
.layout_mode
== SMALL_LAYOUT
) {
901 gtk_widget_hide(summaryview
->toggle_eventbox
);
902 gtk_widget_hide(summaryview
->statlabel_msgs
);
904 gtk_widget_show(summaryview
->toggle_eventbox
);
905 gtk_widget_show(summaryview
->statlabel_msgs
);
910 summary_set_column_order(summaryview
);
912 g_object_unref(summaryview
->hbox_l
);
913 g_object_unref(summaryview
->statlabel_msgs
);
914 quicksearch_relayout(summaryview
->quicksearch
);
915 if (prefs_common
.show_searchbar
)
916 quicksearch_show(summaryview
->quicksearch
);
918 quicksearch_hide(summaryview
->quicksearch
);
921 static void summary_set_fonts(SummaryView
*summaryview
)
923 PangoFontDescription
*font_desc
;
926 font_desc
= pango_font_description_from_string(NORMAL_FONT
);
928 gtk_widget_modify_font(summaryview
->ctree
, font_desc
);
929 pango_font_description_free(font_desc
);
933 bold_style
= gtk_style_copy
934 (gtk_widget_get_style(summaryview
->ctree
));
936 if (prefs_common
.derive_from_normal_font
|| !BOLD_FONT
) {
937 font_desc
= pango_font_description_from_string(NORMAL_FONT
);
939 pango_font_description_free(bold_style
->font_desc
);
940 bold_style
->font_desc
= font_desc
;
942 pango_font_description_set_weight
943 (bold_style
->font_desc
, PANGO_WEIGHT_BOLD
);
945 font_desc
= pango_font_description_from_string(BOLD_FONT
);
947 pango_font_description_free(bold_style
->font_desc
);
948 bold_style
->font_desc
= font_desc
;
951 bold_marked_style
= gtk_style_copy(bold_style
);
952 bold_marked_style
->text
[GTK_STATE_NORMAL
] =
953 summaryview
->color_marked
;
954 bold_deleted_style
= gtk_style_copy(bold_style
);
955 bold_deleted_style
->text
[GTK_STATE_NORMAL
] =
956 summaryview
->color_dim
;
959 if (prefs_common
.derive_from_normal_font
|| !SMALL_FONT
) {
960 font_desc
= pango_font_description_new();
961 size
= pango_font_description_get_size
962 (gtk_widget_get_style(summaryview
->ctree
)->font_desc
);
963 pango_font_description_set_size(font_desc
, size
* PANGO_SCALE_SMALL
);
965 font_desc
= pango_font_description_from_string(SMALL_FONT
);
968 gtk_widget_modify_font(summaryview
->statlabel_folder
, font_desc
);
969 gtk_widget_modify_font(summaryview
->statlabel_select
, font_desc
);
970 gtk_widget_modify_font(summaryview
->statlabel_msgs
, font_desc
);
971 pango_font_description_free(font_desc
);
976 static void summary_set_folder_pixmap(SummaryView
*summaryview
, StockPixmap icon
)
979 if (!summaryview
->folder_pixmap_eventbox
) {
980 summaryview
->folder_pixmap_eventbox
= gtk_event_box_new();
981 gtk_widget_show(summaryview
->folder_pixmap_eventbox
);
982 gtk_box_pack_start(GTK_BOX(summaryview
->hbox_l
), summaryview
->folder_pixmap_eventbox
, FALSE
, FALSE
, 4);
983 gtk_box_reorder_child(GTK_BOX(summaryview
->hbox_l
), summaryview
->folder_pixmap_eventbox
, 0); /* search_toggle before */
984 g_signal_connect(G_OBJECT(summaryview
->folder_pixmap_eventbox
), "button_press_event",
985 G_CALLBACK(summary_folder_eventbox_pressed
),
988 if (summaryview
->folder_pixmap
)
989 gtk_widget_destroy(summaryview
->folder_pixmap
);
991 pixmap
= stock_pixmap_widget(icon
);
992 gtk_container_add(GTK_CONTAINER(summaryview
->folder_pixmap_eventbox
), pixmap
);
993 gtk_widget_show(pixmap
);
994 summaryview
->folder_pixmap
= pixmap
;
997 void summary_init(SummaryView
*summaryview
)
1001 gtk_widget_realize(summaryview
->ctree
);
1002 stock_pixbuf_gdk(STOCK_PIXMAP_MARK
, &markxpm
);
1003 stock_pixbuf_gdk(STOCK_PIXMAP_DELETED
, &deletedxpm
);
1004 stock_pixbuf_gdk(STOCK_PIXMAP_NEW
, &newxpm
);
1005 stock_pixbuf_gdk(STOCK_PIXMAP_UNREAD
, &unreadxpm
);
1006 stock_pixbuf_gdk(STOCK_PIXMAP_REPLIED
, &repliedxpm
);
1007 stock_pixbuf_gdk(STOCK_PIXMAP_FORWARDED
, &forwardedxpm
);
1008 stock_pixbuf_gdk(STOCK_PIXMAP_REPLIED_AND_FORWARDED
, &repliedandforwardedxpm
);
1009 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP
, &clipxpm
);
1010 stock_pixbuf_gdk(STOCK_PIXMAP_LOCKED
, &lockedxpm
);
1011 stock_pixbuf_gdk(STOCK_PIXMAP_IGNORETHREAD
, &ignorethreadxpm
);
1012 stock_pixbuf_gdk(STOCK_PIXMAP_WATCHTHREAD
, &watchthreadxpm
);
1013 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP_KEY
, &clipkeyxpm
);
1014 stock_pixbuf_gdk(STOCK_PIXMAP_KEY_SIGN
, &keysignxpm
);
1015 stock_pixbuf_gdk(STOCK_PIXMAP_KEY
, &keyxpm
);
1016 stock_pixbuf_gdk(STOCK_PIXMAP_GPG_SIGNED
, &gpgsignedxpm
);
1017 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP_GPG_SIGNED
, &clipgpgsignedxpm
);
1018 stock_pixbuf_gdk(STOCK_PIXMAP_SPAM
, &spamxpm
);
1019 stock_pixbuf_gdk(STOCK_PIXMAP_MOVED
, &movedxpm
);
1020 stock_pixbuf_gdk(STOCK_PIXMAP_COPIED
, &copiedxpm
);
1022 summary_set_fonts(summaryview
);
1024 summary_set_folder_pixmap(summaryview
, STOCK_PIXMAP_DIR_OPEN
);
1026 pixmap
= stock_pixmap_widget(STOCK_PIXMAP_QUICKSEARCH
);
1027 gtk_container_add (GTK_CONTAINER(summaryview
->toggle_search
), pixmap
);
1028 gtk_widget_show(pixmap
);
1029 summaryview
->quick_search_pixmap
= pixmap
;
1032 pixmap
= stock_pixmap_widget(STOCK_PIXMAP_SELECTION
);
1033 gtk_container_add(GTK_CONTAINER(summaryview
->multiple_sel_togbtn
), pixmap
);
1034 gtk_widget_show(pixmap
);
1035 summaryview
->multiple_sel_image
= pixmap
;
1038 /* Init summaryview prefs */
1039 summaryview
->sort_key
= SORT_BY_NONE
;
1040 summaryview
->sort_type
= SORT_ASCENDING
;
1042 /* Init summaryview extra data */
1043 summaryview
->simplify_subject_preg
= NULL
;
1044 summary_clear_list(summaryview
);
1045 summary_set_column_titles(summaryview
);
1046 summary_colorlabel_menu_create(summaryview
, FALSE
);
1047 summary_tags_menu_create(summaryview
, FALSE
);
1048 main_create_mailing_list_menu (summaryview
->mainwin
, NULL
);
1049 summary_set_menu_sensitive(summaryview
);
1051 summaryview
->header_menu_lock
= FALSE
;
1054 #define CURRENTLY_DISPLAYED(m) \
1055 ( (m->msgnum == displayed_msgnum) \
1056 && (!g_ascii_strcasecmp(m->folder->name,item->name)) )
1058 #define FOLDER_SHOWS_TO_HDR(i) \
1059 ( i && (folder_has_parent_of_type(i, F_OUTBOX) \
1060 || folder_has_parent_of_type(i, F_DRAFT) \
1061 || folder_has_parent_of_type(i, F_QUEUE)) )
1063 static void summary_switch_from_to(SummaryView
*summaryview
, FolderItem
*item
)
1065 gboolean show_from
= FALSE
, show_to
= FALSE
;
1066 gboolean showing_from
= FALSE
, showing_to
= FALSE
;
1067 gint from_pos
= 0, to_pos
= 0;
1068 SummaryColumnState
*col_state
= summaryview
->col_state
;
1069 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
1071 if (!item
|| ((prefs_common
.layout_mode
== VERTICAL_LAYOUT
|| prefs_common
.layout_mode
== SMALL_LAYOUT
) && prefs_common
.two_line_vert
) )
1073 if (FOLDER_SHOWS_TO_HDR(item
))
1078 from_pos
= summaryview
->col_pos
[S_COL_FROM
];
1079 to_pos
= summaryview
->col_pos
[S_COL_TO
];
1080 showing_from
= col_state
[from_pos
].visible
;
1081 showing_to
= col_state
[to_pos
].visible
;
1083 if (showing_from
&& showing_to
) {
1084 debug_print("showing both\n");
1088 if (!showing_from
&& !showing_to
) {
1089 debug_print("showing none\n");
1093 debug_print("showing %s %s, must show %s %s\n",
1094 showing_from
?"From":"",
1096 show_from
?"From":"",
1099 if (showing_from
== show_from
&& showing_to
== show_to
)
1101 /* else we'll switch both */
1103 debug_print("switching columns\n");
1104 col_state
[from_pos
].type
= S_COL_TO
;
1105 col_state
[from_pos
].visible
= show_to
;
1107 col_state
[to_pos
].type
= S_COL_FROM
;
1108 col_state
[to_pos
].visible
= show_from
;
1110 summaryview
->col_pos
[S_COL_TO
] = from_pos
;
1111 summaryview
->col_pos
[S_COL_FROM
] = to_pos
;
1113 gtk_cmclist_set_column_visibility
1114 (GTK_CMCLIST(ctree
), from_pos
, col_state
[from_pos
].visible
);
1115 gtk_cmclist_set_column_visibility
1116 (GTK_CMCLIST(ctree
), to_pos
, col_state
[to_pos
].visible
);
1118 summary_set_column_titles(summaryview
);
1121 static void summaryview_reset_recursive_folder_match(SummaryView
*summaryview
)
1125 for (cur
= summaryview
->recursive_matched_folders
; cur
!= NULL
; cur
= cur
->next
) {
1126 folderview_update_search_icon(cur
->data
, FALSE
);
1129 g_slist_free(summaryview
->recursive_matched_folders
);
1130 summaryview
->recursive_matched_folders
= NULL
;
1131 summaryview
->search_root_folder
= NULL
;
1134 static gboolean
summaryview_quicksearch_recursive_progress(gpointer data
, guint at
, guint matched
, guint total
)
1136 QuickSearch
*search
= (QuickSearch
*) data
;
1137 gint interval
= quicksearch_is_fast(search
) ? 5000 : 100;
1139 statusbar_progress_all(at
, total
, interval
);
1140 if (at
% interval
== 0)
1149 static void summaryview_quicksearch_recurse_step(SummaryView
*summaryview
, FolderItem
*item
)
1151 MsgInfoList
*msgs
= NULL
;
1152 gboolean result
= TRUE
;
1154 statusbar_print_all(_("Searching in %s... \n"),
1155 item
->path
? item
->path
: "(null)");
1156 folder_item_update_freeze();
1158 quicksearch_set_on_progress_cb(summaryview
->quicksearch
, summaryview_quicksearch_recursive_progress
, summaryview
->quicksearch
);
1159 if (!quicksearch_run_on_folder(summaryview
->quicksearch
, item
, &msgs
))
1162 result
= result
&& msgs
!= NULL
;
1165 procmsg_msg_list_free(msgs
);
1167 folder_item_update_thaw();
1168 statusbar_progress_all(0, 0, 0);
1169 statusbar_pop_all();
1172 summaryview
->recursive_matched_folders
= g_slist_prepend(
1173 summaryview
->recursive_matched_folders
, item
);
1175 folderview_update_search_icon(item
, TRUE
);
1179 static void summaryview_quicksearch_search_subfolders(SummaryView
*summaryview
, FolderItem
*folder_item
)
1181 FolderItem
*cur
= NULL
;
1182 GNode
*node
= folder_item
->node
->children
;
1184 if (!prefs_common
.summary_quicksearch_recurse
1185 || !quicksearch_has_sat_predicate(summaryview
->quicksearch
)
1186 || quicksearch_is_in_typing(summaryview
->quicksearch
))
1189 for (; node
!= NULL
; node
= node
->next
) {
1190 if (!quicksearch_has_sat_predicate(summaryview
->quicksearch
))
1193 cur
= FOLDER_ITEM(node
->data
);
1194 summaryview_quicksearch_recurse_step(summaryview
, cur
);
1195 if (cur
->node
->children
)
1196 summaryview_quicksearch_search_subfolders(summaryview
, cur
);
1200 static void summaryview_quicksearch_recurse(SummaryView
*summaryview
)
1202 if (!prefs_common
.summary_quicksearch_recurse
1203 || !quicksearch_has_sat_predicate(summaryview
->quicksearch
)
1204 || summaryview
->folder_item
== NULL
) {
1208 main_window_cursor_wait(summaryview
->mainwin
);
1210 summaryview_reset_recursive_folder_match(summaryview
);
1211 summaryview
->search_root_folder
= summaryview
->folder_item
;
1213 summaryview_quicksearch_search_subfolders(summaryview
, summaryview
->folder_item
);
1215 main_window_cursor_normal(summaryview
->mainwin
);
1219 static gboolean
summary_check_consistency(FolderItem
*item
, GSList
*mlist
)
1221 int u
= 0, n
= 0, m
= 0, t
= 0, r
= 0, f
= 0, l
= 0, i
= 0, w
= 0;
1224 for(cur
= mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= g_slist_next(cur
)) {
1225 MsgInfo
* msginfo
= (MsgInfo
*) cur
->data
;
1227 if (MSG_IS_NEW(msginfo
->flags
))
1229 if (MSG_IS_UNREAD(msginfo
->flags
))
1231 if (MSG_IS_MARKED(msginfo
->flags
))
1233 if (MSG_IS_REPLIED(msginfo
->flags
))
1235 if (MSG_IS_FORWARDED(msginfo
->flags
))
1237 if (MSG_IS_LOCKED(msginfo
->flags
))
1239 if (MSG_IS_IGNORE_THREAD(msginfo
->flags
))
1241 if (MSG_IS_WATCH_THREAD(msginfo
->flags
))
1244 if (t
!= item
->total_msgs
1245 || n
!= item
->new_msgs
1246 || u
!= item
->unread_msgs
1247 || m
!= item
->marked_msgs
1248 || r
!= item
->replied_msgs
1249 || f
!= item
->forwarded_msgs
1250 || l
!= item
->locked_msgs
1251 || i
!= item
->ignored_msgs
1252 || w
!= item
->watched_msgs
1253 || (m
== 0 && item
->unreadmarked_msgs
!= 0)
1254 || item
->unreadmarked_msgs
< 0) {
1255 debug_print("Inconsistency\n");
1256 folder_item_scan_full(item
, FALSE
);
1264 gboolean
summaryview_search_root_progress(gpointer data
, guint at
, guint matched
, guint total
)
1266 SummaryView
*summaryview
= (SummaryView
*) data
;
1268 gint interval
= quicksearch_is_fast(summaryview
->quicksearch
) ? 5000 : 100;
1270 statusbar_progress_all(at
, total
, interval
);
1272 if (at
% interval
== 0)
1278 gboolean
summary_show(SummaryView
*summaryview
, FolderItem
*item
, gboolean avoid_refresh
)
1280 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
1281 GtkCMCTreeNode
*node
= NULL
;
1282 GSList
*mlist
= NULL
;
1284 gboolean is_refresh
;
1285 guint selected_msgnum
= 0;
1286 guint displayed_msgnum
= 0;
1289 gboolean hidden_removed
= FALSE
;
1291 if (summary_is_locked(summaryview
)) return FALSE
;
1293 if (!summaryview
->mainwin
)
1296 summary_switch_from_to(summaryview
, item
);
1299 summary_lock(summaryview
);
1301 menu_set_sensitive_all(GTK_MENU_SHELL(summaryview
->popupmenu
), TRUE
);
1305 is_refresh
= (item
== summaryview
->folder_item
&& !avoid_refresh
) ? TRUE
: FALSE
;
1307 if (item
&& item
->folder
->klass
->item_opened
) {
1308 item
->folder
->klass
->item_opened(item
);
1312 main_create_mailing_list_menu (summaryview
->mainwin
, NULL
);
1313 if (prefs_common
.layout_mode
== SMALL_LAYOUT
) {
1315 mainwindow_enter_folder(summaryview
->mainwin
);
1316 gtk_widget_grab_focus(summaryview
->ctree
);
1320 if (!prefs_common
.summary_quicksearch_sticky
1321 && (!prefs_common
.summary_quicksearch_recurse
1322 || !quicksearch_has_sat_predicate(summaryview
->quicksearch
)
1323 || (item
&& !folder_is_child_of(item
, summaryview
->search_root_folder
)))
1324 && !quicksearch_is_running(summaryview
->quicksearch
)
1326 quicksearch_set(summaryview
->quicksearch
, prefs_common
.summary_quicksearch_type
, "");
1329 /* STATUSBAR_POP(summaryview->mainwin); */
1332 selected_msgnum
= summary_get_msgnum(summaryview
,
1333 summaryview
->selected
);
1334 displayed_msgnum
= summary_get_msgnum(summaryview
,
1335 summaryview
->displayed
);
1338 /* process the marks if any */
1340 (summaryview
->mainwin
->lock_count
== 0 &&
1341 (summaryview
->moved
> 0 || summaryview
->copied
> 0))) {
1343 gboolean changed
= FALSE
;
1345 val
= alertpanel(_("Process mark"),
1346 _("Some marks are left. Process them?"),
1347 GTK_STOCK_NO
, GTK_STOCK_YES
, GTK_STOCK_CANCEL
, ALERTFOCUS_FIRST
);
1348 if (G_ALERTALTERNATE
== val
) {
1349 summary_unlock(summaryview
);
1350 summary_execute(summaryview
);
1351 summary_lock(summaryview
);
1353 } else if (G_ALERTDEFAULT
== val
) {
1356 summary_unlock(summaryview
);
1361 if (changed
|| !quicksearch_has_sat_predicate(summaryview
->quicksearch
))
1362 folder_update_op_count();
1365 summary_freeze(summaryview
);
1367 summary_clear_list(summaryview
);
1370 if (!item
|| !item
->path
|| !folder_item_parent(item
) || item
->no_select
) {
1372 debug_print("empty folder (%p %s %p %d)\n",
1374 (item
&& item
->path
)?item
->path
:"(null)",
1375 item
?folder_item_parent(item
):0x0,
1376 item
?item
->no_select
:FALSE
);
1377 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadMessages", FALSE
);
1378 summary_set_hide_menu(summaryview
, "/Menu/View/HideDelMessages", FALSE
);
1379 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadThreads", FALSE
);
1380 summary_clear_all(summaryview
);
1381 summaryview
->folder_item
= item
;
1382 summary_thaw(summaryview
);
1383 summary_unlock(summaryview
);
1391 messageview_clear(summaryview
->messageview
);
1393 summaryview
->folder_item
= item
;
1394 item
->opened
= TRUE
;
1396 buf
= g_strdup_printf(_("Scanning folder (%s)..."), item
->path
);
1397 debug_print("%s\n", buf
);
1398 STATUSBAR_PUSH(summaryview
->mainwin
, buf
);
1401 main_window_cursor_wait(summaryview
->mainwin
);
1403 mlist
= folder_item_get_msg_list(item
);
1405 if (!summary_check_consistency(item
, mlist
)) {
1406 debug_print("reloading due to inconsistency\n");
1407 procmsg_msg_list_free(mlist
);
1408 mlist
= folder_item_get_msg_list(item
);
1411 if (quicksearch_has_sat_predicate(summaryview
->quicksearch
)) {
1412 procmsg_msg_list_free(mlist
);
1415 START_TIMING("quicksearch");
1417 statusbar_print_all(_("Searching in %s... \n"),
1418 summaryview
->folder_item
->path
?
1419 summaryview
->folder_item
->path
: "(null)");
1421 folder_item_update_freeze();
1423 quicksearch_set_on_progress_cb(summaryview
->quicksearch
, summaryview_search_root_progress
, summaryview
);
1424 quicksearch_run_on_folder(summaryview
->quicksearch
, summaryview
->folder_item
, &mlist
);
1426 folder_item_update_thaw();
1427 statusbar_progress_all(0, 0, 0);
1428 statusbar_pop_all();
1430 if (!quicksearch_has_sat_predicate(summaryview
->quicksearch
)) {
1431 debug_print("search cancelled!\n");
1432 summary_thaw(summaryview
);
1433 STATUSBAR_POP(summaryview
->mainwin
);
1434 main_window_cursor_normal(summaryview
->mainwin
);
1435 summary_unlock(summaryview
);
1437 summary_show(summaryview
, summaryview
->folder_item
, FALSE
);
1444 if ((summaryview
->folder_item
->hide_read_msgs
1445 || summaryview
->folder_item
->hide_del_msgs
1446 || summaryview
->folder_item
->hide_read_threads
) &&
1447 quicksearch_has_sat_predicate(summaryview
->quicksearch
) == FALSE
) {
1450 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadMessages",
1451 summaryview
->folder_item
->hide_read_msgs
);
1452 summary_set_hide_menu(summaryview
, "/Menu/View/HideDelMessages",
1453 summaryview
->folder_item
->hide_del_msgs
);
1454 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadThreads",
1455 summaryview
->folder_item
->hide_read_threads
);
1457 for(cur
= mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= g_slist_next(cur
)) {
1458 MsgInfo
* msginfo
= (MsgInfo
*) cur
->data
;
1460 if (!msginfo
->hidden
) {
1461 if (MSG_IS_DELETED(msginfo
->flags
) && summaryview
->folder_item
->hide_del_msgs
) {
1462 procmsg_msginfo_free(&msginfo
);
1465 if (summaryview
->folder_item
->hide_read_msgs
) {
1466 if (MSG_IS_UNREAD(msginfo
->flags
) &&
1467 !MSG_IS_IGNORE_THREAD(msginfo
->flags
))
1468 not_killed
= g_slist_prepend(not_killed
, msginfo
);
1469 else if (MSG_IS_MARKED(msginfo
->flags
) ||
1470 MSG_IS_LOCKED(msginfo
->flags
))
1471 not_killed
= g_slist_prepend(not_killed
, msginfo
);
1472 else if (is_refresh
&&
1473 (msginfo
->msgnum
== selected_msgnum
||
1474 msginfo
->msgnum
== displayed_msgnum
))
1475 not_killed
= g_slist_prepend(not_killed
, msginfo
);
1477 procmsg_msginfo_free(&msginfo
);
1479 not_killed
= g_slist_prepend(not_killed
, msginfo
);
1482 procmsg_msginfo_free(&msginfo
);
1484 hidden_removed
= TRUE
;
1485 g_slist_free(mlist
);
1488 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadMessages",
1490 summary_set_hide_menu(summaryview
, "/Menu/View/HideDelMessages",
1492 summary_set_hide_menu(summaryview
, "/Menu/View/HideReadThreads",
1496 if (!hidden_removed
) {
1497 START_TIMING("removing hidden");
1499 for(cur
= mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= g_slist_next(cur
)) {
1500 MsgInfo
* msginfo
= (MsgInfo
*) cur
->data
;
1502 if (!msginfo
->hidden
)
1503 not_killed
= g_slist_prepend(not_killed
, msginfo
);
1505 procmsg_msginfo_free(&msginfo
);
1507 g_slist_free(mlist
);
1512 STATUSBAR_POP(summaryview
->mainwin
);
1514 /* set ctree and hash table from the msginfo list, and
1515 create the thread */
1516 summary_set_ctree_from_list(summaryview
, mlist
, selected_msgnum
);
1518 g_slist_free(mlist
);
1521 if (!quicksearch_is_in_typing(summaryview
->quicksearch
)) {
1522 summaryview
->displayed
=
1523 summary_find_msg_by_msgnum(summaryview
,
1525 if (!summaryview
->displayed
)
1526 messageview_clear(summaryview
->messageview
);
1527 summary_unlock(summaryview
);
1529 if (quicksearch_is_running(summaryview
->quicksearch
))
1530 summary_select_by_msgnum(summaryview
, selected_msgnum
,
1531 OPEN_SELECTED_ON_SEARCH_RESULTS
);
1533 summary_select_by_msgnum(summaryview
, selected_msgnum
,
1536 summary_lock(summaryview
);
1537 if (!summaryview
->selected
) {
1538 /* no selected message - select first unread
1539 message, but do not display it */
1540 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1542 if (node
== NULL
&& GTK_CMCLIST(ctree
)->row_list
!= NULL
)
1543 node
= gtk_cmctree_node_nth
1545 item
->sort_type
== SORT_DESCENDING
1546 ? 0 : GTK_CMCLIST(ctree
)->rows
- 1);
1547 summary_unlock(summaryview
);
1549 if (quicksearch_is_running(summaryview
->quicksearch
))
1550 summary_select_node(summaryview
, node
,
1551 OPEN_SELECTED_ON_SEARCH_RESULTS
);
1553 summary_select_node(summaryview
, node
,
1554 OPEN_SELECTED_ON_FOLDER_OPEN
);
1556 summary_lock(summaryview
);
1559 /* just select first/last */
1560 if (GTK_CMCLIST(ctree
)->row_list
!= NULL
)
1561 node
= gtk_cmctree_node_nth
1563 item
->sort_type
== SORT_DESCENDING
1564 ? 0 : GTK_CMCLIST(ctree
)->rows
- 1);
1565 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_SEARCH_RESULTS
);
1568 /* backward compat */
1570 gboolean set
= FALSE
, stop
= FALSE
;
1571 for (i
= 0; i
< 6; i
++) {
1572 EntryAction act
= prefs_common
.summary_select_prio
[i
];
1574 if (act
!= ACTION_UNSET
) {
1580 prefs_summary_open_set_defaults();
1582 for (i
= 0; i
< 6 && node
== NULL
; i
++) {
1583 EntryAction act
= prefs_common
.summary_select_prio
[i
];
1586 case ACTION_OLDEST_MARKED
:
1587 if (summaryview
->sort_type
== SORT_ASCENDING
)
1588 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1591 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1594 case ACTION_NEWEST_MARKED
:
1595 if (summaryview
->sort_type
== SORT_ASCENDING
)
1596 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1599 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1602 case ACTION_OLDEST_NEW
:
1603 if (summaryview
->sort_type
== SORT_ASCENDING
)
1604 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1607 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1610 case ACTION_NEWEST_NEW
:
1611 if (summaryview
->sort_type
== SORT_ASCENDING
)
1612 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1615 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1618 case ACTION_OLDEST_UNREAD
:
1619 if (summaryview
->sort_type
== SORT_ASCENDING
)
1620 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1623 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1626 case ACTION_NEWEST_UNREAD
:
1627 if (summaryview
->sort_type
== SORT_ASCENDING
)
1628 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1631 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1634 case ACTION_LAST_OPENED
:
1635 if (summaryview
->folder_item
) {
1636 node
= summary_find_msg_by_msgnum(summaryview
,
1637 summaryview
->folder_item
->last_seen
);
1640 case ACTION_NEWEST_LIST
:
1641 if (GTK_CMCLIST(ctree
)->row_list
!= NULL
) {
1642 node
= gtk_cmctree_node_nth
1644 item
->sort_type
== SORT_DESCENDING
1645 ? 0 : GTK_CMCLIST(ctree
)->rows
- 1);
1648 case ACTION_OLDEST_LIST
:
1649 if (GTK_CMCLIST(ctree
)->row_list
!= NULL
) {
1650 node
= gtk_cmctree_node_nth
1652 item
->sort_type
== SORT_ASCENDING
1653 ? 0 : GTK_CMCLIST(ctree
)->rows
- 1);
1656 case ACTION_NOTHING
:
1667 summary_unlock(summaryview
);
1670 summary_select_node(summaryview
, node
,
1671 OPEN_SELECTED_ON_FOLDER_OPEN
);
1673 summary_lock(summaryview
);
1676 summary_status_show(summaryview
);
1677 summary_set_menu_sensitive(summaryview
);
1678 toolbar_main_set_sensitive(summaryview
->mainwin
);
1680 summary_thaw(summaryview
);
1682 STATUSBAR_PUSH(summaryview
->mainwin
, _("Done."));
1683 STATUSBAR_POP(summaryview
->mainwin
);
1684 main_window_cursor_normal(summaryview
->mainwin
);
1685 summary_unlock(summaryview
);
1691 #undef CURRENTLY_DISPLAYED
1693 static void summary_cancel_mark_read_timeout(SummaryView
*summaryview
) {
1694 if (summaryview
->mark_as_read_timeout_tag
!= 0) {
1695 g_source_remove(summaryview
->mark_as_read_timeout_tag
);
1696 summaryview
->mark_as_read_timeout_tag
= 0;
1700 void summary_clear_list(SummaryView
*summaryview
)
1702 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
1705 summary_freeze(summaryview
);
1707 gtk_cmctree_pre_recursive(GTK_CMCTREE(summaryview
->ctree
),
1708 NULL
, summary_free_msginfo_func
, NULL
);
1710 if (summaryview
->folder_item
) {
1711 summaryview
->folder_item
->opened
= FALSE
;
1712 summaryview
->folder_item
= NULL
;
1715 summary_cancel_mark_read_timeout(summaryview
);
1717 summaryview
->display_msg
= FALSE
;
1719 summaryview
->selected
= NULL
;
1720 summaryview
->displayed
= NULL
;
1721 summaryview
->total_size
= 0;
1722 summaryview
->deleted
= summaryview
->moved
= 0;
1723 summaryview
->copied
= 0;
1724 if (summaryview
->msgid_table
) {
1725 g_hash_table_destroy(summaryview
->msgid_table
);
1726 summaryview
->msgid_table
= NULL
;
1728 if (summaryview
->subject_table
) {
1729 g_hash_table_destroy(summaryview
->subject_table
);
1730 summaryview
->subject_table
= NULL
;
1732 summaryview
->mlist
= NULL
;
1734 gtk_cmclist_clear(clist
);
1735 if (summaryview
->col_pos
[S_COL_SUBJECT
] == N_SUMMARY_COLS
- 1) {
1736 optimal_width
= gtk_cmclist_optimal_column_width
1737 (clist
, summaryview
->col_pos
[S_COL_SUBJECT
]);
1738 gtk_cmclist_set_column_width
1739 (clist
, summaryview
->col_pos
[S_COL_SUBJECT
],
1743 summary_thaw(summaryview
);
1746 void summary_clear_all(SummaryView
*summaryview
)
1748 messageview_clear(summaryview
->messageview
);
1749 summary_clear_list(summaryview
);
1750 summary_set_menu_sensitive(summaryview
);
1751 toolbar_main_set_sensitive(summaryview
->mainwin
);
1752 summary_status_show(summaryview
);
1755 void summary_lock(SummaryView
*summaryview
)
1757 summaryview
->lock_count
++;
1760 void summary_unlock(SummaryView
*summaryview
)
1762 if (summaryview
->lock_count
)
1763 summaryview
->lock_count
--;
1766 gboolean
summary_is_locked(SummaryView
*summaryview
)
1768 return summaryview
->lock_count
> 0;
1771 SummarySelection
summary_get_selection_type(SummaryView
*summaryview
)
1773 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
1774 SummarySelection selection
;
1776 if (!clist
->row_list
)
1777 selection
= SUMMARY_NONE
;
1778 else if (!clist
->selection
)
1779 selection
= SUMMARY_SELECTED_NONE
;
1780 else if (!clist
->selection
->next
)
1781 selection
= SUMMARY_SELECTED_SINGLE
;
1783 selection
= SUMMARY_SELECTED_MULTIPLE
;
1789 *\return MsgInfo * Selected message if there's one selected;
1790 * if multiple selected, or none, return NULL.
1792 MsgInfo
*summary_get_selected_msg(SummaryView
*summaryview
)
1794 /* summaryview->selected may be valid when multiple
1795 * messages were selected */
1796 GList
*sellist
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
1798 if (sellist
== NULL
|| sellist
->next
)
1801 return GTKUT_CTREE_NODE_GET_ROW_DATA(sellist
->data
);
1804 GSList
*summary_get_selected_msg_list(SummaryView
*summaryview
)
1806 GSList
*mlist
= NULL
;
1810 for (cur
= GTK_CMCLIST(summaryview
->ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
;
1812 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(cur
->data
);
1813 mlist
= g_slist_prepend(mlist
,
1814 procmsg_msginfo_new_ref(msginfo
));
1817 mlist
= g_slist_reverse(mlist
);
1822 void summary_set_menu_sensitive(SummaryView
*summaryview
)
1824 SensitiveCondMask state
;
1826 main_window_set_menu_sensitive(summaryview
->mainwin
);
1828 state
= main_window_get_current_state(summaryview
->mainwin
);
1830 #define SET_SENSITIVE(entry_str, ...) \
1832 SensitiveCondMask cond = main_window_get_mask(__VA_ARGS__, -1); \
1833 cm_menu_set_sensitive_full(summaryview->mainwin->ui_manager, \
1834 (const gchar *) entry_str, \
1835 ((cond & state) == cond)); \
1837 SET_SENSITIVE("Menus/SummaryViewPopup/Reedit", M_ALLOW_REEDIT
);
1838 SET_SENSITIVE("Menus/SummaryViewPopup/Reply", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1839 #ifndef GENERIC_UMPC
1840 SET_SENSITIVE("Menus/SummaryViewPopup/ReplyTo", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1841 SET_SENSITIVE("Menus/SummaryViewPopup/ReplyTo/All", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1842 SET_SENSITIVE("Menus/SummaryViewPopup/ReplyTo/Sender", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1843 SET_SENSITIVE("Menus/SummaryViewPopup/ReplyTo/MailingList", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1846 SET_SENSITIVE("Menus/SummaryViewPopup/Forward", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1847 #ifndef GENERIC_UMPC
1848 SET_SENSITIVE("Menus/SummaryViewPopup/ForwardAtt", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1849 SET_SENSITIVE("Menus/SummaryViewPopup/Redirect", M_HAVE_ACCOUNT
, M_TARGET_EXIST
);
1852 SET_SENSITIVE("Menus/SummaryViewPopup/Move", M_TARGET_EXIST
, M_ALLOW_DELETE
, M_NOT_NEWS
);
1853 SET_SENSITIVE("Menus/SummaryViewPopup/Copy", M_TARGET_EXIST
, M_EXEC
);
1854 SET_SENSITIVE("Menus/SummaryViewPopup/Trash", M_TARGET_EXIST
, M_ALLOW_DELETE
, M_NOT_NEWS
, M_NOT_TRASH
);
1855 #ifndef GENERIC_UMPC
1856 SET_SENSITIVE("Menus/SummaryViewPopup/Delete", M_TARGET_EXIST
, M_ALLOW_DELETE
);
1859 SET_SENSITIVE("Menus/SummaryViewPopup/Mark", M_TARGET_EXIST
);
1860 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/Mark", M_TARGET_EXIST
);
1861 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/Unmark", M_TARGET_EXIST
);
1862 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/MarkRead", M_TARGET_EXIST
);
1863 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/MarkUnread", M_TARGET_EXIST
);
1864 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/MarkAllRead", M_TARGET_EXIST
);
1865 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/MarkAllUnread", M_TARGET_EXIST
);
1866 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/IgnoreThread", M_TARGET_EXIST
);
1867 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/UnignoreThread", M_TARGET_EXIST
);
1868 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/WatchThread", M_TARGET_EXIST
);
1869 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/UnwatchThread", M_TARGET_EXIST
);
1870 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/Lock", M_TARGET_EXIST
);
1871 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/Unlock", M_TARGET_EXIST
);
1872 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/MarkSpam", M_TARGET_EXIST
, M_CAN_LEARN_SPAM
);
1873 SET_SENSITIVE("Menus/SummaryViewPopup/Mark/MarkHam", M_TARGET_EXIST
, M_CAN_LEARN_SPAM
);
1874 SET_SENSITIVE("Menus/SummaryViewPopup/ColorLabel", M_TARGET_EXIST
);
1875 SET_SENSITIVE("Menus/SummaryViewPopup/Tags", M_TARGET_EXIST
);
1877 #ifndef GENERIC_UMPC
1878 SET_SENSITIVE("Menus/SummaryViewPopup/AddSenderToAB", M_SINGLE_TARGET_EXIST
);
1880 SET_SENSITIVE("Menus/SummaryViewPopup/CreateFilterRule", M_SINGLE_TARGET_EXIST
, M_UNLOCKED
);
1881 #ifndef GENERIC_UMPC
1882 SET_SENSITIVE("Menus/SummaryViewPopup/CreateProcessingRule", M_SINGLE_TARGET_EXIST
, M_UNLOCKED
);
1885 SET_SENSITIVE("Menus/SummaryViewPopup/View", M_SINGLE_TARGET_EXIST
);
1886 SET_SENSITIVE("Menus/SummaryViewPopup/View/OpenNewWindow", M_SINGLE_TARGET_EXIST
);
1887 SET_SENSITIVE("Menus/SummaryViewPopup/View/MessageSource", M_SINGLE_TARGET_EXIST
);
1888 #ifndef GENERIC_UMPC
1889 SET_SENSITIVE("Menus/SummaryViewPopup/View/AllHeaders", M_SINGLE_TARGET_EXIST
);
1891 SET_SENSITIVE("Menus/SummaryViewPopup/SaveAs", M_TARGET_EXIST
);
1892 #ifndef GENERIC_UMPC
1893 SET_SENSITIVE("Menus/SummaryViewPopup/Print", M_TARGET_EXIST
);
1895 #undef SET_SENSITIVE
1897 summary_lock(summaryview
);
1898 #ifndef GENERIC_UMPC
1899 if (summaryview
->messageview
1900 && summaryview
->messageview
->mimeview
1901 && summaryview
->messageview
->mimeview
->textview
)
1902 cm_toggle_menu_set_active_full(summaryview
->mainwin
->ui_manager
, "Menus/SummaryViewPopup/View/AllHeaders",
1903 prefs_common
.show_all_headers
);
1905 summary_unlock(summaryview
);
1907 void summary_select_prev(SummaryView
*summaryview
)
1909 GtkCMCTreeNode
*node
= summaryview
->selected
;
1910 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
1912 if (summaryview
->sort_type
== SORT_ASCENDING
)
1913 node
= gtkut_ctree_node_prev(ctree
, node
);
1915 node
= gtkut_ctree_node_next(ctree
, node
);
1917 if (node
&& node
!= summaryview
->selected
)
1918 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
1921 void summary_select_next(SummaryView
*summaryview
)
1923 GtkCMCTreeNode
*node
= summaryview
->selected
;
1924 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
1926 if (summaryview
->sort_type
== SORT_ASCENDING
)
1927 node
= gtkut_ctree_node_next(ctree
, node
);
1929 node
= gtkut_ctree_node_prev(ctree
, node
);
1931 if (node
&& node
!= summaryview
->selected
)
1932 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
1935 void summary_select_prev_unread(SummaryView
*summaryview
)
1937 GtkCMCTreeNode
*node
;
1939 if (summaryview
->sort_type
== SORT_ASCENDING
)
1940 node
= summary_find_prev_flagged_msg
1941 (summaryview
, summaryview
->selected
, MSG_UNREAD
, TRUE
);
1943 node
= summary_find_next_flagged_msg
1944 (summaryview
, summaryview
->selected
, MSG_UNREAD
, TRUE
);
1946 if (!node
|| node
== summaryview
->selected
) {
1949 switch (prefs_common
.next_unread_msg_dialog
) {
1950 case NEXTUNREADMSGDIALOG_ALWAYS
:
1951 val
= alertpanel(_("No more unread messages"),
1952 _("No unread message found. "
1953 "Search from the end?"),
1954 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
1956 case NEXTUNREADMSGDIALOG_ASSUME_YES
:
1957 val
= G_ALERTALTERNATE
;
1959 case NEXTUNREADMSGDIALOG_ASSUME_NO
:
1960 val
= !G_ALERTALTERNATE
;
1964 _("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n"));
1966 if (val
!= G_ALERTALTERNATE
) return;
1967 if (summaryview
->sort_type
== SORT_ASCENDING
)
1968 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
1971 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
1976 alertpanel_notice(_("No unread messages."));
1978 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
1981 void summary_select_next_unread(SummaryView
*summaryview
)
1983 GtkCMCTreeNode
*node
= summaryview
->selected
;
1985 if (summaryview
->sort_type
== SORT_ASCENDING
)
1986 node
= summary_find_next_flagged_msg
1987 (summaryview
, node
, MSG_UNREAD
, TRUE
);
1989 node
= summary_find_prev_flagged_msg
1990 (summaryview
, node
, MSG_UNREAD
, TRUE
);
1993 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
1997 switch (prefs_common
.next_unread_msg_dialog
) {
1998 case NEXTUNREADMSGDIALOG_ALWAYS
:
1999 val
= alertpanel(_("No more unread messages"),
2000 _("No unread message found. "
2001 "Go to next folder?"),
2002 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
2004 case NEXTUNREADMSGDIALOG_ASSUME_YES
:
2005 val
= G_ALERTALTERNATE
;
2007 case NEXTUNREADMSGDIALOG_ASSUME_NO
:
2012 _("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n"));
2015 if (val
== G_ALERTALTERNATE
)
2016 folderview_select_next_with_flag(summaryview
->folderview
, MSG_UNREAD
);
2020 void summary_select_prev_new(SummaryView
*summaryview
)
2022 GtkCMCTreeNode
*node
;
2024 if (summaryview
->sort_type
== SORT_ASCENDING
)
2025 node
= summary_find_prev_flagged_msg
2026 (summaryview
, summaryview
->selected
, MSG_NEW
, TRUE
);
2028 node
= summary_find_next_flagged_msg
2029 (summaryview
, summaryview
->selected
, MSG_NEW
, TRUE
);
2031 if (!node
|| node
== summaryview
->selected
) {
2034 switch (prefs_common
.next_unread_msg_dialog
) {
2035 case NEXTUNREADMSGDIALOG_ALWAYS
:
2036 val
= alertpanel(_("No more new messages"),
2037 _("No new message found. "
2038 "Search from the end?"),
2039 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
2041 case NEXTUNREADMSGDIALOG_ASSUME_YES
:
2042 val
= G_ALERTALTERNATE
;
2044 case NEXTUNREADMSGDIALOG_ASSUME_NO
:
2045 val
= !G_ALERTALTERNATE
;
2049 _("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n"));
2051 if (val
!= G_ALERTALTERNATE
) return;
2052 if (summaryview
->sort_type
== SORT_ASCENDING
)
2053 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
2056 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
2061 alertpanel_notice(_("No new messages."));
2063 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2066 void summary_select_next_new(SummaryView
*summaryview
)
2068 GtkCMCTreeNode
*node
= summaryview
->selected
;
2070 if (summaryview
->sort_type
== SORT_ASCENDING
)
2071 node
= summary_find_next_flagged_msg
2072 (summaryview
, node
, MSG_NEW
, TRUE
);
2074 node
= summary_find_prev_flagged_msg
2075 (summaryview
, node
, MSG_NEW
, TRUE
);
2078 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2082 switch (prefs_common
.next_unread_msg_dialog
) {
2083 case NEXTUNREADMSGDIALOG_ALWAYS
:
2084 val
= alertpanel(_("No more new messages"),
2085 _("No new message found. "
2086 "Go to next folder?"),
2087 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
2089 case NEXTUNREADMSGDIALOG_ASSUME_YES
:
2090 val
= G_ALERTALTERNATE
;
2092 case NEXTUNREADMSGDIALOG_ASSUME_NO
:
2097 _("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n"));
2099 if (val
== G_ALERTALTERNATE
)
2100 folderview_select_next_with_flag(summaryview
->folderview
, MSG_NEW
);
2104 void summary_select_prev_marked(SummaryView
*summaryview
)
2106 GtkCMCTreeNode
*node
;
2108 if (summaryview
->sort_type
== SORT_ASCENDING
)
2109 node
= summary_find_prev_flagged_msg
2110 (summaryview
, summaryview
->selected
, MSG_MARKED
, TRUE
);
2112 node
= summary_find_next_flagged_msg
2113 (summaryview
, summaryview
->selected
, MSG_MARKED
, TRUE
);
2118 val
= alertpanel(_("No more marked messages"),
2119 _("No marked message found. "
2120 "Search from the end?"),
2121 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
2122 if (val
!= G_ALERTALTERNATE
) return;
2123 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
2128 alertpanel_notice(_("No marked messages."));
2130 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2133 void summary_select_next_marked(SummaryView
*summaryview
)
2135 GtkCMCTreeNode
*node
= summaryview
->selected
;
2137 if (summaryview
->sort_type
== SORT_ASCENDING
)
2138 node
= summary_find_next_flagged_msg
2139 (summaryview
, node
, MSG_MARKED
, TRUE
);
2141 node
= summary_find_prev_flagged_msg
2142 (summaryview
, node
, MSG_MARKED
, TRUE
);
2145 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2149 switch (prefs_common
.next_unread_msg_dialog
) {
2150 case NEXTUNREADMSGDIALOG_ALWAYS
:
2151 val
= alertpanel(_("No more marked messages"),
2152 _("No marked message found. "
2153 "Go to next folder?"),
2154 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
2156 case NEXTUNREADMSGDIALOG_ASSUME_YES
:
2157 val
= G_ALERTALTERNATE
;
2159 case NEXTUNREADMSGDIALOG_ASSUME_NO
:
2164 _("Internal error: unexpected value for prefs_common.next_unread_msg_dialog\n"));
2166 if (val
== G_ALERTALTERNATE
)
2167 folderview_select_next_with_flag(summaryview
->folderview
, MSG_MARKED
);
2171 void summary_select_prev_labeled(SummaryView
*summaryview
)
2173 GtkCMCTreeNode
*node
;
2175 if (summaryview
->sort_type
== SORT_ASCENDING
)
2176 node
= summary_find_prev_flagged_msg
2177 (summaryview
, summaryview
->selected
, MSG_CLABEL_FLAG_MASK
, TRUE
);
2179 node
= summary_find_next_flagged_msg
2180 (summaryview
, summaryview
->selected
, MSG_CLABEL_FLAG_MASK
, TRUE
);
2185 val
= alertpanel(_("No more labeled messages"),
2186 _("No labeled message found. "
2187 "Search from the end?"),
2188 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
2189 if (val
!= G_ALERTALTERNATE
) return;
2190 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
2191 MSG_CLABEL_FLAG_MASK
, TRUE
);
2195 alertpanel_notice(_("No labeled messages."));
2197 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2200 void summary_select_next_labeled(SummaryView
*summaryview
)
2202 GtkCMCTreeNode
*node
;
2204 if (summaryview
->sort_type
== SORT_ASCENDING
)
2205 node
= summary_find_next_flagged_msg
2206 (summaryview
, summaryview
->selected
, MSG_CLABEL_FLAG_MASK
, TRUE
);
2208 node
= summary_find_prev_flagged_msg
2209 (summaryview
, summaryview
->selected
, MSG_CLABEL_FLAG_MASK
, TRUE
);
2214 val
= alertpanel(_("No more labeled messages"),
2215 _("No labeled message found. "
2216 "Search from the beginning?"),
2217 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_SECOND
);
2218 if (val
!= G_ALERTALTERNATE
) return;
2219 if (summaryview
->sort_type
== SORT_ASCENDING
)
2220 node
= summary_find_next_flagged_msg(summaryview
, NULL
,
2221 MSG_CLABEL_FLAG_MASK
, TRUE
);
2223 node
= summary_find_prev_flagged_msg(summaryview
, NULL
,
2224 MSG_CLABEL_FLAG_MASK
, TRUE
);
2228 alertpanel_notice(_("No labeled messages."));
2230 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2233 void summary_select_parent(SummaryView
*summaryview
)
2235 GtkCMCTreeNode
*node
= NULL
;
2237 if (summaryview
->selected
)
2238 node
= GTK_CMCTREE_ROW(summaryview
->selected
)->parent
;
2240 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_PREVNEXT
);
2243 void summary_select_by_msgnum(SummaryView
*summaryview
, guint msgnum
,
2246 GtkCMCTreeNode
*node
;
2248 node
= summary_find_msg_by_msgnum(summaryview
, msgnum
);
2249 summary_select_node(summaryview
, node
, show
);
2252 void summary_select_by_msg_list(SummaryView
*summaryview
, GSList
*msginfos
)
2255 GSList
*msgnum_list
, *walk
;
2256 gboolean froze
= FALSE
;
2258 ctree
= GTK_CMCTREE(summaryview
->ctree
);
2260 msgnum_list
= procmsg_get_number_list_for_msgs(msginfos
);
2262 START_LONG_OPERATION(summaryview
, FALSE
);
2263 for(walk
= msgnum_list
; walk
; walk
= walk
->next
) {
2264 GtkCMCTreeNode
*node
;
2265 node
= summary_find_msg_by_msgnum(summaryview
, GPOINTER_TO_UINT(walk
->data
));
2267 gtk_cmctree_select(ctree
, node
);
2269 END_LONG_OPERATION(summaryview
);
2270 g_slist_free(msgnum_list
);
2273 typedef struct _PostponedSelectData
2276 GtkCMCTreeNode
*row
;
2277 GtkCMCTreeNode
*node
;
2280 SummaryView
*summaryview
;
2281 gboolean display_msg
;
2282 } PostponedSelectData
;
2284 static gboolean
summary_select_retry(void *data
)
2286 PostponedSelectData
*psdata
= (PostponedSelectData
*)data
;
2287 debug_print("trying again\n");
2289 summary_selected(psdata
->ctree
, psdata
->row
,
2290 psdata
->column
, psdata
->summaryview
);
2291 else if (psdata
->node
)
2292 summary_select_node(psdata
->summaryview
, psdata
->node
,
2293 psdata
->display_msg
);
2299 * summary_select_node:
2300 * @summaryview: Summary view.
2301 * @node: Summary tree node.
2302 * @display_msg: whether to also display the message
2304 * Select @node (bringing it into view by scrolling and expanding its
2305 * thread, if necessary) and unselect all others.
2308 void summary_select_node(SummaryView
*summaryview
, GtkCMCTreeNode
*node
,
2309 gboolean display_msg
)
2311 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2313 /* If msgview is hidden, we never want to automatically display
2314 * a selected message, since that would unhide the msgview. */
2315 if (!messageview_is_visible(summaryview
->messageview
))
2316 display_msg
= FALSE
;
2318 if (summary_is_locked(summaryview
)
2319 && !GTK_SCTREE(ctree
)->selecting_range
2320 && summaryview
->messageview
->mimeview
2321 && summaryview
->messageview
->mimeview
->type
== MIMEVIEW_TEXT
2322 && summaryview
->messageview
->mimeview
->textview
->loading
) {
2323 PostponedSelectData
*data
= g_new0(PostponedSelectData
, 1);
2324 summaryview
->messageview
->mimeview
->textview
->stop_loading
= TRUE
;
2326 data
->ctree
= ctree
;
2329 data
->summaryview
= summaryview
;
2330 data
->display_msg
= display_msg
;
2331 debug_print("postponing open of message till end of load\n");
2332 g_timeout_add(100, summary_select_retry
, data
);
2335 if (summary_is_locked(summaryview
)) {
2338 if (!summaryview
->folder_item
)
2341 gtkut_ctree_expand_parent_all(ctree
, node
);
2343 summary_lock(summaryview
);
2345 summary_unlock(summaryview
);
2347 /* If quicksearch has focus, let's keep it there. */
2348 if (!quicksearch_has_focus(summaryview
->quicksearch
) ||
2349 quicksearch_is_running(summaryview
->quicksearch
))
2350 summary_grab_focus(summaryview
);
2352 gtkut_ctree_node_move_if_on_the_edge(ctree
, node
, -1);
2354 if (display_msg
&& summaryview
->displayed
== node
)
2355 summaryview
->displayed
= NULL
;
2356 summaryview
->display_msg
= display_msg
;
2357 gtk_sctree_select(GTK_SCTREE(ctree
), node
);
2358 if (summaryview
->selected
== NULL
)
2359 summaryview
->selected
= node
;
2363 guint
summary_get_msgnum(SummaryView
*summaryview
, GtkCMCTreeNode
*node
)
2365 GtkCMCTree
*ctree
=NULL
;
2370 ctree
= GTK_CMCTREE(summaryview
->ctree
);
2373 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2375 return msginfo
->msgnum
;
2380 static GtkCMCTreeNode
*summary_find_prev_msg(SummaryView
*summaryview
,
2381 GtkCMCTreeNode
*current_node
,
2382 gboolean start_from_prev
)
2384 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2385 GtkCMCTreeNode
*node
;
2389 if (start_from_prev
)
2390 node
= gtkut_ctree_node_prev(ctree
, current_node
);
2392 node
= current_node
;
2394 node
= gtk_cmctree_node_nth(ctree
, GTK_CMCLIST(ctree
)->rows
- 1);
2396 for (; node
!= NULL
; node
= gtkut_ctree_node_prev(ctree
, node
)) {
2397 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2398 if (msginfo
&& !MSG_IS_DELETED(msginfo
->flags
)) break;
2404 static GtkCMCTreeNode
*summary_find_next_msg(SummaryView
*summaryview
,
2405 GtkCMCTreeNode
*current_node
,
2406 gboolean start_from_next
)
2408 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2409 GtkCMCTreeNode
*node
;
2413 if (start_from_next
)
2414 node
= gtkut_ctree_node_next(ctree
, current_node
);
2416 node
= current_node
;
2418 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
2420 for (; node
!= NULL
; node
= gtkut_ctree_node_next(ctree
, node
)) {
2421 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2422 if (msginfo
&& !MSG_IS_DELETED(msginfo
->flags
)
2423 && !MSG_IS_MOVE(msginfo
->flags
)) break;
2429 static GtkCMCTreeNode
*summary_find_prev_flagged_msg(SummaryView
*summaryview
,
2430 GtkCMCTreeNode
*current_node
,
2432 gboolean start_from_prev
)
2434 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2435 GtkCMCTreeNode
*node
;
2439 if (start_from_prev
)
2440 node
= gtkut_ctree_node_prev(ctree
, current_node
);
2442 node
= current_node
;
2444 node
= gtk_cmctree_node_nth(ctree
, GTK_CMCLIST(ctree
)->rows
- 1);
2446 for (; node
!= NULL
; node
= gtkut_ctree_node_prev(ctree
, node
)) {
2447 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2448 if (msginfo
&& (msginfo
->flags
.perm_flags
& flags
) != 0) break;
2454 static GtkCMCTreeNode
*summary_find_next_flagged_msg(SummaryView
*summaryview
,
2455 GtkCMCTreeNode
*current_node
,
2457 gboolean start_from_next
)
2459 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2460 GtkCMCTreeNode
*node
;
2464 if (start_from_next
)
2465 node
= gtkut_ctree_node_next(ctree
, current_node
);
2467 node
= current_node
;
2469 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
2471 for (; node
!= NULL
; node
= gtkut_ctree_node_next(ctree
, node
)) {
2472 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2473 /* Find msg with matching flags but ignore messages with
2474 ignore flags, if searching for new or unread messages */
2475 if ((msginfo
&& (msginfo
->flags
.perm_flags
& flags
) != 0) &&
2476 !(((flags
& (MSG_NEW
| MSG_UNREAD
)) != 0) && MSG_IS_IGNORE_THREAD(msginfo
->flags
))
2484 static GtkCMCTreeNode
*summary_find_msg_by_msgnum(SummaryView
*summaryview
,
2487 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2488 GtkCMCTreeNode
*node
;
2491 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
2493 for (; node
!= NULL
; node
= gtkut_ctree_node_next(ctree
, node
)) {
2494 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2495 if (msginfo
&& msginfo
->msgnum
== msgnum
) break;
2501 static guint
attract_hash_func(gconstpointer key
)
2507 Xstrdup_a(str
, (const gchar
*)key
, return 0);
2514 for (p
+= 1; *p
!= '\0'; p
++)
2515 h
= (h
<< 5) - h
+ *p
;
2521 static gint
attract_compare_func(gconstpointer a
, gconstpointer b
)
2523 return subject_compare((const gchar
*)a
, (const gchar
*)b
) == 0;
2526 void summary_attract_by_subject(SummaryView
*summaryview
)
2528 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2529 GtkCMCList
*clist
= GTK_CMCLIST(ctree
);
2530 GtkCMCTreeNode
*src_node
;
2531 GtkCMCTreeNode
*dst_node
, *sibling
;
2532 GtkCMCTreeNode
*tmp
;
2533 MsgInfo
*src_msginfo
, *dst_msginfo
;
2534 GHashTable
*subject_table
;
2536 debug_print("Attracting messages by subject...\n");
2537 STATUSBAR_PUSH(summaryview
->mainwin
,
2538 _("Attracting messages by subject..."));
2540 main_window_cursor_wait(summaryview
->mainwin
);
2541 summary_freeze(summaryview
);
2543 subject_table
= g_hash_table_new(attract_hash_func
,
2544 attract_compare_func
);
2546 for (src_node
= GTK_CMCTREE_NODE(clist
->row_list
);
2549 tmp
= GTK_CMCTREE_ROW(src_node
)->sibling
;
2550 src_msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(src_node
);
2551 if (!src_msginfo
) continue;
2552 if (!src_msginfo
->subject
) continue;
2554 /* find attracting node */
2555 dst_node
= g_hash_table_lookup(subject_table
,
2556 src_msginfo
->subject
);
2559 dst_msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(dst_node
);
2561 /* if the time difference is more than 20 days,
2563 if (ABS(src_msginfo
->date_t
- dst_msginfo
->date_t
)
2564 > 60 * 60 * 24 * 20)
2567 sibling
= GTK_CMCTREE_ROW(dst_node
)->sibling
;
2568 if (src_node
!= sibling
)
2569 gtk_cmctree_move(ctree
, src_node
, NULL
, sibling
);
2572 g_hash_table_insert(subject_table
,
2573 src_msginfo
->subject
, src_node
);
2576 g_hash_table_destroy(subject_table
);
2578 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
2580 summary_thaw(summaryview
);
2582 debug_print("Attracting messages by subject done.\n");
2583 STATUSBAR_POP(summaryview
->mainwin
);
2585 main_window_cursor_normal(summaryview
->mainwin
);
2588 static void summary_free_msginfo_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
2591 MsgInfo
*msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2594 procmsg_msginfo_free(&msginfo
);
2597 static void summary_set_marks_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
2600 SummaryView
*summaryview
= data
;
2603 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
2605 cm_return_if_fail(msginfo
!= NULL
);
2607 if (MSG_IS_DELETED(msginfo
->flags
))
2608 summaryview
->deleted
++;
2610 summaryview
->total_size
+= msginfo
->size
;
2612 summary_set_row_marks(summaryview
, node
);
2615 static void summary_update_status(SummaryView
*summaryview
)
2617 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2618 GtkCMCTreeNode
*node
;
2621 summaryview
->total_size
=
2622 summaryview
->deleted
= summaryview
->moved
= summaryview
->copied
= 0;
2624 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
2625 node
!= NULL
; node
= gtkut_ctree_node_next(ctree
, node
)) {
2626 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
2631 if (MSG_IS_DELETED(msginfo
->flags
))
2632 summaryview
->deleted
++;
2633 if (MSG_IS_MOVE(msginfo
->flags
))
2634 summaryview
->moved
++;
2635 if (MSG_IS_COPY(msginfo
->flags
))
2636 summaryview
->copied
++;
2637 summaryview
->total_size
+= msginfo
->size
;
2641 static void summary_status_show(SummaryView
*summaryview
)
2644 gchar
*del
, *mv
, *cp
;
2648 GList
*rowlist
, *cur
;
2649 guint n_selected
= 0, n_new
= 0, n_unread
= 0, n_total
= 0;
2650 guint n_marked
= 0, n_replied
= 0, n_forwarded
= 0, n_locked
= 0, n_ignored
= 0, n_watched
= 0;
2651 goffset sel_size
= 0, n_size
= 0;
2656 if (!summaryview
->folder_item
) {
2657 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_folder
), "");
2658 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_select
), "");
2659 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_msgs
), "");
2660 toolbar_main_set_sensitive(summaryview
->mainwin
);
2664 rowlist
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
2665 for (cur
= rowlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
2666 msginfo
= gtk_cmctree_node_get_row_data
2667 (GTK_CMCTREE(summaryview
->ctree
),
2668 GTK_CMCTREE_NODE(cur
->data
));
2670 sel_size
+= msginfo
->size
;
2675 if (summaryview
->folder_item
->hide_read_msgs
2676 || summaryview
->folder_item
->hide_del_msgs
2677 || summaryview
->folder_item
->hide_read_threads
2678 || quicksearch_has_sat_predicate(summaryview
->quicksearch
)) {
2679 rowlist
= GTK_CMCLIST(summaryview
->ctree
)->row_list
;
2680 for (cur
= rowlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
2681 msginfo
= gtk_cmctree_node_get_row_data
2682 (GTK_CMCTREE(summaryview
->ctree
),
2683 GTK_CMCTREE_NODE(cur
));
2685 n_size
+= msginfo
->size
;
2687 if (MSG_IS_NEW(msginfo
->flags
))
2689 if (MSG_IS_UNREAD(msginfo
->flags
))
2691 if (MSG_IS_MARKED(msginfo
->flags
))
2693 if (MSG_IS_REPLIED(msginfo
->flags
))
2695 if (MSG_IS_FORWARDED(msginfo
->flags
))
2697 if (MSG_IS_LOCKED(msginfo
->flags
))
2699 if (MSG_IS_IGNORE_THREAD(msginfo
->flags
))
2701 if (MSG_IS_WATCH_THREAD(msginfo
->flags
))
2706 n_new
= summaryview
->folder_item
->new_msgs
;
2707 n_unread
= summaryview
->folder_item
->unread_msgs
;
2708 n_marked
= summaryview
->folder_item
->marked_msgs
;
2709 n_replied
= summaryview
->folder_item
->replied_msgs
;
2710 n_forwarded
= summaryview
->folder_item
->forwarded_msgs
;
2711 n_locked
= summaryview
->folder_item
->locked_msgs
;
2712 n_ignored
= summaryview
->folder_item
->ignored_msgs
;
2713 n_watched
= summaryview
->folder_item
->watched_msgs
;
2714 n_total
= summaryview
->folder_item
->total_msgs
;
2715 n_size
= summaryview
->total_size
;
2718 name
= folder_item_get_name(summaryview
->folder_item
);
2719 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_folder
), name
);
2722 if (summaryview
->deleted
)
2723 del
= g_strdup_printf(_("%d deleted"), summaryview
->deleted
);
2726 if (summaryview
->moved
)
2727 mv
= g_strdup_printf(_("%s%d moved"),
2728 summaryview
->deleted
? _(", ") : "",
2729 summaryview
->moved
);
2732 if (summaryview
->copied
)
2733 cp
= g_strdup_printf(_("%s%d copied"),
2734 summaryview
->deleted
||
2735 summaryview
->moved
? _(", ") : "",
2736 summaryview
->copied
);
2740 if (summaryview
->deleted
|| summaryview
->moved
|| summaryview
->copied
)
2746 sel
= g_strdup_printf(" (%s)", to_human_readable((goffset
)sel_size
));
2747 itstr
= g_strdup_printf(ngettext(" item selected"," items selected", n_selected
));
2750 itstr
= g_strdup("");
2753 if (prefs_common
.layout_mode
!= SMALL_LAYOUT
) {
2754 str
= g_strconcat(n_selected
? itos(n_selected
) : "",
2755 itstr
, sel
, spc
, del
, mv
, cp
, NULL
);
2762 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_select
), str
);
2765 str
= g_strdup_printf(_("%d new, %d unread, %d total (%s)"),
2766 n_new
, n_unread
, n_total
,
2767 to_human_readable((goffset
)n_size
));
2769 g_signal_connect(G_OBJECT(summaryview
->popupmenu
), "selection-done",
2770 G_CALLBACK(popup_menu_selection_done
), summaryview
);
2772 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_msgs
), str
);
2774 tooltip
= g_strdup_printf("<b>%s</b>\n"
2785 _("Message summary"),
2787 _("Unread:"), n_unread
,
2788 _("Total:"), n_total
,
2789 _("Size:"), to_human_readable((goffset
)n_size
),
2790 _("Marked:"), n_marked
,
2791 _("Replied:"), n_replied
,
2792 _("Forwarded:"), n_forwarded
,
2793 _("Locked:"), n_locked
,
2794 _("Ignored:"), n_ignored
,
2795 _("Watched:"), n_watched
);
2797 gtk_widget_set_tooltip_markup(GTK_WIDGET(summaryview
->statlabel_msgs
),
2801 gchar
*ssize
, *tsize
;
2803 ssize
= g_strdup(to_human_readable((goffset
)sel_size
));
2804 tsize
= g_strdup(to_human_readable((goffset
)n_size
));
2805 str
= g_strdup_printf(_("%d/%d selected (%s/%s), %d unread"),
2806 n_selected
, n_total
, ssize
, tsize
, n_unread
);
2810 str
= g_strdup_printf(_("%d new, %d unread, %d total (%s)"),
2811 n_new
, n_unread
, n_total
, to_human_readable((goffset
)n_size
));
2818 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_select
), str
);
2822 summary_set_menu_sensitive(summaryview
);
2823 toolbar_main_set_sensitive(summaryview
->mainwin
);
2826 static void summary_set_column_titles(SummaryView
*summaryview
)
2828 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
2829 FolderItem
*item
= summaryview
->folder_item
;
2835 SummaryColumnType type
;
2836 GtkJustification justify
;
2838 static FolderSortKey sort_by
[N_SUMMARY_COLS
] = {
2853 for (pos
= 0; pos
< N_SUMMARY_COLS
; pos
++) {
2854 type
= summaryview
->col_state
[pos
].type
;
2856 /* CLAWS: mime and unread are single char headers */
2857 justify
= (type
== S_COL_NUMBER
|| type
== S_COL_SIZE
)
2858 ? GTK_JUSTIFY_RIGHT
: GTK_JUSTIFY_LEFT
;
2866 if(type
== S_COL_FROM
&& item
!= NULL
&&
2867 FOLDER_SHOWS_TO_HDR(item
) &&
2868 !summaryview
->col_state
[summaryview
->col_pos
[S_COL_TO
]].visible
)
2870 if(type
== S_COL_NUMBER
)
2871 title
= gettext(col_label
[type
]);
2873 title
= prefs_common_translated_header_name(col_label
[type
]);
2876 title
= gettext(col_label
[type
]);
2879 if (type
== S_COL_MIME
) {
2880 label
= gtk_image_new_from_pixbuf(clipxpm
);
2881 gtk_widget_show(label
);
2882 gtk_cmclist_set_column_widget(clist
, pos
, label
);
2883 gtk_sctree_set_column_tooltip(GTK_SCTREE(clist
), pos
, _("Attachment"));
2885 } else if (type
== S_COL_MARK
) {
2886 label
= gtk_image_new_from_pixbuf(markxpm
);
2887 gtk_widget_show(label
);
2888 gtk_cmclist_set_column_widget(clist
, pos
, label
);
2889 gtk_sctree_set_column_tooltip(GTK_SCTREE(clist
), pos
, _("Mark"));
2891 } else if (type
== S_COL_LOCKED
) {
2892 label
= gtk_image_new_from_pixbuf(lockedxpm
);
2893 gtk_widget_show(label
);
2894 gtk_cmclist_set_column_widget(clist
, pos
, label
);
2895 gtk_sctree_set_column_tooltip(GTK_SCTREE(clist
), pos
, _("Locked"));
2897 } else if (type
== S_COL_STATUS
) {
2898 gtk_cmclist_set_column_title(clist
, pos
, title
);
2899 gtk_sctree_set_column_tooltip(GTK_SCTREE(clist
), pos
, _("Status"));
2903 hbox
= gtk_hbox_new(FALSE
, 4);
2904 label
= gtk_label_new(title
);
2906 gtk_widget_set_size_request(hbox
, -1, 20);
2909 if (justify
== GTK_JUSTIFY_RIGHT
)
2910 gtk_box_pack_end(GTK_BOX(hbox
), label
,
2913 gtk_box_pack_start(GTK_BOX(hbox
), label
,
2916 if (summaryview
->sort_key
== sort_by
[type
] ||
2917 (summaryview
->sort_key
== SORT_BY_THREAD_DATE
&&
2918 sort_by
[SORT_BY_DATE
] && type
== S_COL_DATE
)) {
2919 arrow
= gtk_arrow_new
2920 (summaryview
->sort_type
== SORT_ASCENDING
2921 ? GTK_ARROW_DOWN
: GTK_ARROW_UP
,
2923 gtk_widget_set_size_request(GTK_WIDGET(arrow
), 10, 10);
2924 if (justify
== GTK_JUSTIFY_RIGHT
)
2925 gtk_box_pack_start(GTK_BOX(hbox
), arrow
,
2928 gtk_box_pack_end(GTK_BOX(hbox
), arrow
,
2932 gtk_widget_show_all(hbox
);
2933 gtk_cmclist_set_column_widget(clist
, pos
, hbox
);
2937 void summary_reflect_tags_changes(SummaryView
*summaryview
)
2940 GList
*children
, *cur
;
2941 GtkCMCTreeNode
*node
;
2942 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
2943 gboolean froze
= FALSE
;
2944 gboolean redisplay
= FALSE
;
2946 /* re-create colorlabel submenu */
2947 menu
= GTK_MENU_SHELL(summaryview
->tags_menu
);
2948 cm_return_if_fail(menu
!= NULL
);
2950 /* clear items. get item pointers. */
2951 children
= gtk_container_get_children(GTK_CONTAINER(menu
));
2952 for (cur
= children
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
2953 gtk_menu_item_set_submenu(GTK_MENU_ITEM(cur
->data
), NULL
);
2955 g_list_free(children
);
2956 summary_tags_menu_create(summaryview
, TRUE
);
2958 START_LONG_OPERATION(summaryview
, TRUE
);
2959 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
); node
!= NULL
;
2960 node
= gtkut_ctree_node_next(ctree
, node
)) {
2961 redisplay
|= summary_set_row_tag(summaryview
,
2962 node
, TRUE
, FALSE
, 0);
2964 END_LONG_OPERATION(summaryview
);
2966 summary_redisplay_msg(summaryview
);
2970 void summary_reflect_prefs(void)
2972 static gchar
*last_smallfont
= NULL
;
2973 static gchar
*last_normalfont
= NULL
;
2974 static gchar
*last_boldfont
= NULL
;
2975 static gboolean last_derive
= 0;
2976 gboolean update_font
= FALSE
;
2977 SummaryView
*summaryview
= NULL
;
2979 if (!mainwindow_get_mainwindow())
2981 summaryview
= mainwindow_get_mainwindow()->summaryview
;
2983 if (!last_smallfont
|| strcmp(last_smallfont
, SMALL_FONT
) ||
2984 !last_normalfont
|| strcmp(last_normalfont
, NORMAL_FONT
) ||
2985 !last_boldfont
|| strcmp(last_boldfont
, BOLD_FONT
) ||
2986 last_derive
!= prefs_common
.derive_from_normal_font
)
2989 g_free(last_smallfont
);
2990 last_smallfont
= g_strdup(SMALL_FONT
);
2991 g_free(last_normalfont
);
2992 last_normalfont
= g_strdup(NORMAL_FONT
);
2993 g_free(last_boldfont
);
2994 last_boldfont
= g_strdup(BOLD_FONT
);
2995 last_derive
= prefs_common
.derive_from_normal_font
;
2997 #define STYLE_FREE(s) \
2999 g_object_unref(s); \
3004 STYLE_FREE(bold_style
);
3005 STYLE_FREE(bold_style
);
3006 STYLE_FREE(bold_marked_style
);
3007 STYLE_FREE(bold_deleted_style
);
3008 STYLE_FREE(small_style
);
3009 STYLE_FREE(small_marked_style
);
3010 STYLE_FREE(small_deleted_style
);
3011 summary_set_fonts(summaryview
);
3016 summary_set_column_titles(summaryview
);
3017 summary_relayout(summaryview
);
3019 if (summaryview
->folder_item
)
3020 summary_show(summaryview
, summaryview
->folder_item
, FALSE
);
3023 void summary_sort(SummaryView
*summaryview
,
3024 FolderSortKey sort_key
, FolderSortType sort_type
)
3026 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3027 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
3028 GtkCMCListCompareFunc cmp_func
= NULL
;
3030 g_signal_handlers_block_by_func(G_OBJECT(summaryview
->ctree
),
3031 G_CALLBACK(summary_tree_expanded
), summaryview
);
3032 summary_freeze(summaryview
);
3036 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_mark
;
3038 case SORT_BY_STATUS
:
3039 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_status
;
3042 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_mime
;
3044 case SORT_BY_NUMBER
:
3045 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_num
;
3048 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_size
;
3051 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_date
;
3053 case SORT_BY_THREAD_DATE
:
3054 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_thread_date
;
3057 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_from
;
3059 case SORT_BY_SUBJECT
:
3060 if (summaryview
->simplify_subject_preg
)
3061 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_simplified_subject
;
3063 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_subject
;
3066 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_score
;
3069 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_label
;
3072 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_to
;
3074 case SORT_BY_LOCKED
:
3075 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_locked
;
3078 cmp_func
= (GtkCMCListCompareFunc
)summary_cmp_by_tags
;
3086 summaryview
->sort_key
= sort_key
;
3087 summaryview
->sort_type
= sort_type
;
3089 summary_set_column_titles(summaryview
);
3090 summary_set_menu_sensitive(summaryview
);
3092 /* allow fallback to don't sort */
3093 if (summaryview
->sort_key
== SORT_BY_NONE
)
3096 if (cmp_func
!= NULL
) {
3097 debug_print("Sorting summary...\n");
3098 STATUSBAR_PUSH(summaryview
->mainwin
, _("Sorting summary..."));
3100 main_window_cursor_wait(summaryview
->mainwin
);
3102 gtk_cmclist_set_compare_func(clist
, cmp_func
);
3104 gtk_cmclist_set_sort_type(clist
, (GtkSortType
)sort_type
);
3105 gtk_sctree_sort_recursive(ctree
, NULL
);
3107 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
3109 main_window_cursor_normal(summaryview
->mainwin
);
3111 debug_print("Sorting summary done.\n");
3112 STATUSBAR_POP(summaryview
->mainwin
);
3115 summary_thaw(summaryview
);
3116 g_signal_handlers_unblock_by_func(G_OBJECT(summaryview
->ctree
),
3117 G_CALLBACK(summary_tree_expanded
), summaryview
);
3121 static gboolean
summary_update_thread_age(GNode
*node
, gpointer data
)
3123 MsgInfo
*msginfo
= node
->data
;
3124 time_t *most_recent
= (time_t *)data
;
3126 if (msginfo
->date_t
> *most_recent
) {
3127 *most_recent
= msginfo
->date_t
;
3132 static void summary_find_thread_age(GNode
*gnode
)
3134 MsgInfo
*msginfo
= (MsgInfo
*)gnode
->data
;
3139 most_recent
= msginfo
->thread_date
= msginfo
->date_t
;
3141 g_node_traverse(gnode
, G_IN_ORDER
, G_TRAVERSE_ALL
, -1, summary_update_thread_age
, &most_recent
);
3143 msginfo
->thread_date
= most_recent
;
3146 static gboolean
summary_update_is_read(GNode
*node
, gpointer data
)
3148 MsgInfo
*msginfo
= node
->data
;
3149 gboolean
*all_read
= (gboolean
*)data
;
3151 if (MSG_IS_UNREAD(msginfo
->flags
)) {
3158 static gboolean
summary_thread_is_read(GNode
*gnode
)
3160 MsgInfo
*msginfo
= (MsgInfo
*)gnode
->data
;
3161 gboolean all_read
= TRUE
;
3166 g_node_traverse(gnode
, G_IN_ORDER
, G_TRAVERSE_ALL
, -1, summary_update_is_read
, &all_read
);
3170 typedef struct _ThreadSelectedData
{
3172 gboolean is_selected
;
3173 } ThreadSelectedData
;
3175 static gboolean
summary_update_is_selected(GNode
*gnode
, gpointer data
)
3177 ThreadSelectedData
*selected
= (ThreadSelectedData
*)data
;
3178 MsgInfo
*msginfo
= (MsgInfo
*)gnode
->data
;
3180 if (msginfo
->msgnum
== selected
->msgnum
) {
3181 selected
->is_selected
= TRUE
;
3188 static gboolean
summary_thread_is_selected(GNode
*gnode
, guint selected_msgnum
)
3190 ThreadSelectedData selected
;
3192 selected
.msgnum
= selected_msgnum
;
3193 selected
.is_selected
= FALSE
;
3194 g_node_traverse(gnode
, G_IN_ORDER
, G_TRAVERSE_ALL
, -1,
3195 summary_update_is_selected
, &selected
);
3196 return selected
.is_selected
;
3199 static gboolean
summary_insert_gnode_func(GtkCMCTree
*ctree
, guint depth
, GNode
*gnode
,
3200 GtkCMCTreeNode
*cnode
, gpointer data
)
3202 SummaryView
*summaryview
= (SummaryView
*)data
;
3203 MsgInfo
*msginfo
= (MsgInfo
*)gnode
->data
;
3204 gchar
*text
[N_SUMMARY_COLS
];
3205 gint
*col_pos
= summaryview
->col_pos
;
3206 const gchar
*msgid
= msginfo
->msgid
;
3207 GHashTable
*msgid_table
= summaryview
->msgid_table
;
3208 gboolean vert_layout
= (prefs_common
.layout_mode
== VERTICAL_LAYOUT
);
3209 gboolean small_layout
= (prefs_common
.layout_mode
== SMALL_LAYOUT
);
3211 summary_set_header(summaryview
, text
, msginfo
);
3213 gtk_cmctree_set_node_info(ctree
, cnode
, text
[col_pos
[S_COL_SUBJECT
]], 2,
3214 NULL
, NULL
, FALSE
, summaryview
->threaded
&& !summaryview
->thread_collapsed
);
3215 #define SET_TEXT(col) { \
3216 gtk_cmctree_node_set_text(ctree, cnode, col_pos[col], \
3217 text[col_pos[col]]); \
3220 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_NUMBER
]].visible
)
3221 SET_TEXT(S_COL_NUMBER
);
3222 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_SCORE
]].visible
)
3223 SET_TEXT(S_COL_SCORE
);
3224 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_SIZE
]].visible
)
3225 SET_TEXT(S_COL_SIZE
);
3226 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_DATE
]].visible
)
3227 SET_TEXT(S_COL_DATE
);
3228 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_FROM
]].visible
)
3229 SET_TEXT(S_COL_FROM
);
3230 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_TO
]].visible
)
3232 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_TAGS
]].visible
)
3233 SET_TEXT(S_COL_TAGS
);
3235 if ((vert_layout
|| small_layout
) && prefs_common
.two_line_vert
)
3236 g_free(text
[summaryview
->col_pos
[S_COL_SUBJECT
]]);
3240 GTKUT_CTREE_NODE_SET_ROW_DATA(cnode
, msginfo
);
3241 summary_set_marks_func(ctree
, cnode
, summaryview
);
3243 if (msgid
&& msgid
[0] != '\0')
3244 g_hash_table_insert(msgid_table
, (gchar
*)msgid
, cnode
);
3249 static void summary_set_ctree_from_list(SummaryView
*summaryview
,
3250 GSList
*mlist
, guint selected_msgnum
)
3252 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3254 GtkCMCTreeNode
*node
= NULL
;
3255 GHashTable
*msgid_table
;
3256 GHashTable
*subject_table
= NULL
;
3258 gboolean vert_layout
= (prefs_common
.layout_mode
== VERTICAL_LAYOUT
);
3259 gboolean small_layout
= (prefs_common
.layout_mode
== SMALL_LAYOUT
);
3264 debug_print("Setting summary from message data...\n");
3265 STATUSBAR_PUSH(summaryview
->mainwin
,
3266 _("Setting summary from message data..."));
3269 g_signal_handlers_block_by_func(G_OBJECT(ctree
),
3270 G_CALLBACK(summary_tree_expanded
), summaryview
);
3272 msgid_table
= g_hash_table_new(g_str_hash
, g_str_equal
);
3273 summaryview
->msgid_table
= msgid_table
;
3275 if (prefs_common
.thread_by_subject
) {
3276 subject_table
= g_hash_table_new(g_str_hash
, g_str_equal
);
3277 summaryview
->subject_table
= subject_table
;
3279 summaryview
->subject_table
= NULL
;
3282 if (prefs_common
.use_addr_book
)
3283 start_address_completion(NULL
);
3285 if (summaryview
->threaded
) {
3286 GNode
*root
, *gnode
;
3287 START_TIMING("threaded");
3288 root
= procmsg_get_thread_tree(mlist
);
3291 for (gnode
= root
->children
; gnode
!= NULL
;
3292 gnode
= gnode
->next
) {
3293 if (!summaryview
->folder_item
->hide_read_threads
||
3294 !summary_thread_is_read(gnode
) ||
3295 summary_thread_is_selected(gnode
, selected_msgnum
)) {
3296 summary_find_thread_age(gnode
);
3297 node
= gtk_sctree_insert_gnode
3298 (ctree
, NULL
, node
, gnode
,
3299 summary_insert_gnode_func
, summaryview
);
3303 g_node_destroy(root
);
3307 gchar
*text
[N_SUMMARY_COLS
];
3308 START_TIMING("unthreaded");
3310 for (; mlist
!= NULL
; mlist
= mlist
->next
) {
3311 msginfo
= (MsgInfo
*)mlist
->data
;
3313 summary_set_header(summaryview
, text
, msginfo
);
3315 node
= gtk_sctree_insert_node
3316 (ctree
, NULL
, node
, text
, 2,
3319 if ((vert_layout
|| small_layout
) && prefs_common
.two_line_vert
)
3320 g_free(text
[summaryview
->col_pos
[S_COL_SUBJECT
]]);
3322 GTKUT_CTREE_NODE_SET_ROW_DATA(node
, msginfo
);
3323 summary_set_marks_func(ctree
, node
, summaryview
);
3325 if (msginfo
->msgid
&& msginfo
->msgid
[0] != '\0')
3326 g_hash_table_insert(msgid_table
,
3327 msginfo
->msgid
, node
);
3329 if (prefs_common
.thread_by_subject
)
3330 subject_table_insert(subject_table
,
3338 if (prefs_common
.enable_hscrollbar
&&
3339 summaryview
->col_pos
[S_COL_SUBJECT
] == N_SUMMARY_COLS
- 1) {
3342 optimal_width
= gtk_cmclist_optimal_column_width
3343 (GTK_CMCLIST(ctree
), summaryview
->col_pos
[S_COL_SUBJECT
]);
3344 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
),
3345 summaryview
->col_pos
[S_COL_SUBJECT
],
3349 if (prefs_common
.use_addr_book
)
3350 end_address_completion();
3352 debug_print("Setting summary from message data done.\n");
3353 STATUSBAR_POP(summaryview
->mainwin
);
3354 if (debug_get_mode()) {
3355 debug_print("\tmsgid hash table size = %d\n",
3356 g_hash_table_size(msgid_table
));
3357 if (prefs_common
.thread_by_subject
)
3358 debug_print("\tsubject hash table size = %d\n",
3359 g_hash_table_size(subject_table
));
3362 summary_sort(summaryview
, summaryview
->sort_key
, summaryview
->sort_type
);
3364 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
3366 if (prefs_common
.bold_unread
) {
3367 START_TIMING("bold_unread");
3369 GtkCMCTreeNode
*next
= GTK_CMCTREE_NODE_NEXT(node
);
3370 if (GTK_CMCTREE_ROW(node
)->children
)
3371 summary_set_row_marks(summaryview
, node
);
3377 g_signal_handlers_unblock_by_func(G_OBJECT(ctree
),
3378 G_CALLBACK(summary_tree_expanded
), summaryview
);
3382 static gchar
*summary_complete_address(const gchar
*addr
)
3385 gchar
*res
, *tmp
, *email_addr
;
3387 if (addr
== NULL
|| !strchr(addr
, '@'))
3390 Xstrdup_a(email_addr
, addr
, return NULL
);
3391 extract_address(email_addr
);
3396 * completion stuff must be already initialized
3399 if (1 < (count
= complete_address(email_addr
))) {
3400 tmp
= get_complete_address(1);
3401 res
= procheader_get_fromname(tmp
);
3408 static inline void summary_set_header(SummaryView
*summaryview
, gchar
*text
[],
3411 static gchar date_modified
[80];
3412 static gchar col_score
[11];
3413 static gchar from_buf
[BUFFSIZE
], to_buf
[BUFFSIZE
];
3414 static gchar tmp1
[BUFFSIZE
], tmp2
[BUFFSIZE
+4], tmp3
[BUFFSIZE
];
3415 gint
*col_pos
= summaryview
->col_pos
;
3416 gchar
*from_text
= NULL
, *to_text
= NULL
, *tags_text
= NULL
;
3417 gboolean should_swap
= FALSE
;
3418 gboolean vert_layout
= (prefs_common
.layout_mode
== VERTICAL_LAYOUT
);
3419 gboolean small_layout
= (prefs_common
.layout_mode
== SMALL_LAYOUT
);
3420 static const gchar
*color_dim_rgb
= NULL
;
3422 color_dim_rgb
= gdk_color_to_string(&summaryview
->color_dim
);
3423 text
[col_pos
[S_COL_FROM
]] = "";
3424 text
[col_pos
[S_COL_TO
]] = "";
3425 text
[col_pos
[S_COL_SUBJECT
]]= "";
3426 text
[col_pos
[S_COL_MARK
]] = "";
3427 text
[col_pos
[S_COL_STATUS
]] = "";
3428 text
[col_pos
[S_COL_MIME
]] = "";
3429 text
[col_pos
[S_COL_LOCKED
]] = "";
3430 text
[col_pos
[S_COL_DATE
]] = "";
3431 text
[col_pos
[S_COL_TAGS
]] = "";
3432 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_NUMBER
]].visible
)
3433 text
[col_pos
[S_COL_NUMBER
]] = itos(msginfo
->msgnum
);
3435 text
[col_pos
[S_COL_NUMBER
]] = "";
3438 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_SIZE
]].visible
)
3439 text
[col_pos
[S_COL_SIZE
]] = to_human_readable(msginfo
->size
);
3441 text
[col_pos
[S_COL_SIZE
]] = "";
3443 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_SCORE
]].visible
)
3444 text
[col_pos
[S_COL_SCORE
]] = itos_buf(col_score
, msginfo
->score
);
3446 text
[col_pos
[S_COL_SCORE
]] = "";
3448 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_TAGS
]].visible
) {
3449 tags_text
= procmsg_msginfo_get_tags_str(msginfo
);
3451 text
[col_pos
[S_COL_TAGS
]] = "-";
3453 strncpy2(tmp1
, tags_text
, sizeof(tmp1
));
3454 tmp1
[sizeof(tmp1
)-1]='\0';
3456 text
[col_pos
[S_COL_TAGS
]] = tmp1
;
3459 text
[col_pos
[S_COL_TAGS
]] = "";
3462 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_DATE
]].visible
||
3463 ((vert_layout
|| small_layout
) && prefs_common
.two_line_vert
)) {
3464 if (msginfo
->date_t
&& msginfo
->date_t
> 0) {
3465 procheader_date_get_localtime(date_modified
,
3466 sizeof(date_modified
),
3468 text
[col_pos
[S_COL_DATE
]] = date_modified
;
3469 } else if (msginfo
->date
)
3470 text
[col_pos
[S_COL_DATE
]] = msginfo
->date
;
3472 text
[col_pos
[S_COL_DATE
]] = _("(No Date)");
3475 if (prefs_common
.swap_from
&& msginfo
->from
&& msginfo
->to
3476 && !summaryview
->col_state
[summaryview
->col_pos
[S_COL_TO
]].visible
) {
3479 addr
= g_strdup(msginfo
->from
);
3482 extract_address(addr
);
3483 if (account_find_from_address(addr
, FALSE
)) {
3490 if (!prefs_common
.use_addr_book
) {
3491 if (prefs_common
.summary_from_show
== SHOW_NAME
)
3492 from_text
= msginfo
->fromname
;
3493 else if (prefs_common
.summary_from_show
== SHOW_BOTH
)
3494 from_text
= msginfo
->from
;
3496 from_text
= msginfo
->from
;
3497 extract_address(from_text
);
3500 from_text
= _("(No From)");
3502 gchar
*tmp
= summary_complete_address(msginfo
->from
);
3504 strncpy2(from_buf
, tmp
, sizeof(from_buf
));
3506 from_text
= from_buf
;
3508 if (prefs_common
.summary_from_show
== SHOW_NAME
)
3509 from_text
= msginfo
->fromname
;
3510 else if (prefs_common
.summary_from_show
== SHOW_BOTH
)
3511 from_text
= msginfo
->from
;
3513 from_text
= msginfo
->from
;
3515 extract_address(from_text
);
3518 from_text
= _("(No From)");
3522 to_text
= msginfo
->to
? msginfo
->to
:
3523 (msginfo
->cc
? msginfo
->cc
:
3524 (msginfo
->newsgroups
? msginfo
->newsgroups
: NULL
3529 to_text
= _("(No Recipient)");
3531 if (prefs_common
.summary_from_show
== SHOW_NAME
) {
3532 gchar
*tmp
= procheader_get_fromname(to_text
);
3533 /* need to keep to_text pointing to stack, so heap-allocated
3534 * string from procheader_get_fromname() will be copied to to_buf */
3536 strncpy2(to_buf
, tmp
, sizeof(to_buf
));
3540 } else if (prefs_common
.summary_from_show
== SHOW_ADDR
)
3541 extract_address(to_text
);
3544 text
[col_pos
[S_COL_TO
]] = to_text
;
3546 text
[col_pos
[S_COL_FROM
]] = from_text
;
3548 if (prefs_common
.use_addr_book
) {
3549 gchar
*tmp
= summary_complete_address(to_text
);
3550 /* need to keep to_text pointing to stack, so heap-allocated
3551 * string from summary_complete_address() will be copied to to_buf */
3553 strncpy2(to_buf
, tmp
, sizeof(to_buf
));
3557 to_text
= to_text
? to_text
: _("(No From)");
3560 snprintf(tmp2
, BUFFSIZE
+4, "➜ %s", to_text
);
3561 tmp2
[BUFFSIZE
-1]='\0';
3562 text
[col_pos
[S_COL_FROM
]] = tmp2
;
3565 if (summaryview
->simplify_subject_preg
!= NULL
)
3566 text
[col_pos
[S_COL_SUBJECT
]] = msginfo
->subject
?
3567 string_remove_match(tmp3
, BUFFSIZE
, msginfo
->subject
,
3568 summaryview
->simplify_subject_preg
) :
3571 text
[col_pos
[S_COL_SUBJECT
]] = msginfo
->subject
? msginfo
->subject
:
3573 if ((vert_layout
|| small_layout
) && prefs_common
.two_line_vert
) {
3574 if (!FOLDER_SHOWS_TO_HDR(summaryview
->folder_item
)) {
3575 gchar
*tmp
= g_markup_printf_escaped(g_strconcat("%s\n",
3576 "<span color='%s' style='italic'>",
3577 _("From: %s, on %s"), "</span>", NULL
),
3578 text
[col_pos
[S_COL_SUBJECT
]],
3580 text
[col_pos
[S_COL_FROM
]],
3581 text
[col_pos
[S_COL_DATE
]]);
3582 text
[col_pos
[S_COL_SUBJECT
]] = tmp
;
3584 gchar
*tmp
= g_markup_printf_escaped(g_strconcat("%s\n",
3585 "<span color='%s' style='italic'>",
3586 _("To: %s, on %s"), "</span>", NULL
),
3587 text
[col_pos
[S_COL_SUBJECT
]],
3589 text
[col_pos
[S_COL_TO
]],
3590 text
[col_pos
[S_COL_DATE
]]);
3591 text
[col_pos
[S_COL_SUBJECT
]] = tmp
;
3596 static void summary_display_msg(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
3598 summary_display_msg_full(summaryview
, row
, FALSE
, FALSE
);
3601 static gboolean
defer_change(gpointer data
);
3607 typedef struct _ChangeData
{
3610 MsgPermFlags set_flags
;
3611 MsgTmpFlags set_tmp_flags
;
3612 MsgPermFlags unset_flags
;
3613 MsgTmpFlags unset_tmp_flags
;
3616 static void summary_msginfo_unset_flags(MsgInfo
*msginfo
, MsgPermFlags flags
, MsgTmpFlags tmp_flags
)
3618 if (!msginfo
->folder
|| !msginfo
->folder
->processing_pending
) {
3619 debug_print("flags: doing unset now\n");
3620 procmsg_msginfo_unset_flags(msginfo
, flags
, tmp_flags
);
3622 ChangeData
*unset_data
= g_new0(ChangeData
, 1);
3623 unset_data
->info
= msginfo
;
3624 unset_data
->op
= FLAGS_UNSET
;
3625 unset_data
->unset_flags
= flags
;
3626 unset_data
->unset_tmp_flags
= tmp_flags
;
3627 debug_print("flags: deferring unset\n");
3628 g_timeout_add(100, defer_change
, unset_data
);
3632 static void summary_msginfo_set_flags(MsgInfo
*msginfo
, MsgPermFlags flags
, MsgTmpFlags tmp_flags
)
3634 if (!msginfo
->folder
|| !msginfo
->folder
->processing_pending
) {
3635 debug_print("flags: doing set now\n");
3636 procmsg_msginfo_set_flags(msginfo
, flags
, tmp_flags
);
3638 ChangeData
*set_data
= g_new0(ChangeData
, 1);
3639 set_data
->info
= msginfo
;
3640 set_data
->op
= FLAGS_SET
;
3641 set_data
->set_flags
= flags
;
3642 set_data
->set_tmp_flags
= tmp_flags
;
3643 debug_print("flags: deferring set\n");
3644 g_timeout_add(100, defer_change
, set_data
);
3648 static void summary_msginfo_change_flags(MsgInfo
*msginfo
,
3649 MsgPermFlags add_flags
, MsgTmpFlags add_tmp_flags
,
3650 MsgPermFlags rem_flags
, MsgTmpFlags rem_tmp_flags
)
3652 if (!msginfo
->folder
|| !msginfo
->folder
->processing_pending
) {
3653 debug_print("flags: doing change now\n");
3654 procmsg_msginfo_change_flags(msginfo
, add_flags
, add_tmp_flags
,
3655 rem_flags
, rem_tmp_flags
);
3657 ChangeData
*change_data
= g_new0(ChangeData
, 1);
3658 change_data
->info
= msginfo
;
3659 change_data
->op
= FLAGS_CHANGE
;
3660 change_data
->set_flags
= add_flags
;
3661 change_data
->set_tmp_flags
= add_tmp_flags
;
3662 change_data
->unset_flags
= rem_flags
;
3663 change_data
->unset_tmp_flags
= rem_tmp_flags
;
3664 debug_print("flags: deferring change\n");
3665 g_timeout_add(100, defer_change
, change_data
);
3669 gboolean
defer_change(gpointer data
)
3671 ChangeData
*chg
= (ChangeData
*)data
;
3672 if (chg
->info
->folder
&& chg
->info
->folder
->processing_pending
) {
3673 debug_print("flags: trying later\n");
3674 return TRUE
; /* try again */
3676 debug_print("flags: finally doing it\n");
3679 procmsg_msginfo_unset_flags(chg
->info
, chg
->unset_flags
, chg
->unset_tmp_flags
);
3682 procmsg_msginfo_set_flags(chg
->info
, chg
->set_flags
, chg
->set_tmp_flags
);
3685 procmsg_msginfo_change_flags(chg
->info
, chg
->set_flags
, chg
->set_tmp_flags
,
3686 chg
->unset_flags
, chg
->unset_tmp_flags
);
3689 g_warning("unknown change op");
3696 static void msginfo_mark_as_read (SummaryView
*summaryview
, MsgInfo
*msginfo
,
3697 GtkCMCTreeNode
*row
)
3699 cm_return_if_fail(summaryview
!= NULL
);
3700 cm_return_if_fail(msginfo
!= NULL
);
3701 cm_return_if_fail(row
!= NULL
);
3703 if (MSG_IS_NEW(msginfo
->flags
) || MSG_IS_UNREAD(msginfo
->flags
)) {
3704 summary_msginfo_unset_flags
3705 (msginfo
, MSG_NEW
| MSG_UNREAD
, 0);
3706 summary_set_row_marks(summaryview
, row
);
3707 summary_status_show(summaryview
);
3713 SummaryView
*summaryview
;
3716 static int msginfo_mark_as_read_timeout(void *data
)
3718 MarkAsReadData
*mdata
= (MarkAsReadData
*)data
;
3722 summary_lock(mdata
->summaryview
);
3723 if (mdata
->msginfo
== summary_get_selected_msg(mdata
->summaryview
))
3724 msginfo_mark_as_read(mdata
->summaryview
, mdata
->msginfo
,
3725 mdata
->summaryview
->selected
);
3726 procmsg_msginfo_free(&(mdata
->msginfo
));
3728 mdata
->summaryview
->mark_as_read_timeout_tag
= 0;
3729 summary_unlock(mdata
->summaryview
);
3735 static void summary_display_msg_full(SummaryView
*summaryview
,
3736 GtkCMCTreeNode
*row
,
3737 gboolean new_window
, gboolean all_headers
)
3739 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3744 if (summaryview
->displayed
== row
&&
3745 messageview_is_visible(summaryview
->messageview
))
3747 else if (summaryview
->messageview
)
3748 summaryview
->messageview
->filtered
= FALSE
;
3750 cm_return_if_fail(row
!= NULL
);
3752 if (summary_is_locked(summaryview
)) return;
3753 summary_lock(summaryview
);
3755 STATUSBAR_POP(summaryview
->mainwin
);
3758 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
3761 debug_print("NULL msginfo\n");
3762 summary_unlock(summaryview
);
3767 if (new_window
&& prefs_common
.layout_mode
!= SMALL_LAYOUT
) {
3768 MessageView
*msgview
;
3770 msgview
= messageview_create_with_new_window(summaryview
->mainwin
);
3771 val
= messageview_show(msgview
, msginfo
, all_headers
);
3773 MessageView
*msgview
;
3775 if (prefs_common
.layout_mode
== SMALL_LAYOUT
) {
3776 if (summaryview
->ext_messageview
== NULL
)
3777 summaryview
->ext_messageview
= messageview_create_with_new_window(summaryview
->mainwin
);
3779 gtkut_window_popup(summaryview
->ext_messageview
->window
);
3780 msgview
= summaryview
->ext_messageview
;
3781 summaryview
->displayed
= row
;
3782 val
= messageview_show(msgview
, msginfo
, all_headers
);
3783 if (mimeview_tree_is_empty(msgview
->mimeview
))
3784 gtk_widget_grab_focus(summaryview
->ctree
);
3785 gtkut_ctree_node_move_if_on_the_edge(ctree
, row
,
3786 GTK_CMCLIST(summaryview
->ctree
)->focus_row
);
3788 msgview
= summaryview
->messageview
;
3789 summaryview
->displayed
= row
;
3790 if (!messageview_is_visible(msgview
) &&
3791 gtk_window_is_active(GTK_WINDOW(summaryview
->mainwin
->window
))) {
3792 main_window_toggle_message_view(summaryview
->mainwin
);
3795 val
= messageview_show(msgview
, msginfo
, all_headers
);
3796 if (mimeview_tree_is_empty(msgview
->mimeview
))
3797 gtk_widget_grab_focus(summaryview
->ctree
);
3798 gtkut_ctree_node_move_if_on_the_edge(ctree
, row
,
3799 GTK_CMCLIST(summaryview
->ctree
)->focus_row
);
3803 if (val
== 0 && MSG_IS_UNREAD(msginfo
->flags
)) {
3804 if (!prefs_common
.mark_as_read_on_new_window
&&
3805 prefs_common
.mark_as_read_delay
) {
3806 MarkAsReadData
*data
= g_new0(MarkAsReadData
, 1);
3807 data
->summaryview
= summaryview
;
3808 data
->msginfo
= procmsg_msginfo_new_ref(msginfo
);
3809 if (summaryview
->mark_as_read_timeout_tag
!= 0)
3810 g_source_remove(summaryview
->mark_as_read_timeout_tag
);
3811 summaryview
->mark_as_read_timeout_tag
=
3812 g_timeout_add_seconds(prefs_common
.mark_as_read_delay
,
3813 msginfo_mark_as_read_timeout
, data
);
3814 } else if (new_window
|| !prefs_common
.mark_as_read_on_new_window
) {
3815 msginfo_mark_as_read(summaryview
, msginfo
, row
);
3819 summary_set_menu_sensitive(summaryview
);
3820 toolbar_main_set_sensitive(summaryview
->mainwin
);
3821 messageview_set_menu_sensitive(summaryview
->messageview
);
3823 summary_unlock(summaryview
);
3827 void summary_display_msg_selected(SummaryView
*summaryview
,
3828 gboolean all_headers
)
3830 if (summary_is_locked(summaryview
)) return;
3831 summaryview
->displayed
= NULL
;
3832 summary_display_msg_full(summaryview
, summaryview
->selected
, FALSE
,
3836 void summary_redisplay_msg(SummaryView
*summaryview
)
3838 GtkCMCTreeNode
*node
;
3840 if (summaryview
->displayed
) {
3841 node
= summaryview
->displayed
;
3842 summaryview
->displayed
= NULL
;
3843 summary_display_msg(summaryview
, node
);
3847 void summary_open_msg(SummaryView
*summaryview
)
3849 if (!summaryview
->selected
) return;
3851 /* CLAWS: if separate message view, don't open a new window
3852 * but rather use the current separated message view */
3853 summary_display_msg_full(summaryview
, summaryview
->selected
,
3857 void summary_view_source(SummaryView
* summaryview
)
3859 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3861 SourceWindow
*srcwin
;
3863 if (!summaryview
->selected
) return;
3865 srcwin
= source_window_create();
3866 msginfo
= gtk_cmctree_node_get_row_data(ctree
, summaryview
->selected
);
3867 source_window_show_msg(srcwin
, msginfo
);
3868 source_window_show(srcwin
);
3871 void summary_reedit(SummaryView
*summaryview
)
3875 if (!summaryview
->selected
) return;
3876 if (!summaryview
->folder_item
) return;
3877 if (!FOLDER_SHOWS_TO_HDR(summaryview
->folder_item
))
3880 msginfo
= gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview
->ctree
),
3881 summaryview
->selected
);
3882 if (!msginfo
) return;
3884 compose_reedit(msginfo
, FALSE
);
3887 gboolean
summary_is_list(SummaryView
*summaryview
)
3889 return (gtk_notebook_get_current_page(
3890 GTK_NOTEBOOK(summaryview
->mainwidget_book
)) == 0);
3893 void summary_toggle_view(SummaryView
*summaryview
)
3895 if (prefs_common
.layout_mode
== SMALL_LAYOUT
)
3897 if (summary_is_locked(summaryview
))
3899 if (!messageview_is_visible(summaryview
->messageview
) &&
3900 summaryview
->selected
&& summary_is_list(summaryview
))
3901 summary_display_msg(summaryview
,
3902 summaryview
->selected
);
3904 main_window_toggle_message_view(summaryview
->mainwin
);
3907 static gboolean
summary_search_unread_recursive(GtkCMCTree
*ctree
,
3908 GtkCMCTreeNode
*node
)
3913 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
3914 if (msginfo
&& MSG_IS_UNREAD(msginfo
->flags
) && !MSG_IS_IGNORE_THREAD(msginfo
->flags
))
3916 node
= GTK_CMCTREE_ROW(node
)->children
;
3918 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
3921 if (summary_search_unread_recursive(ctree
, node
) == TRUE
)
3923 node
= GTK_CMCTREE_ROW(node
)->sibling
;
3929 static gboolean
summary_have_unread_children(SummaryView
*summaryview
,
3930 GtkCMCTreeNode
*node
)
3932 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3934 if (!node
) return FALSE
;
3936 node
= GTK_CMCTREE_ROW(node
)->children
;
3939 if (summary_search_unread_recursive(ctree
, node
) == TRUE
)
3941 node
= GTK_CMCTREE_ROW(node
)->sibling
;
3946 static void summary_set_row_marks(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
3948 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
3949 GtkStyle
*style
= NULL
;
3952 gint
*col_pos
= summaryview
->col_pos
;
3954 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
3955 if (!msginfo
) return;
3957 flags
= msginfo
->flags
;
3959 gtk_cmctree_node_set_foreground(ctree
, row
, NULL
);
3961 /* set new/unread column */
3962 if (MSG_IS_IGNORE_THREAD(flags
)) {
3963 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3965 } else if (MSG_IS_WATCH_THREAD(flags
)) {
3966 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3968 } else if (MSG_IS_SPAM(flags
)) {
3969 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3971 } else if (MSG_IS_NEW(flags
)) {
3972 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3974 } else if (MSG_IS_UNREAD(flags
)) {
3975 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3977 } else if (MSG_IS_REPLIED(flags
) && MSG_IS_FORWARDED(flags
)) {
3978 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3979 repliedandforwardedxpm
);
3980 } else if (MSG_IS_REPLIED(flags
)) {
3981 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3983 } else if (MSG_IS_FORWARDED(flags
)) {
3984 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_STATUS
],
3987 gtk_cmctree_node_set_text(ctree
, row
, col_pos
[S_COL_STATUS
],
3991 if (prefs_common
.bold_unread
&&
3992 ((MSG_IS_UNREAD(flags
) && !MSG_IS_IGNORE_THREAD(flags
)) ||
3993 (!GTK_CMCTREE_ROW(row
)->expanded
&&
3994 GTK_CMCTREE_ROW(row
)->children
&&
3995 summary_have_unread_children(summaryview
, row
))))
3998 /* set mark column */
3999 if (MSG_IS_DELETED(flags
)) {
4000 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MARK
],
4003 style
= bold_deleted_style
;
4005 style
= small_deleted_style
;
4007 gtk_cmctree_node_set_foreground
4008 (ctree
, row
, &summaryview
->color_dim
);
4009 } else if (MSG_IS_MARKED(flags
)) {
4010 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MARK
],
4012 } else if (MSG_IS_MOVE(flags
)) {
4013 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MARK
],
4015 if (!msginfo
->to_folder
||
4016 !folder_has_parent_of_type(msginfo
->to_folder
, F_TRASH
)) {
4018 style
= bold_marked_style
;
4020 style
= small_marked_style
;
4022 gtk_cmctree_node_set_foreground
4023 (ctree
, row
, &summaryview
->color_marked
);
4026 style
= bold_deleted_style
;
4028 style
= small_deleted_style
;
4030 gtk_cmctree_node_set_foreground
4031 (ctree
, row
, &summaryview
->color_dim
);
4033 } else if (MSG_IS_COPY(flags
)) {
4034 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MARK
],
4037 style
= bold_marked_style
;
4039 style
= small_marked_style
;
4041 gtk_cmctree_node_set_foreground
4042 (ctree
, row
, &summaryview
->color_marked
);
4044 gtk_cmctree_node_set_text(ctree
, row
, col_pos
[S_COL_MARK
], "");
4047 if (MSG_IS_LOCKED(flags
)) {
4048 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_LOCKED
],
4052 gtk_cmctree_node_set_text(ctree
, row
, col_pos
[S_COL_LOCKED
], "");
4055 if (MSG_IS_WITH_ATTACHMENT(flags
) && MSG_IS_SIGNED(flags
)) {
4056 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4058 } else if (MSG_IS_SIGNED(flags
)) {
4059 if (MSG_IS_ENCRYPTED(flags
)) {
4060 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4063 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4066 } else if (MSG_IS_WITH_ATTACHMENT(flags
) && MSG_IS_ENCRYPTED(flags
)) {
4067 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4069 } else if (MSG_IS_ENCRYPTED(flags
)) {
4070 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4072 } else if (MSG_IS_WITH_ATTACHMENT(flags
)) {
4073 gtk_cmctree_node_set_pixbuf(ctree
, row
, col_pos
[S_COL_MIME
],
4076 gtk_cmctree_node_set_text(ctree
, row
, col_pos
[S_COL_MIME
], "");
4079 style
= small_style
;
4081 gtk_cmctree_node_set_row_style(ctree
, row
, style
);
4083 if (MSG_GET_COLORLABEL(flags
))
4084 summary_set_colorlabel_color(ctree
, row
, MSG_GET_COLORLABEL_VALUE(flags
));
4087 static void summary_mark_row(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
4089 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4092 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4093 cm_return_if_fail(msginfo
);
4094 if (MSG_IS_DELETED(msginfo
->flags
))
4095 summaryview
->deleted
--;
4096 if (MSG_IS_MOVE(msginfo
->flags
))
4097 summaryview
->moved
--;
4098 if (MSG_IS_COPY(msginfo
->flags
))
4099 summaryview
->copied
--;
4101 procmsg_msginfo_set_to_folder(msginfo
, NULL
);
4102 summary_msginfo_change_flags(msginfo
, MSG_MARKED
, 0, MSG_DELETED
,
4103 MSG_MOVE
| MSG_COPY
| MSG_MOVE_DONE
);
4104 summary_set_row_marks(summaryview
, row
);
4105 debug_print("Message %s/%d is marked\n", msginfo
->folder
->path
, msginfo
->msgnum
);
4108 static void summary_lock_row(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
4110 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4113 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4114 cm_return_if_fail(msginfo
);
4115 if (MSG_IS_DELETED(msginfo
->flags
))
4116 summaryview
->deleted
--;
4117 if (MSG_IS_MOVE(msginfo
->flags
)) {
4118 summaryview
->moved
--;
4120 if (MSG_IS_COPY(msginfo
->flags
)) {
4121 summaryview
->copied
--;
4123 procmsg_msginfo_set_to_folder(msginfo
, NULL
);
4124 summary_msginfo_change_flags(msginfo
, MSG_LOCKED
, 0, MSG_DELETED
,
4125 MSG_MOVE
| MSG_COPY
| MSG_MOVE_DONE
);
4127 summary_set_row_marks(summaryview
, row
);
4128 debug_print("Message %d is locked\n", msginfo
->msgnum
);
4131 static void summary_unlock_row(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
4133 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4136 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4137 cm_return_if_fail(msginfo
);
4138 if (!MSG_IS_LOCKED(msginfo
->flags
))
4140 procmsg_msginfo_set_to_folder(msginfo
, NULL
);
4141 summary_msginfo_unset_flags(msginfo
, MSG_LOCKED
, 0);
4142 summary_set_row_marks(summaryview
, row
);
4143 debug_print("Message %d is unlocked\n", msginfo
->msgnum
);
4146 void summary_mark(SummaryView
*summaryview
)
4148 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4150 gboolean froze
= FALSE
;
4152 if (summary_is_locked(summaryview
))
4154 START_LONG_OPERATION(summaryview
, FALSE
);
4155 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4156 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4157 summary_mark_row(summaryview
, GTK_CMCTREE_NODE(cur
->data
));
4158 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4159 END_LONG_OPERATION(summaryview
);
4161 summary_status_show(summaryview
);
4164 static void summary_mark_row_as_read(SummaryView
*summaryview
,
4165 GtkCMCTreeNode
*row
)
4167 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4170 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4171 cm_return_if_fail(msginfo
);
4173 if(!(MSG_IS_NEW(msginfo
->flags
) || MSG_IS_UNREAD(msginfo
->flags
)))
4176 summary_msginfo_unset_flags(msginfo
, MSG_NEW
| MSG_UNREAD
, 0);
4177 summary_set_row_marks(summaryview
, row
);
4178 debug_print("Message %d is marked as read\n",
4182 static void summary_mark_row_as_unread(SummaryView
*summaryview
,
4183 GtkCMCTreeNode
*row
)
4185 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4188 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4189 cm_return_if_fail(msginfo
);
4191 if(MSG_IS_NEW(msginfo
->flags
) || MSG_IS_UNREAD(msginfo
->flags
))
4194 summary_msginfo_set_flags(msginfo
, MSG_UNREAD
, 0);
4195 summary_set_row_marks(summaryview
, row
);
4196 debug_print("Message %d is marked as unread\n",
4200 void summary_mark_as_read(SummaryView
*summaryview
)
4202 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4204 gboolean froze
= FALSE
;
4206 if (summary_is_locked(summaryview
))
4209 if (!summaryview
->folder_item
)
4212 if ((summaryview
->folder_item
->total_msgs
== (gint
)g_list_length(GTK_CMCLIST(ctree
)->selection
) &&
4213 summaryview
->folder_item
->total_msgs
> 1) &&
4214 !summary_mark_all_read_confirm(TRUE
))
4217 START_LONG_OPERATION(summaryview
, FALSE
);
4218 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4219 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4220 summary_mark_row_as_read(summaryview
,
4221 GTK_CMCTREE_NODE(cur
->data
));
4222 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4223 END_LONG_OPERATION(summaryview
);
4225 summary_status_show(summaryview
);
4228 void summary_mark_as_unread(SummaryView
*summaryview
)
4230 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4232 gboolean froze
= FALSE
;
4234 if (summary_is_locked(summaryview
))
4237 if ((summaryview
->folder_item
->total_msgs
== (gint
)g_list_length(GTK_CMCLIST(ctree
)->selection
) &&
4238 summaryview
->folder_item
->total_msgs
> 1) &&
4239 !summary_mark_all_unread_confirm(TRUE
))
4242 START_LONG_OPERATION(summaryview
, FALSE
);
4243 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4244 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4245 summary_mark_row_as_unread(summaryview
,
4246 GTK_CMCTREE_NODE(cur
->data
));
4247 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4248 END_LONG_OPERATION(summaryview
);
4250 summary_status_show(summaryview
);
4253 void summary_msgs_lock(SummaryView
*summaryview
)
4255 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4257 gboolean froze
= FALSE
;
4259 if (summary_is_locked(summaryview
))
4261 START_LONG_OPERATION(summaryview
, FALSE
);
4262 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4263 summary_lock_row(summaryview
,
4264 GTK_CMCTREE_NODE(cur
->data
));
4265 END_LONG_OPERATION(summaryview
);
4267 summary_status_show(summaryview
);
4270 void summary_msgs_unlock(SummaryView
*summaryview
)
4272 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4274 gboolean froze
= FALSE
;
4276 if (summary_is_locked(summaryview
))
4278 START_LONG_OPERATION(summaryview
, FALSE
);
4279 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4280 summary_unlock_row(summaryview
,
4281 GTK_CMCTREE_NODE(cur
->data
));
4282 END_LONG_OPERATION(summaryview
);
4284 summary_status_show(summaryview
);
4287 static gboolean
summary_mark_all_read_confirm(gboolean ask_if_needed
)
4289 /* ask_if_needed is FALSE when user-asking is performed by caller,
4290 commonly when the caller is a mark-as-read-recursive func */
4291 if (ask_if_needed
&& prefs_common
.ask_mark_all_read
) {
4292 AlertValue val
= alertpanel_full(_("Mark all as read"),
4293 _("Do you really want to mark all mails in this folder as read?"),
4294 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_FIRST
,
4295 TRUE
, NULL
, ALERT_QUESTION
);
4297 if ((val
& ~G_ALERTDISABLE
) != G_ALERTALTERNATE
)
4299 else if (val
& G_ALERTDISABLE
)
4300 prefs_common
.ask_mark_all_read
= FALSE
;
4305 void summary_mark_all_read(SummaryView
*summaryview
, gboolean ask_if_needed
)
4307 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4308 GtkCMCTreeNode
*node
;
4309 gboolean froze
= FALSE
;
4311 if (summary_is_locked(summaryview
))
4314 if (!summary_mark_all_read_confirm(ask_if_needed
))
4317 START_LONG_OPERATION(summaryview
, TRUE
);
4318 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4319 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
); node
!= NULL
;
4320 node
= gtkut_ctree_node_next(ctree
, node
))
4321 summary_mark_row_as_read(summaryview
, node
);
4322 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4323 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
); node
!= NULL
;
4324 node
= gtkut_ctree_node_next(ctree
, node
)) {
4325 if (!GTK_CMCTREE_ROW(node
)->expanded
)
4326 summary_set_row_marks(summaryview
, node
);
4328 END_LONG_OPERATION(summaryview
);
4330 summary_status_show(summaryview
);
4333 static gboolean
summary_mark_all_unread_confirm(gboolean ask_if_needed
)
4335 /* ask_if_needed is FALSE when user-asking is performed by caller,
4336 commonly when the caller is a mark-as-unread-recursive func */
4337 if (ask_if_needed
&& prefs_common
.ask_mark_all_read
) {
4338 AlertValue val
= alertpanel_full(_("Mark all as unread"),
4339 _("Do you really want to mark all mails in this folder as unread?"),
4340 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_FIRST
,
4341 TRUE
, NULL
, ALERT_QUESTION
);
4343 if ((val
& ~G_ALERTDISABLE
) != G_ALERTALTERNATE
)
4345 else if (val
& G_ALERTDISABLE
)
4346 prefs_common
.ask_mark_all_read
= FALSE
;
4351 void summary_mark_all_unread(SummaryView
*summaryview
, gboolean ask_if_needed
)
4353 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4354 GtkCMCTreeNode
*node
;
4355 gboolean froze
= FALSE
;
4357 if (summary_is_locked(summaryview
))
4360 if (!summary_mark_all_unread_confirm(ask_if_needed
))
4363 START_LONG_OPERATION(summaryview
, TRUE
);
4364 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4365 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
); node
!= NULL
;
4366 node
= gtkut_ctree_node_next(ctree
, node
))
4367 summary_mark_row_as_unread(summaryview
, node
);
4368 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4369 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
); node
!= NULL
;
4370 node
= gtkut_ctree_node_next(ctree
, node
)) {
4371 if (!GTK_CMCTREE_ROW(node
)->expanded
)
4372 summary_set_row_marks(summaryview
, node
);
4374 END_LONG_OPERATION(summaryview
);
4376 summary_status_show(summaryview
);
4379 void summary_mark_as_spam(SummaryView
*summaryview
, guint action
, GtkWidget
*widget
)
4381 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4383 gboolean is_spam
= action
;
4384 GSList
*msgs
= NULL
;
4385 gboolean immediate_exec
= prefs_common
.immediate_exec
;
4386 gboolean moved
= FALSE
;
4387 gboolean froze
= FALSE
;
4390 if (summary_is_locked(summaryview
))
4393 prefs_common
.immediate_exec
= FALSE
;
4394 START_LONG_OPERATION(summaryview
, FALSE
);
4395 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4396 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
4397 GtkCMCTreeNode
*row
= GTK_CMCTREE_NODE(cur
->data
);
4398 MsgInfo
*msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4400 msgs
= g_slist_prepend(msgs
, msginfo
);
4403 if (procmsg_spam_learner_learn(NULL
, msgs
, is_spam
) == 0) {
4404 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
4405 GtkCMCTreeNode
*row
= GTK_CMCTREE_NODE(cur
->data
);
4406 MsgInfo
*msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4410 summary_msginfo_change_flags(msginfo
, MSG_SPAM
, 0, MSG_NEW
|MSG_UNREAD
, 0);
4411 if (procmsg_spam_get_folder(msginfo
) != summaryview
->folder_item
) {
4412 summary_move_row_to(summaryview
, row
,
4413 procmsg_spam_get_folder(msginfo
));
4417 summary_msginfo_unset_flags(msginfo
, MSG_SPAM
, 0);
4419 summaryview
->display_msg
= prefs_common
.always_show_msg
;
4421 summary_set_row_marks(summaryview
, row
);
4424 log_error(LOG_PROTOCOL
, _("An error happened while learning.\n"));
4427 prefs_common
.immediate_exec
= immediate_exec
;
4428 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4429 END_LONG_OPERATION(summaryview
);
4431 if (prefs_common
.immediate_exec
&& moved
) {
4432 summary_execute(summaryview
);
4435 if (!moved
&& msgs
) {
4436 MsgInfo
*msginfo
= (MsgInfo
*)msgs
->data
;
4437 toolbar_set_learn_button
4438 (summaryview
->mainwin
->toolbar
,
4439 MSG_IS_SPAM(msginfo
->flags
)?LEARN_HAM
:LEARN_SPAM
);
4443 summary_status_show(summaryview
);
4446 static gboolean
check_permission(SummaryView
*summaryview
, MsgInfo
* msginfo
)
4451 switch (FOLDER_TYPE(summaryview
->folder_item
->folder
)) {
4456 security : checks if one the accounts correspond to
4457 the author of the post
4461 for(cur
= account_get_list() ; cur
!= NULL
; cur
= cur
->next
) {
4462 PrefsAccount
* account
;
4465 account
= cur
->data
;
4466 if (account
->name
&& *account
->name
)
4468 g_strdup_printf("%s <%s>",
4473 g_strdup_printf("%s",
4476 if (g_utf8_collate(from_name
, msginfo
->from
) == 0) {
4485 alertpanel_error(_("You're not the author of the article."));
4495 static void summary_delete_row(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
4497 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4500 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4501 cm_return_if_fail(msginfo
);
4503 if (MSG_IS_LOCKED(msginfo
->flags
)) return;
4505 if (MSG_IS_DELETED(msginfo
->flags
)) return;
4507 if (MSG_IS_MOVE(msginfo
->flags
))
4508 summaryview
->moved
--;
4509 if (MSG_IS_COPY(msginfo
->flags
))
4510 summaryview
->copied
--;
4512 procmsg_msginfo_set_to_folder(msginfo
, NULL
);
4513 summary_msginfo_change_flags(msginfo
, MSG_DELETED
, 0, MSG_MARKED
,
4514 MSG_MOVE
| MSG_COPY
| MSG_MOVE_DONE
);
4515 summaryview
->deleted
++;
4517 if (!prefs_common
.immediate_exec
&&
4518 !folder_has_parent_of_type(summaryview
->folder_item
, F_TRASH
)) {
4519 summary_set_row_marks(summaryview
, row
);
4521 debug_print("Message %s/%d is set to delete\n",
4522 msginfo
->folder
->path
, msginfo
->msgnum
);
4525 void summary_cancel(SummaryView
*summaryview
)
4529 msginfo
= gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview
->ctree
),
4530 summaryview
->selected
);
4531 if (!msginfo
) return;
4533 if (!check_permission(summaryview
, msginfo
))
4536 news_cancel_article(summaryview
->folder_item
->folder
, msginfo
);
4538 if (summary_is_locked(summaryview
)) return;
4540 summary_lock(summaryview
);
4542 summary_freeze(summaryview
);
4544 summary_update_status(summaryview
);
4545 summary_status_show(summaryview
);
4547 summary_thaw(summaryview
);
4549 summary_unlock(summaryview
);
4552 void summary_delete(SummaryView
*summaryview
)
4554 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4555 FolderItem
*item
= summaryview
->folder_item
;
4557 GtkCMCTreeNode
*sel_last
= NULL
;
4558 GtkCMCTreeNode
*node
;
4561 gboolean froze
= FALSE
;
4565 if (summary_is_locked(summaryview
)) return;
4567 if (!summaryview
->folder_item
) return;
4569 START_LONG_OPERATION(summaryview
, FALSE
);
4571 if (!prefs_common
.live_dangerously
) {
4573 guint num
= g_list_length(GTK_CMCLIST(summaryview
->ctree
)->selection
);
4574 buf
= g_strdup_printf(ngettext(
4575 "Do you really want to delete the selected message?",
4576 "Do you really want to delete the %d selected messages?", num
),
4578 aval
= alertpanel(ngettext("Delete message", "Delete messages", num
),
4580 GTK_STOCK_CANCEL
, GTK_STOCK_DELETE
, NULL
, ALERTFOCUS_SECOND
);
4582 if (aval
!= G_ALERTALTERNATE
) {
4583 END_LONG_OPERATION(summaryview
);
4588 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
;
4590 GtkCMCTreeNode
*row
= GTK_CMCTREE_NODE(cur
->data
);
4591 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4592 if (msginfo
&& msginfo
->total_size
!= 0 &&
4593 msginfo
->size
!= (goffset
)msginfo
->total_size
)
4594 partial_mark_for_delete(msginfo
);
4597 main_window_cursor_wait(summaryview
->mainwin
);
4599 /* next code sets current row focus right. We need to find a row
4600 * that is not deleted. */
4601 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4602 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
4603 sel_last
= GTK_CMCTREE_NODE(cur
->data
);
4604 summary_delete_row(summaryview
, sel_last
);
4606 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4607 END_LONG_OPERATION(summaryview
);
4609 if (summaryview
->sort_type
== SORT_ASCENDING
) {
4610 node
= summary_find_next_msg(summaryview
, sel_last
, TRUE
);
4611 if (!node
|| prefs_common
.next_on_delete
== FALSE
)
4612 node
= summary_find_prev_msg(summaryview
, sel_last
,TRUE
);
4614 node
= summary_find_prev_msg(summaryview
, sel_last
,TRUE
);
4615 if (!node
|| prefs_common
.next_on_delete
== FALSE
)
4616 node
= summary_find_next_msg(summaryview
, sel_last
,TRUE
);
4618 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_DELETEMOVE
);
4620 if (prefs_common
.immediate_exec
|| folder_has_parent_of_type(item
, F_TRASH
)) {
4621 summary_execute(summaryview
);
4622 /* after deleting, the anchor may be at an invalid row
4623 * so reset it to the node we found earlier */
4624 gtk_sctree_set_anchor_row(GTK_SCTREE(ctree
), node
);
4626 summary_status_show(summaryview
);
4629 main_window_cursor_normal(summaryview
->mainwin
);
4632 void summary_delete_trash(SummaryView
*summaryview
)
4634 FolderItem
*to_folder
= NULL
;
4636 if (!summaryview
->folder_item
||
4637 FOLDER_TYPE(summaryview
->folder_item
->folder
) == F_NEWS
) return;
4639 if (NULL
!= (ac
= account_find_from_item(summaryview
->folder_item
)))
4640 to_folder
= account_get_special_folder(ac
, F_TRASH
);
4642 if (to_folder
== NULL
)
4643 to_folder
= summaryview
->folder_item
->folder
->trash
;
4645 if (to_folder
== NULL
|| to_folder
== summaryview
->folder_item
4646 || folder_has_parent_of_type(summaryview
->folder_item
, F_TRASH
))
4647 summary_delete(summaryview
);
4649 summary_move_selected_to(summaryview
, to_folder
);
4653 static void summary_unmark_row(SummaryView
*summaryview
, GtkCMCTreeNode
*row
)
4655 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4658 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4659 cm_return_if_fail(msginfo
);
4660 if (MSG_IS_DELETED(msginfo
->flags
))
4661 summaryview
->deleted
--;
4662 if (MSG_IS_MOVE(msginfo
->flags
))
4663 summaryview
->moved
--;
4664 if (MSG_IS_COPY(msginfo
->flags
))
4665 summaryview
->copied
--;
4667 procmsg_msginfo_set_to_folder(msginfo
, NULL
);
4668 summary_msginfo_unset_flags(msginfo
, MSG_MARKED
| MSG_DELETED
,
4669 MSG_MOVE
| MSG_COPY
| MSG_MOVE_DONE
);
4670 summary_set_row_marks(summaryview
, row
);
4672 debug_print("Message %s/%d is unmarked\n",
4673 msginfo
->folder
->path
, msginfo
->msgnum
);
4676 void summary_unmark(SummaryView
*summaryview
)
4678 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4680 gboolean froze
= FALSE
;
4682 if (summary_is_locked(summaryview
))
4684 START_LONG_OPERATION(summaryview
, FALSE
);
4685 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
4686 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4687 summary_unmark_row(summaryview
, GTK_CMCTREE_NODE(cur
->data
));
4688 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
4689 END_LONG_OPERATION(summaryview
);
4691 summary_status_show(summaryview
);
4694 static void summary_move_row_to(SummaryView
*summaryview
, GtkCMCTreeNode
*row
,
4695 FolderItem
*to_folder
)
4697 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4700 cm_return_if_fail(to_folder
!= NULL
);
4702 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4703 cm_return_if_fail(msginfo
);
4704 if (MSG_IS_LOCKED(msginfo
->flags
))
4707 procmsg_msginfo_set_to_folder(msginfo
, to_folder
);
4708 if (MSG_IS_DELETED(msginfo
->flags
))
4709 summaryview
->deleted
--;
4710 if (MSG_IS_COPY(msginfo
->flags
)) {
4711 summaryview
->copied
--;
4713 if (!MSG_IS_MOVE(msginfo
->flags
)) {
4714 summary_msginfo_change_flags(msginfo
, 0, MSG_MOVE
, MSG_DELETED
,
4715 MSG_COPY
| MSG_MOVE_DONE
);
4716 summaryview
->moved
++;
4718 summary_msginfo_unset_flags(msginfo
, MSG_DELETED
, MSG_COPY
);
4721 if (!prefs_common
.immediate_exec
) {
4722 summary_set_row_marks(summaryview
, row
);
4725 debug_print("Message %d is set to move to %s\n",
4726 msginfo
->msgnum
, to_folder
->path
);
4729 void summary_move_selected_to(SummaryView
*summaryview
, FolderItem
*to_folder
)
4732 GtkCMCTreeNode
*sel_last
= NULL
;
4733 gboolean froze
= FALSE
;
4735 if (!to_folder
) return;
4736 if (!summaryview
->folder_item
||
4737 FOLDER_TYPE(summaryview
->folder_item
->folder
) == F_NEWS
) return;
4739 if (summary_is_locked(summaryview
)) return;
4741 if (summaryview
->folder_item
== to_folder
) {
4742 alertpanel_error(_("Destination is same as current folder."));
4746 if (to_folder
->no_select
) {
4747 alertpanel_error(_("The destination folder can only be used to "
4748 "store subfolders."));
4752 START_LONG_OPERATION(summaryview
, FALSE
);
4754 for (cur
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
4755 cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
4756 sel_last
= GTK_CMCTREE_NODE(cur
->data
);
4758 (summaryview
, GTK_CMCTREE_NODE(cur
->data
), to_folder
);
4760 END_LONG_OPERATION(summaryview
);
4762 if (prefs_common
.immediate_exec
) {
4763 summary_execute(summaryview
);
4765 GtkCMCTreeNode
*node
= NULL
;
4766 if (summaryview
->sort_type
== SORT_ASCENDING
) {
4767 node
= summary_find_next_msg(summaryview
, sel_last
,TRUE
);
4768 if (!node
|| prefs_common
.next_on_delete
== FALSE
)
4769 node
= summary_find_prev_msg(summaryview
, sel_last
,TRUE
);
4771 node
= summary_find_prev_msg(summaryview
, sel_last
,TRUE
);
4772 if (!node
|| prefs_common
.next_on_delete
== FALSE
)
4773 node
= summary_find_next_msg(summaryview
, sel_last
,TRUE
);
4775 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_DELETEMOVE
);
4776 summary_status_show(summaryview
);
4779 if (!summaryview
->selected
) { /* this was the last message */
4780 GtkCMCTreeNode
*node
= gtk_cmctree_node_nth (GTK_CMCTREE(summaryview
->ctree
),
4781 GTK_CMCLIST(summaryview
->ctree
)->rows
- 1);
4783 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_DELETEMOVE
);
4788 void summary_move_to(SummaryView
*summaryview
)
4790 FolderItem
*to_folder
;
4792 if (!summaryview
->folder_item
||
4793 FOLDER_TYPE(summaryview
->folder_item
->folder
) == F_NEWS
) return;
4795 to_folder
= foldersel_folder_sel(NULL
, FOLDER_SEL_MOVE
, NULL
, FALSE
,
4797 "Select folder to move selected message to",
4798 "Select folder to move selected messages to",
4799 g_list_length(GTK_CMCLIST(summaryview
->ctree
)->selection
))
4801 summary_move_selected_to(summaryview
, to_folder
);
4804 static void summary_copy_row_to(SummaryView
*summaryview
, GtkCMCTreeNode
*row
,
4805 FolderItem
*to_folder
)
4807 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4810 cm_return_if_fail(to_folder
!= NULL
);
4812 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
4813 cm_return_if_fail(msginfo
);
4814 procmsg_msginfo_set_to_folder(msginfo
, to_folder
);
4815 if (MSG_IS_DELETED(msginfo
->flags
))
4816 summaryview
->deleted
--;
4817 if (MSG_IS_MOVE(msginfo
->flags
)) {
4818 summaryview
->moved
--;
4821 if (!MSG_IS_COPY(msginfo
->flags
)) {
4822 summary_msginfo_change_flags(msginfo
, 0, MSG_COPY
, MSG_DELETED
,
4823 MSG_MOVE
| MSG_MOVE_DONE
);
4824 summaryview
->copied
++;
4826 summary_msginfo_unset_flags(msginfo
, MSG_DELETED
, MSG_MOVE
);
4828 if (!prefs_common
.immediate_exec
) {
4829 summary_set_row_marks(summaryview
, row
);
4832 debug_print("Message %d is set to copy to %s\n",
4833 msginfo
->msgnum
, to_folder
->path
);
4836 void summary_copy_selected_to(SummaryView
*summaryview
, FolderItem
*to_folder
)
4839 gboolean froze
= FALSE
;
4841 if (!to_folder
) return;
4842 if (!summaryview
->folder_item
) return;
4844 if (summary_is_locked(summaryview
)) return;
4846 if (summaryview
->folder_item
== to_folder
) {
4848 (_("Destination to copy is same as current folder."));
4852 if (to_folder
->no_select
) {
4853 alertpanel_error(_("The destination folder can only be used to "
4854 "store subfolders."));
4858 START_LONG_OPERATION(summaryview
, FALSE
);
4860 for (cur
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
4861 cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
4863 (summaryview
, GTK_CMCTREE_NODE(cur
->data
), to_folder
);
4865 END_LONG_OPERATION(summaryview
);
4867 if (prefs_common
.immediate_exec
)
4868 summary_execute(summaryview
);
4870 summary_status_show(summaryview
);
4874 void summary_copy_to(SummaryView
*summaryview
)
4876 FolderItem
*to_folder
;
4878 if (!summaryview
->folder_item
) return;
4880 to_folder
= foldersel_folder_sel(NULL
, FOLDER_SEL_COPY
, NULL
, FALSE
,
4882 "Select folder to copy selected message to",
4883 "Select folder to copy selected messages to",
4884 g_list_length(GTK_CMCLIST(summaryview
->ctree
)->selection
))
4886 summary_copy_selected_to(summaryview
, to_folder
);
4889 void summary_add_address(SummaryView
*summaryview
)
4891 MsgInfo
*msginfo
, *full_msginfo
;
4893 GdkPixbuf
*picture
= NULL
;
4894 AvatarRender
*avatarr
;
4896 msginfo
= gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview
->ctree
),
4897 summaryview
->selected
);
4898 if (!msginfo
|| !msginfo
->from
)
4901 Xstrdup_a(from
, msginfo
->from
, return);
4902 eliminate_address_comment(from
);
4903 extract_address(from
);
4905 full_msginfo
= procmsg_msginfo_get_full_info(msginfo
);
4907 avatarr
= avatars_avatarrender_new(full_msginfo
);
4908 hooks_invoke(AVATAR_IMAGE_RENDER_HOOKLIST
, avatarr
);
4910 procmsg_msginfo_free(&full_msginfo
);
4913 picture
= gtk_image_get_pixbuf(GTK_IMAGE(avatarr
->image
));
4915 #ifndef USE_ALT_ADDRBOOK
4916 addressbook_add_contact(msginfo
->fromname
, from
, NULL
, picture
);
4918 if (addressadd_selection(msginfo
->fromname
, from
, NULL
, picture
)) {
4919 debug_print( "addressbook_add_contact - added\n" );
4922 avatars_avatarrender_free(avatarr
);
4925 void summary_select_all(SummaryView
*summaryview
)
4927 GtkCMCTreeNode
*node
;
4929 if (!summaryview
->folder_item
) return;
4931 if (GTK_CMCLIST(summaryview
->ctree
)->focus_row
< 0) {
4932 /* If no row is selected, select (but do not open) the first
4933 * row, to get summaryview into correct state for selecting all. */
4934 debug_print("summary_select_all: no row selected, selecting first one\n");
4935 if (GTK_CMCLIST(summaryview
->ctree
)->row_list
!= NULL
) {
4936 node
= gtk_cmctree_node_nth(GTK_CMCTREE(summaryview
->ctree
), 0);
4937 summary_select_node(summaryview
, node
, FALSE
);
4941 /* Now select all rows while locking the summaryview for
4942 * faster performance. */
4943 summary_lock(summaryview
);
4944 gtk_cmclist_select_all(GTK_CMCLIST(summaryview
->ctree
));
4945 summary_unlock(summaryview
);
4947 summary_status_show(summaryview
);
4950 void summary_unselect_all(SummaryView
*summaryview
)
4952 summary_lock(summaryview
);
4953 gtk_sctree_unselect_all(GTK_SCTREE(summaryview
->ctree
));
4954 summary_unlock(summaryview
);
4955 summary_status_show(summaryview
);
4958 void summary_select_thread(SummaryView
*summaryview
, gboolean delete_thread
,
4959 gboolean trash_thread
)
4961 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
4962 GtkCMCTreeNode
*node
= NULL
;
4963 gboolean froze
= FALSE
;
4966 if (!GTK_CMCLIST(summaryview
->ctree
)->selection
)
4970 START_LONG_OPERATION(summaryview
, FALSE
);
4971 copy
= g_list_copy(GTK_CMCLIST(summaryview
->ctree
)->selection
);
4972 for (cur
= copy
; cur
!= NULL
&& cur
->data
!= NULL
;
4974 node
= GTK_CMCTREE_NODE(cur
->data
);
4977 while (GTK_CMCTREE_ROW(node
)->parent
!= NULL
)
4978 node
= GTK_CMCTREE_ROW(node
)->parent
;
4980 gtk_cmctree_select_recursive(ctree
, node
);
4983 END_LONG_OPERATION(summaryview
);
4986 if (FOLDER_TYPE(summaryview
->folder_item
->folder
) == F_NEWS
)
4987 summary_delete(summaryview
);
4989 summary_delete_trash(summaryview
);
4990 } else if (delete_thread
)
4991 summary_delete(summaryview
);
4993 summary_status_show(summaryview
);
4996 void summary_save_as(SummaryView
*summaryview
)
4998 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5000 gchar
*filename
= NULL
;
5003 gchar
*filedir
= NULL
;
5004 gchar
*converted_filename
= NULL
;
5005 gchar
* filepath
= NULL
;
5007 AlertValue aval
= 0;
5009 if (!summaryview
->selected
) return;
5010 msginfo
= gtk_cmctree_node_get_row_data(ctree
, summaryview
->selected
);
5011 if (!msginfo
) return;
5013 if (msginfo
->subject
) {
5014 Xstrdup_a(filename
, msginfo
->subject
, return);
5015 subst_for_filename(filename
);
5018 manage_window_focus_in(summaryview
->window
, NULL
, NULL
);
5020 if (filename
&& !g_utf8_validate(filename
, -1, NULL
)) {
5021 converted_filename
= conv_codeset_strdup(filename
,
5022 conv_get_locale_charset_str(),
5024 if (!converted_filename
) {
5025 g_warning("summary_save_as(): failed to convert character set");
5027 filename
= converted_filename
;
5033 if (prefs_common
.attach_save_dir
&& *prefs_common
.attach_save_dir
) {
5034 filepath
= g_strconcat(prefs_common
.attach_save_dir
, G_DIR_SEPARATOR_S
,
5037 dest
= filesel_select_file_save(_("Save as"), filepath
? filepath
: filename
);
5040 if (converted_filename
)
5041 g_free(converted_filename
);
5045 if (is_file_exist(dest
)) {
5046 aval
= alertpanel(_("Append or Overwrite"),
5047 _("Append or overwrite existing file?"),
5048 _("_Append"), _("_Overwrite"), GTK_STOCK_CANCEL
,
5050 if (aval
!= 0 && aval
!= 1)
5054 src
= procmsg_get_message_file(msginfo
);
5055 tmp
= g_path_get_basename(dest
);
5057 if ( aval
==0 ) { /* append */
5058 if (append_file(src
, dest
, TRUE
) < 0)
5059 alertpanel_error(_("Couldn't save the file '%s'."), tmp
);
5060 } else { /* overwrite */
5061 if (copy_file(src
, dest
, TRUE
) < 0)
5062 alertpanel_error(_("Couldn't save the file '%s'."), tmp
);
5067 * If two or more msgs are selected,
5068 * append them to the output file.
5070 if (GTK_CMCLIST(ctree
)->selection
->next
) {
5072 for (item
= GTK_CMCLIST(ctree
)->selection
->next
; item
!= NULL
; item
=item
->next
) {
5073 msginfo
= gtk_cmctree_node_get_row_data(ctree
, GTK_CMCTREE_NODE(item
->data
));
5074 if (!msginfo
) break;
5075 src
= procmsg_get_message_file(msginfo
);
5076 if (append_file(src
, dest
, TRUE
) < 0) {
5077 alertpanel_error(_("Couldn't save the file '%s'."), tmp
);
5083 filedir
= g_path_get_dirname(dest
);
5085 if (strcmp(filedir
, ".")) {
5086 g_free(prefs_common
.attach_save_dir
);
5087 prefs_common
.attach_save_dir
= g_filename_to_utf8(filedir
, -1, NULL
, NULL
, NULL
);
5096 void summary_print(SummaryView
*summaryview
)
5098 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
5100 gchar
*msg
= g_strdup_printf(_("You are about to print %d "
5101 "messages, one by one. Do you "
5102 "want to continue?"),
5103 g_list_length(clist
->selection
));
5104 if (g_list_length(clist
->selection
) > 9
5105 && alertpanel(_("Warning"), msg
, GTK_STOCK_CANCEL
, GTK_STOCK_YES
,
5106 NULL
, ALERTFOCUS_SECOND
) != G_ALERTALTERNATE
) {
5112 if (clist
->selection
== NULL
) return;
5113 for (cur
= clist
->selection
;
5114 cur
!= NULL
&& cur
->data
!= NULL
;
5116 GtkCMCTreeNode
*node
= GTK_CMCTREE_NODE(cur
->data
);
5117 MsgInfo
*msginfo
= gtk_cmctree_node_get_row_data(
5118 GTK_CMCTREE(summaryview
->ctree
),
5120 gint sel_start
= -1, sel_end
= -1, partnum
= 0;
5122 if (node
== summaryview
->displayed
) {
5123 partnum
= mimeview_get_selected_part_num(summaryview
->messageview
->mimeview
);
5124 textview_get_selection_offsets(summaryview
->messageview
->mimeview
->textview
,
5125 &sel_start
, &sel_end
);
5127 messageview_print(msginfo
, summaryview
->messageview
->all_headers
,
5128 sel_start
, sel_end
, partnum
);
5132 gboolean
summary_execute(SummaryView
*summaryview
)
5134 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5135 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
5136 GtkCMCTreeNode
*node
, *next
;
5137 GtkCMCTreeNode
*new_selected
= NULL
;
5140 if (!summaryview
->folder_item
) return FALSE
;
5142 if (summary_is_locked(summaryview
)) return FALSE
;
5143 summary_lock(summaryview
);
5145 summary_freeze(summaryview
);
5147 main_window_cursor_wait(summaryview
->mainwin
);
5149 if (summaryview
->threaded
)
5150 summary_unthread_for_exec(summaryview
);
5152 folder_item_update_freeze();
5153 move_val
= summary_execute_move(summaryview
);
5154 summary_execute_copy(summaryview
);
5155 summary_execute_delete(summaryview
);
5157 node
= GTK_CMCTREE_NODE(clist
->row_list
);
5158 for (; node
!= NULL
; node
= next
) {
5159 next
= gtkut_ctree_node_next(ctree
, node
);
5160 if (gtk_cmctree_node_get_row_data(ctree
, node
) != NULL
) continue;
5162 if (node
== summaryview
->displayed
) {
5163 messageview_clear(summaryview
->messageview
);
5164 summary_cancel_mark_read_timeout(summaryview
);
5165 summaryview
->displayed
= NULL
;
5167 if (GTK_CMCTREE_ROW(node
)->children
!= NULL
) {
5169 if (GTK_CMCTREE_ROW(node
)->sibling
) {
5170 next
= GTK_CMCTREE_ROW(node
)->sibling
;
5172 GtkCMCTreeNode
*parent
= NULL
;
5173 for (parent
= GTK_CMCTREE_ROW(node
)->parent
; parent
!= NULL
;
5174 parent
= GTK_CMCTREE_ROW(parent
)->parent
) {
5175 if (GTK_CMCTREE_ROW(parent
)->sibling
) {
5176 next
= GTK_CMCTREE_ROW(parent
)->sibling
;
5182 if (!new_selected
&&
5183 gtkut_ctree_node_is_selected(ctree
, node
)) {
5184 summary_unselect_all(summaryview
);
5185 if (summaryview
->sort_type
== SORT_ASCENDING
) {
5186 new_selected
= summary_find_next_msg(summaryview
, node
,TRUE
);
5187 if (!new_selected
|| prefs_common
.next_on_delete
== FALSE
)
5188 new_selected
= summary_find_prev_msg(summaryview
, node
,TRUE
);
5190 new_selected
= summary_find_prev_msg(summaryview
, node
,TRUE
);
5191 if (!new_selected
|| prefs_common
.next_on_delete
== FALSE
)
5192 new_selected
= summary_find_next_msg(summaryview
, node
,TRUE
);
5196 gtk_sctree_remove_node((GtkSCTree
*)ctree
, node
);
5199 folder_item_update_thaw();
5202 summary_unlock(summaryview
);
5203 summary_select_node(summaryview
, new_selected
, OPEN_SELECTED_ON_DELETEMOVE
);
5204 summary_lock(summaryview
);
5207 if (summaryview
->threaded
) {
5208 summary_thread_build(summaryview
);
5209 summary_thread_init(summaryview
);
5212 summary_thaw(summaryview
);
5214 summaryview
->selected
= clist
->selection
?
5215 GTK_CMCTREE_NODE(clist
->selection
->data
) : NULL
;
5217 if (!GTK_CMCLIST(summaryview
->ctree
)->row_list
) {
5218 menu_set_insensitive_all
5219 (GTK_MENU_SHELL(summaryview
->popupmenu
));
5220 folderview_grab_focus(summaryview
->folderview
);
5222 menu_set_sensitive_all(GTK_MENU_SHELL(summaryview
->popupmenu
), TRUE
);
5223 gtk_widget_grab_focus(summaryview
->ctree
);
5225 summary_update_status(summaryview
);
5226 summary_status_show(summaryview
);
5228 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
5230 summary_unlock(summaryview
);
5232 main_window_cursor_normal(summaryview
->mainwin
);
5235 summary_show(summaryview
, summaryview
->folder_item
, FALSE
);
5239 gboolean
summary_expunge(SummaryView
*summaryview
)
5241 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5242 GtkCMCList
*clist
= GTK_CMCLIST(summaryview
->ctree
);
5243 GtkCMCTreeNode
*node
, *next
;
5244 GtkCMCTreeNode
*new_selected
= NULL
;
5246 if (!summaryview
->folder_item
) return FALSE
;
5248 if (summary_is_locked(summaryview
)) return FALSE
;
5250 summary_lock(summaryview
);
5252 summary_freeze(summaryview
);
5254 main_window_cursor_wait(summaryview
->mainwin
);
5256 if (summaryview
->threaded
)
5257 summary_unthread_for_exec(summaryview
);
5259 folder_item_update_freeze();
5260 summary_execute_expunge(summaryview
);
5262 node
= GTK_CMCTREE_NODE(clist
->row_list
);
5263 for (; node
!= NULL
; node
= next
) {
5264 next
= gtkut_ctree_node_next(ctree
, node
);
5265 if (gtk_cmctree_node_get_row_data(ctree
, node
) != NULL
) continue;
5267 if (node
== summaryview
->displayed
) {
5268 messageview_clear(summaryview
->messageview
);
5269 summary_cancel_mark_read_timeout(summaryview
);
5270 summaryview
->displayed
= NULL
;
5272 if (GTK_CMCTREE_ROW(node
)->children
!= NULL
) {
5274 if (GTK_CMCTREE_ROW(node
)->sibling
) {
5275 next
= GTK_CMCTREE_ROW(node
)->sibling
;
5277 GtkCMCTreeNode
*parent
= NULL
;
5278 for (parent
= GTK_CMCTREE_ROW(node
)->parent
; parent
!= NULL
;
5279 parent
= GTK_CMCTREE_ROW(parent
)->parent
) {
5280 if (GTK_CMCTREE_ROW(parent
)->sibling
) {
5281 next
= GTK_CMCTREE_ROW(parent
)->sibling
;
5287 if (!new_selected
&&
5288 gtkut_ctree_node_is_selected(ctree
, node
)) {
5289 summary_unselect_all(summaryview
);
5290 new_selected
= summary_find_next_msg(summaryview
, node
,TRUE
);
5292 new_selected
= summary_find_prev_msg
5293 (summaryview
, node
,TRUE
);
5296 gtk_sctree_remove_node((GtkSCTree
*)ctree
, node
);
5299 folder_item_update_thaw();
5302 summary_unlock(summaryview
);
5303 summary_select_node(summaryview
, new_selected
, OPEN_SELECTED_ON_DELETEMOVE
);
5304 summary_lock(summaryview
);
5307 if (summaryview
->threaded
) {
5308 summary_thread_build(summaryview
);
5309 summary_thread_init(summaryview
);
5312 summary_thaw(summaryview
);
5314 summaryview
->selected
= clist
->selection
?
5315 GTK_CMCTREE_NODE(clist
->selection
->data
) : NULL
;
5317 if (!GTK_CMCLIST(summaryview
->ctree
)->row_list
) {
5318 menu_set_insensitive_all
5319 (GTK_MENU_SHELL(summaryview
->popupmenu
));
5320 folderview_grab_focus(summaryview
->folderview
);
5322 menu_set_sensitive_all(GTK_MENU_SHELL(summaryview
->popupmenu
), TRUE
);
5323 gtk_widget_grab_focus(summaryview
->ctree
);
5326 summary_update_status(summaryview
);
5327 summary_status_show(summaryview
);
5329 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
5331 summary_unlock(summaryview
);
5333 main_window_cursor_normal(summaryview
->mainwin
);
5338 static gint
summary_execute_move(SummaryView
*summaryview
)
5340 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5343 /* search moving messages and execute */
5345 gtk_cmctree_pre_recursive(ctree
, NULL
, summary_execute_move_func
,
5348 if (summaryview
->mlist
) {
5349 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST
,
5350 summaryview
->msginfo_update_callback_id
);
5351 val
= procmsg_move_messages(summaryview
->mlist
);
5352 summaryview
->msginfo_update_callback_id
=
5353 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
,
5354 summary_update_msg
, (gpointer
) summaryview
);
5356 for (cur
= summaryview
->mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
5357 procmsg_msginfo_free((MsgInfo
**)&(cur
->data
));
5360 g_slist_free(summaryview
->mlist
);
5361 summaryview
->mlist
= NULL
;
5367 static void summary_execute_move_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5370 SummaryView
*summaryview
= data
;
5373 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5375 if (msginfo
&& MSG_IS_MOVE(msginfo
->flags
) && msginfo
->to_folder
) {
5376 summaryview
->mlist
=
5377 g_slist_prepend(summaryview
->mlist
, msginfo
);
5378 gtk_cmctree_node_set_row_data(ctree
, node
, NULL
);
5380 if (msginfo
->msgid
&& *msginfo
->msgid
&&
5381 node
== g_hash_table_lookup(summaryview
->msgid_table
,
5383 g_hash_table_remove(summaryview
->msgid_table
,
5385 if (prefs_common
.thread_by_subject
&&
5386 msginfo
->subject
&& *msginfo
->subject
&&
5387 node
== subject_table_lookup(summaryview
->subject_table
,
5388 msginfo
->subject
)) {
5389 subject_table_remove(summaryview
->subject_table
,
5395 static void summary_execute_copy(SummaryView
*summaryview
)
5397 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5399 /* search copying messages and execute */
5400 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST
,
5401 summaryview
->msginfo_update_callback_id
);
5402 gtk_cmctree_pre_recursive(ctree
, NULL
, summary_execute_copy_func
,
5405 if (summaryview
->mlist
) {
5406 summaryview
->mlist
= g_slist_reverse(summaryview
->mlist
);
5407 procmsg_copy_messages(summaryview
->mlist
);
5409 g_slist_free(summaryview
->mlist
);
5410 summaryview
->mlist
= NULL
;
5412 summaryview
->msginfo_update_callback_id
=
5413 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
,
5414 summary_update_msg
, (gpointer
) summaryview
);
5417 static void summary_execute_copy_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5420 SummaryView
*summaryview
= data
;
5423 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5425 if (msginfo
&& MSG_IS_COPY(msginfo
->flags
) && msginfo
->to_folder
) {
5426 summaryview
->mlist
=
5427 g_slist_prepend(summaryview
->mlist
, msginfo
);
5429 summary_msginfo_unset_flags(msginfo
, 0, MSG_COPY
);
5430 summary_set_row_marks(summaryview
, node
);
5434 static void summary_execute_delete(SummaryView
*summaryview
)
5436 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5439 /* search deleting messages and execute */
5440 gtk_cmctree_pre_recursive
5441 (ctree
, NULL
, summary_execute_delete_func
, summaryview
);
5443 if (!summaryview
->mlist
) return;
5445 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST
,
5446 summaryview
->msginfo_update_callback_id
);
5448 folder_item_remove_msgs(summaryview
->folder_item
,
5449 summaryview
->mlist
);
5451 summaryview
->msginfo_update_callback_id
=
5452 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
,
5453 summary_update_msg
, (gpointer
) summaryview
);
5455 for (cur
= summaryview
->mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
5456 procmsg_msginfo_free((MsgInfo
**)&(cur
->data
));
5459 g_slist_free(summaryview
->mlist
);
5460 summaryview
->mlist
= NULL
;
5463 static void summary_execute_delete_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5466 SummaryView
*summaryview
= data
;
5469 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5471 if (msginfo
&& MSG_IS_DELETED(msginfo
->flags
)) {
5472 summaryview
->mlist
=
5473 g_slist_prepend(summaryview
->mlist
, msginfo
);
5474 gtk_cmctree_node_set_row_data(ctree
, node
, NULL
);
5476 if (msginfo
->msgid
&& *msginfo
->msgid
&&
5477 node
== g_hash_table_lookup(summaryview
->msgid_table
,
5479 g_hash_table_remove(summaryview
->msgid_table
,
5482 if (prefs_common
.thread_by_subject
&&
5483 msginfo
->subject
&& *msginfo
->subject
&&
5484 node
== subject_table_lookup(summaryview
->subject_table
,
5485 msginfo
->subject
)) {
5486 subject_table_remove(summaryview
->subject_table
,
5492 static void summary_execute_expunge_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5495 SummaryView
*summaryview
= data
;
5498 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5500 if (msginfo
&& MSG_IS_DELETED(msginfo
->flags
)) {
5501 summaryview
->mlist
=
5502 g_slist_prepend(summaryview
->mlist
, msginfo
);
5503 gtk_cmctree_node_set_row_data(ctree
, node
, NULL
);
5505 if (msginfo
->msgid
&& *msginfo
->msgid
&&
5506 node
== g_hash_table_lookup(summaryview
->msgid_table
,
5508 g_hash_table_remove(summaryview
->msgid_table
,
5511 if (prefs_common
.thread_by_subject
&&
5512 msginfo
->subject
&& *msginfo
->subject
&&
5513 node
== subject_table_lookup(summaryview
->subject_table
,
5514 msginfo
->subject
)) {
5515 subject_table_remove(summaryview
->subject_table
,
5521 static void summary_execute_expunge(SummaryView
*summaryview
)
5523 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5526 gtk_cmctree_pre_recursive
5527 (ctree
, NULL
, summary_execute_expunge_func
, summaryview
);
5529 hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST
,
5530 summaryview
->msginfo_update_callback_id
);
5532 folder_item_expunge(summaryview
->folder_item
);
5534 summaryview
->msginfo_update_callback_id
=
5535 hooks_register_hook(MSGINFO_UPDATE_HOOKLIST
,
5536 summary_update_msg
, (gpointer
) summaryview
);
5537 for (cur
= summaryview
->mlist
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
5538 procmsg_msginfo_free((MsgInfo
**)&(cur
->data
));
5540 g_slist_free(summaryview
->mlist
);
5541 summaryview
->mlist
= NULL
;
5544 /* thread functions */
5546 static void summary_thread_build(SummaryView
*summaryview
)
5548 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5549 GtkCMCTreeNode
*node
;
5550 GtkCMCTreeNode
*next
;
5551 GtkCMCTreeNode
*parent
;
5555 summary_lock(summaryview
);
5557 debug_print("Building threads...\n");
5558 STATUSBAR_PUSH(summaryview
->mainwin
, _("Building threads..."));
5559 main_window_cursor_wait(summaryview
->mainwin
);
5561 g_signal_handlers_block_by_func(G_OBJECT(ctree
),
5562 G_CALLBACK(summary_tree_expanded
), summaryview
);
5563 summary_freeze(summaryview
);
5565 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
5567 next
= GTK_CMCTREE_ROW(node
)->sibling
;
5569 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5573 if (msginfo
&& msginfo
->inreplyto
) {
5574 parent
= g_hash_table_lookup(summaryview
->msgid_table
,
5575 msginfo
->inreplyto
);
5577 if (!parent
&& msginfo
->references
) {
5578 for (reflist
= msginfo
->references
;
5579 reflist
!= NULL
; reflist
= reflist
->next
)
5580 if ((parent
= g_hash_table_lookup
5581 (summaryview
->msgid_table
,
5587 if (msginfo
&& prefs_common
.thread_by_subject
&& parent
== NULL
) {
5588 parent
= subject_table_lookup
5589 (summaryview
->subject_table
,
5593 if (parent
&& parent
!= node
&& parent
!= GTK_CMCTREE_ROW(node
)->parent
) {
5594 gtk_cmctree_move(ctree
, node
, parent
, NULL
);
5600 gtkut_ctree_set_focus_row(ctree
, summaryview
->selected
);
5602 summary_thaw(summaryview
);
5603 g_signal_handlers_unblock_by_func(G_OBJECT(ctree
),
5604 G_CALLBACK(summary_tree_expanded
), summaryview
);
5606 debug_print("Building threads done.\n");
5607 STATUSBAR_POP(summaryview
->mainwin
);
5608 main_window_cursor_normal(summaryview
->mainwin
);
5610 summaryview
->threaded
= TRUE
;
5612 summary_unlock(summaryview
);
5615 static void summary_thread_init(SummaryView
*summaryview
)
5617 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5618 GtkCMCTreeNode
*node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
5619 GtkCMCTreeNode
*next
;
5621 if (!summaryview
->thread_collapsed
) {
5622 g_signal_handlers_block_by_func(G_OBJECT(ctree
),
5623 G_CALLBACK(summary_tree_expanded
), summaryview
);
5625 next
= GTK_CMCTREE_ROW(node
)->sibling
;
5626 if (GTK_CMCTREE_ROW(node
)->children
)
5627 gtk_cmctree_expand_recursive(ctree
, node
);
5630 g_signal_handlers_unblock_by_func(G_OBJECT(ctree
),
5631 G_CALLBACK(summary_tree_expanded
), summaryview
);
5636 static void summary_unthread_for_exec(SummaryView
*summaryview
)
5638 GtkCMCTreeNode
*node
;
5639 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5640 gboolean froze
= FALSE
;
5642 debug_print("Unthreading for execution...\n");
5644 START_LONG_OPERATION(summaryview
, TRUE
);
5645 for (node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
5646 node
!= NULL
; node
= GTK_CMCTREE_NODE_NEXT(node
)) {
5647 summary_unthread_for_exec_func(ctree
, node
, summaryview
);
5650 END_LONG_OPERATION(summaryview
);
5652 debug_print("Unthreading for execution done.\n");
5655 static void summary_unthread_for_exec_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
5659 GtkCMCTreeNode
*top_parent
;
5660 GtkCMCTreeNode
*child
;
5661 GtkCMCTreeNode
*sibling
;
5662 SummaryView
* summaryview
= (SummaryView
*)data
;
5663 msginfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(node
);
5666 (!MSG_IS_MOVE(msginfo
->flags
) &&
5667 !MSG_IS_DELETED(msginfo
->flags
)))
5669 child
= GTK_CMCTREE_ROW(node
)->children
;
5672 if (node
== summaryview
->selected
)
5673 summaryview
->selected
= NULL
;
5674 if (node
== summaryview
->displayed
)
5675 summaryview
->displayed
= NULL
;
5677 summary_cancel_mark_read_timeout(summaryview
);
5679 for (top_parent
= node
;
5680 GTK_CMCTREE_ROW(top_parent
)->parent
!= NULL
;
5681 top_parent
= GTK_CMCTREE_ROW(top_parent
)->parent
)
5683 sibling
= GTK_CMCTREE_ROW(top_parent
)->sibling
;
5685 GTK_SCTREE(ctree
)->sorting
= TRUE
;
5686 while (child
!= NULL
) {
5687 GtkCMCTreeNode
*next_child
;
5688 MsgInfo
*cinfo
= GTKUT_CTREE_NODE_GET_ROW_DATA(child
);
5690 next_child
= GTK_CMCTREE_ROW(child
)->sibling
;
5692 if (!MSG_IS_MOVE(cinfo
->flags
) && !MSG_IS_DELETED(cinfo
->flags
)) {
5693 gtk_cmctree_move(ctree
, child
,
5697 if (child
== summaryview
->displayed
) {
5698 messageview_clear(summaryview
->messageview
);
5699 summaryview
->displayed
= NULL
;
5701 if (child
== summaryview
->selected
) {
5702 messageview_clear(summaryview
->messageview
);
5703 summaryview
->selected
= NULL
;
5708 GTK_SCTREE(ctree
)->sorting
= FALSE
;
5711 void summary_expand_threads(SummaryView
*summaryview
)
5713 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5714 GtkCMCTreeNode
*node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
5715 GtkCMCTreeNode
*focus_node
= GTK_CMCTREE_NODE (g_list_nth (GTK_CMCLIST(ctree
)->row_list
, GTK_CMCLIST(ctree
)->focus_row
));
5717 g_signal_handlers_block_by_func(G_OBJECT(ctree
),
5718 G_CALLBACK(summary_tree_expanded
), summaryview
);
5719 summary_freeze(summaryview
);
5720 GTK_SCTREE(ctree
)->sorting
= TRUE
;
5723 if (GTK_CMCTREE_ROW(node
)->children
) {
5724 gtk_cmctree_expand(ctree
, node
);
5725 summary_set_row_marks(summaryview
, node
);
5727 node
= GTK_CMCTREE_NODE_NEXT(node
);
5730 GTK_SCTREE(ctree
)->sorting
= FALSE
;
5732 GTK_CMCLIST(ctree
)->focus_row
= g_list_position (GTK_CMCLIST(ctree
)->row_list
,(GList
*)focus_node
);
5734 summary_thaw(summaryview
);
5736 g_signal_handlers_unblock_by_func(G_OBJECT(ctree
),
5737 G_CALLBACK(summary_tree_expanded
), summaryview
);
5739 summaryview
->thread_collapsed
= FALSE
;
5741 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
5744 void summary_collapse_threads(SummaryView
*summaryview
)
5746 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
5747 GtkCMCTreeNode
*node
= NULL
;
5748 GtkCMCTreeNode
*focus_node
= GTK_CMCTREE_NODE (g_list_nth (GTK_CMCLIST(ctree
)->row_list
, GTK_CMCLIST(ctree
)->focus_row
));
5750 g_signal_handlers_block_by_func(G_OBJECT(ctree
),
5751 G_CALLBACK(summary_tree_collapsed
), summaryview
);
5752 summary_freeze(summaryview
);
5753 GTK_SCTREE(ctree
)->sorting
= TRUE
;
5756 while (node
&& GTK_CMCTREE_ROW(node
)->parent
) {
5757 focus_node
= node
= GTK_CMCTREE_ROW(node
)->parent
;
5759 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_DIRECTIONAL
);
5760 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->row_list
);
5762 if (GTK_CMCTREE_ROW(node
)->children
) {
5763 gtk_cmctree_collapse(ctree
, node
);
5764 summary_set_row_marks(summaryview
, node
);
5766 node
= GTK_CMCTREE_ROW(node
)->sibling
;
5769 GTK_SCTREE(ctree
)->sorting
= FALSE
;
5771 GTK_CMCLIST(ctree
)->focus_row
= g_list_position (GTK_CMCLIST(ctree
)->row_list
,(GList
*)focus_node
);
5773 GTK_SCTREE(ctree
)->anchor_row
=
5774 gtk_cmctree_node_nth(ctree
, GTK_CMCLIST(ctree
)->focus_row
);
5775 summary_thaw(summaryview
);
5776 g_signal_handlers_unblock_by_func(G_OBJECT(ctree
),
5777 G_CALLBACK(summary_tree_collapsed
), summaryview
);
5779 summaryview
->thread_collapsed
= TRUE
;
5781 gtk_cmctree_node_moveto(ctree
, summaryview
->selected
, 0, 0.5, 0);
5784 static void account_rules_radio_button_toggled_cb(GtkToggleButton
*btn
, gpointer data
)
5786 prefs_common
.apply_per_account_filtering_rules
= GPOINTER_TO_INT(data
);
5789 static gboolean
summary_filter_get_mode(void)
5790 /* ask what to do w/ them: skip them, apply them regardless to the account,
5791 use the current account */
5793 /* TODO: eventually also propose to use the current folder's default account,
5795 /* TODO: eventually allow to select the account to use from a optmenu */
5798 GtkWidget
*account_rules_skip
;
5799 GtkWidget
*account_rules_force
;
5800 GtkWidget
*account_rules_user_current
;
5803 vbox
= gtk_vbox_new (FALSE
, 0);
5805 account_rules_skip
= gtk_radio_button_new_with_label
5806 (NULL
, _("Skip these rules"));
5807 account_rules_force
= gtk_radio_button_new_with_label_from_widget
5808 (GTK_RADIO_BUTTON(account_rules_skip
),
5809 _("Apply these rules regardless of the account they belong to"));
5810 account_rules_user_current
= gtk_radio_button_new_with_label_from_widget
5811 (GTK_RADIO_BUTTON(account_rules_skip
),
5812 _("Apply these rules if they apply to the current account"));
5813 gtk_box_pack_start (GTK_BOX (vbox
), account_rules_skip
, FALSE
, FALSE
, 0);
5814 gtk_box_pack_start (GTK_BOX (vbox
), account_rules_force
, FALSE
, FALSE
, 0);
5815 gtk_box_pack_start (GTK_BOX (vbox
), account_rules_user_current
, FALSE
, FALSE
, 0);
5816 g_signal_connect(G_OBJECT(account_rules_skip
), "toggled",
5817 G_CALLBACK(account_rules_radio_button_toggled_cb
),
5818 GINT_TO_POINTER(FILTERING_ACCOUNT_RULES_SKIP
));
5819 g_signal_connect(G_OBJECT(account_rules_force
), "toggled",
5820 G_CALLBACK(account_rules_radio_button_toggled_cb
),
5821 GINT_TO_POINTER(FILTERING_ACCOUNT_RULES_FORCE
));
5822 g_signal_connect(G_OBJECT(account_rules_user_current
), "toggled",
5823 G_CALLBACK(account_rules_radio_button_toggled_cb
),
5824 GINT_TO_POINTER(FILTERING_ACCOUNT_RULES_USE_CURRENT
));
5825 switch (prefs_common
.apply_per_account_filtering_rules
) {
5826 case FILTERING_ACCOUNT_RULES_SKIP
:
5827 gtk_toggle_button_set_active(
5828 GTK_TOGGLE_BUTTON(account_rules_skip
), TRUE
);
5830 case FILTERING_ACCOUNT_RULES_FORCE
:
5831 gtk_toggle_button_set_active(
5832 GTK_TOGGLE_BUTTON(account_rules_force
), TRUE
);
5834 case FILTERING_ACCOUNT_RULES_USE_CURRENT
:
5835 gtk_toggle_button_set_active(
5836 GTK_TOGGLE_BUTTON(account_rules_user_current
), TRUE
);
5840 val
= alertpanel_with_widget(
5842 _("There are some filtering rules that belong to an account.\n"
5843 "Please choose what to do with these rules:"),
5844 GTK_STOCK_CANCEL
, _("_Filter"), NULL
, ALERTFOCUS_SECOND
,
5847 if ((val
& ~G_ALERTDISABLE
) != G_ALERTALTERNATE
) {
5849 } else if (val
& G_ALERTDISABLE
)
5850 prefs_common
.ask_apply_per_account_filtering_rules
= FALSE
;
5855 void summary_filter(SummaryView
*summaryview
, gboolean selected_only
)
5857 GSList
*mlist
= NULL
, *cur_list
;
5858 PrefsAccount
*ac_prefs
= NULL
;
5859 summary_lock(summaryview
);
5861 /* are there any per-account filtering rules? */
5862 if (prefs_common
.ask_apply_per_account_filtering_rules
== TRUE
&&
5863 filtering_peek_per_account_rules(filtering_rules
)) {
5865 if (summary_filter_get_mode() == FALSE
) {
5866 summary_unlock(summaryview
);
5871 folder_item_update_freeze();
5873 debug_print("filtering...\n");
5874 STATUSBAR_PUSH(summaryview
->mainwin
, _("Filtering..."));
5875 main_window_cursor_wait(summaryview
->mainwin
);
5877 summary_freeze(summaryview
);
5879 if (selected_only
) {
5882 for (cur
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
5883 cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
5884 mlist
= g_slist_prepend(mlist
,
5885 procmsg_msginfo_new_ref(
5886 GTKUT_CTREE_NODE_GET_ROW_DATA(cur
->data
)));
5888 mlist
= g_slist_reverse(mlist
);
5890 mlist
= folder_item_get_msg_list(summaryview
->folder_item
);
5893 ac_prefs
= ((summaryview
->folder_item
->folder
!= NULL
) &&
5894 (summaryview
->folder_item
->folder
->account
!= NULL
))
5895 ? summaryview
->folder_item
->folder
->account
: NULL
;
5897 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
5898 for (cur_list
= mlist
; cur_list
; cur_list
= cur_list
->next
) {
5899 summary_filter_func((MsgInfo
*)cur_list
->data
, ac_prefs
);
5901 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
5903 filtering_move_and_copy_msgs(mlist
);
5905 for (cur_list
= mlist
; cur_list
; cur_list
= cur_list
->next
) {
5906 procmsg_msginfo_free((MsgInfo
**)&(cur_list
->data
));
5908 g_slist_free(mlist
);
5910 summary_thaw(summaryview
);
5912 folder_item_update_thaw();
5913 debug_print("filtering done.\n");
5914 STATUSBAR_POP(summaryview
->mainwin
);
5915 main_window_cursor_normal(summaryview
->mainwin
);
5917 summary_unlock(summaryview
);
5920 * CLAWS: summary_show() only valid after having a lock. ideally
5921 * we want the lock to be context aware...
5923 summary_show(summaryview
, summaryview
->folder_item
, TRUE
);
5926 static void summary_filter_func(MsgInfo
*msginfo
, PrefsAccount
*ac_prefs
)
5928 MailFilteringData mail_filtering_data
;
5930 mail_filtering_data
.msginfo
= msginfo
;
5931 mail_filtering_data
.msglist
= NULL
;
5932 mail_filtering_data
.filtered
= NULL
;
5933 mail_filtering_data
.unfiltered
= NULL
;
5934 if (hooks_invoke(MAIL_MANUAL_FILTERING_HOOKLIST
, &mail_filtering_data
))
5937 filter_message_by_msginfo(filtering_rules
, msginfo
, ac_prefs
,
5938 FILTERING_MANUALLY
, NULL
);
5941 void summary_msginfo_filter_open(FolderItem
* item
, MsgInfo
*msginfo
,
5942 PrefsFilterType type
, gint processing_rule
)
5944 gchar
*header
= NULL
;
5947 procmsg_get_filter_keyword(msginfo
, &header
, &key
, type
);
5949 if (processing_rule
) {
5951 prefs_filtering_open(&pre_global_processing
,
5952 _("Processing rules to apply before folder rules"),
5953 MANUAL_ANCHOR_PROCESSING
,
5954 header
, key
, FALSE
);
5956 prefs_filtering_open(&item
->prefs
->processing
,
5957 _("Processing configuration"),
5958 MANUAL_ANCHOR_PROCESSING
,
5959 header
, key
, FALSE
);
5962 prefs_filtering_open(&filtering_rules
,
5963 _("Filtering configuration"),
5964 MANUAL_ANCHOR_FILTERING
,
5972 void summary_filter_open(SummaryView
*summaryview
, PrefsFilterType type
,
5973 gint processing_rule
)
5978 if (!summaryview
->selected
) return;
5980 msginfo
= gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview
->ctree
),
5981 summaryview
->selected
);
5982 if (!msginfo
) return;
5984 item
= summaryview
->folder_item
;
5985 summary_msginfo_filter_open(item
, msginfo
, type
, processing_rule
);
5990 #define N_COLOR_LABELS colorlabel_get_color_count()
5992 static void summary_colorlabel_menu_item_activate_cb(GtkWidget
*widget
,
5995 guint color
= GPOINTER_TO_UINT(data
);
5996 SummaryView
*summaryview
;
5998 summaryview
= g_object_get_data(G_OBJECT(widget
), "summaryview");
5999 cm_return_if_fail(summaryview
!= NULL
);
6001 /* "dont_toggle" state set? */
6002 if (g_object_get_data(G_OBJECT(summaryview
->colorlabel_menu
),
6006 summary_set_colorlabel(summaryview
, color
, NULL
);
6009 /* summary_set_colorlabel_color() - labelcolor parameter is the color *flag*
6010 * for the message; not the color index */
6011 void summary_set_colorlabel_color(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
6015 GtkStyle
*style
, *prev_style
, *ctree_style
;
6019 msginfo
= gtk_cmctree_node_get_row_data(ctree
, node
);
6020 cm_return_if_fail(msginfo
);
6022 color_index
= labelcolor
== 0 ? -1 : (gint
)labelcolor
- 1;
6023 ctree_style
= gtk_widget_get_style(GTK_WIDGET(ctree
));
6024 prev_style
= gtk_cmctree_node_get_row_style(ctree
, node
);
6026 if (color_index
< 0 || color_index
>= N_COLOR_LABELS
) {
6027 if (!prev_style
) return;
6028 style
= gtk_style_copy(prev_style
);
6029 color
= ctree_style
->text
[GTK_STATE_NORMAL
];
6030 style
->text
[GTK_STATE_NORMAL
] = color
;
6031 color
= ctree_style
->text
[GTK_STATE_SELECTED
];
6032 style
->text
[GTK_STATE_SELECTED
] = color
;
6035 style
= gtk_style_copy(prev_style
);
6037 style
= gtk_style_copy(ctree_style
);
6038 color
= colorlabel_get_color(color_index
);
6039 style
->text
[GTK_STATE_NORMAL
] = color
;
6040 /* get the average of label color and selected fg color
6042 style
->text
[GTK_STATE_SELECTED
].red
= (color
.red
+ 3*ctree_style
->text
[GTK_STATE_SELECTED
].red
) / 4;
6043 style
->text
[GTK_STATE_SELECTED
].green
= (color
.green
+ 3*ctree_style
->text
[GTK_STATE_SELECTED
].green
) / 4;
6044 style
->text
[GTK_STATE_SELECTED
].blue
= (color
.blue
+ 3*ctree_style
->text
[GTK_STATE_SELECTED
].blue
) / 4;
6047 gtk_cmctree_node_set_row_style(ctree
, node
, style
);
6048 g_object_unref(style
);
6051 static void summary_set_row_colorlabel(SummaryView
*summaryview
, GtkCMCTreeNode
*row
, guint labelcolor
)
6053 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
6056 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
6057 cm_return_if_fail(msginfo
);
6059 summary_msginfo_change_flags(msginfo
, MSG_COLORLABEL_TO_FLAGS(labelcolor
), 0,
6060 MSG_CLABEL_FLAG_MASK
, 0);
6061 summary_set_row_marks(summaryview
, row
);
6064 void summary_set_colorlabel(SummaryView
*summaryview
, guint labelcolor
,
6067 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
6069 gboolean froze
= FALSE
;
6071 if (prefs_common
.ask_override_colorlabel
) {
6072 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
6073 gboolean ask
= FALSE
;
6076 gboolean already_this_color_everywhere
= TRUE
;
6078 /* if clearing color labels (applying 'none', 0):
6079 - ask if at least one message has a non-0 color label set
6080 if applying a non-0 color label:
6081 - ask if at least one of the selected messages has a non-0 color label different
6082 from the one we want to apply.
6083 - don't ask if all messages have the same color label as the one we're applying
6085 for (cur
= GTK_CMCLIST(ctree
)->selection
;
6086 !ask
&& cur
!= NULL
&& cur
->data
!= NULL
;
6088 MsgInfo
*msginfo
= gtk_cmctree_node_get_row_data(ctree
, GTK_CMCTREE_NODE(cur
->data
));
6090 color
= MSG_GET_COLORLABEL_VALUE(msginfo
->flags
);
6091 if (labelcolor
== 0) {
6092 /* clearing color labels */
6095 already_this_color_everywhere
&= (color
== labelcolor
);
6096 ask
= ((color
!= 0) && (color
!= labelcolor
)) && !already_this_color_everywhere
;
6104 if (labelcolor
== 0)
6105 msg
= _("Do you really want to reset the color label of all selected messages?");
6107 msg
= _("Do you really want to apply this color label to all selected messages?");
6108 val
= alertpanel_full(labelcolor
== 0? _("Reset color label"): _("Set color label"), msg
,
6109 GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
, ALERTFOCUS_FIRST
,
6110 TRUE
, NULL
, ALERT_QUESTION
);
6112 if ((val
& ~G_ALERTDISABLE
) != G_ALERTALTERNATE
)
6114 else if (val
& G_ALERTDISABLE
)
6115 prefs_common
.ask_override_colorlabel
= FALSE
;
6119 START_LONG_OPERATION(summaryview
, FALSE
);
6120 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
6121 summary_set_row_colorlabel(summaryview
,
6122 GTK_CMCTREE_NODE(cur
->data
), labelcolor
);
6123 END_LONG_OPERATION(summaryview
);
6126 static gboolean
summary_set_row_tag(SummaryView
*summaryview
, GtkCMCTreeNode
*row
, gboolean refresh
, gboolean set
, gint id
)
6128 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
6130 gchar
*tags_str
= NULL
;
6131 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
6132 cm_return_val_if_fail(msginfo
, FALSE
);
6134 procmsg_msginfo_update_tags(msginfo
, set
, id
);
6136 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_TAGS
]].visible
) {
6137 tags_str
= procmsg_msginfo_get_tags_str(msginfo
);
6138 gtk_cmctree_node_set_text(ctree
, row
,
6139 summaryview
->col_pos
[S_COL_TAGS
],
6140 tags_str
?tags_str
:"-");
6144 summary_set_row_marks(summaryview
, row
);
6145 if (row
== summaryview
->displayed
) {
6151 void summary_set_tag(SummaryView
*summaryview
, gint tag_id
,
6154 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
6156 gboolean set
= tag_id
> 0;
6157 gint real_id
= set
? tag_id
:-tag_id
;
6158 gboolean froze
= FALSE
;
6159 gboolean redisplay
= FALSE
;
6161 if (summary_is_locked(summaryview
))
6163 START_LONG_OPERATION(summaryview
, FALSE
);
6164 folder_item_set_batch(summaryview
->folder_item
, TRUE
);
6165 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
6166 redisplay
|= summary_set_row_tag(summaryview
,
6167 GTK_CMCTREE_NODE(cur
->data
), FALSE
, set
, real_id
);
6169 folder_item_set_batch(summaryview
->folder_item
, FALSE
);
6170 END_LONG_OPERATION(summaryview
);
6172 summary_redisplay_msg(summaryview
);
6175 static void summary_tags_menu_item_activate_cb(GtkWidget
*widget
,
6178 gint id
= GPOINTER_TO_INT(data
);
6179 gboolean set
= gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget
));
6180 SummaryView
*summaryview
;
6182 summaryview
= g_object_get_data(G_OBJECT(widget
), "summaryview");
6183 cm_return_if_fail(summaryview
!= NULL
);
6185 /* "dont_toggle" state set? */
6186 if (g_object_get_data(G_OBJECT(summaryview
->tags_menu
),
6192 summary_set_tag(summaryview
, id
, NULL
);
6195 static void summary_colorlabel_menu_item_activate_item_cb(GtkMenuItem
*menu_item
,
6198 SummaryView
*summaryview
;
6200 GtkCheckMenuItem
**items
;
6202 GList
*children
, *cur
, *sel
;
6204 summaryview
= (SummaryView
*)data
;
6205 cm_return_if_fail(summaryview
!= NULL
);
6207 sel
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
6210 menu
= GTK_MENU_SHELL(summaryview
->colorlabel_menu
);
6212 cm_return_if_fail(menu
!= NULL
);
6214 Xalloca(items
, (N_COLOR_LABELS
+ 1) * sizeof(GtkWidget
*), return);
6216 /* NOTE: don't return prematurely because we set the "dont_toggle"
6217 * state for check menu items */
6218 g_object_set_data(G_OBJECT(menu
), "dont_toggle",
6219 GINT_TO_POINTER(1));
6221 /* clear items. get item pointers. */
6222 children
= gtk_container_get_children(GTK_CONTAINER(menu
));
6223 for (n
= 0, cur
= children
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
6224 if (GTK_IS_CHECK_MENU_ITEM(cur
->data
)) {
6225 gtk_check_menu_item_set_active
6226 (GTK_CHECK_MENU_ITEM(cur
->data
), FALSE
);
6227 items
[n
] = GTK_CHECK_MENU_ITEM(cur
->data
);
6232 g_list_free(children
);
6234 if (n
== (N_COLOR_LABELS
+ 1)) {
6235 /* iterate all messages and set the state of the appropriate
6237 for (; sel
!= NULL
; sel
= sel
->next
) {
6241 msginfo
= gtk_cmctree_node_get_row_data
6242 (GTK_CMCTREE(summaryview
->ctree
),
6243 GTK_CMCTREE_NODE(sel
->data
));
6245 clabel
= MSG_GET_COLORLABEL_VALUE(msginfo
->flags
);
6246 if (!gtk_check_menu_item_get_active(items
[clabel
]))
6247 gtk_check_menu_item_set_active
6248 (items
[clabel
], TRUE
);
6252 g_warning("invalid number of color elements (%d)", n
);
6254 /* reset "dont_toggle" state */
6255 g_object_set_data(G_OBJECT(menu
), "dont_toggle",
6256 GINT_TO_POINTER(0));
6259 static void summary_colorlabel_menu_create(SummaryView
*summaryview
, gboolean refresh
)
6261 GtkWidget
*label_menuitem
;
6265 gchar
*accel_path
= NULL
;
6267 label_menuitem
= gtk_ui_manager_get_widget(summaryview
->mainwin
->ui_manager
, "/Menus/SummaryViewPopup/ColorLabel");
6268 g_signal_connect(G_OBJECT(label_menuitem
), "activate",
6269 G_CALLBACK(summary_colorlabel_menu_item_activate_item_cb
),
6271 gtk_widget_show(label_menuitem
);
6273 menu
= gtk_menu_new();
6275 gtk_menu_set_accel_group (GTK_MENU (menu
),
6276 gtk_ui_manager_get_accel_group(mainwindow_get_mainwindow()->ui_manager
));
6278 /* create sub items. for the menu item activation callback we pass the
6279 * index of label_colors[] as data parameter. for the None color we
6280 * pass an invalid (high) value. also we attach a data pointer so we
6281 * can always get back the SummaryView pointer. */
6283 item
= gtk_check_menu_item_new_with_label(_("None"));
6284 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6285 g_signal_connect(G_OBJECT(item
), "activate",
6286 G_CALLBACK(summary_colorlabel_menu_item_activate_cb
),
6287 GUINT_TO_POINTER(0));
6288 g_object_set_data(G_OBJECT(item
), "summaryview", summaryview
);
6289 gtk_widget_show(item
);
6291 accel_path
= g_strdup_printf("<ClawsColorLabels>/None");
6292 gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item
), accel_path
);
6294 gtk_accel_map_add_entry("<ClawsColorLabels>/None", GDK_KEY_0
, GDK_CONTROL_MASK
);
6296 item
= gtk_menu_item_new();
6297 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6298 gtk_widget_show(item
);
6300 /* create pixmap/label menu items */
6301 for (i
= 0; i
< N_COLOR_LABELS
; i
++) {
6302 item
= colorlabel_create_check_color_menu_item(
6303 i
, refresh
, SUMMARY_COLORMENU
);
6304 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6305 g_signal_connect(G_OBJECT(item
), "activate",
6306 G_CALLBACK(summary_colorlabel_menu_item_activate_cb
),
6307 GUINT_TO_POINTER(i
+ 1));
6308 g_object_set_data(G_OBJECT(item
), "summaryview",
6310 gtk_widget_show(item
);
6311 accel_path
= g_strdup_printf("<ClawsColorLabels>/%d", i
+1);
6312 gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item
), accel_path
);
6314 gtk_accel_map_add_entry(accel_path
, GDK_KEY_1
+i
, GDK_CONTROL_MASK
);
6316 g_signal_connect (gtk_ui_manager_get_accel_group(mainwindow_get_mainwindow()->ui_manager
),
6317 "accel-changed", G_CALLBACK (mainwin_accel_changed_cb
), item
);
6320 gtk_widget_show(menu
);
6321 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem
), menu
);
6322 summaryview
->colorlabel_menu
= menu
;
6325 static void summary_tags_menu_item_activate_item_cb(GtkMenuItem
*menu_item
,
6329 GList
*children
, *cur
;
6331 GHashTable
*menu_table
= g_hash_table_new_full(
6335 GHashTable
*menu_allsel_table
= g_hash_table_new_full(
6340 SummaryView
*summaryview
= (SummaryView
*)data
;
6341 cm_return_if_fail(summaryview
!= NULL
);
6343 sel
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
6346 menu
= GTK_MENU_SHELL(summaryview
->tags_menu
);
6347 cm_return_if_fail(menu
!= NULL
);
6349 /* NOTE: don't return prematurely because we set the "dont_toggle"
6350 * state for check menu items */
6351 g_object_set_data(G_OBJECT(menu
), "dont_toggle",
6352 GINT_TO_POINTER(1));
6354 /* clear items. get item pointers. */
6355 children
= gtk_container_get_children(GTK_CONTAINER(menu
));
6356 for (cur
= children
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
6357 if (GTK_IS_CHECK_MENU_ITEM(cur
->data
)) {
6358 gint id
= GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur
->data
),
6360 gtk_check_menu_item_set_active
6361 (GTK_CHECK_MENU_ITEM(cur
->data
), FALSE
);
6363 g_hash_table_insert(menu_table
, GINT_TO_POINTER(id
), GTK_CHECK_MENU_ITEM(cur
->data
));
6364 g_hash_table_insert(menu_allsel_table
, GINT_TO_POINTER(id
), GINT_TO_POINTER(0));
6368 g_list_free(children
);
6370 /* iterate all messages and set the state of the appropriate
6373 for (; sel
!= NULL
; sel
= sel
->next
) {
6375 GSList
*tags
= NULL
;
6376 GtkCheckMenuItem
*item
;
6377 msginfo
= gtk_cmctree_node_get_row_data
6378 (GTK_CMCTREE(summaryview
->ctree
),
6379 GTK_CMCTREE_NODE(sel
->data
));
6382 tags
= msginfo
->tags
;
6386 for (; tags
; tags
= tags
->next
) {
6387 gint num_checked
= GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table
, tags
->data
));
6388 item
= g_hash_table_lookup(menu_table
, GINT_TO_POINTER(tags
->data
));
6389 if (item
&& !gtk_check_menu_item_get_active(item
)) {
6390 gtk_check_menu_item_set_active
6394 g_hash_table_replace(menu_allsel_table
, tags
->data
, GINT_TO_POINTER(num_checked
));
6399 children
= gtk_container_get_children(GTK_CONTAINER(menu
));
6400 for (cur
= children
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
6401 if (GTK_IS_CHECK_MENU_ITEM(cur
->data
)) {
6402 gint id
= GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur
->data
),
6404 gint num_checked
= GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table
, GINT_TO_POINTER(id
)));
6405 if (num_checked
< sel_len
&& num_checked
> 0)
6406 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur
->data
), TRUE
);
6408 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur
->data
), FALSE
);
6411 g_list_free(children
);
6412 g_hash_table_destroy(menu_table
);
6413 g_hash_table_destroy(menu_allsel_table
);
6414 /* reset "dont_toggle" state */
6415 g_object_set_data(G_OBJECT(menu
), "dont_toggle",
6416 GINT_TO_POINTER(0));
6419 void summaryview_destroy(SummaryView
*summaryview
)
6421 if(summaryview
->simplify_subject_preg
) {
6422 regfree(summaryview
->simplify_subject_preg
);
6423 g_free(summaryview
->simplify_subject_preg
);
6424 summaryview
->simplify_subject_preg
= NULL
;
6427 static void summary_tags_menu_item_apply_tags_activate_cb(GtkWidget
*widget
,
6430 SummaryView
*summaryview
;
6432 summaryview
= g_object_get_data(G_OBJECT(widget
), "summaryview");
6433 cm_return_if_fail(summaryview
!= NULL
);
6435 /* "dont_toggle" state set? */
6436 if (g_object_get_data(G_OBJECT(summaryview
->tags_menu
),
6440 tags_window_open(summary_get_selection(summaryview
));
6443 static gint
summary_tag_cmp_list(gconstpointer a
, gconstpointer b
)
6445 gint id_a
= GPOINTER_TO_INT(a
);
6446 gint id_b
= GPOINTER_TO_INT(b
);
6447 const gchar
*tag_a
= tags_get_tag(id_a
);
6448 const gchar
*tag_b
= tags_get_tag(id_b
);
6451 return tag_b
== NULL
? 0:1;
6456 return g_utf8_collate(tag_a
, tag_b
);
6459 static void summary_tags_menu_create(SummaryView
*summaryview
, gboolean refresh
)
6462 GtkWidget
*label_menuitem
;
6465 GSList
*cur
= tags_get_list();
6466 GSList
*orig
= NULL
;
6467 gboolean existing_tags
= FALSE
;
6468 gchar
*accel_path
= NULL
;
6470 cur
= orig
= g_slist_sort(cur
, summary_tag_cmp_list
);
6471 label_menuitem
= gtk_ui_manager_get_widget(summaryview
->mainwin
->ui_manager
, "/Menus/SummaryViewPopup/Tags");
6472 g_signal_connect(G_OBJECT(label_menuitem
), "activate",
6473 G_CALLBACK(summary_tags_menu_item_activate_item_cb
),
6476 gtk_widget_show(label_menuitem
);
6478 menu
= gtk_menu_new();
6480 gtk_menu_set_accel_group (GTK_MENU (menu
),
6481 gtk_ui_manager_get_accel_group(summaryview
->mainwin
->ui_manager
));
6483 /* create tags menu items */
6484 for (; cur
; cur
= cur
->next
) {
6485 gint id
= GPOINTER_TO_INT(cur
->data
);
6486 const gchar
*tag
= tags_get_tag(id
);
6487 item
= gtk_check_menu_item_new_with_label(tag
);
6488 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6489 g_signal_connect(G_OBJECT(item
), "activate",
6490 G_CALLBACK(summary_tags_menu_item_activate_cb
),
6491 GINT_TO_POINTER(id
));
6492 g_object_set_data(G_OBJECT(item
), "summaryview",
6494 g_object_set_data(G_OBJECT(item
), "tag_id",
6495 GINT_TO_POINTER(id
));
6496 gtk_widget_show(item
);
6497 accel_path
= g_strconcat("<ClawsTags>/",tag
, NULL
);
6498 gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item
), accel_path
);
6500 existing_tags
= TRUE
;
6502 if (existing_tags
) {
6504 item
= gtk_menu_item_new();
6505 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6506 gtk_widget_show(item
);
6509 item
= gtk_menu_item_new_with_label(_("Modify tags..."));
6510 gtk_menu_shell_append(GTK_MENU_SHELL(menu
), item
);
6511 g_signal_connect(G_OBJECT(item
), "activate",
6512 G_CALLBACK(summary_tags_menu_item_apply_tags_activate_cb
),
6514 g_object_set_data(G_OBJECT(item
), "summaryview",
6516 gtk_widget_show(item
);
6517 accel_path
= g_strdup_printf("<ClawsTags>/ModifyTags");
6518 gtk_menu_item_set_accel_path(GTK_MENU_ITEM(item
), accel_path
);
6522 gtk_widget_show(menu
);
6523 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem
), menu
);
6524 summaryview
->tags_menu
= menu
;
6527 static gboolean
summary_popup_menu(GtkWidget
*widget
, gpointer data
)
6529 SummaryView
*summaryview
= (SummaryView
*)data
;
6530 summaryview
->display_msg
= messageview_is_visible(summaryview
->messageview
);
6532 gtk_menu_popup(GTK_MENU(summaryview
->popupmenu
),
6533 NULL
, NULL
, NULL
, NULL
,
6534 3, gtk_get_current_event_time());
6540 static gchar
*summaryview_get_tooltip_text(SummaryView
*summaryview
, MsgInfo
*info
, gint column
)
6546 flags
= info
->flags
;
6548 switch(summaryview
->col_state
[column
].type
) {
6550 if (MSG_IS_IGNORE_THREAD(flags
)) {
6551 return _("Ignored thread");
6552 } else if (MSG_IS_WATCH_THREAD(flags
)) {
6553 return _("Watched thread");
6554 } else if (MSG_IS_SPAM(flags
)) {
6556 } else if (MSG_IS_NEW(flags
)) {
6558 } else if (MSG_IS_UNREAD(flags
)) {
6560 } else if (MSG_IS_REPLIED(flags
) && MSG_IS_FORWARDED(flags
)) {
6561 return _("Replied but also forwarded - click to see reply");
6562 } else if (MSG_IS_REPLIED(flags
)) {
6563 return _("Replied - click to see reply");
6564 } else if (MSG_IS_FORWARDED(flags
)) {
6565 return _("Forwarded");
6570 if (MSG_IS_DELETED(flags
)) {
6571 return _("Deleted");
6572 } else if (MSG_IS_MARKED(flags
)) {
6574 } else if (MSG_IS_MOVE(flags
)) {
6575 return _("To be moved");
6576 } else if (MSG_IS_COPY(flags
)) {
6577 return _("To be copied");
6582 if (MSG_IS_LOCKED(flags
)) {
6588 if (MSG_IS_WITH_ATTACHMENT(flags
) && MSG_IS_SIGNED(flags
)) {
6589 return _("Signed, has attachment(s)");
6590 } else if (MSG_IS_SIGNED(flags
)) {
6592 } else if (MSG_IS_WITH_ATTACHMENT(flags
) && MSG_IS_ENCRYPTED(flags
)) {
6593 return _("Encrypted, has attachment(s)");
6594 } else if (MSG_IS_ENCRYPTED(flags
)) {
6595 return _("Encrypted");
6596 } else if (MSG_IS_WITH_ATTACHMENT(flags
)) {
6597 return _("Has attachment(s)");
6605 static gboolean
tooltip_cb (GtkWidget
*widget
,
6608 gboolean keyboard_mode
,
6609 GtkTooltip
*tooltip
,
6612 GtkCMCTree
*ctree
= GTK_CMCTREE(widget
);
6613 SummaryView
*summaryview
= (SummaryView
*)user_data
;
6614 gint row
= -1, column
= -1;
6615 int offset
= prefs_common
.show_col_headers
? 24:0;
6616 GtkCMCTreeNode
*node
= NULL
;
6618 gchar
*formatted
= NULL
;
6619 MsgInfo
*info
= NULL
;
6621 gboolean vert_layout
= (prefs_common
.layout_mode
== VERTICAL_LAYOUT
);
6622 gboolean small_layout
= (prefs_common
.layout_mode
== SMALL_LAYOUT
);
6623 if (!prefs_common
.show_tooltips
)
6629 if (!gtk_cmclist_get_selection_info(GTK_CMCLIST(ctree
), x
, y
- offset
,
6633 if ((node
= gtk_cmctree_node_nth(ctree
, row
)) == NULL
)
6636 if ((info
= gtk_cmctree_node_get_row_data(ctree
, node
)) == NULL
)
6639 switch (gtk_cmctree_node_get_cell_type(ctree
, node
, column
)) {
6640 case GTK_CMCELL_TEXT
:
6641 if (gtk_cmctree_node_get_text(ctree
, node
, column
, &text
) != TRUE
)
6644 case GTK_CMCELL_PIXTEXT
:
6645 if (gtk_cmctree_node_get_pixtext(ctree
, node
, column
, &text
,
6646 NULL
, NULL
) != TRUE
)
6650 if ((text
= summaryview_get_tooltip_text(summaryview
, info
, column
)) == NULL
)
6654 if (!text
|| !*text
)
6657 formatted
= g_strdup(text
);
6658 g_strstrip(formatted
);
6660 if ((vert_layout
|| small_layout
) && prefs_common
.two_line_vert
)
6661 gtk_tooltip_set_markup (tooltip
, formatted
);
6663 gtk_tooltip_set_text (tooltip
, formatted
);
6670 gtk_tooltip_set_tip_area(tooltip
, &rect
);
6676 static gboolean
summary_header_button_pressed(GtkWidget
*widget
,
6680 GdkEventButton
*event
= (GdkEventButton
*)_event
;
6681 SummaryView
*summaryview
= (SummaryView
*)user_data
;
6683 cm_return_val_if_fail(summaryview
!= NULL
, FALSE
);
6685 /* Only handle single button presses. */
6686 if (event
->type
== GDK_2BUTTON_PRESS
||
6687 event
->type
== GDK_3BUTTON_PRESS
)
6690 /* Handle right-click for context menu */
6691 if (event
->button
== 3) {
6692 /* Set up any menu items that need setting up. */
6693 summaryview
->header_menu_lock
= TRUE
;
6694 cm_toggle_menu_set_active_full(summaryview
->mainwin
->ui_manager
,
6695 "Menus/SummaryViewHeaderPopup/LockColumnHeaders",
6696 prefs_common_get_prefs()->summary_col_lock
);
6697 summaryview
->header_menu_lock
= FALSE
;
6699 gtk_menu_popup(GTK_MENU(summaryview
->headerpopupmenu
),
6700 NULL
, NULL
, NULL
, NULL
, 3, event
->time
);
6707 static GtkWidget
*summary_ctree_create(SummaryView
*summaryview
)
6710 gint
*col_pos
= summaryview
->col_pos
;
6711 SummaryColumnState
*col_state
;
6712 gchar
*titles
[N_SUMMARY_COLS
];
6713 SummaryColumnType type
;
6715 gboolean vert_layout
= (prefs_common
.layout_mode
== VERTICAL_LAYOUT
);
6716 gboolean small_layout
= (prefs_common
.layout_mode
== SMALL_LAYOUT
);
6717 memset(titles
, 0, sizeof(titles
));
6719 col_state
= prefs_summary_column_get_config();
6720 for (pos
= 0; pos
< N_SUMMARY_COLS
; pos
++) {
6721 summaryview
->col_state
[pos
] = col_state
[pos
];
6722 type
= col_state
[pos
].type
;
6723 col_pos
[type
] = pos
;
6724 titles
[pos
] = "dummy";
6726 col_state
= summaryview
->col_state
;
6728 ctree
= gtk_sctree_new_with_titles
6729 (N_SUMMARY_COLS
, col_pos
[S_COL_SUBJECT
], titles
);
6731 if (prefs_common
.show_col_headers
== FALSE
)
6732 gtk_cmclist_column_titles_hide(GTK_CMCLIST(ctree
));
6734 gtk_cmclist_set_selection_mode(GTK_CMCLIST(ctree
), GTK_SELECTION_MULTIPLE
);
6735 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_MARK
],
6736 GTK_JUSTIFY_CENTER
);
6737 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_STATUS
],
6738 GTK_JUSTIFY_CENTER
);
6739 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_LOCKED
],
6740 GTK_JUSTIFY_CENTER
);
6741 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_MIME
],
6742 GTK_JUSTIFY_CENTER
);
6743 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_SIZE
],
6745 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_NUMBER
],
6747 gtk_cmclist_set_column_justification(GTK_CMCLIST(ctree
), col_pos
[S_COL_SCORE
],
6749 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_MARK
],
6750 prefs_common
.summary_col_size
[S_COL_MARK
]);
6751 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_STATUS
],
6752 prefs_common
.summary_col_size
[S_COL_STATUS
]);
6753 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_LOCKED
],
6754 prefs_common
.summary_col_size
[S_COL_LOCKED
]);
6755 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_MIME
],
6756 prefs_common
.summary_col_size
[S_COL_MIME
]);
6757 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_SUBJECT
],
6758 prefs_common
.summary_col_size
[S_COL_SUBJECT
]);
6759 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_FROM
],
6760 prefs_common
.summary_col_size
[S_COL_FROM
]);
6761 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_TO
],
6762 prefs_common
.summary_col_size
[S_COL_TO
]);
6763 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_DATE
],
6764 prefs_common
.summary_col_size
[S_COL_DATE
]);
6765 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_SIZE
],
6766 prefs_common
.summary_col_size
[S_COL_SIZE
]);
6767 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_NUMBER
],
6768 prefs_common
.summary_col_size
[S_COL_NUMBER
]);
6769 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_SCORE
],
6770 prefs_common
.summary_col_size
[S_COL_SCORE
]);
6771 gtk_cmclist_set_column_width(GTK_CMCLIST(ctree
), col_pos
[S_COL_TAGS
],
6772 prefs_common
.summary_col_size
[S_COL_TAGS
]);
6774 gtk_cmctree_set_expander_style(GTK_CMCTREE(ctree
),
6775 GTK_CMCTREE_EXPANDER_TRIANGLE
);
6777 gtk_sctree_set_stripes(GTK_SCTREE(ctree
), prefs_common
.use_stripes_in_summaries
);
6779 gtk_cmctree_set_indent(GTK_CMCTREE(ctree
), 12);
6780 g_object_set_data(G_OBJECT(ctree
), "summaryview", (gpointer
)summaryview
);
6782 for (pos
= 0; pos
< N_SUMMARY_COLS
; pos
++) {
6783 gtk_widget_set_can_focus(GTK_CMCLIST(ctree
)->column
[pos
].button
,
6785 if (((pos
== summaryview
->col_pos
[S_COL_FROM
] && !FOLDER_SHOWS_TO_HDR(summaryview
->folder_item
)) ||
6786 (pos
== summaryview
->col_pos
[S_COL_TO
] && FOLDER_SHOWS_TO_HDR(summaryview
->folder_item
)) ||
6787 pos
== summaryview
->col_pos
[S_COL_DATE
]) && (vert_layout
|| small_layout
) &&
6788 prefs_common
.two_line_vert
)
6789 gtk_cmclist_set_column_visibility
6790 (GTK_CMCLIST(ctree
), pos
, FALSE
);
6792 gtk_cmclist_set_column_visibility
6793 (GTK_CMCLIST(ctree
), pos
, col_state
[pos
].visible
);
6795 if (prefs_common
.two_line_vert
)
6796 gtk_sctree_set_use_markup(GTK_SCTREE(ctree
), summaryview
->col_pos
[S_COL_SUBJECT
], vert_layout
||small_layout
);
6798 /* connect signal to the buttons for sorting */
6799 #define CLIST_BUTTON_SIGNAL_CONNECT(col, func) \
6801 (G_OBJECT(GTK_CMCLIST(ctree)->column[col_pos[col]].button), \
6802 "button-press-event", \
6803 G_CALLBACK(summary_header_button_pressed), \
6806 (G_OBJECT(GTK_CMCLIST(ctree)->column[col_pos[col]].button), \
6811 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_MARK
, summary_mark_clicked
)
6812 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_STATUS
, summary_status_clicked
)
6813 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_MIME
, summary_mime_clicked
)
6814 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_NUMBER
, summary_num_clicked
)
6815 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_SIZE
, summary_size_clicked
)
6816 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_DATE
, summary_date_clicked
)
6817 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_FROM
, summary_from_clicked
)
6818 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_TO
, summary_to_clicked
)
6819 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_SUBJECT
, summary_subject_clicked
)
6820 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_SCORE
, summary_score_clicked
)
6821 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_LOCKED
, summary_locked_clicked
)
6822 CLIST_BUTTON_SIGNAL_CONNECT(S_COL_TAGS
, summary_tags_clicked
)
6824 #undef CLIST_BUTTON_SIGNAL_CONNECT
6826 g_signal_connect(G_OBJECT(ctree
), "tree_select_row",
6827 G_CALLBACK(summary_selected
), summaryview
);
6828 g_signal_connect(G_OBJECT(ctree
), "tree_unselect_row",
6829 G_CALLBACK(summary_unselected
), summaryview
);
6830 g_signal_connect(G_OBJECT(ctree
), "button_press_event",
6831 G_CALLBACK(summary_button_pressed
),
6833 g_signal_connect(G_OBJECT(ctree
), "popup-menu",
6834 G_CALLBACK(summary_popup_menu
), summaryview
);
6835 g_signal_connect(G_OBJECT(ctree
), "button_release_event",
6836 G_CALLBACK(summary_button_released
),
6838 g_signal_connect(G_OBJECT(ctree
), "key_press_event",
6839 G_CALLBACK(summary_key_pressed
), summaryview
);
6840 g_signal_connect(G_OBJECT(ctree
), "resize_column",
6841 G_CALLBACK(summary_col_resized
), summaryview
);
6842 g_signal_connect(G_OBJECT(ctree
), "open_row",
6843 G_CALLBACK(summary_open_row
), summaryview
);
6845 g_signal_connect_after(G_OBJECT(ctree
), "tree_expand",
6846 G_CALLBACK(summary_tree_expanded
),
6848 g_signal_connect_after(G_OBJECT(ctree
), "tree_collapse",
6849 G_CALLBACK(summary_tree_collapsed
),
6852 g_signal_connect(G_OBJECT(ctree
), "start_drag",
6853 G_CALLBACK(summary_start_drag
),
6855 g_signal_connect(G_OBJECT(ctree
), "drag_data_get",
6856 G_CALLBACK(summary_drag_data_get
),
6858 g_signal_connect(G_OBJECT(ctree
), "drag_end",
6859 G_CALLBACK(summary_drag_end
),
6862 gtk_drag_dest_set(ctree
, GTK_DEST_DEFAULT_ALL
& ~GTK_DEST_DEFAULT_HIGHLIGHT
,
6863 summary_drag_types
, 3,
6864 GDK_ACTION_MOVE
| GDK_ACTION_COPY
| GDK_ACTION_DEFAULT
);
6866 g_signal_connect(G_OBJECT(ctree
), "drag_data_received",
6867 G_CALLBACK(summary_drag_data_received
),
6870 g_signal_connect(G_OBJECT(ctree
), "drag_motion",
6871 G_CALLBACK(summary_drag_motion_cb
),
6875 g_object_set (G_OBJECT(ctree
), "has-tooltip", TRUE
, NULL
);
6876 g_signal_connect(G_OBJECT(ctree
), "query-tooltip",
6877 G_CALLBACK(tooltip_cb
),
6883 void summary_set_column_order(SummaryView
*summaryview
)
6886 GtkWidget
*scrolledwin
= summaryview
->scrolledwin
;
6888 guint selected_msgnum
= summary_get_msgnum(summaryview
, summaryview
->selected
);
6889 guint displayed_msgnum
= summary_get_msgnum(summaryview
, summaryview
->displayed
);
6891 item
= summaryview
->folder_item
;
6893 summary_clear_all(summaryview
);
6894 gtk_widget_destroy(summaryview
->ctree
);
6896 summaryview
->ctree
= ctree
= summary_ctree_create(summaryview
);
6897 summary_set_fonts(summaryview
);
6898 summary_set_column_titles(summaryview
);
6899 gtk_scrolled_window_set_hadjustment(GTK_SCROLLED_WINDOW(scrolledwin
),
6900 GTK_CMCLIST(ctree
)->hadjustment
);
6901 gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(scrolledwin
),
6902 GTK_CMCLIST(ctree
)->vadjustment
);
6903 gtk_container_add(GTK_CONTAINER(scrolledwin
), ctree
);
6904 gtk_widget_show(ctree
);
6906 summary_show(summaryview
, item
, FALSE
);
6908 summary_select_by_msgnum(summaryview
, selected_msgnum
, FALSE
);
6910 summaryview
->selected
= summary_find_msg_by_msgnum(summaryview
, selected_msgnum
);
6911 summaryview
->displayed
= summary_find_msg_by_msgnum(summaryview
, displayed_msgnum
);
6912 if (!summaryview
->displayed
)
6913 messageview_clear(summaryview
->messageview
);
6915 summary_redisplay_msg(summaryview
);
6917 /* get normal row height */
6918 gtk_cmclist_set_row_height(GTK_CMCLIST(ctree
), 0);
6919 normal_row_height
= GTK_CMCLIST(ctree
)->row_height
;
6921 if ((prefs_common
.layout_mode
== SMALL_LAYOUT
|| prefs_common
.layout_mode
== VERTICAL_LAYOUT
) &&
6922 prefs_common
.two_line_vert
) {
6923 gtk_cmclist_set_row_height(GTK_CMCLIST(summaryview
->ctree
), 2*normal_row_height
+ 2);
6928 /* callback functions */
6930 static gint
summary_folder_eventbox_pressed(GtkWidget
*eventbox
, GdkEventButton
*event
,
6931 SummaryView
*summaryview
)
6934 folderview_grab_focus(summaryview
->folderview
);
6935 mainwindow_exit_folder(summaryview
->mainwin
);
6940 static gint
summary_toggle_pressed(GtkWidget
*eventbox
, GdkEventButton
*event
,
6941 SummaryView
*summaryview
)
6944 summary_toggle_view(summaryview
);
6948 static void summary_toggle_multiple_pressed(GtkWidget
*widget
,
6949 SummaryView
*summaryview
)
6951 GTK_SCTREE(summaryview
->ctree
)->force_additive_sel
=
6952 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget
));
6955 static gboolean
summary_button_pressed(GtkWidget
*ctree
, GdkEventButton
*event
,
6956 SummaryView
*summaryview
)
6958 if (!event
) return FALSE
;
6959 if (event
->window
!= GTK_CMCLIST(ctree
)->clist_window
) return FALSE
;
6961 if (event
->button
== 3) {
6963 summary_set_menu_sensitive(summaryview
);
6964 gtk_menu_popup(GTK_MENU(summaryview
->popupmenu
), NULL
, NULL
,
6965 NULL
, NULL
, event
->button
, event
->time
);
6966 } else if (event
->button
== 2) {
6967 summaryview
->display_msg
= messageview_is_visible(summaryview
->messageview
);
6968 } else if (event
->button
== 1) {
6969 if (!prefs_common
.emulate_emacs
&&
6970 messageview_is_visible(summaryview
->messageview
))
6971 summaryview
->display_msg
= TRUE
;
6977 static gboolean
summary_button_released(GtkWidget
*ctree
, GdkEventButton
*event
,
6978 SummaryView
*summaryview
)
6983 gboolean
summary_pass_key_press_event(SummaryView
*summaryview
, GdkEventKey
*event
)
6987 if (summary_is_list(summaryview
))
6988 return summary_key_pressed(summaryview
->ctree
, event
, summaryview
);
6993 #define BREAK_ON_MODIFIER_KEY() \
6994 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
6996 /* Copied from gtkcmclist.c, if it changes there, it has to change
6997 * here as well. This is an ugly hack, there must be a better way to
6998 * find out how much to move for page up/down. */
6999 #define CELL_SPACING 1
7000 static gboolean
summary_key_pressed(GtkWidget
*widget
, GdkEventKey
*event
,
7001 SummaryView
*summaryview
)
7003 GtkCMCTree
*ctree
= GTK_CMCTREE(widget
);
7004 GtkCMCTreeNode
*node
;
7005 MessageView
*messageview
;
7007 gboolean mod_pressed
;
7012 if (quicksearch_has_focus(summaryview
->quicksearch
))
7015 messageview
= summaryview
->messageview
;
7018 ((event
->state
& (GDK_SHIFT_MASK
|GDK_MOD1_MASK
)) != 0);
7020 if (summaryview
->selected
) {
7021 gboolean handled
= FALSE
;
7022 switch (event
->keyval
) {
7023 case GDK_KEY_space
: /* Page down or go to the next */
7025 if (event
->state
& GDK_CONTROL_MASK
) {
7029 if (event
->state
& GDK_SHIFT_MASK
)
7030 mimeview_scroll_page(messageview
->mimeview
, TRUE
);
7031 if (summaryview
->displayed
!= summaryview
->selected
) {
7032 summary_display_msg(summaryview
,
7033 summaryview
->selected
);
7036 if (!mimeview_scroll_page(messageview
->mimeview
, TRUE
))
7037 summary_select_prev_unread(summaryview
);
7039 if (!mimeview_scroll_page(messageview
->mimeview
, FALSE
))
7040 summary_select_next_unread(summaryview
);
7044 case GDK_KEY_BackSpace
: /* Page up */
7046 mimeview_scroll_page(messageview
->mimeview
, TRUE
);
7048 case GDK_KEY_Return
: /* Scroll up/down one line */
7049 case GDK_KEY_KP_Enter
:
7051 if (summaryview
->displayed
!= summaryview
->selected
) {
7052 #ifndef GENERIC_UMPC
7053 summary_display_msg(summaryview
,
7054 summaryview
->selected
);
7056 summary_open_row(NULL
, summaryview
);
7060 mimeview_scroll_one_line(messageview
->mimeview
, mod_pressed
);
7067 if (summary_is_locked(summaryview
))
7070 switch (event
->keyval
) {
7071 case GDK_KEY_Left
: /* Move focus */
7072 adj
= gtk_scrolled_window_get_hadjustment
7073 (GTK_SCROLLED_WINDOW(summaryview
->scrolledwin
));
7074 if (gtk_adjustment_get_lower(adj
) != gtk_adjustment_get_value(adj
))
7077 case GDK_KEY_Escape
:
7078 folderview_grab_focus(summaryview
->folderview
);
7079 mainwindow_exit_folder(summaryview
->mainwin
);
7081 case GDK_KEY_Home
: case GDK_KEY_KP_Home
:
7082 case GDK_KEY_End
: case GDK_KEY_KP_End
:
7083 case GDK_KEY_Up
: case GDK_KEY_KP_Up
:
7084 case GDK_KEY_Down
: case GDK_KEY_KP_Down
:
7085 case GDK_KEY_Page_Up
: case GDK_KEY_KP_Page_Up
:
7086 case GDK_KEY_Page_Down
: case GDK_KEY_KP_Page_Down
:
7087 if ((node
= summaryview
->selected
) != NULL
) {
7088 GtkCMCTreeNode
*next
= NULL
;
7089 switch (event
->keyval
) {
7090 case GDK_KEY_Home
: case GDK_KEY_KP_Home
:
7091 next
= gtk_cmctree_node_nth(ctree
, 0);
7093 case GDK_KEY_End
: case GDK_KEY_KP_End
:
7094 next
= gtk_cmctree_node_nth(ctree
,
7095 g_list_length(GTK_CMCLIST(ctree
)->row_list
)-1);
7097 case GDK_KEY_Up
: case GDK_KEY_KP_Up
:
7098 next
= gtk_cmctree_node_nth(ctree
,
7099 MAX(0, GTK_CMCLIST(ctree
)->focus_row
- 1));
7101 case GDK_KEY_Down
: case GDK_KEY_KP_Down
:
7102 next
= gtk_cmctree_node_nth(ctree
,
7103 MIN(GTK_CMCLIST(ctree
)->focus_row
+ 1, GTK_CMCLIST(ctree
)->rows
- 1));
7105 case GDK_KEY_Page_Up
: case GDK_KEY_KP_Page_Up
:
7106 next
= gtk_cmctree_node_nth(ctree
,
7107 MAX(0, GTK_CMCLIST(ctree
)->focus_row
-
7108 (2 * GTK_CMCLIST(ctree
)->clist_window_height
-
7109 GTK_CMCLIST(ctree
)->row_height
- CELL_SPACING
) /
7110 (2 * (GTK_CMCLIST(ctree
)->row_height
+ CELL_SPACING
))));
7112 case GDK_KEY_Page_Down
: case GDK_KEY_KP_Page_Down
:
7113 next
= gtk_cmctree_node_nth(ctree
,
7114 MIN(GTK_CMCLIST(ctree
)->rows
- 1, GTK_CMCLIST(ctree
)->focus_row
+
7115 (2 * GTK_CMCLIST(ctree
)->clist_window_height
-
7116 GTK_CMCLIST(ctree
)->row_height
- CELL_SPACING
) /
7117 (2 * (GTK_CMCLIST(ctree
)->row_height
+ CELL_SPACING
))));
7122 next
!= gtk_cmctree_node_nth(ctree
, GTK_CMCLIST(ctree
)->focus_row
)) {
7123 gtk_sctree_select_with_state
7124 (GTK_SCTREE(ctree
), next
, (event
->state
& ~GDK_CONTROL_MASK
) );
7126 /* Deprecated - what are the non-deprecated equivalents? */
7127 if (gtk_cmctree_node_is_visible(GTK_CMCTREE(ctree
), next
) != GTK_VISIBILITY_FULL
)
7128 gtkut_ctree_node_move_if_on_the_edge(GTK_CMCTREE(ctree
), next
, -1);
7130 summary_select_node(summaryview
, summaryview
->selected
, OPEN_SELECTED_ON_DIRECTIONAL
);
7131 summaryview
->selected
= next
;
7139 if (!summaryview
->selected
) {
7140 node
= gtk_cmctree_node_nth(ctree
, 0);
7142 gtk_sctree_select(GTK_SCTREE(ctree
), node
);
7147 switch (event
->keyval
) {
7148 case GDK_KEY_Delete
:
7149 BREAK_ON_MODIFIER_KEY();
7150 summary_delete_trash(summaryview
);
7159 static void quicksearch_execute_cb(QuickSearch
*quicksearch
, gpointer data
)
7161 SummaryView
*summaryview
= data
;
7163 summaryview_reset_recursive_folder_match(summaryview
);
7164 if (summary_show(summaryview
, summaryview
->folder_item
, FALSE
))
7165 summaryview_quicksearch_recurse(summaryview
);
7167 summaryview_reset_recursive_folder_match(summaryview
);
7170 static void tog_searchbar_cb(GtkWidget
*w
, gpointer data
)
7172 SummaryView
*summaryview
= (SummaryView
*)data
;
7174 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w
))) {
7175 prefs_common
.show_searchbar
= TRUE
;
7176 quicksearch_show(summaryview
->quicksearch
);
7178 prefs_common
.show_searchbar
= FALSE
;
7179 quicksearch_hide(summaryview
->quicksearch
);
7183 void summaryview_activate_quicksearch(SummaryView
*summaryview
, gboolean show
)
7185 prefs_common
.show_searchbar
= show
;
7186 gtk_toggle_button_set_active(
7187 GTK_TOGGLE_BUTTON(summaryview
->toggle_search
),
7190 quicksearch_show(summaryview
->quicksearch
);
7192 quicksearch_hide(summaryview
->quicksearch
);
7193 summary_grab_focus(summaryview
);
7197 void summary_open_row(GtkSCTree
*sctree
, SummaryView
*summaryview
)
7199 if (FOLDER_SHOWS_TO_HDR(summaryview
->folder_item
))
7200 summary_reedit(summaryview
);
7202 summary_open_msg(summaryview
);
7204 summaryview
->display_msg
= FALSE
;
7207 static void summary_tree_expanded(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
7208 SummaryView
*summaryview
)
7210 summary_set_row_marks(summaryview
, node
);
7211 if (prefs_common
.bold_unread
) {
7213 GtkCMCTreeNode
*next
= GTK_CMCTREE_NODE_NEXT(node
);
7214 if (GTK_CMCTREE_ROW(node
)->children
)
7215 summary_set_row_marks(summaryview
, node
);
7221 static void summary_tree_collapsed(GtkCMCTree
*ctree
, GtkCMCTreeNode
*node
,
7222 SummaryView
*summaryview
)
7224 gtk_sctree_select(GTK_SCTREE(ctree
), node
);
7225 summary_set_row_marks(summaryview
, node
);
7228 static void summary_unselected(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
,
7229 gint column
, SummaryView
*summaryview
)
7231 if (summary_is_locked(summaryview
)
7232 || GTK_SCTREE(ctree
)->selecting_range
) {
7236 summary_status_show(summaryview
);
7239 static void summary_selected(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
,
7240 gint column
, SummaryView
*summaryview
)
7242 const GList
*list
, *cur
;
7243 MessageView
*msgview
;
7245 gboolean marked_unread
= FALSE
;
7247 if (summary_is_locked(summaryview
)
7248 && !GTK_SCTREE(ctree
)->selecting_range
7249 && summaryview
->messageview
7250 && summaryview
->messageview
->mimeview
7251 && summaryview
->messageview
->mimeview
->type
== MIMEVIEW_TEXT
7252 && summaryview
->messageview
->mimeview
->textview
->loading
) {
7253 PostponedSelectData
*data
= g_new0(PostponedSelectData
, 1);
7254 summaryview
->messageview
->mimeview
->textview
->stop_loading
= TRUE
;
7256 data
->ctree
= ctree
;
7259 data
->column
= column
;
7260 data
->summaryview
= summaryview
;
7261 debug_print("postponing open of message till end of load\n");
7262 g_timeout_add(100, summary_select_retry
, data
);
7265 if (summary_is_locked(summaryview
)
7266 || GTK_SCTREE(ctree
)->selecting_range
) {
7270 summary_status_show(summaryview
);
7272 if (GTK_CMCLIST(ctree
)->selection
&&
7273 GTK_CMCLIST(ctree
)->selection
->next
) {
7274 summaryview
->display_msg
= FALSE
;
7275 summary_set_menu_sensitive(summaryview
);
7276 toolbar_main_set_sensitive(summaryview
->mainwin
);
7280 summaryview
->selected
= row
;
7282 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
7283 cm_return_if_fail(msginfo
!= NULL
);
7285 main_create_mailing_list_menu (summaryview
->mainwin
, msginfo
);
7286 toolbar_set_learn_button
7287 (summaryview
->mainwin
->toolbar
,
7288 MSG_IS_SPAM(msginfo
->flags
)?LEARN_HAM
:LEARN_SPAM
);
7290 switch (column
< 0 ? column
: summaryview
->col_state
[column
].type
) {
7292 if (!MSG_IS_DELETED(msginfo
->flags
) &&
7293 !MSG_IS_MOVE(msginfo
->flags
) &&
7294 !MSG_IS_COPY(msginfo
->flags
)) {
7295 if (MSG_IS_MARKED(msginfo
->flags
)) {
7296 summary_unmark_row(summaryview
, row
);
7297 summary_status_show(summaryview
);
7299 summary_mark_row(summaryview
, row
);
7300 summary_status_show(summaryview
);
7305 if (MSG_IS_UNREAD(msginfo
->flags
)) {
7306 summary_mark_row_as_read(summaryview
, row
);
7307 summary_status_show(summaryview
);
7308 } else if (MSG_IS_SPAM(msginfo
->flags
)) {
7309 if (procmsg_spam_learner_learn(msginfo
, NULL
, FALSE
) == 0)
7310 summary_msginfo_unset_flags(msginfo
, MSG_SPAM
, 0);
7312 log_error(LOG_PROTOCOL
, _("An error happened while learning.\n"));
7313 } else if (!MSG_IS_REPLIED(msginfo
->flags
) &&
7314 !MSG_IS_FORWARDED(msginfo
->flags
)) {
7315 marked_unread
= TRUE
;
7316 } else if (MSG_IS_REPLIED(msginfo
->flags
)) {
7317 summary_find_answers(summaryview
, msginfo
);
7322 if (MSG_IS_LOCKED(msginfo
->flags
)) {
7323 summary_unlock_row(summaryview
, row
);
7324 summary_status_show(summaryview
);
7327 summary_lock_row(summaryview
, row
);
7328 summary_status_show(summaryview
);
7335 list
= messageview_get_msgview_list();
7336 for (cur
= list
; cur
!= NULL
; cur
= cur
->next
) {
7337 msgview
= (MessageView
*) cur
->data
;
7339 if (msgview
->new_window
&& msgview
->update_needed
) {
7340 MsgInfo
*new_msginfo
= summary_get_selected_msg(summaryview
);
7341 messageview_show(msgview
, new_msginfo
, msgview
->all_headers
);
7342 msgview
->update_needed
= FALSE
;
7346 if (summaryview
->display_msg
) {
7347 summaryview
->display_msg
= FALSE
;
7348 if (summaryview
->displayed
!= row
) {
7349 summary_display_msg(summaryview
, row
);
7350 if (marked_unread
) {
7351 summary_mark_row_as_unread(summaryview
, row
);
7352 summary_status_show(summaryview
);
7358 if (marked_unread
) {
7359 summary_mark_row_as_unread(summaryview
, row
);
7360 summary_status_show(summaryview
);
7363 summary_set_menu_sensitive(summaryview
);
7364 toolbar_main_set_sensitive(summaryview
->mainwin
);
7367 static void summary_col_resized(GtkCMCList
*clist
, gint column
, gint width
,
7368 SummaryView
*summaryview
)
7370 SummaryColumnType type
= summaryview
->col_state
[column
].type
;
7372 prefs_common
.summary_col_size
[type
] = width
;
7377 * \brief get List of msginfo selected in SummaryView
7379 * \param summaryview
7381 * \return GSList holding MsgInfo
7383 GSList
*summary_get_selection(SummaryView
*summaryview
)
7386 GSList
*msginfo_list
= NULL
;
7388 cm_return_val_if_fail(summaryview
!= NULL
, NULL
);
7390 sel
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
7392 cm_return_val_if_fail(sel
!= NULL
, NULL
);
7394 for ( ; sel
!= NULL
; sel
= sel
->next
)
7396 g_slist_prepend(msginfo_list
,
7397 gtk_cmctree_node_get_row_data(GTK_CMCTREE(summaryview
->ctree
),
7398 GTK_CMCTREE_NODE(sel
->data
)));
7399 return g_slist_reverse(msginfo_list
);
7403 * \brief get number of messages currently selected in SummaryView
7405 * \param summaryview
7407 * \return number of messages currently selected
7409 guint
summary_get_selection_count(SummaryView
*summaryview
)
7411 cm_return_val_if_fail(summaryview
!= NULL
, 0);
7412 return g_list_length(GTK_CMCLIST(summaryview
->ctree
)->selection
);
7415 static void summary_sort_by_column_click(SummaryView
*summaryview
,
7416 FolderSortKey sort_key
)
7418 if (prefs_common
.summary_col_lock
) {
7419 debug_print("summaryview columns locked, ignoring\n");
7423 GtkCMCTreeNode
*node
= NULL
;
7425 if (summaryview
->sort_key
== sort_key
)
7426 summary_sort(summaryview
, sort_key
,
7427 summaryview
->sort_type
== SORT_ASCENDING
7428 ? SORT_DESCENDING
: SORT_ASCENDING
);
7430 summary_sort(summaryview
, sort_key
, summaryview
->sort_type
);
7432 node
= GTK_CMCTREE_NODE(GTK_CMCLIST(summaryview
->ctree
)->row_list
);
7434 summary_freeze(summaryview
);
7435 if (prefs_common
.bold_unread
) {
7437 GtkCMCTreeNode
*next
= GTK_CMCTREE_NODE_NEXT(node
);
7438 if (GTK_CMCTREE_ROW(node
)->children
)
7439 summary_set_row_marks(summaryview
, node
);
7443 summary_thaw(summaryview
);
7447 static void summary_mark_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7449 summary_sort_by_column_click(summaryview
, SORT_BY_MARK
);
7452 static void summary_status_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7454 summary_sort_by_column_click(summaryview
, SORT_BY_STATUS
);
7457 static void summary_mime_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7459 summary_sort_by_column_click(summaryview
, SORT_BY_MIME
);
7462 static void summary_num_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7464 summary_sort_by_column_click(summaryview
, SORT_BY_NUMBER
);
7467 static void summary_size_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7469 summary_sort_by_column_click(summaryview
, SORT_BY_SIZE
);
7472 static void summary_date_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7474 if (summaryview
->sort_key
== SORT_BY_THREAD_DATE
)
7475 summary_sort_by_column_click(summaryview
, SORT_BY_THREAD_DATE
);
7477 summary_sort_by_column_click(summaryview
, SORT_BY_DATE
);
7480 static void summary_from_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7482 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_FROM
]].visible
)
7483 summary_sort_by_column_click(summaryview
, SORT_BY_FROM
);
7485 summary_sort_by_column_click(summaryview
, SORT_BY_TO
);
7488 static void summary_to_clicked(GtkWidget
*button
, SummaryView
*summaryview
)
7490 if (summaryview
->col_state
[summaryview
->col_pos
[S_COL_TO
]].visible
)
7491 summary_sort_by_column_click(summaryview
, SORT_BY_TO
);
7493 summary_sort_by_column_click(summaryview
, SORT_BY_FROM
);
7496 static void summary_subject_clicked(GtkWidget
*button
,
7497 SummaryView
*summaryview
)
7499 summary_sort_by_column_click(summaryview
, SORT_BY_SUBJECT
);
7502 static void summary_score_clicked(GtkWidget
*button
,
7503 SummaryView
*summaryview
)
7505 summary_sort_by_column_click(summaryview
, SORT_BY_SCORE
);
7508 static void summary_locked_clicked(GtkWidget
*button
,
7509 SummaryView
*summaryview
)
7511 summary_sort_by_column_click(summaryview
, SORT_BY_LOCKED
);
7514 static void summary_tags_clicked(GtkWidget
*button
,
7515 SummaryView
*summaryview
)
7517 summary_sort_by_column_click(summaryview
, SORT_BY_TAGS
);
7520 static void summary_start_drag(GtkWidget
*widget
, gint button
, GdkEvent
*event
,
7521 SummaryView
*summaryview
)
7523 GdkDragContext
*context
;
7525 cm_return_if_fail(summaryview
!= NULL
);
7526 cm_return_if_fail(summaryview
->folder_item
!= NULL
);
7527 cm_return_if_fail(summaryview
->folder_item
->folder
!= NULL
);
7529 if (summaryview
->selected
== NULL
) return;
7531 context
= gtk_drag_begin(widget
, summaryview
->target_list
,
7532 GDK_ACTION_MOVE
|GDK_ACTION_COPY
|GDK_ACTION_DEFAULT
, button
, event
);
7533 gtk_drag_set_icon_default(context
);
7534 if (prefs_common
.layout_mode
== SMALL_LAYOUT
) {
7535 GtkWidget
*paned
= gtk_widget_get_parent(GTK_WIDGET_PTR(summaryview
));
7536 if (paned
&& GTK_IS_PANED(paned
)) {
7537 mainwindow_reset_paned(GTK_PANED(paned
));
7542 static gboolean
summary_return_to_list(void *data
)
7544 SummaryView
*summaryview
= (SummaryView
*)data
;
7545 mainwindow_enter_folder(summaryview
->mainwin
);
7549 static void summary_drag_end (GtkWidget
*widget
,
7550 GdkDragContext
*drag_context
,
7551 SummaryView
*summaryview
)
7553 if (prefs_common
.layout_mode
== SMALL_LAYOUT
) {
7554 g_timeout_add(250, summary_return_to_list
, summaryview
);
7558 static void summary_drag_data_get(GtkWidget
*widget
,
7559 GdkDragContext
*drag_context
,
7560 GtkSelectionData
*selection_data
,
7563 SummaryView
*summaryview
)
7565 if (info
== TARGET_MAIL_URI_LIST
) {
7566 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
7569 gchar
*mail_list
= NULL
, *tmp1
, *tmp2
;
7571 for (cur
= GTK_CMCLIST(ctree
)->selection
;
7572 cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
7573 msginfo
= gtk_cmctree_node_get_row_data
7574 (ctree
, GTK_CMCTREE_NODE(cur
->data
));
7575 tmp2
= procmsg_get_message_file(msginfo
);
7576 if (!tmp2
) continue;
7577 if (msginfo
->subject
) {
7578 gchar
*san_subject
= g_strdup(msginfo
->subject
);
7580 subst_for_filename(san_subject
);
7581 dest
= g_strdup_printf("%s%s%s.%d.txt",
7584 san_subject
, msginfo
->msgnum
);
7585 g_free(san_subject
);
7586 san_subject
= g_filename_from_utf8(dest
, -1, NULL
, NULL
, NULL
);
7588 g_warning("failed to convert encoding of file name: %s", dest
);
7593 if (copy_file(tmp2
, dest
, TRUE
) < 0) {
7594 g_warning("summary_drag_data_get: can't copy %s to %s",
7600 tmp1
= g_filename_to_uri(tmp2
, NULL
, NULL
);
7602 tmp2
= g_strconcat(tmp1
, "\r\n", NULL
);
7609 tmp2
= g_strconcat(mail_list
, tmp1
, NULL
);
7616 if (mail_list
!= NULL
) {
7617 gtk_selection_data_set(selection_data
,
7618 gtk_selection_data_get_target(selection_data
), 8,
7619 mail_list
, strlen(mail_list
));
7622 } else if (info
== TARGET_DUMMY
) {
7623 if (GTK_CMCLIST(summaryview
->ctree
)->selection
)
7624 gtk_selection_data_set(selection_data
,
7625 gtk_selection_data_get_target(selection_data
), 8,
7626 "Dummy-Summaryview",
7627 strlen("Dummy-Summaryview")+1);
7628 } else if (info
== TARGET_MAIL_CM_PATH_LIST
) {
7629 /* content: folder_item_identifier\nmsgid1\nmsgid2\nmsgid3 */
7631 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
7634 gchar
*path_list
= NULL
;
7637 if(GTK_CMCLIST(ctree
)->selection
!= NULL
) {
7638 msginfo
= gtk_cmctree_node_get_row_data(ctree
, GTK_CMCTREE_NODE(GTK_CMCLIST(ctree
)->selection
->data
));
7639 if(msginfo
&& msginfo
->folder
)
7640 path_list
= folder_item_get_identifier(msginfo
->folder
);
7643 if (path_list
!= NULL
) {
7644 for (cur
= GTK_CMCLIST(ctree
)->selection
;
7645 cur
!= NULL
&& cur
->data
!= NULL
&& path_list
!= NULL
; cur
= cur
->next
) {
7648 msginfo
= gtk_cmctree_node_get_row_data(ctree
, GTK_CMCTREE_NODE(cur
->data
));
7652 path_list
= g_strconcat(path_list
, "\n", (msginfo
->msgid
? msginfo
->msgid
: "unknown"), NULL
);
7656 if (path_list
!= NULL
) {
7657 gtk_selection_data_set(selection_data
,
7658 gtk_selection_data_get_target(selection_data
), 8,
7659 path_list
, strlen(path_list
));
7663 g_warning("summary_drag_data_get: no folder item identifier");
7668 static gboolean
summary_drag_motion_cb(GtkWidget
*widget
,
7669 GdkDragContext
*context
,
7673 SummaryView
*summaryview
)
7675 FolderItem
*item
= summaryview
->folder_item
;
7676 if (!(item
&& item
->folder
&& folder_item_parent(item
) != NULL
7677 && FOLDER_CLASS(item
->folder
)->add_msg
!= NULL
)) {
7678 gdk_drag_status(context
, 0, time
);
7680 } else if (gtk_drag_get_source_widget(context
) ==
7681 mainwindow_get_mainwindow()->folderview
->ctree
) {
7683 gdk_drag_status(context
, 0, time
);
7685 } else if (gtk_drag_get_source_widget(context
) ==
7686 summaryview
->ctree
) {
7687 /* not from same folder */
7688 gdk_drag_status(context
, 0, time
);
7691 gdk_drag_status(context
, GDK_ACTION_COPY
, time
);
7696 static void summary_drag_data_received(GtkWidget
*widget
,
7697 GdkDragContext
*drag_context
,
7700 GtkSelectionData
*data
,
7703 SummaryView
*summaryview
)
7705 if (info
== TARGET_MAIL_URI_LIST
) {
7706 FolderItem
*item
= summaryview
->folder_item
;
7708 gtk_drag_finish(drag_context
, FALSE
, FALSE
, time
);
7711 folderview_finish_dnd(gtk_selection_data_get_data(data
),
7712 drag_context
, time
, item
);
7718 /* custom compare functions for sorting */
7720 static gint
summary_cmp_by_date(GtkCMCList
*clist
,
7721 gconstpointer ptr1
, gconstpointer ptr2
)
7723 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7724 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7726 if (!msginfo1
|| !msginfo2
)
7729 res
= (msginfo1
->date_t
- msginfo2
->date_t
);
7731 res
= msginfo1
->msgnum
- msginfo2
->msgnum
;
7735 #define CMP_FUNC_DEF(func_name, val) \
7736 static gint func_name(GtkCMCList *clist, \
7737 gconstpointer ptr1, gconstpointer ptr2) \
7739 MsgInfo *msginfo1 = ((GtkCMCListRow *)ptr1)->data; \
7740 MsgInfo *msginfo2 = ((GtkCMCListRow *)ptr2)->data; \
7742 if (!msginfo1 || !msginfo2) \
7746 return (res != 0) ? res:summary_cmp_by_date(clist, ptr1, ptr2); \
7749 CMP_FUNC_DEF(summary_cmp_by_mark
,
7750 MSG_IS_MARKED(msginfo1
->flags
) - MSG_IS_MARKED(msginfo2
->flags
))
7751 CMP_FUNC_DEF(summary_cmp_by_status
,
7752 (-(MSG_IS_SPAM(msginfo1
->flags
))+(MSG_IS_UNREAD(msginfo1
->flags
)<<1)+(MSG_IS_NEW(msginfo1
->flags
)<<2))
7753 - (-(MSG_IS_SPAM(msginfo2
->flags
))+(MSG_IS_UNREAD(msginfo2
->flags
)<<1)+(MSG_IS_NEW(msginfo2
->flags
)<<2)) )
7754 CMP_FUNC_DEF(summary_cmp_by_mime
,
7755 MSG_IS_WITH_ATTACHMENT(msginfo1
->flags
) - MSG_IS_WITH_ATTACHMENT(msginfo2
->flags
))
7756 CMP_FUNC_DEF(summary_cmp_by_label
,
7757 MSG_GET_COLORLABEL(msginfo1
->flags
) -
7758 MSG_GET_COLORLABEL(msginfo2
->flags
))
7759 CMP_FUNC_DEF(summary_cmp_by_locked
,
7760 MSG_IS_LOCKED(msginfo1
->flags
) - MSG_IS_LOCKED(msginfo2
->flags
))
7762 CMP_FUNC_DEF(summary_cmp_by_num
, msginfo1
->msgnum
- msginfo2
->msgnum
)
7763 CMP_FUNC_DEF(summary_cmp_by_size
, msginfo1
->size
- msginfo2
->size
)
7767 static gint
summary_cmp_by_subject(GtkCMCList
*clist
,
7771 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7772 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7775 if (!msginfo1
->subject
)
7776 return (msginfo2
->subject
!= NULL
);
7777 if (!msginfo2
->subject
)
7780 res
= subject_compare_for_sort
7781 (msginfo1
->subject
, msginfo2
->subject
);
7782 return (res
!= 0)? res
: summary_cmp_by_date(clist
, ptr1
, ptr2
);
7785 static gint
summary_cmp_by_thread_date(GtkCMCList
*clist
,
7789 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7790 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7791 gint thread_diff
= msginfo1
->thread_date
- msginfo2
->thread_date
;
7793 if (msginfo1
->thread_date
> 0 && msginfo2
->thread_date
> 0)
7796 return msginfo1
->date_t
- msginfo2
->date_t
;
7799 static gint
summary_cmp_by_from(GtkCMCList
*clist
, gconstpointer ptr1
,
7802 const gchar
*str1
, *str2
;
7803 const GtkCMCListRow
*r1
= (const GtkCMCListRow
*) ptr1
;
7804 const GtkCMCListRow
*r2
= (const GtkCMCListRow
*) ptr2
;
7805 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7806 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7807 const SummaryView
*sv
= g_object_get_data(G_OBJECT(clist
), "summaryview");
7810 cm_return_val_if_fail(sv
, -1);
7811 if (sv
->col_state
[sv
->col_pos
[S_COL_FROM
]].visible
) {
7812 str1
= GTK_CMCELL_TEXT(r1
->cell
[sv
->col_pos
[S_COL_FROM
]])->text
;
7813 str2
= GTK_CMCELL_TEXT(r2
->cell
[sv
->col_pos
[S_COL_FROM
]])->text
;
7815 str1
= msginfo1
->from
;
7816 str2
= msginfo2
->from
;
7820 return str2
!= NULL
;
7825 res
= g_utf8_collate(str1
, str2
);
7826 return (res
!= 0)? res
: summary_cmp_by_date(clist
, ptr1
, ptr2
);
7829 static gint
summary_cmp_by_to(GtkCMCList
*clist
, gconstpointer ptr1
,
7832 const gchar
*str1
, *str2
;
7833 const GtkCMCListRow
*r1
= (const GtkCMCListRow
*) ptr1
;
7834 const GtkCMCListRow
*r2
= (const GtkCMCListRow
*) ptr2
;
7835 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7836 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7837 const SummaryView
*sv
= g_object_get_data(G_OBJECT(clist
), "summaryview");
7839 cm_return_val_if_fail(sv
, -1);
7841 if (sv
->col_state
[sv
->col_pos
[S_COL_TO
]].visible
) {
7842 str1
= GTK_CMCELL_TEXT(r1
->cell
[sv
->col_pos
[S_COL_TO
]])->text
;
7843 str2
= GTK_CMCELL_TEXT(r2
->cell
[sv
->col_pos
[S_COL_TO
]])->text
;
7845 str1
= msginfo1
->to
;
7846 str2
= msginfo2
->to
;
7850 return str2
!= NULL
;
7855 res
= g_utf8_collate(str1
, str2
);
7856 return (res
!= 0)? res
: summary_cmp_by_date(clist
, ptr1
, ptr2
);
7859 static gint
summary_cmp_by_tags(GtkCMCList
*clist
, gconstpointer ptr1
,
7863 const GtkCMCListRow
*r1
= (const GtkCMCListRow
*) ptr1
;
7864 const GtkCMCListRow
*r2
= (const GtkCMCListRow
*) ptr2
;
7865 const SummaryView
*sv
= g_object_get_data(G_OBJECT(clist
), "summaryview");
7866 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7867 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7869 cm_return_val_if_fail(sv
, -1);
7871 if (sv
->col_state
[sv
->col_pos
[S_COL_TAGS
]].visible
) {
7872 str1
= g_strdup(GTK_CMCELL_TEXT(r1
->cell
[sv
->col_pos
[S_COL_TAGS
]])->text
);
7873 str2
= g_strdup(GTK_CMCELL_TEXT(r2
->cell
[sv
->col_pos
[S_COL_TAGS
]])->text
);
7875 str1
= procmsg_msginfo_get_tags_str(msginfo1
);
7876 str2
= procmsg_msginfo_get_tags_str(msginfo2
);
7880 res
= (str2
!= NULL
);
7889 res
= g_utf8_collate(str1
, str2
);
7892 return (res
!= 0)? res
: summary_cmp_by_date(clist
, ptr1
, ptr2
);
7895 static gint summary_cmp_by_simplified_subject
7896 (GtkCMCList
*clist
, gconstpointer ptr1
, gconstpointer ptr2
)
7898 const FolderItemPrefs
*prefs
;
7899 const gchar
*str1
, *str2
;
7900 const GtkCMCListRow
*r1
= (const GtkCMCListRow
*) ptr1
;
7901 const GtkCMCListRow
*r2
= (const GtkCMCListRow
*) ptr2
;
7902 const MsgInfo
*msginfo1
= r1
->data
;
7903 const MsgInfo
*msginfo2
= r2
->data
;
7904 const SummaryView
*sv
= g_object_get_data(G_OBJECT(clist
), "summaryview");
7907 cm_return_val_if_fail(sv
, -1);
7908 cm_return_val_if_fail(msginfo1
!= NULL
&& msginfo2
!= NULL
, -1);
7910 if (sv
->col_state
[sv
->col_pos
[S_COL_SUBJECT
]].visible
) {
7911 str1
= GTK_CMCELL_TEXT(r1
->cell
[sv
->col_pos
[S_COL_SUBJECT
]])->text
;
7912 str2
= GTK_CMCELL_TEXT(r2
->cell
[sv
->col_pos
[S_COL_SUBJECT
]])->text
;
7914 str1
= msginfo1
->subject
;
7915 str2
= msginfo2
->subject
;
7919 return str2
!= NULL
;
7924 prefs
= msginfo1
->folder
->prefs
;
7926 prefs
= msginfo2
->folder
->prefs
;
7930 res
= subject_compare_for_sort(str1
, str2
);
7931 return (res
!= 0)? res
: summary_cmp_by_date(clist
, ptr1
, ptr2
);
7934 static gint
summary_cmp_by_score(GtkCMCList
*clist
,
7935 gconstpointer ptr1
, gconstpointer ptr2
)
7937 MsgInfo
*msginfo1
= ((GtkCMCListRow
*)ptr1
)->data
;
7938 MsgInfo
*msginfo2
= ((GtkCMCListRow
*)ptr2
)->data
;
7941 /* if score are equal, sort by date */
7943 diff
= msginfo1
->score
- msginfo2
->score
;
7947 return summary_cmp_by_date(clist
, ptr1
, ptr2
);
7950 static void summary_ignore_thread_func_mark_unread(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
7954 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
7955 cm_return_if_fail(msginfo
);
7957 summary_msginfo_unset_flags(msginfo
, MSG_WATCH_THREAD
, 0);
7958 summary_msginfo_change_flags(msginfo
, MSG_IGNORE_THREAD
, 0, MSG_NEW
| MSG_UNREAD
, 0);
7960 debug_print("Message %d is marked as ignore thread\n", msginfo
->msgnum
);
7963 static void summary_ignore_thread_func_set_row(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
7965 SummaryView
*summaryview
= (SummaryView
*) data
;
7968 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
7969 cm_return_if_fail(msginfo
);
7971 summary_set_row_marks(summaryview
, row
);
7972 debug_print("Message %d update in row view\n", msginfo
->msgnum
);
7975 void summary_ignore_thread(SummaryView
*summaryview
)
7977 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
7979 gboolean froze
= FALSE
;
7981 START_LONG_OPERATION(summaryview
, FALSE
);
7982 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
7983 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
7984 GTK_CMCTREE_FUNC(summary_ignore_thread_func_mark_unread
),
7987 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
7988 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
7989 GTK_CMCTREE_FUNC(summary_ignore_thread_func_set_row
),
7992 END_LONG_OPERATION(summaryview
);
7994 summary_status_show(summaryview
);
7997 static void summary_unignore_thread_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
7999 SummaryView
*summaryview
= (SummaryView
*) data
;
8002 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
8003 cm_return_if_fail(msginfo
);
8005 summary_msginfo_unset_flags(msginfo
, MSG_IGNORE_THREAD
, 0);
8007 summary_set_row_marks(summaryview
, row
);
8008 debug_print("Message %d is marked as unignore thread\n",
8012 void summary_unignore_thread(SummaryView
*summaryview
)
8014 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
8016 gboolean froze
= FALSE
;
8018 START_LONG_OPERATION(summaryview
, FALSE
);
8019 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
8020 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
8021 GTK_CMCTREE_FUNC(summary_unignore_thread_func
),
8024 END_LONG_OPERATION(summaryview
);
8026 summary_status_show(summaryview
);
8029 static void summary_check_ignore_thread_func
8030 (GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
8033 gint
*found_ignore
= (gint
*) data
;
8035 if (*found_ignore
) return;
8037 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
8038 *found_ignore
= msginfo
&& MSG_IS_IGNORE_THREAD(msginfo
->flags
);
8042 void summary_toggle_ignore_thread(SummaryView
*summaryview
)
8044 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
8046 gint found_ignore
= 0;
8048 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
8049 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
8050 GTK_CMCTREE_FUNC(summary_check_ignore_thread_func
),
8054 summary_unignore_thread(summaryview
);
8056 summary_ignore_thread(summaryview
);
8059 static void summary_watch_thread_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
8061 SummaryView
*summaryview
= (SummaryView
*) data
;
8064 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
8065 cm_return_if_fail(msginfo
);
8067 summary_msginfo_change_flags(msginfo
, MSG_WATCH_THREAD
, 0, MSG_IGNORE_THREAD
, 0);
8069 summary_set_row_marks(summaryview
, row
);
8070 debug_print("Message %d is marked as watch thread\n",
8074 void summary_watch_thread(SummaryView
*summaryview
)
8076 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
8078 gboolean froze
= FALSE
;
8080 START_LONG_OPERATION(summaryview
, FALSE
);
8081 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
8082 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
8083 GTK_CMCTREE_FUNC(summary_watch_thread_func
),
8086 END_LONG_OPERATION(summaryview
);
8088 summary_status_show(summaryview
);
8091 static void summary_unwatch_thread_func(GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
8093 SummaryView
*summaryview
= (SummaryView
*) data
;
8096 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
8097 cm_return_if_fail(msginfo
);
8099 summary_msginfo_unset_flags(msginfo
, MSG_WATCH_THREAD
, 0);
8101 summary_set_row_marks(summaryview
, row
);
8102 debug_print("Message %d is marked as unwatch thread\n",
8106 void summary_unwatch_thread(SummaryView
*summaryview
)
8108 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
8110 gboolean froze
= FALSE
;
8112 START_LONG_OPERATION(summaryview
, FALSE
);
8113 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
8114 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
8115 GTK_CMCTREE_FUNC(summary_unwatch_thread_func
),
8118 END_LONG_OPERATION(summaryview
);
8120 summary_status_show(summaryview
);
8123 static void summary_check_watch_thread_func
8124 (GtkCMCTree
*ctree
, GtkCMCTreeNode
*row
, gpointer data
)
8127 gint
*found_watch
= (gint
*) data
;
8129 if (*found_watch
) return;
8131 msginfo
= gtk_cmctree_node_get_row_data(ctree
, row
);
8132 *found_watch
= msginfo
&& MSG_IS_WATCH_THREAD(msginfo
->flags
);
8136 void summary_toggle_watch_thread(SummaryView
*summaryview
)
8138 GtkCMCTree
*ctree
= GTK_CMCTREE(summaryview
->ctree
);
8140 gint found_watch
= 0;
8142 for (cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
)
8143 gtk_cmctree_pre_recursive(ctree
, GTK_CMCTREE_NODE(cur
->data
),
8144 GTK_CMCTREE_FUNC(summary_check_watch_thread_func
),
8148 summary_unwatch_thread(summaryview
);
8150 summary_watch_thread(summaryview
);
8154 void summary_toggle_show_read_messages(SummaryView
*summaryview
)
8156 FolderItemUpdateData source
;
8157 if (summaryview
->folder_item
->hide_read_msgs
)
8158 summaryview
->folder_item
->hide_read_msgs
= 0;
8160 summaryview
->folder_item
->hide_read_msgs
= 1;
8162 source
.item
= summaryview
->folder_item
;
8163 source
.update_flags
= F_ITEM_UPDATE_NAME
;
8165 hooks_invoke(FOLDER_ITEM_UPDATE_HOOKLIST
, &source
);
8166 summary_show(summaryview
, summaryview
->folder_item
, FALSE
);
8169 void summary_toggle_show_del_messages(SummaryView
*summaryview
)
8171 FolderItemUpdateData source
;
8172 if (summaryview
->folder_item
->hide_del_msgs
)
8173 summaryview
->folder_item
->hide_del_msgs
= 0;
8175 summaryview
->folder_item
->hide_del_msgs
= 1;
8177 source
.item
= summaryview
->folder_item
;
8178 source
.update_flags
= F_ITEM_UPDATE_NAME
;
8180 hooks_invoke(FOLDER_ITEM_UPDATE_HOOKLIST
, &source
);
8181 summary_show(summaryview
, summaryview
->folder_item
, FALSE
);
8184 void summary_toggle_show_read_threads(SummaryView
*summaryview
)
8186 FolderItemUpdateData source
;
8187 if (summaryview
->folder_item
->hide_read_threads
)
8188 summaryview
->folder_item
->hide_read_threads
= 0;
8190 summaryview
->folder_item
->hide_read_threads
= 1;
8192 source
.item
= summaryview
->folder_item
;
8193 source
.update_flags
= F_ITEM_UPDATE_NAME
;
8195 hooks_invoke(FOLDER_ITEM_UPDATE_HOOKLIST
, &source
);
8196 summary_show(summaryview
, summaryview
->folder_item
, FALSE
);
8199 static void summary_set_hide_menu (SummaryView
*summaryview
,
8200 const gchar
*menu_item
,
8205 widget
= gtk_ui_manager_get_widget(summaryview
->mainwin
->ui_manager
, menu_item
);
8206 cm_return_if_fail(widget
!= NULL
);
8208 g_object_set_data(G_OBJECT(widget
), "dont_toggle",
8209 GINT_TO_POINTER(1));
8210 gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(widget
), action
);
8211 g_object_set_data(G_OBJECT(widget
), "dont_toggle",
8212 GINT_TO_POINTER(0));
8215 void summary_reflect_prefs_pixmap_theme(SummaryView
*summaryview
)
8219 stock_pixbuf_gdk(STOCK_PIXMAP_MARK
, &markxpm
);
8220 stock_pixbuf_gdk(STOCK_PIXMAP_DELETED
, &deletedxpm
);
8221 stock_pixbuf_gdk(STOCK_PIXMAP_NEW
, &newxpm
);
8222 stock_pixbuf_gdk(STOCK_PIXMAP_UNREAD
, &unreadxpm
);
8223 stock_pixbuf_gdk(STOCK_PIXMAP_REPLIED
, &repliedxpm
);
8224 stock_pixbuf_gdk(STOCK_PIXMAP_FORWARDED
, &forwardedxpm
);
8225 stock_pixbuf_gdk(STOCK_PIXMAP_REPLIED_AND_FORWARDED
, &repliedandforwardedxpm
);
8226 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP
, &clipxpm
);
8227 stock_pixbuf_gdk(STOCK_PIXMAP_LOCKED
, &lockedxpm
);
8228 stock_pixbuf_gdk(STOCK_PIXMAP_IGNORETHREAD
, &ignorethreadxpm
);
8229 stock_pixbuf_gdk(STOCK_PIXMAP_WATCHTHREAD
, &watchthreadxpm
);
8230 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP_KEY
, &clipkeyxpm
);
8231 stock_pixbuf_gdk(STOCK_PIXMAP_KEY
, &keyxpm
);
8232 stock_pixbuf_gdk(STOCK_PIXMAP_KEY_SIGN
, &keysignxpm
);
8233 stock_pixbuf_gdk(STOCK_PIXMAP_GPG_SIGNED
, &gpgsignedxpm
);
8234 stock_pixbuf_gdk(STOCK_PIXMAP_CLIP_GPG_SIGNED
, &clipgpgsignedxpm
);
8235 stock_pixbuf_gdk(STOCK_PIXMAP_SPAM
, &spamxpm
);
8236 stock_pixbuf_gdk(STOCK_PIXMAP_MOVED
, &movedxpm
);
8237 stock_pixbuf_gdk(STOCK_PIXMAP_COPIED
, &copiedxpm
);
8239 summary_set_folder_pixmap(summaryview
, STOCK_PIXMAP_DIR_OPEN
);
8241 pixmap
= stock_pixmap_widget(STOCK_PIXMAP_QUICKSEARCH
);
8242 gtk_container_remove (GTK_CONTAINER(summaryview
->toggle_search
),
8243 summaryview
->quick_search_pixmap
);
8244 gtk_container_add(GTK_CONTAINER(summaryview
->toggle_search
), pixmap
);
8245 gtk_widget_show(pixmap
);
8246 summaryview
->quick_search_pixmap
= pixmap
;
8249 pixmap
= stock_pixmap_widget(STOCK_PIXMAP_SELECTION
);
8250 gtk_container_remove (GTK_CONTAINER(summaryview
->multiple_sel_togbtn
),
8251 summaryview
->multiple_sel_image
);
8252 gtk_container_add(GTK_CONTAINER(summaryview
->multiple_sel_togbtn
), pixmap
);
8253 gtk_widget_show(pixmap
);
8254 summaryview
->multiple_sel_togbtn
= pixmap
;
8257 folderview_unselect(summaryview
->folderview
);
8258 folderview_select(summaryview
->folderview
, summaryview
->folder_item
);
8259 summary_set_column_titles(summaryview
);
8262 void summary_reflect_prefs_custom_colors(SummaryView
*summaryview
)
8265 GList
*children
, *cur
;
8267 /* re-create colorlabel submenu */
8268 menu
= GTK_MENU_SHELL(summaryview
->colorlabel_menu
);
8269 cm_return_if_fail(menu
!= NULL
);
8271 /* clear items. get item pointers. */
8272 children
= gtk_container_get_children(GTK_CONTAINER(menu
));
8273 for (cur
= children
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
8274 g_signal_handlers_disconnect_matched
8275 (gtk_ui_manager_get_accel_group(summaryview
->mainwin
->ui_manager
),
8276 G_SIGNAL_MATCH_DATA
|G_SIGNAL_MATCH_FUNC
,
8277 0, 0, NULL
, mainwin_accel_changed_cb
, cur
->data
);
8278 gtk_menu_item_set_submenu(GTK_MENU_ITEM(cur
->data
), NULL
);
8280 g_list_free(children
);
8281 summary_colorlabel_menu_create(summaryview
, TRUE
);
8285 * Harvest addresses for selected messages in summary view.
8287 void summary_harvest_address(SummaryView
*summaryview
)
8289 GtkCMCTree
*ctree
= GTK_CMCTREE( summaryview
->ctree
);
8295 for( cur
= GTK_CMCLIST(ctree
)->selection
; cur
!= NULL
&& cur
->data
!= NULL
; cur
= cur
->next
) {
8296 msginfo
= gtk_cmctree_node_get_row_data( ctree
, GTK_CMCTREE_NODE(cur
->data
) );
8299 msgList
= g_list_append( msgList
, GUINT_TO_POINTER( msginfo
->msgnum
) );
8302 addressbook_harvest( summaryview
->folder_item
, TRUE
, msgList
);
8304 g_list_free( msgList
);
8307 static regex_t
*summary_compile_simplify_regexp(gchar
*simplify_subject_regexp
)
8310 gchar buf
[BUFFSIZE
];
8311 regex_t
*preg
= NULL
;
8313 preg
= g_new0(regex_t
, 1);
8315 err
= string_match_precompile(simplify_subject_regexp
,
8316 preg
, REG_EXTENDED
);
8318 regerror(err
, preg
, buf
, BUFFSIZE
);
8319 alertpanel_error(_("Regular expression (regexp) error:\n%s"), buf
);
8326 void summary_set_prefs_from_folderitem(SummaryView
*summaryview
, FolderItem
*item
)
8328 FolderSortKey sort_key
;
8329 FolderSortType sort_type
;
8330 cm_return_if_fail(summaryview
!= NULL
);
8331 cm_return_if_fail(item
!= NULL
);
8333 /* Subject simplification */
8334 if(summaryview
->simplify_subject_preg
) {
8335 regfree(summaryview
->simplify_subject_preg
);
8336 g_free(summaryview
->simplify_subject_preg
);
8337 summaryview
->simplify_subject_preg
= NULL
;
8339 if(item
->prefs
&& item
->prefs
->simplify_subject_regexp
&&
8340 item
->prefs
->simplify_subject_regexp
[0] && item
->prefs
->enable_simplify_subject
)
8341 summaryview
->simplify_subject_preg
= summary_compile_simplify_regexp(item
->prefs
->simplify_subject_regexp
);
8344 sort_key
= item
->sort_key
;
8345 sort_type
= item
->sort_type
;
8347 folder_get_sort_type(item
->folder
, &sort_key
, &sort_type
);
8349 summaryview
->sort_key
= sort_key
;
8350 summaryview
->sort_type
= sort_type
;
8353 summaryview
->threaded
= item
->threaded
;
8354 summaryview
->thread_collapsed
= item
->thread_collapsed
;
8359 void summary_save_prefs_to_folderitem(SummaryView
*summaryview
, FolderItem
*item
)
8362 item
->sort_key
= summaryview
->sort_key
;
8363 item
->sort_type
= summaryview
->sort_type
;
8366 item
->threaded
= summaryview
->threaded
;
8367 item
->thread_collapsed
= summaryview
->thread_collapsed
;
8370 static gboolean
summary_update_msg(gpointer source
, gpointer data
)
8372 MsgInfoUpdate
*msginfo_update
= (MsgInfoUpdate
*) source
;
8373 SummaryView
*summaryview
= (SummaryView
*)data
;
8374 GtkCMCTreeNode
*node
;
8376 cm_return_val_if_fail(msginfo_update
!= NULL
, TRUE
);
8377 cm_return_val_if_fail(summaryview
!= NULL
, FALSE
);
8379 if (msginfo_update
->msginfo
->folder
!= summaryview
->folder_item
)
8382 if (msginfo_update
->flags
& MSGINFO_UPDATE_FLAGS
) {
8383 node
= gtk_cmctree_find_by_row_data(
8384 GTK_CMCTREE(summaryview
->ctree
), NULL
,
8385 msginfo_update
->msginfo
);
8388 summary_set_row_marks(summaryview
, node
);
8394 void summary_update_unread(SummaryView
*summaryview
, FolderItem
*removed_item
)
8396 guint
new, unread
, unreadmarked
, marked
, total
;
8397 guint replied
, forwarded
, locked
, ignored
, watched
;
8398 static gboolean tips_initialized
= FALSE
;
8400 if (prefs_common
.layout_mode
!= SMALL_LAYOUT
) {
8401 if (tips_initialized
) {
8402 summary_set_folder_pixmap(summaryview
, STOCK_PIXMAP_DIR_OPEN
);
8403 CLAWS_SET_TIP(summaryview
->folder_pixmap_eventbox
,
8405 tips_initialized
= FALSE
;
8409 folder_count_total_msgs(&new, &unread
, &unreadmarked
, &marked
, &total
,
8410 &replied
, &forwarded
, &locked
, &ignored
,
8413 total
-= removed_item
->total_msgs
;
8414 new -= removed_item
->new_msgs
;
8415 unread
-= removed_item
->unread_msgs
;
8418 if (new > 0 || unread
> 0) {
8419 tips_initialized
= TRUE
;
8420 summary_set_folder_pixmap(summaryview
, STOCK_PIXMAP_DIR_OPEN_HRM
);
8421 CLAWS_SET_TIP(summaryview
->folder_pixmap_eventbox
,
8422 _("Go back to the folder list (You have unread messages)"));
8424 tips_initialized
= TRUE
;
8425 summary_set_folder_pixmap(summaryview
, STOCK_PIXMAP_DIR_OPEN
);
8426 CLAWS_SET_TIP(summaryview
->folder_pixmap_eventbox
,
8427 _("Go back to the folder list"));
8431 static gboolean
summary_update_folder_item_hook(gpointer source
, gpointer data
)
8433 FolderItemUpdateData
*hookdata
= (FolderItemUpdateData
*)source
;
8434 SummaryView
*summaryview
= (SummaryView
*)data
;
8436 cm_return_val_if_fail(hookdata
!= NULL
, FALSE
);
8437 cm_return_val_if_fail(hookdata
->item
!= NULL
, FALSE
);
8438 cm_return_val_if_fail(summaryview
!= NULL
, FALSE
);
8440 if (hookdata
->item
== summaryview
->folder_item
&&
8441 hookdata
->update_flags
& F_ITEM_UPDATE_NAME
) {
8442 gchar
*name
= folder_item_get_name(hookdata
->item
);
8443 gtk_label_set_text(GTK_LABEL(summaryview
->statlabel_folder
), name
);
8446 summary_update_unread(summaryview
, NULL
);
8451 static gboolean
summary_update_folder_hook(gpointer source
, gpointer data
)
8453 FolderUpdateData
*hookdata
;
8454 SummaryView
*summaryview
= (SummaryView
*)data
;
8456 if (hookdata
->update_flags
& FOLDER_REMOVE_FOLDERITEM
) {
8457 summary_update_unread(summaryview
, hookdata
->item
);
8459 summary_update_unread(summaryview
, NULL
);
8465 *\brief change summaryview to display your answer(s) to a message
8467 *\param summaryview The SummaryView ;)
8468 *\param msginfo The message for which answers are searched
8471 static void summary_find_answers (SummaryView
*summaryview
, MsgInfo
*msg
)
8473 FolderItem
*sent_folder
= NULL
;
8474 PrefsAccount
*account
= NULL
;
8475 GtkCMCTreeNode
*node
= NULL
;
8477 if (msg
== NULL
|| msg
->msgid
== NULL
)
8480 account
= account_get_reply_account(msg
, prefs_common
.reply_account_autosel
);
8481 if (account
== NULL
)
8483 sent_folder
= account_get_special_folder
8484 (account
, F_OUTBOX
);
8486 buf
= g_strdup_printf("inreplyto matchcase \"%s\"", msg
->msgid
);
8488 if (sent_folder
!= summaryview
->folder_item
) {
8489 folderview_select(summaryview
->mainwin
->folderview
, sent_folder
);
8492 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(summaryview
->toggle_search
), TRUE
);
8494 quicksearch_set(summaryview
->quicksearch
, ADVANCED_SEARCH_EXTENDED
, buf
);
8497 node
= gtk_cmctree_node_nth(GTK_CMCTREE(summaryview
->ctree
), 0);
8499 summary_select_node(summaryview
, node
, OPEN_SELECTED_ON_SEARCH_RESULTS
);
8502 gint
summaryview_export_mbox_list(SummaryView
*summaryview
)
8503 /* return values: -2 skipped, -1 error, 0 OK */
8505 GSList
*list
= summary_get_selected_msg_list(summaryview
);
8506 gchar
*mbox
= filesel_select_file_save(_("Export to mbox file"), NULL
);
8514 ret
= export_list_to_mbox(list
, mbox
);
8522 void summaryview_lock(SummaryView
*summaryview
, FolderItem
*item
)
8524 if (!summaryview
|| !summaryview
->folder_item
|| !item
) {
8528 if (summaryview
->folder_item
->folder
== item
->folder
) {
8529 gtk_widget_set_sensitive(summaryview
->ctree
, FALSE
);
8532 void summaryview_unlock(SummaryView
*summaryview
, FolderItem
*item
)
8534 gtk_widget_set_sensitive(summaryview
->ctree
, TRUE
);
8537 static void summary_reedit_cb(GtkAction
*gaction
, gpointer data
)
8539 SummaryView
*summaryview
= (SummaryView
*)data
;
8540 summary_reedit(summaryview
);
8543 #define DO_ACTION(name, act) { if (!strcmp(a_name, name)) action = act; }
8544 static void summary_reply_cb(GtkAction
*gaction
, gpointer data
)
8546 SummaryView
*summaryview
= (SummaryView
*)data
;
8547 GSList
*msginfo_list
= NULL
;
8548 gint action
= COMPOSE_REPLY
;
8549 const gchar
*a_name
= gtk_action_get_name(gaction
);
8551 DO_ACTION("SummaryViewPopup/Reply", COMPOSE_REPLY
);
8552 DO_ACTION("SummaryViewPopup/ReplyTo/All", COMPOSE_REPLY_TO_ALL
);
8553 DO_ACTION("SummaryViewPopup/ReplyTo/Sender", COMPOSE_REPLY_TO_SENDER
);
8554 DO_ACTION("SummaryViewPopup/ReplyTo/List", COMPOSE_REPLY_TO_LIST
);
8555 DO_ACTION("SummaryViewPopup/Forward", COMPOSE_FORWARD_INLINE
);
8556 DO_ACTION("SummaryViewPopup/ForwardAtt", COMPOSE_FORWARD_AS_ATTACH
);
8557 DO_ACTION("SummaryViewPopup/Redirect", COMPOSE_REDIRECT
);
8559 msginfo_list
= summary_get_selection(summaryview
);
8560 cm_return_if_fail(msginfo_list
!= NULL
);
8561 compose_reply_from_messageview(NULL
, msginfo_list
, action
);
8562 g_slist_free(msginfo_list
);
8565 gboolean
summary_is_opened_message_selected(SummaryView
*summaryview
)
8569 cm_return_val_if_fail(summaryview
!= NULL
, FALSE
);
8571 sel
= GTK_CMCLIST(summaryview
->ctree
)->selection
;
8573 if (summaryview
->displayed
== NULL
|| sel
== NULL
) {
8577 for ( ; sel
!= NULL
; sel
= sel
->next
) {
8578 if (summaryview
->displayed
== GTK_CMCTREE_NODE(sel
->data
)) {
8585 gboolean
summary_has_opened_message(SummaryView
*summaryview
)
8587 cm_return_val_if_fail(summaryview
!= NULL
, FALSE
);
8589 return (summaryview
->displayed
!= NULL
);
8592 static void summary_header_lock_sorting_cb(GtkAction
*gaction
, gpointer data
)
8594 SummaryView
*summaryview
= (SummaryView
*)data
;
8595 gboolean sorting_lock
= prefs_common_get_prefs()->summary_col_lock
;
8597 if (summaryview
->header_menu_lock
)
8600 debug_print("%slocking summaryview columns\n",
8601 sorting_lock
? "un" : "");
8602 prefs_common_get_prefs()->summary_col_lock
= !sorting_lock
;
8605 static void summary_header_set_displayed_columns_cb(GtkAction
*gaction
,
8608 SummaryView
*summaryview
= (SummaryView
*)data
;
8610 if (summaryview
->header_menu_lock
)
8613 prefs_summary_column_open();