2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2002 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
55 #include "stock_pixmap.h"
62 #include "prefs_common.h"
63 #include "prefs_filter.h"
64 #include "prefs_actions.h"
65 #include "prefs_filtering.h"
66 #include "prefs_scoring.h"
67 #include "prefs_account.h"
68 #include "prefs_folder_item.h"
69 #include "prefs_summary_column.h"
70 #include "prefs_template.h"
72 #include "addressbook.h"
73 #include "logwindow.h"
74 #include "manage_window.h"
75 #include "alertpanel.h"
76 #include "statusbar.h"
77 #include "inputdialog.h"
84 #include "selective_download.h"
86 #define AC_LABEL_WIDTH 240
88 #define STATUSBAR_PUSH(mainwin, str) \
90 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
91 mainwin->mainwin_cid, str); \
92 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
95 #define STATUSBAR_POP(mainwin) \
97 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
98 mainwin->mainwin_cid); \
101 /* list of all instantiated MainWindow */
102 static GList *mainwin_list = NULL;
104 static GdkCursor *watch_cursor;
106 static void main_window_menu_callback_block (MainWindow *mainwin);
107 static void main_window_menu_callback_unblock (MainWindow *mainwin);
109 static void main_window_show_cur_account (MainWindow *mainwin);
111 static void main_window_set_widgets (MainWindow *mainwin,
113 static void main_window_toolbar_create (MainWindow *mainwin,
114 GtkWidget *container);
116 /* callback functions */
117 static void toolbar_inc_cb (GtkWidget *widget,
119 static void toolbar_inc_all_cb (GtkWidget *widget,
121 static void toolbar_send_cb (GtkWidget *widget,
124 static void toolbar_compose_cb (GtkWidget *widget,
126 static void toolbar_compose_news_cb (GtkWidget *widget,
128 static void toolbar_compose_mail_cb (GtkWidget *widget,
130 static void toolbar_reply_cb (GtkWidget *widget,
132 static void toolbar_reply_popup_cb (GtkWidget *widget,
133 GdkEventButton *event,
135 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell,
137 static void toolbar_reply_to_all_cb (GtkWidget *widget,
139 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget,
140 GdkEventButton *event,
142 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell,
144 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
146 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
147 GdkEventButton *event,
149 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell,
151 static void toolbar_forward_cb (GtkWidget *widget,
153 static void toolbar_forward_popup_cb (GtkWidget *widget,
154 GdkEventButton *event,
156 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell,
159 static void toolbar_delete_cb (GtkWidget *widget,
161 static void toolbar_exec_cb (GtkWidget *widget,
164 static void toolbar_next_unread_cb (GtkWidget *widget,
167 static void toolbar_prefs_cb (GtkWidget *widget,
169 static void toolbar_account_cb (GtkWidget *widget,
173 static void toolbar_account_button_pressed (GtkWidget *widget,
174 GdkEventButton *event,
177 static void ac_label_button_pressed (GtkWidget *widget,
178 GdkEventButton *event,
180 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
183 static gint main_window_close_cb (GtkWidget *widget,
186 static gint folder_window_close_cb (GtkWidget *widget,
189 static gint message_window_close_cb (GtkWidget *widget,
193 static void add_mailbox_cb (MainWindow *mainwin,
196 static void add_mbox_cb (MainWindow *mainwin,
199 static void update_folderview_cb (MainWindow *mainwin,
202 static void new_folder_cb (MainWindow *mainwin,
205 static void rename_folder_cb (MainWindow *mainwin,
208 static void delete_folder_cb (MainWindow *mainwin,
211 static void import_mbox_cb (MainWindow *mainwin,
214 static void export_mbox_cb (MainWindow *mainwin,
217 static void empty_trash_cb (MainWindow *mainwin,
221 static void save_as_cb (MainWindow *mainwin,
224 static void print_cb (MainWindow *mainwin,
227 static void app_exit_cb (MainWindow *mainwin,
231 static void search_cb (MainWindow *mainwin,
235 static void toggle_folder_cb (MainWindow *mainwin,
238 static void toggle_message_cb (MainWindow *mainwin,
241 static void toggle_toolbar_cb (MainWindow *mainwin,
244 static void toggle_statusbar_cb (MainWindow *mainwin,
247 static void separate_widget_cb (MainWindow *mainwin,
251 static void addressbook_open_cb (MainWindow *mainwin,
254 static void log_window_show_cb (MainWindow *mainwin,
257 static void sel_download_cb (MainWindow *mainwin,
261 static void inc_mail_cb (MainWindow *mainwin,
264 static void inc_all_account_mail_cb (MainWindow *mainwin,
267 static void inc_cancel_cb (MainWindow *mainwin,
271 static void send_queue_cb (MainWindow *mainwin,
275 static void compose_cb (MainWindow *mainwin,
278 static void compose_mail_cb(MainWindow *mainwin, guint action,
280 static void compose_news_cb(MainWindow *mainwin, guint action,
282 static void reply_cb (MainWindow *mainwin,
286 static void open_msg_cb (MainWindow *mainwin,
290 static void view_source_cb (MainWindow *mainwin,
294 static void show_all_header_cb (MainWindow *mainwin,
298 static void reedit_cb (MainWindow *mainwin,
302 static void move_to_cb (MainWindow *mainwin,
305 static void copy_to_cb (MainWindow *mainwin,
308 static void delete_cb (MainWindow *mainwin,
312 static void mark_cb (MainWindow *mainwin,
315 static void unmark_cb (MainWindow *mainwin,
319 static void mark_as_unread_cb (MainWindow *mainwin,
322 static void mark_as_read_cb (MainWindow *mainwin,
325 static void mark_all_read_cb (MainWindow *mainwin,
328 static void add_address_cb (MainWindow *mainwin,
332 static void set_charset_cb (MainWindow *mainwin,
336 static void hide_read_messages (MainWindow *mainwin,
340 static void thread_cb (MainWindow *mainwin,
343 static void expand_threads_cb (MainWindow *mainwin,
346 static void collapse_threads_cb (MainWindow *mainwin,
350 static void set_display_item_cb (MainWindow *mainwin,
353 static void sort_summary_cb (MainWindow *mainwin,
356 static void sort_summary_type_cb (MainWindow *mainwin,
359 static void attract_by_subject_cb(MainWindow *mainwin,
363 static void delete_duplicated_cb (MainWindow *mainwin,
366 static void filter_cb (MainWindow *mainwin,
369 static void execute_summary_cb (MainWindow *mainwin,
372 static void update_summary_cb (MainWindow *mainwin,
376 static void prev_cb (MainWindow *mainwin,
379 static void next_cb (MainWindow *mainwin,
383 static void prev_unread_cb (MainWindow *mainwin,
386 static void next_unread_cb (MainWindow *mainwin,
389 static void prev_marked_cb (MainWindow *mainwin,
392 static void next_marked_cb (MainWindow *mainwin,
395 static void prev_labeled_cb (MainWindow *mainwin,
398 static void next_labeled_cb (MainWindow *mainwin,
402 static void goto_folder_cb (MainWindow *mainwin,
406 static void copy_cb (MainWindow *mainwin,
409 static void allsel_cb (MainWindow *mainwin,
412 static void selthread_cb (MainWindow *mainwin,
415 static void create_filter_cb (MainWindow *mainwin,
419 static void prefs_common_open_cb (MainWindow *mainwin,
422 static void prefs_filter_open_cb (MainWindow *mainwin,
425 static void prefs_scoring_open_cb (MainWindow *mainwin,
428 static void prefs_filtering_open_cb (MainWindow *mainwin,
431 static void prefs_account_open_cb(MainWindow *mainwin,
434 static void prefs_template_open_cb (MainWindow *mainwin,
437 static void prefs_actions_open_cb (MainWindow *mainwin,
441 static void new_account_cb (MainWindow *mainwin,
445 static void account_menu_cb (GtkMenuItem *menuitem,
448 static void online_switch_clicked(GtkButton *btn,
451 static void manual_open_cb (MainWindow *mainwin,
454 static void faq_open_cb (MainWindow *mainwin,
458 static void scan_tree_func (Folder *folder,
462 static void activate_compose_button (MainWindow *mainwin,
464 ComposeButtonType type);
466 static void key_pressed (GtkWidget *widget,
470 static void set_toolbar_style(MainWindow *mainwin);
472 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
474 static void addr_harvest_cb ( MainWindow *mainwin,
478 static void addr_harvest_msg_cb ( MainWindow *mainwin,
482 #define SEPARATE_ACTION 500
484 static GtkItemFactoryEntry mainwin_entries[] =
486 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
487 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
488 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
489 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
490 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
491 {N_("/_File/_Folder/Create _new folder..."),
492 NULL, new_folder_cb, 0, NULL},
493 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
494 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
495 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
496 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
497 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
498 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
499 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
500 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
501 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
502 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
503 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
504 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
506 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
507 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
508 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
509 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
510 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
511 {N_("/_Edit/_Find in current message..."),
512 "<control>F", search_cb, 0, NULL},
513 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
514 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
515 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
516 {N_("/_View/Show or hi_de/_Folder tree"),
517 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
518 {N_("/_View/Show or hi_de/_Message view"),
519 "V", toggle_message_cb, 0, "<ToggleItem>"},
520 {N_("/_View/Show or hi_de/_Toolbar"),
521 NULL, NULL, 0, "<Branch>"},
522 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
523 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
524 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
525 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
526 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
527 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
528 {N_("/_View/Show or hi_de/_Toolbar/_None"),
529 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
530 {N_("/_View/Show or hi_de/Status _bar"),
531 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
532 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
533 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
534 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
535 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
536 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
537 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
538 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
539 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
540 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
541 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
542 {N_("/_View/_Sort/by _color label"),
543 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
544 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
545 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
546 {N_("/_View/_Sort/by a_ttachment"),
547 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
548 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
549 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
550 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
551 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
552 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
553 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
554 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
555 {N_("/_View/_Sort/_Attract by subject"),
556 NULL, attract_by_subject_cb, 0, NULL},
557 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
558 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
559 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
560 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
561 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
563 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
564 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
565 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
566 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
567 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
568 {N_("/_View/_Go to/P_rev unread message"),
569 "<shift>P", prev_unread_cb, 0, NULL},
570 {N_("/_View/_Go to/N_ext unread message"),
571 "<shift>N", next_unread_cb, 0, NULL},
572 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
573 {N_("/_View/_Go to/Prev _marked message"),
574 NULL, prev_marked_cb, 0, NULL},
575 {N_("/_View/_Go to/Next m_arked message"),
576 NULL, next_marked_cb, 0, NULL},
577 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
578 {N_("/_View/_Go to/Prev _labeled message"),
579 NULL, prev_labeled_cb, 0, NULL},
580 {N_("/_View/_Go to/Next la_beled message"),
581 NULL, next_labeled_cb, 0, NULL},
582 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
583 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
584 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
586 #define CODESET_SEPARATOR \
587 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
588 #define CODESET_ACTION(action) \
589 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
591 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
592 {N_("/_View/_Code set/_Auto detect"),
593 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
594 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
595 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
596 CODESET_ACTION(C_US_ASCII)},
599 {N_("/_View/_Code set/Unicode (_UTF-8)"),
600 CODESET_ACTION(C_UTF_8)},
603 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
604 CODESET_ACTION(C_ISO_8859_1)},
605 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
606 CODESET_ACTION(C_ISO_8859_15)},
609 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
610 CODESET_ACTION(C_ISO_8859_2)},
612 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
613 CODESET_ACTION(C_ISO_8859_13)},
614 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
615 CODESET_ACTION(C_ISO_8859_4)},
617 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
618 CODESET_ACTION(C_ISO_8859_7)},
620 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
621 CODESET_ACTION(C_ISO_8859_9)},
623 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
624 CODESET_ACTION(C_ISO_8859_5)},
625 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
626 CODESET_ACTION(C_KOI8_R)},
627 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
628 CODESET_ACTION(C_WINDOWS_1251)},
631 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
632 CODESET_ACTION(C_ISO_2022_JP)},
634 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
635 CODESET_ACTION(C_ISO_2022_JP_2)},
637 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
638 CODESET_ACTION(C_EUC_JP)},
639 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
640 CODESET_ACTION(C_SHIFT_JIS)},
643 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
644 CODESET_ACTION(C_GB2312)},
645 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
646 CODESET_ACTION(C_BIG5)},
647 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
648 CODESET_ACTION(C_EUC_TW)},
649 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
650 CODESET_ACTION(C_ISO_2022_CN)},
652 {N_("/_View/_Code set/Korean (EUC-_KR)"),
653 CODESET_ACTION(C_EUC_KR)},
654 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
655 CODESET_ACTION(C_ISO_2022_KR)},
657 {N_("/_View/_Code set/Thai (TIS-620)"),
658 CODESET_ACTION(C_TIS_620)},
659 {N_("/_View/_Code set/Thai (Windows-874)"),
660 CODESET_ACTION(C_WINDOWS_874)},
663 #undef CODESET_SEPARATOR
664 #undef CODESET_ACTION
666 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
667 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
668 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
669 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
670 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
671 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
673 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
674 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
675 {N_("/_Message/Get from _all accounts"),
676 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
677 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
678 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
679 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
680 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
681 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
682 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
683 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
684 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
685 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
686 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
687 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
688 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
689 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
690 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
691 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
692 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
693 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
694 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
695 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
696 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
697 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
698 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
699 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
700 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
701 {N_("/_Message/_Mark/Mark as rea_d"),
702 NULL, mark_as_read_cb, 0, NULL},
703 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
705 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
706 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
707 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
708 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
709 {N_("/_Tools/Add sender to address boo_k"),
710 NULL, add_address_cb, 0, NULL},
711 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
712 {N_("/_Tools/_Harvest addresses/from _Folder..."),
713 NULL, addr_harvest_cb, 0, NULL},
714 {N_("/_Tools/_Harvest addresses/from _Messages..."),
715 NULL, addr_harvest_msg_cb, 0, NULL},
716 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
717 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
718 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
719 {N_("/_Tools/_Create filter rule/_Automatically"),
720 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
721 {N_("/_Tools/_Create filter rule/by _From"),
722 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
723 {N_("/_Tools/_Create filter rule/by _To"),
724 NULL, create_filter_cb, FILTER_BY_TO, NULL},
725 {N_("/_Tools/_Create filter rule/by _Subject"),
726 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
727 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
728 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
729 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
730 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
731 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
732 {N_("/_Tools/Delete du_plicated messages"),
733 NULL, delete_duplicated_cb, 0, NULL},
734 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
735 {N_("/_Tools/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
737 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
738 {N_("/_Configuration/_Common preferences..."),
739 NULL, prefs_common_open_cb, 0, NULL},
740 {N_("/_Configuration/_Filter setting..."),
741 NULL, prefs_filter_open_cb, 0, NULL},
742 {N_("/_Configuration/_Scoring..."),
743 NULL, prefs_scoring_open_cb, 0, NULL},
744 {N_("/_Configuration/_Filtering..."),
745 NULL, prefs_filtering_open_cb, 0, NULL},
746 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
747 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
748 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
749 {N_("/_Configuration/_Preferences for current account..."),
750 NULL, prefs_account_open_cb, 0, NULL},
751 {N_("/_Configuration/Create _new account..."),
752 NULL, new_account_cb, 0, NULL},
753 {N_("/_Configuration/_Edit accounts..."),
754 NULL, account_edit_open, 0, NULL},
755 {N_("/_Configuration/C_hange current account"),
756 NULL, NULL, 0, "<Branch>"},
758 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
759 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
760 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
761 {N_("/_Help/_Manual/_German"), NULL, manual_open_cb, MANUAL_LANG_DE, NULL},
762 {N_("/_Help/_Manual/_Spanish"), NULL, manual_open_cb, MANUAL_LANG_ES, NULL},
763 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
764 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
765 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
766 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
767 {N_("/_Help/_FAQ/_German"), NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
768 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
769 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
770 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
771 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
772 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
774 static GtkItemFactoryEntry reply_popup_entries[] =
776 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
777 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
779 static GtkItemFactoryEntry replyall_popup_entries[] =
781 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
782 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
784 static GtkItemFactoryEntry replysender_popup_entries[] =
786 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
787 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
789 static GtkItemFactoryEntry fwd_popup_entries[] =
791 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
792 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
795 MainWindow *main_window_create(SeparateType type)
801 GtkWidget *handlebox;
802 GtkWidget *vbox_body;
803 GtkWidget *hbox_stat;
804 GtkWidget *statusbar;
805 GtkWidget *progressbar;
806 GtkWidget *statuslabel;
807 GtkWidget *ac_button;
809 GtkWidget *online_status;
810 GtkWidget *offline_status;
811 GtkWidget *online_switch;
812 GtkWidget *offline_switch;
814 FolderView *folderview;
815 SummaryView *summaryview;
816 MessageView *messageview;
817 GdkColormap *colormap;
820 guint n_menu_entries;
821 GtkItemFactory *ifactory;
824 GtkWidget *compose_popup;
825 GtkWidget *reply_popup;
826 GtkWidget *replyall_popup;
827 GtkWidget *replysender_popup;
828 GtkWidget *fwd_popup;
831 static GdkGeometry geometry;
833 debug_print(_("Creating main window...\n"));
834 mainwin = g_new0(MainWindow, 1);
837 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
838 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
839 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
840 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
842 if (!geometry.min_height) {
843 geometry.min_width = 320;
844 geometry.min_height = 200;
846 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
849 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
850 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
851 MANAGE_WINDOW_SIGNALS_CONNECT(window);
852 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
853 GTK_SIGNAL_FUNC(key_pressed), mainwin);
855 gtk_widget_realize(window);
856 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
859 gtkut_widget_set_app_icon(window);
861 vbox = gtk_vbox_new(FALSE, 0);
862 gtk_widget_show(vbox);
863 gtk_container_add(GTK_CONTAINER(window), vbox);
866 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
867 menubar = menubar_create(window, mainwin_entries,
868 n_menu_entries, "<Main>", mainwin);
869 gtk_widget_show(menubar);
870 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
871 ifactory = gtk_item_factory_from_widget(menubar);
873 handlebox = gtk_handle_box_new();
874 gtk_widget_show(handlebox);
875 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
877 /* create the popup menus for the reply buttons specials */
878 n_menu_entries = sizeof(reply_popup_entries) /
879 sizeof(reply_popup_entries[0]);
880 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
881 "<ReplyPopup>", mainwin);
882 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
883 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
884 n_menu_entries = sizeof(replyall_popup_entries) /
885 sizeof(replyall_popup_entries[0]);
886 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
887 "<ReplyAllPopup>", mainwin);
888 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
889 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
890 n_menu_entries = sizeof(replysender_popup_entries) /
891 sizeof(replysender_popup_entries[0]);
892 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
893 "<ReplySenderPopup>", mainwin);
894 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
895 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
896 /* create the popup menu for the forward button */
897 n_menu_entries = sizeof(fwd_popup_entries) /
898 sizeof(fwd_popup_entries[0]);
899 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
900 "<ForwardPopup>", mainwin);
901 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
902 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
904 main_window_toolbar_create(mainwin, handlebox);
906 /* vbox that contains body */
907 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
908 gtk_widget_show(vbox_body);
909 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
910 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
912 hbox_stat = gtk_hbox_new(FALSE, 2);
913 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
915 statusbar = statusbar_create();
916 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
918 progressbar = gtk_progress_bar_new();
919 gtk_widget_set_usize(progressbar, 120, 1);
920 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
922 online_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
923 offline_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
924 online_switch = gtk_button_new ();
925 offline_switch = gtk_button_new ();
926 gtk_container_add (GTK_CONTAINER(online_switch), online_status);
927 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
928 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
929 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
930 gtk_container_add (GTK_CONTAINER(offline_switch), offline_status);
931 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
932 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
933 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
935 statuslabel = gtk_label_new("");
936 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
938 ac_button = gtk_button_new();
939 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
940 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
941 gtk_widget_set_usize(ac_button, -1, 1);
942 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
943 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
944 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
946 ac_label = gtk_label_new("");
947 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
949 gtk_widget_show_all(hbox_stat);
951 gtk_widget_hide(offline_switch);
953 mainwin->folderview = folderview = folderview_create();
954 mainwin->summaryview = summaryview = summary_create();
955 mainwin->messageview = messageview = messageview_create();
956 mainwin->logwin = log_window_create();
958 folderview->mainwin = mainwin;
959 folderview->summaryview = summaryview;
961 summaryview->mainwin = mainwin;
962 summaryview->folderview = folderview;
963 summaryview->messageview = messageview;
964 summaryview->window = window;
966 messageview->mainwin = mainwin;
968 mainwin->window = window;
969 mainwin->vbox = vbox;
970 mainwin->menubar = menubar;
971 mainwin->menu_factory = ifactory;
972 mainwin->handlebox = handlebox;
973 mainwin->vbox_body = vbox_body;
974 mainwin->hbox_stat = hbox_stat;
975 mainwin->statusbar = statusbar;
976 mainwin->progressbar = progressbar;
977 mainwin->statuslabel = statuslabel;
978 mainwin->ac_button = ac_button;
979 mainwin->ac_label = ac_label;
981 mainwin->reply_popup = reply_popup;
982 mainwin->replyall_popup = replyall_popup;
983 mainwin->replysender_popup = replysender_popup;
984 mainwin->fwd_popup = fwd_popup;
985 mainwin->online_switch = online_switch;
986 mainwin->offline_switch = offline_switch;
988 /* set context IDs for status bar */
989 mainwin->mainwin_cid = gtk_statusbar_get_context_id
990 (GTK_STATUSBAR(statusbar), "Main Window");
991 mainwin->folderview_cid = gtk_statusbar_get_context_id
992 (GTK_STATUSBAR(statusbar), "Folder View");
993 mainwin->summaryview_cid = gtk_statusbar_get_context_id
994 (GTK_STATUSBAR(statusbar), "Summary View");
996 /* allocate colors for summary view and folder view */
997 summaryview->color_marked.red = summaryview->color_marked.green = 0;
998 summaryview->color_marked.blue = (guint16)65535;
1000 summaryview->color_dim.red = summaryview->color_dim.green =
1001 summaryview->color_dim.blue = COLOR_DIM;
1003 folderview->color_new.red = (guint16)55000;
1004 folderview->color_new.green = folderview->color_new.blue = 15000;
1006 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1007 &folderview->color_op);
1009 summaryview->color_important.red = 0;
1010 summaryview->color_important.green = 0;
1011 summaryview->color_important.blue = (guint16)65535;
1013 color[0] = summaryview->color_marked;
1014 color[1] = summaryview->color_dim;
1015 color[2] = folderview->color_new;
1016 color[3] = folderview->color_op;
1018 colormap = gdk_window_get_colormap(window->window);
1019 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1020 for (i = 0; i < 4; i++) {
1021 if (success[i] == FALSE)
1022 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1025 debug_print(_("done.\n"));
1027 messageview->visible = TRUE;
1029 main_window_set_widgets(mainwin, type);
1031 /* set menu items */
1032 menuitem = gtk_item_factory_get_item
1033 (ifactory, "/View/Code set/Auto detect");
1034 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1036 switch (prefs_common.toolbar_style) {
1038 menuitem = gtk_item_factory_get_item
1039 (ifactory, "/View/Show or hide/Toolbar/None");
1042 menuitem = gtk_item_factory_get_item
1043 (ifactory, "/View/Show or hide/Toolbar/Icon");
1046 menuitem = gtk_item_factory_get_item
1047 (ifactory, "/View/Show or hide/Toolbar/Text");
1050 menuitem = gtk_item_factory_get_item
1051 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1053 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1055 gtk_widget_hide(mainwin->hbox_stat);
1056 menuitem = gtk_item_factory_get_item
1057 (ifactory, "/View/Show or hide/Status bar");
1058 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1059 prefs_common.show_statusbar);
1061 /* set account selection menu */
1062 ac_menu = gtk_item_factory_get_widget
1063 (ifactory, "/Configuration/Change current account");
1064 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1065 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1066 mainwin->ac_menu = ac_menu;
1068 main_window_set_toolbar_sensitive(mainwin);
1070 /* Create actions menu */
1071 update_mainwin_actions_menu(ifactory, mainwin);
1073 /* show main window */
1074 gtk_widget_set_uposition(mainwin->window,
1075 prefs_common.mainwin_x,
1076 prefs_common.mainwin_y);
1077 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1078 prefs_common.mainwin_height);
1079 gtk_widget_show(mainwin->window);
1081 /* initialize views */
1082 folderview_init(folderview);
1083 summary_init(summaryview);
1084 messageview_init(messageview);
1085 log_window_init(mainwin->logwin);
1087 mainwin->lock_count = 0;
1088 mainwin->menu_lock_count = 0;
1089 mainwin->cursor_count = 0;
1092 watch_cursor = gdk_cursor_new(GDK_WATCH);
1094 mainwin_list = g_list_append(mainwin_list, mainwin);
1096 /* init work_offline */
1097 if (prefs_common.work_offline)
1098 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1103 void main_window_cursor_wait(MainWindow *mainwin)
1106 if (mainwin->cursor_count == 0)
1107 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1109 mainwin->cursor_count++;
1114 void main_window_cursor_normal(MainWindow *mainwin)
1116 if (mainwin->cursor_count)
1117 mainwin->cursor_count--;
1119 if (mainwin->cursor_count == 0)
1120 gdk_window_set_cursor(mainwin->window->window, NULL);
1125 /* lock / unlock the user-interface */
1126 void main_window_lock(MainWindow *mainwin)
1128 if (mainwin->lock_count == 0)
1129 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1131 mainwin->lock_count++;
1133 main_window_set_menu_sensitive(mainwin);
1134 main_window_set_toolbar_sensitive(mainwin);
1137 void main_window_unlock(MainWindow *mainwin)
1139 if (mainwin->lock_count)
1140 mainwin->lock_count--;
1142 main_window_set_menu_sensitive(mainwin);
1143 main_window_set_toolbar_sensitive(mainwin);
1145 if (mainwin->lock_count == 0)
1146 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1149 static void main_window_menu_callback_block(MainWindow *mainwin)
1151 mainwin->menu_lock_count++;
1154 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1156 if (mainwin->menu_lock_count)
1157 mainwin->menu_lock_count--;
1160 void main_window_reflect_prefs_all(void)
1162 main_window_reflect_prefs_all_real(FALSE);
1165 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1168 MainWindow *mainwin;
1170 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1171 mainwin = (MainWindow *)cur->data;
1173 main_window_show_cur_account(mainwin);
1174 main_window_set_menu_sensitive(mainwin);
1175 main_window_set_toolbar_sensitive(mainwin);
1178 if (pixmap_theme_changed) {
1179 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1180 mainwin->toolbar = NULL;
1181 main_window_toolbar_create(mainwin, mainwin->handlebox);
1182 set_toolbar_style(mainwin);
1183 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1184 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1185 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1188 summary_redisplay_msg(mainwin->summaryview);
1189 headerview_set_visibility(mainwin->messageview->headerview,
1190 prefs_common.display_header_pane);
1194 void main_window_set_summary_column(void)
1197 MainWindow *mainwin;
1199 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1200 mainwin = (MainWindow *)cur->data;
1201 summary_set_column_order(mainwin->summaryview);
1205 void main_window_set_account_menu(GList *account_list)
1207 GList *cur, *cur_ac, *cur_item;
1208 GtkWidget *menuitem;
1209 MainWindow *mainwin;
1210 PrefsAccount *ac_prefs;
1212 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1213 mainwin = (MainWindow *)cur->data;
1215 /* destroy all previous menu item */
1216 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1217 while (cur_item != NULL) {
1218 GList *next = cur_item->next;
1219 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1223 for (cur_ac = account_list; cur_ac != NULL;
1224 cur_ac = cur_ac->next) {
1225 ac_prefs = (PrefsAccount *)cur_ac->data;
1227 menuitem = gtk_menu_item_new_with_label
1228 (ac_prefs->account_name
1229 ? ac_prefs->account_name : _("Untitled"));
1230 gtk_widget_show(menuitem);
1231 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1232 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1233 GTK_SIGNAL_FUNC(account_menu_cb),
1239 static void main_window_show_cur_account(MainWindow *mainwin)
1244 ac_name = g_strdup(cur_account
1245 ? (cur_account->account_name
1246 ? cur_account->account_name : _("Untitled"))
1250 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1252 buf = g_strdup(PROG_VERSION);
1253 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1256 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1257 gtk_widget_queue_resize(mainwin->ac_button);
1262 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1264 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1265 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1266 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1268 debug_print(_("Changing window separation type from %d to %d\n"),
1269 mainwin->type, type);
1271 if (mainwin->type == type) return;
1273 /* remove widgets from those containers */
1274 gtk_widget_ref(folder_wid);
1275 gtk_widget_ref(summary_wid);
1276 gtk_widget_ref(message_wid);
1277 gtkut_container_remove
1278 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1279 gtkut_container_remove
1280 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1281 gtkut_container_remove
1282 (GTK_CONTAINER(message_wid->parent), message_wid);
1284 /* clean containers */
1285 switch (mainwin->type) {
1287 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1289 case SEPARATE_FOLDER:
1290 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1291 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1293 case SEPARATE_MESSAGE:
1294 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1295 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1298 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1299 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1303 gtk_widget_hide(mainwin->window);
1304 main_window_set_widgets(mainwin, type);
1305 gtk_widget_show(mainwin->window);
1307 gtk_widget_unref(folder_wid);
1308 gtk_widget_unref(summary_wid);
1309 gtk_widget_unref(message_wid);
1312 void main_window_toggle_message_view(MainWindow *mainwin)
1314 SummaryView *summaryview = mainwin->summaryview;
1315 union CompositeWin *cwin = &mainwin->win;
1316 GtkWidget *vpaned = NULL;
1317 GtkWidget *container = NULL;
1318 GtkWidget *msgwin = NULL;
1320 switch (mainwin->type) {
1322 vpaned = cwin->sep_none.vpaned;
1323 container = cwin->sep_none.hpaned;
1325 case SEPARATE_FOLDER:
1326 vpaned = cwin->sep_folder.vpaned;
1327 container = mainwin->vbox_body;
1329 case SEPARATE_MESSAGE:
1330 msgwin = mainwin->win.sep_message.messagewin;
1333 msgwin = mainwin->win.sep_both.messagewin;
1338 if (GTK_WIDGET_VISIBLE(msgwin)) {
1339 gtk_widget_hide(msgwin);
1340 mainwin->messageview->visible = FALSE;
1341 summaryview->displayed = NULL;
1343 gtk_widget_show(msgwin);
1344 mainwin->messageview->visible = TRUE;
1346 } else if (vpaned->parent != NULL) {
1347 mainwin->messageview->visible = FALSE;
1348 summaryview->displayed = NULL;
1349 gtk_widget_ref(vpaned);
1350 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1351 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1352 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1353 GTK_ARROW_UP, GTK_SHADOW_OUT);
1355 mainwin->messageview->visible = TRUE;
1356 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1357 gtk_container_add(GTK_CONTAINER(container), vpaned);
1358 gtk_widget_unref(vpaned);
1359 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1360 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1363 main_window_set_menu_sensitive(mainwin);
1365 gtk_widget_grab_focus(summaryview->ctree);
1368 void main_window_get_size(MainWindow *mainwin)
1370 GtkAllocation *allocation;
1372 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1374 prefs_common.summaryview_width = allocation->width;
1376 if ((mainwin->type == SEPARATE_NONE ||
1377 mainwin->type == SEPARATE_FOLDER) &&
1378 messageview_is_visible(mainwin->messageview))
1379 prefs_common.summaryview_height = allocation->height;
1381 prefs_common.mainview_width = allocation->width;
1383 allocation = &mainwin->window->allocation;
1385 prefs_common.mainview_height = allocation->height;
1386 prefs_common.mainwin_width = allocation->width;
1387 prefs_common.mainwin_height = allocation->height;
1389 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1391 prefs_common.folderview_width = allocation->width;
1392 prefs_common.folderview_height = allocation->height;
1395 void main_window_get_position(MainWindow *mainwin)
1399 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1401 prefs_common.mainview_x = x;
1402 prefs_common.mainview_y = y;
1403 prefs_common.mainwin_x = x;
1404 prefs_common.mainwin_y = y;
1406 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1409 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1415 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1416 folder = FOLDER(list->data);
1417 if (folder && folder->trash && folder->trash->total > 0)
1421 if (!has_trash) return;
1424 if (alertpanel(_("Empty trash"),
1425 _("Empty all messages in trash?"),
1426 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1428 manage_window_focus_in(mainwin->window, NULL, NULL);
1431 procmsg_empty_trash();
1433 for (list = folder_get_list(); list != NULL; list = list->next) {
1434 folder = list->data;
1435 if (folder && folder->trash && folder->trash->total != 0) {
1436 folder_item_scan(folder->trash);
1437 folderview_update_item(folder->trash, TRUE);
1441 if (mainwin->summaryview->folder_item &&
1442 mainwin->summaryview->folder_item->stype == F_TRASH)
1443 gtk_widget_grab_focus(mainwin->folderview->ctree);
1446 void main_window_add_mailbox(MainWindow *mainwin)
1451 path = input_dialog(_("Add mailbox"),
1452 _("Input the location of mailbox.\n"
1453 "If the existing mailbox is specified, it will be\n"
1454 "scanned automatically."),
1457 if (folder_find_from_path(path)) {
1458 alertpanel_error(_("The mailbox `%s' already exists."), path);
1462 if (!strcmp(path, "Mail"))
1463 folder = folder_new(F_MH, _("Mailbox"), path);
1465 folder = folder_new(F_MH, g_basename(path), path);
1468 if (folder->create_tree(folder) < 0) {
1469 alertpanel_error(_("Creation of the mailbox failed.\n"
1470 "Maybe some files already exist, or you don't have the permission to write there."));
1471 folder_destroy(folder);
1476 folder_set_ui_func(folder, scan_tree_func, mainwin);
1477 folder->scan_tree(folder);
1478 folder_set_ui_func(folder, NULL, NULL);
1480 folderview_set(mainwin->folderview);
1483 void main_window_add_mbox(MainWindow *mainwin)
1489 path = input_dialog(_("Add mbox mailbox"),
1490 _("Input the location of mailbox."),
1495 if (folder_find_from_path(path)) {
1496 alertpanel_error(_("The mailbox `%s' already exists."), path);
1502 if (!strcmp(path, "Mail"))
1503 folder = folder_new(F_MBOX, _("Mailbox"), path);
1507 folder = folder_new(F_MBOX, g_basename(path), path);
1510 if (folder->create_tree(folder) < 0) {
1511 alertpanel_error(_("Creation of the mailbox failed."));
1512 folder_destroy(folder);
1518 item = folder_item_new(folder->name, NULL);
1519 item->folder = folder;
1520 folder->node = g_node_new(item);
1522 folder->create_folder(folder, item, "inbox");
1523 folder->create_folder(folder, item, "outbox");
1524 folder->create_folder(folder, item, "queue");
1525 folder->create_folder(folder, item, "draft");
1526 folder->create_folder(folder, item, "trash");
1528 folderview_set(mainwin->folderview);
1533 M_UNLOCKED = 1 << 0,
1534 M_MSG_EXIST = 1 << 1,
1535 M_TARGET_EXIST = 1 << 2,
1536 M_SINGLE_TARGET_EXIST = 1 << 3,
1538 M_ALLOW_REEDIT = 1 << 5,
1539 M_HAVE_ACCOUNT = 1 << 6,
1540 M_THREADED = 1 << 7,
1541 M_UNTHREADED = 1 << 8,
1542 M_ALLOW_DELETE = 1 << 9,
1543 M_INC_ACTIVE = 1 << 10,
1545 M_HAVE_NEWS_ACCOUNT = 1 << 12,
1546 M_HIDE_READ_MSG = 1 << 13
1549 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1551 SensitiveCond state = 0;
1552 SummarySelection selection;
1553 FolderItem *item = mainwin->summaryview->folder_item;
1554 GList *account_list = account_get_list();
1556 selection = summary_get_selection_type(mainwin->summaryview);
1558 if (mainwin->lock_count == 0)
1559 state |= M_UNLOCKED;
1560 if (selection != SUMMARY_NONE)
1561 state |= M_MSG_EXIST;
1565 state |= M_THREADED;
1567 state |= M_UNTHREADED;
1568 /* if (item->folder->type != F_NEWS) */
1569 state |= M_ALLOW_DELETE;
1571 if (selection == SUMMARY_NONE && item->hide_read_msgs
1572 || selection != SUMMARY_NONE)
1573 state |= M_HIDE_READ_MSG;
1575 if (selection == SUMMARY_SELECTED_SINGLE ||
1576 selection == SUMMARY_SELECTED_MULTIPLE)
1577 state |= M_TARGET_EXIST;
1578 if (selection == SUMMARY_SELECTED_SINGLE)
1579 state |= M_SINGLE_TARGET_EXIST;
1580 if (mainwin->summaryview->folder_item &&
1581 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1583 if (selection == SUMMARY_SELECTED_SINGLE &&
1585 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1586 item->stype == F_QUEUE)))
1587 state |= M_ALLOW_REEDIT;
1589 state |= M_HAVE_ACCOUNT;
1591 for ( ; account_list != NULL; account_list = account_list->next) {
1592 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1593 state |= M_HAVE_NEWS_ACCOUNT;
1598 if (inc_is_active())
1599 state |= M_INC_ACTIVE;
1604 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1606 SensitiveCond state;
1615 #define SET_WIDGET_COND(w, c) \
1617 entry[i].widget = w; \
1618 entry[i].cond = c; \
1622 SET_WIDGET_COND(mainwin->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1623 SET_WIDGET_COND(mainwin->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1624 SET_WIDGET_COND(mainwin->compose_news_btn, M_HAVE_ACCOUNT);
1625 SET_WIDGET_COND(mainwin->reply_btn,
1626 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1627 SET_WIDGET_COND(mainwin->replyall_btn,
1628 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1629 SET_WIDGET_COND(mainwin->replysender_btn,
1630 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1631 SET_WIDGET_COND(mainwin->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
1633 SET_WIDGET_COND(mainwin->prefs_btn, M_UNLOCKED);
1634 SET_WIDGET_COND(mainwin->account_btn, M_UNLOCKED);
1636 SET_WIDGET_COND(mainwin->next_btn, M_MSG_EXIST);
1637 SET_WIDGET_COND(mainwin->delete_btn,
1638 M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
1639 SET_WIDGET_COND(mainwin->exec_btn, M_MSG_EXIST|M_EXEC|M_UNLOCKED);
1640 SET_WIDGET_COND(NULL, 0);
1642 #undef SET_WIDGET_COND
1644 state = main_window_get_current_state(mainwin);
1646 for (i = 0; entry[i].widget != NULL; i++) {
1647 sensitive = ((entry[i].cond & state) == entry[i].cond);
1648 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1651 activate_compose_button(mainwin,
1652 prefs_common.toolbar_style,
1653 mainwin->compose_btn_type);
1656 void main_window_set_menu_sensitive(MainWindow *mainwin)
1658 GtkItemFactory *ifactory = mainwin->menu_factory;
1659 SensitiveCond state;
1661 GtkWidget *menuitem;
1666 static const struct {
1670 {"/File/Add mailbox..." , M_UNLOCKED},
1671 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1672 {"/File/Rescan folder tree" , M_UNLOCKED},
1673 {"/File/Folder" , M_UNLOCKED},
1674 {"/File/Import mbox file..." , M_UNLOCKED},
1675 {"/File/Export to mbox file...", M_UNLOCKED},
1676 {"/File/Empty trash" , M_UNLOCKED},
1677 {"/File/Work offline" , M_UNLOCKED},
1678 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1679 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1680 /* {"/File/Close", M_UNLOCKED}, */
1681 {"/File/Exit" , M_UNLOCKED},
1683 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1684 {"/View/Sort" , M_MSG_EXIST},
1685 {"/View/Thread view" , M_EXEC},
1686 {"/View/Expand all threads" , M_MSG_EXIST},
1687 {"/View/Collapse all threads" , M_MSG_EXIST},
1688 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1689 {"/View/Go to/Prev message" , M_MSG_EXIST},
1690 {"/View/Go to/Next message" , M_MSG_EXIST},
1691 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1692 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1693 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1694 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1695 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1696 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1697 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1698 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1699 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1701 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1702 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1703 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1704 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1705 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1706 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1707 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1708 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1709 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1710 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1711 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1712 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1713 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1714 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1715 {"/Message/Mark" , M_TARGET_EXIST},
1717 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1718 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1719 {"/Tools/Harvest addresses" , M_UNLOCKED},
1720 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1721 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1722 {"/Tools/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1723 {"/Tools/Actions" , M_MSG_EXIST},
1724 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1726 {"/Configuration", M_UNLOCKED},
1731 state = main_window_get_current_state(mainwin);
1733 for (i = 0; entry[i].entry != NULL; i++) {
1734 sensitive = ((entry[i].cond & state) == entry[i].cond);
1735 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1738 main_window_menu_callback_block(mainwin);
1740 #define SET_CHECK_MENU_ACTIVE(path, active) \
1742 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1743 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1746 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1747 messageview_is_visible(mainwin->messageview));
1749 item = mainwin->summaryview->folder_item;
1750 menu_path = "/View/Sort/Don't sort";
1752 switch (item->sort_key) {
1753 case SORT_BY_NUMBER:
1754 menu_path = "/View/Sort/by number"; break;
1756 menu_path = "/View/Sort/by size"; break;
1758 menu_path = "/View/Sort/by date"; break;
1760 menu_path = "/View/Sort/by from"; break;
1761 case SORT_BY_SUBJECT:
1762 menu_path = "/View/Sort/by subject"; break;
1764 menu_path = "/View/Sort/by color label"; break;
1766 menu_path = "/View/Sort/by mark"; break;
1767 case SORT_BY_UNREAD:
1768 menu_path = "/View/Sort/by unread"; break;
1770 menu_path = "/View/Sort/by attachment"; break;
1772 menu_path = "/View/Sort/by score"; break;
1773 case SORT_BY_LOCKED:
1774 menu_path = "/View/Sort/by locked"; break;
1777 menu_path = "/View/Sort/Don't sort"; break;
1780 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1782 if (!item || item->sort_type == SORT_ASCENDING) {
1783 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1785 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1788 if (item && item->sort_key != SORT_BY_NONE) {
1789 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1790 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1792 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1793 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1796 SET_CHECK_MENU_ACTIVE("/View/Show all header",
1797 mainwin->messageview->textview->show_all_headers);
1798 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1800 #undef SET_CHECK_MENU_ACTIVE
1802 main_window_menu_callback_unblock(mainwin);
1805 void main_window_popup(MainWindow *mainwin)
1811 gdk_window_get_origin(mainwin->window->window, &x, &y);
1812 sx = gdk_screen_width();
1813 sy = gdk_screen_height();
1814 x %= sx; if (x < 0) x = 0;
1815 y %= sy; if (y < 0) y = 0;
1816 gdk_window_move(mainwin->window->window, x, y);
1817 gdk_window_raise(mainwin->window->window);
1818 gdk_window_show(mainwin->window->window);
1820 debug_print("window position: x = %d, y = %d\n", x, y);
1822 switch (mainwin->type) {
1823 case SEPARATE_FOLDER:
1824 widget = mainwin->win.sep_folder.folderwin;
1825 gdk_window_get_origin(widget->window, &x, &y);
1826 x %= sx; if (x < 0) x = 0;
1827 y %= sy; if (y < 0) y = 0;
1828 gdk_window_move(widget->window, x, y);
1829 gdk_window_raise(widget->window);
1831 case SEPARATE_MESSAGE:
1832 widget = mainwin->win.sep_message.messagewin;
1833 gdk_window_get_origin(widget->window, &x, &y);
1834 x %= sx; if (x < 0) x = 0;
1835 y %= sy; if (y < 0) y = 0;
1836 gdk_window_move(widget->window, x, y);
1837 gdk_window_raise(widget->window);
1840 widget = mainwin->win.sep_both.folderwin;
1841 gdk_window_get_origin(widget->window, &x, &y);
1842 x %= sx; if (x < 0) x = 0;
1843 y %= sy; if (y < 0) y = 0;
1844 gdk_window_move(widget->window, x, y);
1845 gdk_window_raise(widget->window);
1846 widget = mainwin->win.sep_both.messagewin;
1847 gdk_window_get_origin(widget->window, &x, &y);
1848 x %= sx; if (x < 0) x = 0;
1849 y %= sy; if (y < 0) y = 0;
1850 gdk_window_move(widget->window, x, y);
1851 gdk_window_raise(widget->window);
1858 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1860 GtkWidget *folderwin = NULL;
1861 GtkWidget *messagewin = NULL;
1864 GtkWidget *vbox_body = mainwin->vbox_body;
1865 GtkItemFactory *ifactory = mainwin->menu_factory;
1866 GtkWidget *menuitem;
1868 debug_print(_("Setting widgets..."));
1870 /* create separated window(s) if needed */
1871 if (type & SEPARATE_FOLDER) {
1872 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1873 gtk_window_set_title(GTK_WINDOW(folderwin),
1874 _("Sylpheed - Folder View"));
1875 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1876 "folder_view", "Sylpheed");
1877 gtk_window_set_policy(GTK_WINDOW(folderwin),
1879 gtk_widget_set_usize(folderwin, -1,
1880 prefs_common.mainview_height);
1881 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1883 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1884 GTK_SIGNAL_FUNC(folder_window_close_cb),
1887 if (type & SEPARATE_MESSAGE) {
1888 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1889 gtk_window_set_title(GTK_WINDOW(messagewin),
1890 _("Sylpheed - Message View"));
1891 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1892 "message_view", "Sylpheed");
1893 gtk_window_set_policy(GTK_WINDOW(messagewin),
1895 gtk_widget_set_usize
1896 (messagewin, prefs_common.mainview_width,
1897 prefs_common.mainview_height
1898 - prefs_common.summaryview_height
1899 + DEFAULT_HEADERVIEW_HEIGHT);
1900 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1902 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1903 GTK_SIGNAL_FUNC(message_window_close_cb),
1909 hpaned = gtk_hpaned_new();
1910 gtk_widget_show(hpaned);
1911 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1912 gtk_paned_add1(GTK_PANED(hpaned),
1913 GTK_WIDGET_PTR(mainwin->folderview));
1915 vpaned = gtk_vpaned_new();
1916 if (messageview_is_visible(mainwin->messageview)) {
1917 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1918 gtk_paned_add1(GTK_PANED(vpaned),
1919 GTK_WIDGET_PTR(mainwin->summaryview));
1921 gtk_paned_add2(GTK_PANED(hpaned),
1922 GTK_WIDGET_PTR(mainwin->summaryview));
1923 gtk_widget_ref(vpaned);
1925 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1926 prefs_common.summaryview_width,
1927 prefs_common.summaryview_height);
1928 gtk_paned_add2(GTK_PANED(vpaned),
1929 GTK_WIDGET_PTR(mainwin->messageview));
1930 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1931 prefs_common.mainview_width, -1);
1932 gtk_widget_set_usize(mainwin->window,
1933 prefs_common.folderview_width +
1934 prefs_common.mainview_width,
1935 prefs_common.mainwin_height);
1936 gtk_widget_show_all(vpaned);
1938 mainwin->win.sep_none.hpaned = hpaned;
1939 mainwin->win.sep_none.vpaned = vpaned;
1941 case SEPARATE_FOLDER:
1942 vpaned = gtk_vpaned_new();
1943 if (messageview_is_visible(mainwin->messageview)) {
1944 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1946 gtk_paned_add1(GTK_PANED(vpaned),
1947 GTK_WIDGET_PTR(mainwin->summaryview));
1949 gtk_box_pack_start(GTK_BOX(vbox_body),
1950 GTK_WIDGET_PTR(mainwin->summaryview),
1952 gtk_widget_ref(vpaned);
1954 gtk_paned_add2(GTK_PANED(vpaned),
1955 GTK_WIDGET_PTR(mainwin->messageview));
1956 gtk_widget_show_all(vpaned);
1957 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1958 prefs_common.summaryview_width,
1959 prefs_common.summaryview_height);
1960 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1961 prefs_common.mainview_width, -1);
1962 gtk_widget_set_usize(mainwin->window,
1963 prefs_common.mainview_width,
1964 prefs_common.mainview_height);
1966 gtk_container_add(GTK_CONTAINER(folderwin),
1967 GTK_WIDGET_PTR(mainwin->folderview));
1969 mainwin->win.sep_folder.folderwin = folderwin;
1970 mainwin->win.sep_folder.vpaned = vpaned;
1972 gtk_widget_show_all(folderwin);
1974 case SEPARATE_MESSAGE:
1975 hpaned = gtk_hpaned_new();
1976 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1978 gtk_paned_add1(GTK_PANED(hpaned),
1979 GTK_WIDGET_PTR(mainwin->folderview));
1980 gtk_paned_add2(GTK_PANED(hpaned),
1981 GTK_WIDGET_PTR(mainwin->summaryview));
1982 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1983 prefs_common.summaryview_width,
1984 prefs_common.summaryview_height);
1985 gtk_widget_set_usize(mainwin->window,
1986 prefs_common.folderview_width +
1987 prefs_common.mainview_width,
1988 prefs_common.mainwin_height);
1989 gtk_widget_show_all(hpaned);
1990 gtk_container_add(GTK_CONTAINER(messagewin),
1991 GTK_WIDGET_PTR(mainwin->messageview));
1993 mainwin->win.sep_message.messagewin = messagewin;
1994 mainwin->win.sep_message.hpaned = hpaned;
1996 gtk_widget_show_all(messagewin);
1999 gtk_box_pack_start(GTK_BOX(vbox_body),
2000 GTK_WIDGET_PTR(mainwin->summaryview),
2002 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
2003 prefs_common.summaryview_width,
2004 prefs_common.summaryview_height);
2005 gtk_widget_set_usize(mainwin->window,
2006 prefs_common.mainview_width,
2007 prefs_common.mainwin_height);
2008 gtk_container_add(GTK_CONTAINER(folderwin),
2009 GTK_WIDGET_PTR(mainwin->folderview));
2010 gtk_container_add(GTK_CONTAINER(messagewin),
2011 GTK_WIDGET_PTR(mainwin->messageview));
2013 mainwin->win.sep_both.folderwin = folderwin;
2014 mainwin->win.sep_both.messagewin = messagewin;
2016 gtk_widget_show_all(folderwin);
2017 gtk_widget_show_all(messagewin);
2021 mainwin->type = type;
2023 mainwin->messageview->visible = TRUE;
2025 /* toggle menu state */
2026 menuitem = gtk_item_factory_get_item
2027 (ifactory, "/View/Show or hide/Folder tree");
2028 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2029 menuitem = gtk_item_factory_get_item
2030 (ifactory, "/View/Show or hide/Message view");
2031 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2033 menuitem = gtk_item_factory_get_item
2034 (ifactory, "/View/Separate folder tree");
2035 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2036 ((type & SEPARATE_FOLDER) != 0));
2037 menuitem = gtk_item_factory_get_item
2038 (ifactory, "/View/Separate message view");
2039 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2040 ((type & SEPARATE_MESSAGE) != 0));
2042 debug_print(_("done.\n"));
2045 static void main_window_toolbar_create(MainWindow *mainwin,
2046 GtkWidget *container)
2049 GtkWidget *icon_wid;
2051 GtkWidget *getall_btn;
2052 GtkWidget *compose_mail_btn;
2053 GtkWidget *compose_news_btn;
2054 GtkWidget *reply_btn;
2055 GtkWidget *replyall_btn;
2056 GtkWidget *replysender_btn;
2058 GtkWidget *send_btn;
2060 GtkWidget *prefs_btn;
2061 GtkWidget *account_btn;
2063 GtkWidget *next_btn;
2064 GtkWidget *delete_btn;
2065 GtkWidget *exec_btn;
2067 GtkTooltips *tooltips;
2069 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
2071 gtk_container_add(GTK_CONTAINER(container), toolbar);
2072 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
2073 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
2074 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
2075 GTK_TOOLBAR_SPACE_LINE);
2077 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
2078 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2080 _("Get new mail from current account"),
2082 icon_wid, toolbar_inc_cb, mainwin);
2083 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
2084 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2086 _("Get new mail from all accounts"),
2092 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2094 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
2095 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2097 _("Send queued message(s)"),
2103 /* insert compose mail button widget */
2104 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
2105 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2107 _("Compose an email message"),
2110 toolbar_compose_mail_cb,
2113 /* insert compose news button widget */
2114 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2115 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2117 _("Compose a news message"),
2120 toolbar_compose_news_cb,
2123 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2127 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
2128 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2130 _("Reply to the message - Right button: more options"),
2136 /* replyall button */
2138 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
2139 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2141 _("Reply to all - Right button: more options"),
2144 toolbar_reply_to_all_cb,
2147 /* reply to sender button */
2148 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
2149 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2151 _("Reply to sender - Right button: more options"),
2154 toolbar_reply_to_sender_cb,
2157 /* forward button */
2158 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
2159 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2161 _("Forward the message - Right button: more options"),
2167 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2169 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
2170 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2172 _("Delete the message"),
2178 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
2179 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2181 _("Execute marked process"),
2187 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
2188 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2190 _("Next unread message"),
2193 toolbar_next_unread_cb,
2197 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2199 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2200 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2202 _("Common preferences"),
2207 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2208 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2210 _("Account setting"),
2215 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2216 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2220 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2221 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2224 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2225 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2228 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2229 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2232 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2233 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2237 mainwin->toolbar = toolbar;
2238 mainwin->get_btn = get_btn;
2239 mainwin->getall_btn = getall_btn;
2240 mainwin->compose_mail_btn = compose_mail_btn;
2241 mainwin->compose_news_btn = compose_news_btn;
2242 mainwin->reply_btn = reply_btn;
2243 mainwin->replyall_btn = replyall_btn;
2244 mainwin->replysender_btn = replysender_btn;
2245 mainwin->fwd_btn = fwd_btn;
2246 mainwin->send_btn = send_btn;
2248 mainwin->prefs_btn = prefs_btn;
2249 mainwin->account_btn = account_btn;
2251 mainwin->next_btn = next_btn;
2252 mainwin->delete_btn = delete_btn;
2253 mainwin->exec_btn = exec_btn;
2255 gtk_widget_show_all(toolbar);
2258 /* callback functions */
2259 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2261 MainWindow *mainwindow = (MainWindow *) data;
2265 if (event->button == 3) {
2266 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2267 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2268 menu_button_position, widget,
2269 event->button, event->time);
2273 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2275 MainWindow *mainwin = (MainWindow *)data;
2277 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2278 manage_window_focus_in(mainwin->window, NULL, NULL);
2281 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2283 MainWindow *mainwindow = (MainWindow *) data;
2287 if (event->button == 3) {
2288 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2289 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2290 menu_button_position, widget,
2291 event->button, event->time);
2295 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2297 MainWindow *mainwin = (MainWindow *)data;
2299 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2300 manage_window_focus_in(mainwin->window, NULL, NULL);
2303 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2305 MainWindow *mainwindow = (MainWindow *) data;
2306 GtkWidget *replysender_menu, *replysender_item;
2310 if (event->button == 3) {
2311 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2312 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2313 menu_button_position, widget,
2314 event->button, event->time);
2318 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2320 MainWindow *mainwin = (MainWindow *)data;
2322 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2323 manage_window_focus_in(mainwin->window, NULL, NULL);
2326 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2328 MainWindow *mainwindow = (MainWindow *) data;
2332 if (event->button == 3) {
2333 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2334 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2335 menu_button_position, widget,
2336 event->button, event->time);
2340 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2342 MainWindow *mainwin = (MainWindow *)data;
2344 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2345 manage_window_focus_in(mainwin->window, NULL, NULL);
2348 static void toolbar_inc_cb (GtkWidget *widget,
2351 MainWindow *mainwin = (MainWindow *)data;
2353 inc_mail_cb(mainwin, 0, NULL);
2356 static void toolbar_inc_all_cb (GtkWidget *widget,
2359 MainWindow *mainwin = (MainWindow *)data;
2361 inc_all_account_mail_cb(mainwin, 0, NULL);
2364 static void toolbar_send_cb (GtkWidget *widget,
2367 MainWindow *mainwin = (MainWindow *)data;
2369 send_queue_cb(mainwin, 0, NULL);
2372 static void toolbar_compose_cb (GtkWidget *widget,
2375 MainWindow *mainwin = (MainWindow *)data;
2377 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2378 compose_cb(mainwin, 0, NULL);
2380 compose_news_cb(mainwin, 0, NULL);
2383 static void toolbar_compose_news_cb (GtkWidget *widget,
2386 MainWindow *mainwin = (MainWindow *)data;
2388 compose_news_cb(mainwin, 0, NULL);
2391 static void toolbar_compose_mail_cb (GtkWidget *widget,
2394 MainWindow *mainwin = (MainWindow *)data;
2396 compose_mail_cb(mainwin, 0, NULL);
2399 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2401 MainWindow *mainwin = (MainWindow *)data;
2404 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2405 : COMPOSE_REPLY_WITHOUT_QUOTE,
2409 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2411 MainWindow *mainwin = (MainWindow *)data;
2414 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2415 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2420 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2422 MainWindow *mainwin = (MainWindow *)data;
2425 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2426 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2430 static void toolbar_forward_cb (GtkWidget *widget,
2433 MainWindow *mainwin = (MainWindow *)data;
2435 if (prefs_common.forward_as_attachment)
2436 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2438 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2441 static void toolbar_delete_cb (GtkWidget *widget,
2444 MainWindow *mainwin = (MainWindow *)data;
2446 summary_delete(mainwin->summaryview);
2449 static void toolbar_exec_cb (GtkWidget *widget,
2452 MainWindow *mainwin = (MainWindow *)data;
2454 summary_execute(mainwin->summaryview);
2457 static void toolbar_next_unread_cb (GtkWidget *widget,
2460 MainWindow *mainwin = (MainWindow *)data;
2462 next_unread_cb(mainwin, 0, NULL);
2465 static void toolbar_prefs_cb (GtkWidget *widget,
2468 prefs_common_open();
2471 static void toolbar_account_cb (GtkWidget *widget,
2474 MainWindow *mainwin = (MainWindow *)data;
2476 prefs_account_open_cb(mainwin, 0, NULL);
2480 static void toolbar_account_button_pressed(GtkWidget *widget,
2481 GdkEventButton *event,
2484 MainWindow *mainwin = (MainWindow *)data;
2487 if (event->button != 3) return;
2489 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2490 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2493 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2494 menu_button_position, widget,
2495 event->button, event->time);
2499 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2502 MainWindow *mainwin = (MainWindow *)data;
2506 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2507 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2510 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2511 menu_button_position, widget,
2512 event->button, event->time);
2515 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2517 MainWindow *mainwin = (MainWindow *)data;
2520 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2521 if (!button) return;
2522 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2523 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2524 manage_window_focus_in(mainwin->window, NULL, NULL);
2527 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2530 MainWindow *mainwin = (MainWindow *)data;
2532 if (mainwin->lock_count == 0)
2533 app_exit_cb(data, 0, widget);
2538 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2541 MainWindow *mainwin = (MainWindow *)data;
2542 GtkWidget *menuitem;
2544 menuitem = gtk_item_factory_get_item
2545 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2546 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2551 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2554 MainWindow *mainwin = (MainWindow *)data;
2555 GtkWidget *menuitem;
2557 menuitem = gtk_item_factory_get_item
2558 (mainwin->menu_factory, "/View/Show or hide/Message view");
2559 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2564 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2567 main_window_add_mailbox(mainwin);
2570 static void add_mbox_cb(MainWindow *mainwin, guint action,
2573 main_window_add_mbox(mainwin);
2576 static void update_folderview_cb(MainWindow *mainwin, guint action,
2579 summary_show(mainwin->summaryview, NULL, FALSE);
2580 folderview_rescan_all();
2583 static void new_folder_cb(MainWindow *mainwin, guint action,
2586 folderview_new_folder(mainwin->folderview);
2589 static void rename_folder_cb(MainWindow *mainwin, guint action,
2592 folderview_rename_folder(mainwin->folderview);
2595 static void delete_folder_cb(MainWindow *mainwin, guint action,
2598 folderview_delete_folder(mainwin->folderview);
2601 static void import_mbox_cb(MainWindow *mainwin, guint action,
2604 import_mbox(mainwin->summaryview->folder_item);
2607 static void export_mbox_cb(MainWindow *mainwin, guint action,
2610 export_mbox(mainwin->summaryview->folder_item);
2613 static void empty_trash_cb(MainWindow *mainwin, guint action,
2616 main_window_empty_trash(mainwin, TRUE);
2619 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2621 summary_save_as(mainwin->summaryview);
2624 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2626 summary_print(mainwin->summaryview);
2629 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2631 if (prefs_common.confirm_on_exit) {
2632 if (alertpanel(_("Exit"), _("Exit this program?"),
2633 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2635 manage_window_focus_in(mainwin->window, NULL, NULL);
2638 app_will_exit(widget, mainwin);
2641 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2644 summary_search(mainwin->summaryview);
2646 message_search(mainwin->messageview);
2649 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2654 active = GTK_CHECK_MENU_ITEM(widget)->active;
2656 switch (mainwin->type) {
2658 case SEPARATE_MESSAGE:
2661 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2663 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2666 case SEPARATE_FOLDER:
2667 debug_print("separate folder\n");
2669 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2671 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2675 gtk_widget_show(mainwin->win.sep_both.folderwin);
2677 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2682 static void toggle_message_cb(MainWindow *mainwin, guint action,
2687 active = GTK_CHECK_MENU_ITEM(widget)->active;
2689 if (active != messageview_is_visible(mainwin->messageview))
2690 summary_toggle_view(mainwin->summaryview);
2693 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2696 switch ((ToolbarStyle)action) {
2698 gtk_widget_hide(mainwin->handlebox);
2700 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2704 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2708 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2713 if (action != TOOLBAR_NONE) {
2714 gtk_widget_show(mainwin->handlebox);
2715 gtk_widget_queue_resize(mainwin->handlebox);
2718 mainwin->toolbar_style = (ToolbarStyle)action;
2719 prefs_common.toolbar_style = (ToolbarStyle)action;
2722 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2725 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2726 gtk_widget_show(mainwin->hbox_stat);
2727 prefs_common.show_statusbar = TRUE;
2729 gtk_widget_hide(mainwin->hbox_stat);
2730 prefs_common.show_statusbar = FALSE;
2734 static void separate_widget_cb(MainWindow *mainwin, guint action,
2739 if (GTK_CHECK_MENU_ITEM(widget)->active)
2740 type = mainwin->type | action;
2742 type = mainwin->type & ~action;
2744 main_window_separation_change(mainwin, type);
2746 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2747 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2750 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2752 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2753 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2755 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2759 static void online_switch_clicked (GtkButton *btn, gpointer data)
2761 MainWindow *mainwin;
2762 GtkItemFactory *ifactory;
2763 GtkCheckMenuItem *menuitem;
2765 mainwin = (MainWindow *) data;
2767 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2768 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2770 g_return_if_fail(mainwin != NULL);
2771 g_return_if_fail(menuitem != NULL);
2773 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2775 gtk_widget_hide (mainwin->online_switch);
2776 gtk_widget_show (mainwin->offline_switch);
2777 menuitem->active = TRUE;
2778 prefs_common.work_offline = TRUE;
2779 inc_autocheck_timer_remove();
2782 gtk_widget_hide (mainwin->offline_switch);
2783 gtk_widget_show (mainwin->online_switch);
2784 menuitem->active = FALSE;
2785 prefs_common.work_offline = FALSE;
2786 inc_autocheck_timer_set();
2790 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2793 addressbook_open(NULL);
2796 static void log_window_show_cb(MainWindow *mainwin, guint action,
2799 log_window_show(mainwin->logwin);
2802 static void sel_download_cb(MainWindow *mainwin, guint action,
2805 selective_download(mainwin);
2808 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2810 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2813 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2816 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2819 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2824 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2828 if (prefs_common.work_offline)
2829 if (alertpanel(_("Offline warning"),
2830 _("You're working offline. Override?"),
2831 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
2834 for (list = folder_get_list(); list != NULL; list = list->next) {
2835 Folder *folder = list->data;
2837 if (folder->queue) {
2838 if (procmsg_send_queue
2839 (folder->queue, prefs_common.savemsg) < 0)
2840 alertpanel_error(_("Some errors occurred while sending queued messages."));
2841 statusbar_pop_all();
2842 folder_item_scan(folder->queue);
2843 folderview_update_item(folder->queue, TRUE);
2848 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2850 if (mainwin->summaryview->folder_item) {
2851 if (mainwin->summaryview->folder_item->folder->account != NULL
2852 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2853 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2855 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2861 static void compose_mail_cb(MainWindow *mainwin, guint action,
2868 if (mainwin->summaryview->folder_item) {
2869 ac = mainwin->summaryview->folder_item->folder->account;
2870 if (ac && ac->protocol != A_NNTP) {
2871 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2876 if(cur_account && (cur_account->protocol != A_NNTP)) {
2877 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2881 list = account_get_list();
2882 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2883 ac = (PrefsAccount *) cur->data;
2884 if (ac->protocol != A_NNTP) {
2885 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2891 static void compose_news_cb(MainWindow *mainwin, guint action,
2894 PrefsAccount * ac = NULL;
2898 if (mainwin->summaryview->folder_item) {
2899 ac = mainwin->summaryview->folder_item->folder->account;
2900 if (ac && ac->protocol == A_NNTP) {
2901 compose_new_with_recipient
2902 (ac, mainwin->summaryview->folder_item->path);
2907 list = account_get_list();
2908 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2909 ac = (PrefsAccount *) cur->data;
2910 if (ac->protocol == A_NNTP) {
2917 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2919 summary_reply(mainwin->summaryview, (ComposeMode)action);
2922 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2924 summary_move_to(mainwin->summaryview);
2927 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2929 summary_copy_to(mainwin->summaryview);
2932 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2934 summary_delete(mainwin->summaryview);
2937 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2939 summary_open_msg(mainwin->summaryview);
2942 static void view_source_cb(MainWindow *mainwin, guint action,
2945 summary_view_source(mainwin->summaryview);
2948 static void show_all_header_cb(MainWindow *mainwin, guint action,
2951 if (mainwin->menu_lock_count) return;
2952 summary_display_msg_selected(mainwin->summaryview,
2953 GTK_CHECK_MENU_ITEM(widget)->active);
2956 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2958 summary_reedit(mainwin->summaryview);
2961 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2963 summary_mark(mainwin->summaryview);
2966 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2968 summary_unmark(mainwin->summaryview);
2971 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2974 summary_mark_as_unread(mainwin->summaryview);
2977 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2980 summary_mark_as_read(mainwin->summaryview);
2983 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2986 summary_mark_all_read(mainwin->summaryview);
2989 static void add_address_cb(MainWindow *mainwin, guint action,
2992 summary_add_address(mainwin->summaryview);
2995 static void set_charset_cb(MainWindow *mainwin, guint action,
3000 str = conv_get_charset_str((CharSet)action);
3001 g_free(prefs_common.force_charset);
3002 prefs_common.force_charset = str ? g_strdup(str) : NULL;
3004 summary_redisplay_msg(mainwin->summaryview);
3006 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
3009 static void hide_read_messages (MainWindow *mainwin, guint action,
3012 if (!mainwin->summaryview->folder_item
3013 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
3015 summary_toggle_show_read_messages(mainwin->summaryview);
3018 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3020 if (mainwin->menu_lock_count) return;
3021 if (!mainwin->summaryview->folder_item) return;
3023 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3024 summary_thread_build(mainwin->summaryview);
3025 mainwin->summaryview->folder_item->threaded = TRUE;
3027 summary_unthread(mainwin->summaryview);
3028 mainwin->summaryview->folder_item->threaded = FALSE;
3032 static void expand_threads_cb(MainWindow *mainwin, guint action,
3035 summary_expand_threads(mainwin->summaryview);
3038 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3041 summary_collapse_threads(mainwin->summaryview);
3044 static void set_display_item_cb(MainWindow *mainwin, guint action,
3047 prefs_summary_column_open();
3050 static void sort_summary_cb(MainWindow *mainwin, guint action,
3053 FolderItem *item = mainwin->summaryview->folder_item;
3054 GtkWidget *menuitem;
3056 if (mainwin->menu_lock_count) return;
3058 menuitem = gtk_item_factory_get_item
3059 (mainwin->menu_factory, "/View/Sort/Ascending");
3060 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3061 GTK_CHECK_MENU_ITEM(menuitem)->active
3062 ? SORT_ASCENDING : SORT_DESCENDING);
3066 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3069 FolderItem *item = mainwin->summaryview->folder_item;
3071 if (mainwin->menu_lock_count) return;
3073 summary_sort(mainwin->summaryview,
3074 item->sort_key, (FolderSortType)action);
3077 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3080 summary_attract_by_subject(mainwin->summaryview);
3083 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3086 summary_delete_duplicated(mainwin->summaryview);
3089 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3091 summary_filter(mainwin->summaryview);
3094 static void execute_summary_cb(MainWindow *mainwin, guint action,
3097 summary_execute(mainwin->summaryview);
3100 static void update_summary_cb(MainWindow *mainwin, guint action,
3104 FolderView *folderview = mainwin->folderview;
3106 if (!mainwin->summaryview->folder_item) return;
3107 if (!folderview->opened) return;
3109 folder_update_op_count();
3111 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3112 folderview->opened);
3115 summary_show(mainwin->summaryview, fitem, TRUE);
3118 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3120 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3123 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3125 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3128 static void prev_unread_cb(MainWindow *mainwin, guint action,
3131 summary_select_prev_unread(mainwin->summaryview);
3134 static void next_unread_cb(MainWindow *mainwin, guint action,
3137 summary_select_next_unread(mainwin->summaryview);
3140 static void prev_marked_cb(MainWindow *mainwin, guint action,
3143 summary_select_prev_marked(mainwin->summaryview);
3146 static void next_marked_cb(MainWindow *mainwin, guint action,
3149 summary_select_next_marked(mainwin->summaryview);
3152 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3155 summary_select_prev_labeled(mainwin->summaryview);
3158 static void next_labeled_cb(MainWindow *mainwin, guint action,
3161 summary_select_next_labeled(mainwin->summaryview);
3164 static void goto_folder_cb(MainWindow *mainwin, guint action,
3167 FolderItem *to_folder;
3169 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3172 folderview_select(mainwin->folderview, to_folder);
3175 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3177 messageview_copy_clipboard(mainwin->messageview);
3180 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3182 MessageView *msgview = mainwin->messageview;
3184 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3185 summary_select_all(mainwin->summaryview);
3186 else if (messageview_is_visible(msgview) &&
3187 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
3188 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3189 messageview_select_all(mainwin->messageview);
3192 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3194 if (messageview_is_visible(mainwin->summaryview->messageview))
3195 summary_select_thread(mainwin->summaryview);
3198 static void create_filter_cb(MainWindow *mainwin, guint action,
3201 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3204 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3207 prefs_common_open();
3210 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
3213 prefs_filter_open(NULL, NULL);
3216 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3219 prefs_scoring_open(NULL);
3222 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3225 prefs_filtering_open(NULL, NULL, NULL);
3228 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3231 prefs_template_open();
3234 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3237 prefs_actions_open(mainwin);
3240 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3244 new_account_cb(mainwin, 0, widget);
3246 gboolean prev_default = cur_account->is_default;
3248 prefs_account_open(cur_account);
3249 if (!prev_default && cur_account->is_default)
3250 account_set_as_default(cur_account);
3251 account_save_config_all();
3253 main_window_reflect_prefs_all();
3257 static void new_account_cb(MainWindow *mainwin, guint action,
3260 account_edit_open();
3261 if (!compose_get_compose_list()) account_add();
3264 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3266 cur_account = (PrefsAccount *)data;
3267 main_window_reflect_prefs_all();
3270 static void manual_open_cb(MainWindow *mainwin, guint action,
3273 manual_open((ManualLang)action);
3276 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3278 faq_open((ManualLang)action);
3281 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3283 MainWindow *mainwin = (MainWindow *)data;
3287 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3288 LOCAL_FOLDER(folder)->rootpath,
3292 str = g_strdup_printf(_("Scanning folder %s ..."),
3293 LOCAL_FOLDER(folder)->rootpath);
3295 STATUSBAR_PUSH(mainwin, str);
3296 STATUSBAR_POP(mainwin);
3300 static void activate_compose_button (MainWindow *mainwin,
3302 ComposeButtonType type)
3304 SensitiveCond state = main_window_get_current_state(mainwin);
3306 if (style == TOOLBAR_NONE)
3309 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
3310 : mainwin->compose_news_btn);
3311 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
3312 : mainwin->compose_mail_btn);
3313 mainwin->compose_btn_type = type;
3316 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
3318 if (mainwin->compose_btn_type != compose_btn_type)
3319 activate_compose_button(mainwin,
3320 prefs_common.toolbar_style,
3324 #define BREAK_ON_MODIFIER_KEY() \
3325 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3327 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3329 MainWindow *mainwin = (MainWindow*) data;
3331 if (!mainwin || !event) return;
3333 switch (event->keyval) {
3334 case GDK_Q: /* Quit */
3335 BREAK_ON_MODIFIER_KEY();
3337 app_exit_cb(mainwin, 0, NULL);
3344 #undef BREAK_ON_MODIFIER_KEY
3346 static void set_toolbar_style(MainWindow *mainwin)
3348 switch (prefs_common.toolbar_style) {
3350 gtk_widget_hide(mainwin->handlebox);
3353 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3357 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3361 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3366 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3367 gtk_widget_show(mainwin->handlebox);
3368 gtk_widget_queue_resize(mainwin->handlebox);
3370 if (prefs_common.immediate_exec)
3371 gtk_widget_hide(mainwin->exec_btn);
3373 gtk_widget_show(mainwin->exec_btn);
3378 * Harvest addresses for selected folder.
3380 static void addr_harvest_cb( MainWindow *mainwin,
3384 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3388 * Harvest addresses for selected messages in summary view.
3390 static void addr_harvest_msg_cb( MainWindow *mainwin,
3394 summary_harvest_address( mainwin->summaryview );