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,
187 static void add_mailbox_cb (MainWindow *mainwin,
190 static void add_mbox_cb (MainWindow *mainwin,
193 static void update_folderview_cb (MainWindow *mainwin,
196 static void new_folder_cb (MainWindow *mainwin,
199 static void rename_folder_cb (MainWindow *mainwin,
202 static void delete_folder_cb (MainWindow *mainwin,
205 static void import_mbox_cb (MainWindow *mainwin,
208 static void export_mbox_cb (MainWindow *mainwin,
211 static void empty_trash_cb (MainWindow *mainwin,
215 static void save_as_cb (MainWindow *mainwin,
218 static void print_cb (MainWindow *mainwin,
221 static void app_exit_cb (MainWindow *mainwin,
225 static void search_cb (MainWindow *mainwin,
229 static void toggle_folder_cb (MainWindow *mainwin,
232 static void toggle_message_cb (MainWindow *mainwin,
235 static void toggle_toolbar_cb (MainWindow *mainwin,
238 static void toggle_statusbar_cb (MainWindow *mainwin,
241 static void toggle_expand_summaryview_cb (MainWindow *mainwin,
244 static void toggle_expand_messageview_cb (MainWindow *mainwin,
247 static void toggle_work_offline_cb (MainWindow *mainwin,
250 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
254 static void addressbook_open_cb (MainWindow *mainwin,
257 static void log_window_show_cb (MainWindow *mainwin,
260 static void sel_download_cb (MainWindow *mainwin,
264 static void inc_mail_cb (MainWindow *mainwin,
267 static void inc_all_account_mail_cb (MainWindow *mainwin,
270 static void inc_cancel_cb (MainWindow *mainwin,
274 static void send_queue_cb (MainWindow *mainwin,
278 static void compose_cb (MainWindow *mainwin,
281 static void compose_mail_cb(MainWindow *mainwin, guint action,
283 static void compose_news_cb(MainWindow *mainwin, guint action,
285 static void reply_cb (MainWindow *mainwin,
289 static void open_msg_cb (MainWindow *mainwin,
293 static void view_source_cb (MainWindow *mainwin,
297 static void show_all_header_cb (MainWindow *mainwin,
301 static void reedit_cb (MainWindow *mainwin,
305 static void move_to_cb (MainWindow *mainwin,
308 static void copy_to_cb (MainWindow *mainwin,
311 static void delete_cb (MainWindow *mainwin,
315 static void mark_cb (MainWindow *mainwin,
318 static void unmark_cb (MainWindow *mainwin,
322 static void mark_as_unread_cb (MainWindow *mainwin,
325 static void mark_as_read_cb (MainWindow *mainwin,
328 static void mark_all_read_cb (MainWindow *mainwin,
331 static void add_address_cb (MainWindow *mainwin,
335 static void set_charset_cb (MainWindow *mainwin,
339 static void hide_read_messages (MainWindow *mainwin,
343 static void thread_cb (MainWindow *mainwin,
346 static void set_display_item_cb (MainWindow *mainwin,
349 static void sort_summary_cb (MainWindow *mainwin,
352 static void attract_by_subject_cb(MainWindow *mainwin,
356 static void delete_duplicated_cb (MainWindow *mainwin,
359 static void filter_cb (MainWindow *mainwin,
362 static void execute_summary_cb (MainWindow *mainwin,
365 static void update_summary_cb (MainWindow *mainwin,
369 static void prev_cb (MainWindow *mainwin,
372 static void next_cb (MainWindow *mainwin,
376 static void prev_unread_cb (MainWindow *mainwin,
379 static void next_unread_cb (MainWindow *mainwin,
382 static void prev_marked_cb (MainWindow *mainwin,
385 static void next_marked_cb (MainWindow *mainwin,
388 static void prev_labeled_cb (MainWindow *mainwin,
391 static void next_labeled_cb (MainWindow *mainwin,
395 static void goto_folder_cb (MainWindow *mainwin,
399 static void copy_cb (MainWindow *mainwin,
402 static void allsel_cb (MainWindow *mainwin,
405 static void selthread_cb (MainWindow *mainwin,
408 static void create_filter_cb (MainWindow *mainwin,
412 static void prefs_common_open_cb (MainWindow *mainwin,
415 static void prefs_filter_open_cb (MainWindow *mainwin,
418 static void prefs_scoring_open_cb (MainWindow *mainwin,
421 static void prefs_filtering_open_cb (MainWindow *mainwin,
424 static void prefs_account_open_cb(MainWindow *mainwin,
427 static void prefs_template_open_cb (MainWindow *mainwin,
430 static void prefs_actions_open_cb (MainWindow *mainwin,
433 static void new_account_cb (MainWindow *mainwin,
437 static void account_menu_cb (GtkMenuItem *menuitem,
440 static void online_switch_clicked(GtkButton *btn,
443 static void manual_open_cb (MainWindow *mainwin,
446 static void faq_open_cb (MainWindow *mainwin,
450 static void scan_tree_func (Folder *folder,
454 static void activate_compose_button (MainWindow *mainwin,
456 ComposeButtonType type);
458 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
462 static void key_pressed (GtkWidget *widget,
466 static void set_toolbar_style(MainWindow *mainwin);
468 static void addr_harvest_cb ( MainWindow *mainwin,
472 static void addr_harvest_msg_cb ( MainWindow *mainwin,
476 #define SEPARATE_ACTION 667
478 static GtkItemFactoryEntry mainwin_entries[] =
480 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
481 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
482 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
483 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
484 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
485 {N_("/_File/_Folder/Create _new folder..."),
486 NULL, new_folder_cb, 0, NULL},
487 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
488 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
489 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
490 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
491 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
492 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
493 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
494 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
495 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
496 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
497 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
499 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
500 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
501 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
502 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
503 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
504 {N_("/_Edit/_Find in current message..."),
505 "<control>F", search_cb, 0, NULL},
506 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
507 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
508 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
509 {N_("/_View/Show or hi_de/_Toolbar"),
510 NULL, NULL, 0, "<Branch>"},
511 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
512 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
513 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
514 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
515 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
516 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
517 {N_("/_View/Show or hi_de/_Toolbar/_None"),
518 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
519 {N_("/_View/Show or hi_de/Status _bar"),
520 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
521 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
522 {N_("/_View/Separate _Folder Tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
523 {N_("/_View/Separate _Message View"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
524 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
525 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
526 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
527 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
528 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
529 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
530 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
531 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
532 {N_("/_View/_Sort/Sort by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
533 {N_("/_View/_Sort/Sort by _color label"),
534 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
535 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
536 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
537 {N_("/_View/_Sort/Sort by a_ttachment"),
538 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
539 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
540 {N_("/_View/_Sort/_Attract by subject"),
541 NULL, attract_by_subject_cb, 0, NULL},
542 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
543 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
544 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
546 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
547 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
548 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
549 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
550 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
551 {N_("/_View/_Go to/P_rev unread message"),
552 "<shift>P", prev_unread_cb, 0, NULL},
553 {N_("/_View/_Go to/N_ext unread message"),
554 "<shift>N", next_unread_cb, 0, NULL},
555 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
556 {N_("/_View/_Go to/Prev _marked message"),
557 NULL, prev_marked_cb, 0, NULL},
558 {N_("/_View/_Go to/Next m_arked message"),
559 NULL, next_marked_cb, 0, NULL},
560 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
561 {N_("/_View/_Go to/Prev _labeled message"),
562 NULL, prev_labeled_cb, 0, NULL},
563 {N_("/_View/_Go to/Next la_beled message"),
564 NULL, next_labeled_cb, 0, NULL},
565 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
566 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
567 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
569 #define CODESET_SEPARATOR \
570 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
571 #define CODESET_ACTION(action) \
572 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
574 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
575 {N_("/_View/_Code set/_Auto detect"),
576 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
577 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
578 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
579 CODESET_ACTION(C_US_ASCII)},
582 {N_("/_View/_Code set/Unicode (_UTF-8)"),
583 CODESET_ACTION(C_UTF_8)},
586 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
587 CODESET_ACTION(C_ISO_8859_1)},
588 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
589 CODESET_ACTION(C_ISO_8859_15)},
592 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
593 CODESET_ACTION(C_ISO_8859_2)},
595 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
596 CODESET_ACTION(C_ISO_8859_13)},
597 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
598 CODESET_ACTION(C_ISO_8859_4)},
600 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
601 CODESET_ACTION(C_ISO_8859_7)},
603 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
604 CODESET_ACTION(C_ISO_8859_9)},
606 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
607 CODESET_ACTION(C_ISO_8859_5)},
608 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
609 CODESET_ACTION(C_KOI8_R)},
610 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
611 CODESET_ACTION(C_WINDOWS_1251)},
614 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
615 CODESET_ACTION(C_ISO_2022_JP)},
617 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
618 CODESET_ACTION(C_ISO_2022_JP_2)},
620 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
621 CODESET_ACTION(C_EUC_JP)},
622 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
623 CODESET_ACTION(C_SHIFT_JIS)},
626 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
627 CODESET_ACTION(C_GB2312)},
628 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
629 CODESET_ACTION(C_BIG5)},
630 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
631 CODESET_ACTION(C_EUC_TW)},
632 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
633 CODESET_ACTION(C_ISO_2022_CN)},
635 {N_("/_View/_Code set/Korean (EUC-_KR)"),
636 CODESET_ACTION(C_EUC_KR)},
637 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
638 CODESET_ACTION(C_ISO_2022_KR)},
640 {N_("/_View/_Code set/Thai (TIS-620)"),
641 CODESET_ACTION(C_TIS_620)},
642 {N_("/_View/_Code set/Thai (Windows-874)"),
643 CODESET_ACTION(C_WINDOWS_874)},
646 #undef CODESET_SEPARATOR
647 #undef CODESET_ACTION
649 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
650 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
651 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
652 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
653 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
654 {N_("/_View/_Update"), "<control><alt>U", update_summary_cb, 0, NULL},
656 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
657 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
658 {N_("/_Message/Get from _all accounts"),
659 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
660 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
661 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
662 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
663 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
664 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
665 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
666 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
667 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
668 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
669 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
670 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
671 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
672 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
673 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
674 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
675 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
676 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
677 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
678 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
679 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
680 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
681 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
682 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
683 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
684 {N_("/_Message/_Mark/Mark as rea_d"),
685 NULL, mark_as_read_cb, 0, NULL},
686 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
688 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
689 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
690 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
691 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
692 {N_("/_Tools/Add sender to address boo_k"),
693 NULL, add_address_cb, 0, NULL},
694 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
695 {N_("/_Tools/_Harvest addresses/from _Folder..."),
696 NULL, addr_harvest_cb, 0, NULL},
697 {N_("/_Tools/_Harvest addresses/from _Messages..."),
698 NULL, addr_harvest_msg_cb, 0, NULL},
699 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
700 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
701 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
702 {N_("/_Tools/_Create filter rule/_Automatically"),
703 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
704 {N_("/_Tools/_Create filter rule/by _From"),
705 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
706 {N_("/_Tools/_Create filter rule/by _To"),
707 NULL, create_filter_cb, FILTER_BY_TO, NULL},
708 {N_("/_Tools/_Create filter rule/by _Subject"),
709 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
710 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
711 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
712 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
713 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
714 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
715 {N_("/_Tools/Delete du_plicated messages"),
716 NULL, delete_duplicated_cb, 0, NULL},
717 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
718 {N_("/_Tools/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
720 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
721 {N_("/_Configuration/_Common preferences..."),
722 NULL, prefs_common_open_cb, 0, NULL},
723 {N_("/_Configuration/_Filter setting..."),
724 NULL, prefs_filter_open_cb, 0, NULL},
725 {N_("/_Configuration/_Scoring..."),
726 NULL, prefs_scoring_open_cb, 0, NULL},
727 {N_("/_Configuration/_Filtering..."),
728 NULL, prefs_filtering_open_cb, 0, NULL},
729 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
730 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
731 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
732 {N_("/_Configuration/_Preferences for current account..."),
733 NULL, prefs_account_open_cb, 0, NULL},
734 {N_("/_Configuration/Create _new account..."),
735 NULL, new_account_cb, 0, NULL},
736 {N_("/_Configuration/_Edit accounts..."),
737 NULL, account_edit_open, 0, NULL},
738 {N_("/_Configuration/C_hange current account"),
739 NULL, NULL, 0, "<Branch>"},
741 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
742 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
743 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
744 {N_("/_Help/_Manual/_German"), NULL, manual_open_cb, MANUAL_LANG_DE, NULL},
745 {N_("/_Help/_Manual/_Spanish"), NULL, manual_open_cb, MANUAL_LANG_ES, NULL},
746 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
747 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
748 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
749 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
750 {N_("/_Help/_FAQ/_German"), NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
751 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
752 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
753 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
754 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
755 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
757 static GtkItemFactoryEntry reply_popup_entries[] =
759 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
760 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
762 static GtkItemFactoryEntry replyall_popup_entries[] =
764 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
765 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
767 static GtkItemFactoryEntry replysender_popup_entries[] =
769 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
770 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
772 static GtkItemFactoryEntry fwd_popup_entries[] =
774 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
775 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
778 MainWindow *main_window_create(SeparateType type)
784 GtkWidget *handlebox;
785 GtkWidget *vbox_body;
786 GtkWidget *hbox_stat;
787 GtkWidget *statusbar;
788 GtkWidget *progressbar;
789 GtkWidget *statuslabel;
790 GtkWidget *ac_button;
792 GtkWidget *online_status;
793 GtkWidget *offline_status;
794 GtkWidget *online_switch;
795 GtkWidget *offline_switch;
797 FolderView *folderview;
798 SummaryView *summaryview;
799 MessageView *messageview;
800 GdkColormap *colormap;
803 guint n_menu_entries;
804 GtkItemFactory *ifactory;
807 GtkWidget *compose_popup;
808 GtkWidget *reply_popup;
809 GtkWidget *replyall_popup;
810 GtkWidget *replysender_popup;
811 GtkWidget *fwd_popup;
814 static GdkGeometry geometry;
816 debug_print(_("Creating main window...\n"));
817 mainwin = g_new0(MainWindow, 1);
820 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
821 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
822 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
823 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
825 if (!geometry.min_height) {
826 geometry.min_width = 320;
827 geometry.min_height = 200;
829 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
832 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
833 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
834 MANAGE_WINDOW_SIGNALS_CONNECT(window);
835 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
836 GTK_SIGNAL_FUNC(key_pressed), mainwin);
838 gtk_widget_realize(window);
839 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
842 gtkut_widget_set_app_icon(window);
844 vbox = gtk_vbox_new(FALSE, 0);
845 gtk_widget_show(vbox);
846 gtk_container_add(GTK_CONTAINER(window), vbox);
849 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
850 menubar = menubar_create(window, mainwin_entries,
851 n_menu_entries, "<Main>", mainwin);
852 gtk_widget_show(menubar);
853 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
855 handlebox = gtk_handle_box_new();
856 gtk_widget_show(handlebox);
857 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
859 /* create the popup menus for the reply buttons specials */
860 n_menu_entries = sizeof(reply_popup_entries) /
861 sizeof(reply_popup_entries[0]);
862 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
863 "<ReplyPopup>", mainwin);
864 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
865 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
866 n_menu_entries = sizeof(replyall_popup_entries) /
867 sizeof(replyall_popup_entries[0]);
868 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
869 "<ReplyAllPopup>", mainwin);
870 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
871 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
872 n_menu_entries = sizeof(replysender_popup_entries) /
873 sizeof(replysender_popup_entries[0]);
874 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
875 "<ReplySenderPopup>", mainwin);
876 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
877 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
878 /* create the popup menu for the forward button */
879 n_menu_entries = sizeof(fwd_popup_entries) /
880 sizeof(fwd_popup_entries[0]);
881 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
882 "<ForwardPopup>", mainwin);
883 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
884 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
886 main_window_toolbar_create(mainwin, handlebox);
888 /* vbox that contains body */
889 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
890 gtk_widget_show(vbox_body);
891 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
892 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
894 hbox_stat = gtk_hbox_new(FALSE, 2);
895 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
897 statusbar = statusbar_create();
898 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
900 progressbar = gtk_progress_bar_new();
901 gtk_widget_set_usize(progressbar, 120, 1);
902 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
904 online_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
905 offline_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
906 online_switch = gtk_button_new ();
907 offline_switch = gtk_button_new ();
908 gtk_container_add (GTK_CONTAINER(online_switch), online_status);
909 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
910 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
911 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
912 gtk_container_add (GTK_CONTAINER(offline_switch), offline_status);
913 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
914 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
915 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
917 statuslabel = gtk_label_new("");
918 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
920 ac_button = gtk_button_new();
921 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
922 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
923 gtk_widget_set_usize(ac_button, -1, 1);
924 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
925 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
926 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
928 ac_label = gtk_label_new("");
929 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
931 gtk_widget_show_all(hbox_stat);
933 gtk_widget_hide(offline_switch);
935 mainwin->folderview = folderview = folderview_create();
936 mainwin->summaryview = summaryview = summary_create();
937 mainwin->messageview = messageview = messageview_create();
938 mainwin->logwin = log_window_create();
940 folderview->mainwin = mainwin;
941 folderview->summaryview = summaryview;
943 summaryview->mainwin = mainwin;
944 summaryview->folderview = folderview;
945 summaryview->messageview = messageview;
946 summaryview->window = window;
948 messageview->mainwin = mainwin;
950 mainwin->window = window;
951 mainwin->vbox = vbox;
952 mainwin->menubar = menubar;
953 mainwin->handlebox = handlebox;
954 mainwin->vbox_body = vbox_body;
955 mainwin->hbox_stat = hbox_stat;
956 mainwin->statusbar = statusbar;
957 mainwin->progressbar = progressbar;
958 mainwin->statuslabel = statuslabel;
959 mainwin->ac_button = ac_button;
960 mainwin->ac_label = ac_label;
961 mainwin->reply_popup = reply_popup;
962 mainwin->replyall_popup = replyall_popup;
963 mainwin->replysender_popup = replysender_popup;
964 mainwin->fwd_popup = fwd_popup;
965 mainwin->online_switch = online_switch;
966 mainwin->offline_switch = offline_switch;
968 /* set context IDs for status bar */
969 mainwin->mainwin_cid = gtk_statusbar_get_context_id
970 (GTK_STATUSBAR(statusbar), "Main Window");
971 mainwin->folderview_cid = gtk_statusbar_get_context_id
972 (GTK_STATUSBAR(statusbar), "Folder View");
973 mainwin->summaryview_cid = gtk_statusbar_get_context_id
974 (GTK_STATUSBAR(statusbar), "Summary View");
976 /* allocate colors for summary view and folder view */
977 summaryview->color_marked.red = summaryview->color_marked.green = 0;
978 summaryview->color_marked.blue = (guint16)65535;
980 summaryview->color_dim.red = summaryview->color_dim.green =
981 summaryview->color_dim.blue = COLOR_DIM;
983 folderview->color_new.red = (guint16)55000;
984 folderview->color_new.green = folderview->color_new.blue = 15000;
986 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
987 &folderview->color_op);
989 summaryview->color_important.red = 0;
990 summaryview->color_important.green = 0;
991 summaryview->color_important.blue = (guint16)65535;
993 color[0] = summaryview->color_marked;
994 color[1] = summaryview->color_dim;
995 color[2] = folderview->color_new;
996 color[3] = folderview->color_op;
998 colormap = gdk_window_get_colormap(window->window);
999 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1000 for (i = 0; i < 4; i++) {
1001 if (success[i] == FALSE)
1002 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1005 debug_print(_("done.\n"));
1007 main_window_set_widgets(mainwin, type);
1009 /* set menu items */
1010 ifactory = gtk_item_factory_from_widget(menubar);
1011 menuitem = gtk_item_factory_get_item
1012 (ifactory, "/View/Code set/Auto detect");
1013 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1015 switch (prefs_common.toolbar_style) {
1017 menuitem = gtk_item_factory_get_item
1018 (ifactory, "/View/Show or hide/Toolbar/None");
1021 menuitem = gtk_item_factory_get_item
1022 (ifactory, "/View/Show or hide/Toolbar/Icon");
1025 menuitem = gtk_item_factory_get_item
1026 (ifactory, "/View/Show or hide/Toolbar/Text");
1029 menuitem = gtk_item_factory_get_item
1030 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1032 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1034 gtk_widget_hide(mainwin->hbox_stat);
1035 menuitem = gtk_item_factory_get_item
1036 (ifactory, "/View/Show or hide/Status bar");
1037 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1038 prefs_common.show_statusbar);
1039 #if 0 /* FIXED SEPARATE WINDOWS */
1040 /* Message view and Folder tree are always shown at startup
1041 * make that in the menu visible */
1042 menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Message View");
1043 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1044 menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Folder Tree");
1045 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1047 /* set the check of the SEPARATE_xxx menu items. we also need the main window
1048 * as a property and pass the action type to the callback */
1049 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
1051 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
1052 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
1053 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
1054 GUINT_TO_POINTER(SEPARATE_FOLDER));
1056 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
1058 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
1059 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
1060 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
1061 GUINT_TO_POINTER(SEPARATE_MESSAGE));
1063 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
1064 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
1067 /* set account selection menu */
1068 ac_menu = gtk_item_factory_get_widget
1069 (ifactory, "/Configuration/Change current account");
1070 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1071 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1072 mainwin->ac_menu = ac_menu;
1074 main_window_set_toolbar_sensitive(mainwin);
1076 /* Create actions menu */
1077 update_mainwin_actions_menu(ifactory, mainwin);
1079 /* show main window */
1080 gtk_widget_set_uposition(mainwin->window,
1081 prefs_common.mainwin_x,
1082 prefs_common.mainwin_y);
1083 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1084 prefs_common.mainwin_height);
1085 gtk_widget_show(mainwin->window);
1087 /* initialize views */
1088 folderview_init(folderview);
1089 summary_init(summaryview);
1090 messageview_init(messageview);
1091 log_window_init(mainwin->logwin);
1093 mainwin->lock_count = 0;
1094 mainwin->menu_lock_count = 0;
1095 mainwin->cursor_count = 0;
1098 watch_cursor = gdk_cursor_new(GDK_WATCH);
1100 mainwin_list = g_list_append(mainwin_list, mainwin);
1102 /* init work_offline */
1103 if (prefs_common.work_offline)
1104 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1109 void main_window_cursor_wait(MainWindow *mainwin)
1112 if (mainwin->cursor_count == 0)
1113 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1115 mainwin->cursor_count++;
1120 void main_window_cursor_normal(MainWindow *mainwin)
1122 if (mainwin->cursor_count)
1123 mainwin->cursor_count--;
1125 if (mainwin->cursor_count == 0)
1126 gdk_window_set_cursor(mainwin->window->window, NULL);
1131 /* lock / unlock the user-interface */
1132 void main_window_lock(MainWindow *mainwin)
1134 if (mainwin->lock_count == 0)
1135 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1137 mainwin->lock_count++;
1139 main_window_set_menu_sensitive(mainwin);
1140 main_window_set_toolbar_sensitive(mainwin);
1143 void main_window_unlock(MainWindow *mainwin)
1145 if (mainwin->lock_count)
1146 mainwin->lock_count--;
1148 main_window_set_menu_sensitive(mainwin);
1149 main_window_set_toolbar_sensitive(mainwin);
1151 if (mainwin->lock_count == 0)
1152 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1155 static void main_window_menu_callback_block(MainWindow *mainwin)
1157 mainwin->menu_lock_count++;
1160 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1162 if (mainwin->menu_lock_count)
1163 mainwin->menu_lock_count--;
1166 void main_window_reflect_prefs_all(void)
1168 main_window_reflect_prefs_all_real(FALSE);
1171 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1174 MainWindow *mainwin;
1176 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1177 mainwin = (MainWindow *)cur->data;
1179 main_window_show_cur_account(mainwin);
1180 main_window_set_menu_sensitive(mainwin);
1181 main_window_set_toolbar_sensitive(mainwin);
1184 if (pixmap_theme_changed)
1186 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1187 mainwin->toolbar = NULL;
1188 main_window_toolbar_create(mainwin, mainwin->handlebox);
1189 set_toolbar_style(mainwin);
1190 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1191 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1192 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1195 summary_redisplay_msg(mainwin->summaryview);
1196 headerview_set_visibility(mainwin->messageview->headerview,
1197 prefs_common.display_header_pane);
1201 void main_window_set_summary_column(void)
1204 MainWindow *mainwin;
1206 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1207 mainwin = (MainWindow *)cur->data;
1208 summary_set_column_order(mainwin->summaryview);
1212 void main_window_set_account_menu(GList *account_list)
1214 GList *cur, *cur_ac, *cur_item;
1215 GtkWidget *menuitem;
1216 MainWindow *mainwin;
1217 PrefsAccount *ac_prefs;
1219 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1220 mainwin = (MainWindow *)cur->data;
1222 /* destroy all previous menu item */
1223 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1224 while (cur_item != NULL) {
1225 GList *next = cur_item->next;
1226 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1230 for (cur_ac = account_list; cur_ac != NULL;
1231 cur_ac = cur_ac->next) {
1232 ac_prefs = (PrefsAccount *)cur_ac->data;
1234 menuitem = gtk_menu_item_new_with_label
1235 (ac_prefs->account_name
1236 ? ac_prefs->account_name : _("Untitled"));
1237 gtk_widget_show(menuitem);
1238 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1239 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1240 GTK_SIGNAL_FUNC(account_menu_cb),
1246 static void main_window_show_cur_account(MainWindow *mainwin)
1251 ac_name = g_strdup(cur_account
1252 ? (cur_account->account_name
1253 ? cur_account->account_name : _("Untitled"))
1257 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1259 buf = g_strdup(PROG_VERSION);
1260 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1263 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1264 gtk_widget_queue_resize(mainwin->ac_button);
1269 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1271 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1272 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1273 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1275 if (mainwin->type == type) return;
1277 /* remove widgets from those containers */
1278 gtk_widget_ref(folder_wid);
1279 gtk_widget_ref(summary_wid);
1280 gtk_widget_ref(message_wid);
1281 gtkut_container_remove
1282 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1283 gtkut_container_remove
1284 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1285 gtkut_container_remove
1286 (GTK_CONTAINER(message_wid->parent), message_wid);
1288 /* clean containers */
1289 switch (mainwin->type) {
1291 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1293 case SEPARATE_FOLDER:
1294 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1295 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1297 case SEPARATE_MESSAGE:
1298 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1299 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1302 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1303 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1307 gtk_widget_hide(mainwin->window);
1308 main_window_set_widgets(mainwin, type);
1309 gtk_widget_show(mainwin->window);
1311 gtk_widget_unref(folder_wid);
1312 gtk_widget_unref(summary_wid);
1313 gtk_widget_unref(message_wid);
1316 void main_window_get_size(MainWindow *mainwin)
1318 GtkAllocation *allocation;
1320 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1322 prefs_common.summaryview_width = allocation->width;
1324 if (mainwin->summaryview->msg_is_toggled_on)
1325 prefs_common.summaryview_height = allocation->height;
1327 prefs_common.mainview_width = allocation->width;
1329 allocation = &mainwin->window->allocation;
1331 prefs_common.mainview_height = allocation->height;
1332 prefs_common.mainwin_width = allocation->width;
1333 prefs_common.mainwin_height = allocation->height;
1335 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1337 prefs_common.folderview_width = allocation->width;
1338 prefs_common.folderview_height = allocation->height;
1341 void main_window_get_position(MainWindow *mainwin)
1345 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1347 prefs_common.mainview_x = x;
1348 prefs_common.mainview_y = y;
1349 prefs_common.mainwin_x = x;
1350 prefs_common.mainwin_y = y;
1352 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1355 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1361 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1362 folder = FOLDER(list->data);
1363 if (folder && folder->trash && folder->trash->total > 0)
1367 if (!has_trash) return;
1370 if (alertpanel(_("Empty trash"),
1371 _("Empty all messages in trash?"),
1372 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1374 manage_window_focus_in(mainwin->window, NULL, NULL);
1377 procmsg_empty_trash();
1379 for (list = folder_get_list(); list != NULL; list = list->next) {
1380 folder = list->data;
1381 if (folder && folder->trash && folder->trash->total != 0) {
1382 folder_item_scan(folder->trash);
1383 folderview_update_item(folder->trash, TRUE);
1387 if (mainwin->summaryview->folder_item &&
1388 mainwin->summaryview->folder_item->stype == F_TRASH)
1389 gtk_widget_grab_focus(mainwin->folderview->ctree);
1392 void main_window_add_mailbox(MainWindow *mainwin)
1397 path = input_dialog(_("Add mailbox"),
1398 _("Input the location of mailbox.\n"
1399 "If the existing mailbox is specified, it will be\n"
1400 "scanned automatically."),
1403 if (folder_find_from_path(path)) {
1404 alertpanel_error(_("The mailbox `%s' already exists."), path);
1408 if (!strcmp(path, "Mail"))
1409 folder = folder_new(F_MH, _("Mailbox"), path);
1411 folder = folder_new(F_MH, g_basename(path), path);
1414 if (folder->create_tree(folder) < 0) {
1415 alertpanel_error(_("Creation of the mailbox failed.\n"
1416 "Maybe some files already exist, or you don't have the permission to write there."));
1417 folder_destroy(folder);
1422 folder_set_ui_func(folder, scan_tree_func, mainwin);
1423 folder->scan_tree(folder);
1424 folder_set_ui_func(folder, NULL, NULL);
1426 folderview_set(mainwin->folderview);
1429 void main_window_add_mbox(MainWindow *mainwin)
1435 path = input_dialog(_("Add mbox mailbox"),
1436 _("Input the location of mailbox."),
1441 if (folder_find_from_path(path)) {
1442 alertpanel_error(_("The mailbox `%s' already exists."), path);
1448 if (!strcmp(path, "Mail"))
1449 folder = folder_new(F_MBOX, _("Mailbox"), path);
1453 folder = folder_new(F_MBOX, g_basename(path), path);
1456 if (folder->create_tree(folder) < 0) {
1457 alertpanel_error(_("Creation of the mailbox failed."));
1458 folder_destroy(folder);
1464 item = folder_item_new(folder->name, NULL);
1465 item->folder = folder;
1466 folder->node = g_node_new(item);
1468 folder->create_folder(folder, item, "inbox");
1469 folder->create_folder(folder, item, "outbox");
1470 folder->create_folder(folder, item, "queue");
1471 folder->create_folder(folder, item, "draft");
1472 folder->create_folder(folder, item, "trash");
1474 folderview_set(mainwin->folderview);
1479 M_UNLOCKED = 1 << 0,
1480 M_MSG_EXIST = 1 << 1,
1481 M_TARGET_EXIST = 1 << 2,
1482 M_SINGLE_TARGET_EXIST = 1 << 3,
1484 M_ALLOW_REEDIT = 1 << 5,
1485 M_HAVE_ACCOUNT = 1 << 6,
1486 M_THREADED = 1 << 7,
1487 M_UNTHREADED = 1 << 8,
1488 M_ALLOW_DELETE = 1 << 9,
1489 M_INC_ACTIVE = 1 << 10,
1491 M_HAVE_NEWS_ACCOUNT = 1 << 12,
1492 M_HIDE_READ_MSG = 1 << 13
1495 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1497 SensitiveCond state = 0;
1498 SummarySelection selection;
1499 FolderItem *item = mainwin->summaryview->folder_item;
1500 GList *account_list = account_get_list();
1502 selection = summary_get_selection_type(mainwin->summaryview);
1504 if (mainwin->lock_count == 0)
1505 state |= M_UNLOCKED;
1506 if (selection != SUMMARY_NONE)
1507 state |= M_MSG_EXIST;
1511 state |= M_THREADED;
1513 state |= M_UNTHREADED;
1514 /* if (item->folder->type != F_NEWS) */
1515 state |= M_ALLOW_DELETE;
1517 if (selection == SUMMARY_NONE && item->hide_read_msgs
1518 || selection != SUMMARY_NONE)
1519 state |= M_HIDE_READ_MSG;
1521 if (selection == SUMMARY_SELECTED_SINGLE ||
1522 selection == SUMMARY_SELECTED_MULTIPLE)
1523 state |= M_TARGET_EXIST;
1524 if (selection == SUMMARY_SELECTED_SINGLE)
1525 state |= M_SINGLE_TARGET_EXIST;
1526 if (mainwin->summaryview->folder_item &&
1527 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1529 if (selection == SUMMARY_SELECTED_SINGLE &&
1531 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1532 item->stype == F_QUEUE)))
1533 state |= M_ALLOW_REEDIT;
1535 state |= M_HAVE_ACCOUNT;
1537 for ( ; account_list != NULL; account_list = account_list->next) {
1538 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1539 state |= M_HAVE_NEWS_ACCOUNT;
1544 if (inc_is_active())
1545 state |= M_INC_ACTIVE;
1550 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1552 SensitiveCond state;
1561 #define SET_WIDGET_COND(w, c) \
1563 entry[i].widget = w; \
1564 entry[i].cond = c; \
1568 SET_WIDGET_COND(mainwin->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1569 SET_WIDGET_COND(mainwin->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1570 SET_WIDGET_COND(mainwin->compose_news_btn, M_HAVE_ACCOUNT);
1571 SET_WIDGET_COND(mainwin->reply_btn,
1572 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1573 SET_WIDGET_COND(mainwin->replyall_btn,
1574 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1575 SET_WIDGET_COND(mainwin->replysender_btn,
1576 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1577 SET_WIDGET_COND(mainwin->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
1579 SET_WIDGET_COND(mainwin->prefs_btn, M_UNLOCKED);
1580 SET_WIDGET_COND(mainwin->account_btn, M_UNLOCKED);
1582 SET_WIDGET_COND(mainwin->next_btn, M_MSG_EXIST);
1583 SET_WIDGET_COND(mainwin->delete_btn,
1584 M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
1585 SET_WIDGET_COND(mainwin->exec_btn, M_MSG_EXIST|M_EXEC|M_UNLOCKED);
1586 SET_WIDGET_COND(NULL, 0);
1588 #undef SET_WIDGET_COND
1590 state = main_window_get_current_state(mainwin);
1592 for (i = 0; entry[i].widget != NULL; i++) {
1593 sensitive = ((entry[i].cond & state) == entry[i].cond);
1594 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1597 activate_compose_button(mainwin,
1598 prefs_common.toolbar_style,
1599 mainwin->compose_btn_type);
1602 void main_window_set_menu_sensitive(MainWindow *mainwin)
1604 GtkItemFactory *ifactory;
1605 SensitiveCond state;
1607 GtkWidget *menuitem;
1610 static const struct {
1614 {"/File/Add mailbox..." , M_UNLOCKED},
1615 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1616 {"/File/Rescan folder tree" , M_UNLOCKED},
1617 {"/File/Folder" , M_UNLOCKED},
1618 {"/File/Import mbox file..." , M_UNLOCKED},
1619 {"/File/Export to mbox file...", M_UNLOCKED},
1620 {"/File/Empty trash" , M_UNLOCKED},
1621 {"/File/Work offline" , M_UNLOCKED},
1622 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1623 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1624 /* {"/File/Close", M_UNLOCKED}, */
1625 {"/File/Exit" , M_UNLOCKED},
1627 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1628 {"/View/Sort" , M_MSG_EXIST},
1629 {"/View/Thread view" , M_EXEC},
1630 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1631 {"/View/Go to/Prev message" , M_MSG_EXIST},
1632 {"/View/Go to/Next message" , M_MSG_EXIST},
1633 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1634 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1635 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1636 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1637 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1638 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1639 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1640 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1641 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1643 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1644 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1645 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1646 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1647 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1648 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1649 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1650 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1651 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1652 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1653 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1654 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1655 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1656 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1657 {"/Message/Mark" , M_TARGET_EXIST},
1659 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1660 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1661 {"/Tools/Harvest addresses" , M_UNLOCKED},
1662 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1663 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1664 {"/Tools/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1665 {"/Tools/Actions" , M_MSG_EXIST},
1666 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1668 {"/Configuration", M_UNLOCKED},
1673 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1674 state = main_window_get_current_state(mainwin);
1676 for (i = 0; entry[i].entry != NULL; i++) {
1677 sensitive = ((entry[i].cond & state) == entry[i].cond);
1678 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1681 main_window_menu_callback_block(mainwin);
1682 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all header");
1683 gtk_check_menu_item_set_active
1684 (GTK_CHECK_MENU_ITEM(menuitem),
1685 mainwin->messageview->textview->show_all_headers);
1686 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1687 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1688 (state & M_THREADED) != 0);
1689 main_window_menu_callback_unblock(mainwin);
1692 void main_window_popup(MainWindow *mainwin)
1698 gdk_window_get_origin(mainwin->window->window, &x, &y);
1699 sx = gdk_screen_width();
1700 sy = gdk_screen_height();
1701 x %= sx; if (x < 0) x = 0;
1702 y %= sy; if (y < 0) y = 0;
1703 gdk_window_move(mainwin->window->window, x, y);
1704 gdk_window_raise(mainwin->window->window);
1705 gdk_window_show(mainwin->window->window);
1707 debug_print("window position: x = %d, y = %d\n", x, y);
1709 switch (mainwin->type) {
1710 case SEPARATE_FOLDER:
1711 widget = mainwin->win.sep_folder.folderwin;
1712 gdk_window_get_origin(widget->window, &x, &y);
1713 x %= sx; if (x < 0) x = 0;
1714 y %= sy; if (y < 0) y = 0;
1715 gdk_window_move(widget->window, x, y);
1716 gdk_window_raise(widget->window);
1718 case SEPARATE_MESSAGE:
1719 widget = mainwin->win.sep_message.messagewin;
1720 gdk_window_get_origin(widget->window, &x, &y);
1721 x %= sx; if (x < 0) x = 0;
1722 y %= sy; if (y < 0) y = 0;
1723 gdk_window_move(widget->window, x, y);
1724 gdk_window_raise(widget->window);
1727 widget = mainwin->win.sep_both.folderwin;
1728 gdk_window_get_origin(widget->window, &x, &y);
1729 x %= sx; if (x < 0) x = 0;
1730 y %= sy; if (y < 0) y = 0;
1731 gdk_window_move(widget->window, x, y);
1732 gdk_window_raise(widget->window);
1733 widget = mainwin->win.sep_both.messagewin;
1734 gdk_window_get_origin(widget->window, &x, &y);
1735 x %= sx; if (x < 0) x = 0;
1736 y %= sy; if (y < 0) y = 0;
1737 gdk_window_move(widget->window, x, y);
1738 gdk_window_raise(widget->window);
1745 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1747 GtkWidget *folderwin = NULL;
1748 GtkWidget *messagewin = NULL;
1751 GtkWidget *vbox_body = mainwin->vbox_body;
1752 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1753 GtkWidget *menuitem;
1755 debug_print(_("Setting widgets..."));
1757 /* create separated window(s) if needed */
1758 if (type & SEPARATE_FOLDER) {
1759 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1760 gtk_window_set_title(GTK_WINDOW(folderwin),
1761 _("Sylpheed - Folder View"));
1762 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1763 "folder_view", "Sylpheed");
1764 gtk_window_set_policy(GTK_WINDOW(folderwin),
1766 gtk_widget_set_usize(folderwin, -1,
1767 prefs_common.mainview_height);
1768 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1770 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1771 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1774 if (type & SEPARATE_MESSAGE) {
1775 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1776 gtk_window_set_title(GTK_WINDOW(messagewin),
1777 _("Sylpheed - Message View"));
1778 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1779 "message_view", "Sylpheed");
1780 gtk_window_set_policy(GTK_WINDOW(messagewin),
1782 gtk_widget_set_usize
1783 (messagewin, prefs_common.mainview_width,
1784 prefs_common.mainview_height
1785 - prefs_common.summaryview_height
1786 + DEFAULT_HEADERVIEW_HEIGHT);
1787 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1789 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1790 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1796 hpaned = gtk_hpaned_new();
1797 gtk_widget_show(hpaned);
1798 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1799 gtk_paned_add1(GTK_PANED(hpaned),
1800 GTK_WIDGET_PTR(mainwin->folderview));
1802 vpaned = gtk_vpaned_new();
1803 if (mainwin->summaryview->msg_is_toggled_on) {
1804 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1805 gtk_paned_add1(GTK_PANED(vpaned),
1806 GTK_WIDGET_PTR(mainwin->summaryview));
1808 gtk_paned_add2(GTK_PANED(hpaned),
1809 GTK_WIDGET_PTR(mainwin->summaryview));
1810 gtk_widget_ref(vpaned);
1812 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1813 prefs_common.summaryview_width,
1814 prefs_common.summaryview_height);
1815 gtk_paned_add2(GTK_PANED(vpaned),
1816 GTK_WIDGET_PTR(mainwin->messageview));
1817 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1818 prefs_common.mainview_width, -1);
1819 gtk_widget_set_usize(mainwin->window,
1820 prefs_common.folderview_width +
1821 prefs_common.mainview_width,
1822 prefs_common.mainwin_height);
1823 gtk_widget_show_all(vpaned);
1825 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1826 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1827 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1828 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1829 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1830 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1832 mainwin->win.sep_none.hpaned = hpaned;
1833 mainwin->win.sep_none.vpaned = vpaned;
1835 case SEPARATE_FOLDER:
1836 vpaned = gtk_vpaned_new();
1837 if (mainwin->summaryview->msg_is_toggled_on) {
1838 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1840 gtk_paned_add1(GTK_PANED(vpaned),
1841 GTK_WIDGET_PTR(mainwin->summaryview));
1843 gtk_box_pack_start(GTK_BOX(vbox_body),
1844 GTK_WIDGET_PTR(mainwin->summaryview),
1846 gtk_widget_ref(vpaned);
1848 gtk_paned_add2(GTK_PANED(vpaned),
1849 GTK_WIDGET_PTR(mainwin->messageview));
1850 gtk_widget_show_all(vpaned);
1851 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1852 prefs_common.summaryview_width,
1853 prefs_common.summaryview_height);
1854 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1855 prefs_common.mainview_width, -1);
1856 gtk_widget_set_usize(mainwin->window,
1857 prefs_common.mainview_width,
1858 prefs_common.mainview_height);
1860 gtk_container_add(GTK_CONTAINER(folderwin),
1861 GTK_WIDGET_PTR(mainwin->folderview));
1863 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1864 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1866 mainwin->win.sep_folder.folderwin = folderwin;
1867 mainwin->win.sep_folder.vpaned = vpaned;
1869 gtk_widget_show_all(folderwin);
1871 case SEPARATE_MESSAGE:
1872 hpaned = gtk_hpaned_new();
1873 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1875 gtk_paned_add1(GTK_PANED(hpaned),
1876 GTK_WIDGET_PTR(mainwin->folderview));
1877 gtk_paned_add2(GTK_PANED(hpaned),
1878 GTK_WIDGET_PTR(mainwin->summaryview));
1879 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1880 prefs_common.summaryview_width,
1881 prefs_common.summaryview_height);
1882 gtk_widget_set_usize(mainwin->window,
1883 prefs_common.folderview_width +
1884 prefs_common.mainview_width,
1885 prefs_common.mainwin_height);
1886 gtk_widget_show_all(hpaned);
1887 gtk_container_add(GTK_CONTAINER(messagewin),
1888 GTK_WIDGET_PTR(mainwin->messageview));
1890 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1891 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1892 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1893 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1895 mainwin->win.sep_message.messagewin = messagewin;
1896 mainwin->win.sep_message.hpaned = hpaned;
1898 gtk_widget_show_all(messagewin);
1901 gtk_box_pack_start(GTK_BOX(vbox_body),
1902 GTK_WIDGET_PTR(mainwin->summaryview),
1904 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1905 prefs_common.summaryview_width,
1906 prefs_common.summaryview_height);
1907 gtk_widget_set_usize(mainwin->window,
1908 prefs_common.mainview_width,
1909 prefs_common.mainwin_height);
1910 gtk_container_add(GTK_CONTAINER(folderwin),
1911 GTK_WIDGET_PTR(mainwin->folderview));
1912 gtk_container_add(GTK_CONTAINER(messagewin),
1913 GTK_WIDGET_PTR(mainwin->messageview));
1915 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1916 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1918 mainwin->win.sep_both.folderwin = folderwin;
1919 mainwin->win.sep_both.messagewin = messagewin;
1921 gtk_widget_show_all(folderwin);
1922 gtk_widget_show_all(messagewin);
1926 mainwin->type = type;
1928 debug_print(_("done.\n"));
1931 static void main_window_toolbar_create(MainWindow *mainwin,
1932 GtkWidget *container)
1935 GtkWidget *icon_wid;
1937 GtkWidget *getall_btn;
1938 GtkWidget *compose_mail_btn;
1939 GtkWidget *compose_news_btn;
1940 GtkWidget *reply_btn;
1941 GtkWidget *replyall_btn;
1942 GtkWidget *replysender_btn;
1944 GtkWidget *send_btn;
1946 GtkWidget *prefs_btn;
1947 GtkWidget *account_btn;
1949 GtkWidget *next_btn;
1950 GtkWidget *delete_btn;
1951 GtkWidget *exec_btn;
1953 GtkTooltips *tooltips;
1955 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1957 gtk_container_add(GTK_CONTAINER(container), toolbar);
1958 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1959 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1960 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1961 GTK_TOOLBAR_SPACE_LINE);
1963 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1964 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1966 _("Get new mail from current account"),
1968 icon_wid, toolbar_inc_cb, mainwin);
1969 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1970 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1972 _("Get new mail from all accounts"),
1978 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1980 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1981 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1983 _("Send queued message(s)"),
1989 /* insert compose mail button widget */
1990 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1991 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1993 _("Compose an email message"),
1996 toolbar_compose_mail_cb,
1999 /* insert compose news button widget */
2000 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2001 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2003 _("Compose a news message"),
2006 toolbar_compose_news_cb,
2009 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2013 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
2014 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2016 _("Reply to the message - Right button: more options"),
2022 /* replyall button */
2024 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
2025 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2027 _("Reply to all - Right button: more options"),
2030 toolbar_reply_to_all_cb,
2033 /* reply to sender button */
2034 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
2035 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2037 _("Reply to sender - Right button: more options"),
2040 toolbar_reply_to_sender_cb,
2043 /* forward button */
2044 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
2045 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2047 _("Forward the message - Right button: more options"),
2053 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2055 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
2056 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2058 _("Delete the message"),
2064 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
2065 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2067 _("Execute marked process"),
2073 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
2074 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2076 _("Next unread message"),
2079 toolbar_next_unread_cb,
2083 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2085 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2086 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2088 _("Common preferences"),
2093 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2094 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2096 _("Account setting"),
2101 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2102 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2106 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2107 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2110 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2111 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2114 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2115 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2118 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2119 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2123 mainwin->toolbar = toolbar;
2124 mainwin->get_btn = get_btn;
2125 mainwin->getall_btn = getall_btn;
2126 mainwin->compose_mail_btn = compose_mail_btn;
2127 mainwin->compose_news_btn = compose_news_btn;
2128 mainwin->reply_btn = reply_btn;
2129 mainwin->replyall_btn = replyall_btn;
2130 mainwin->replysender_btn = replysender_btn;
2131 mainwin->fwd_btn = fwd_btn;
2132 mainwin->send_btn = send_btn;
2134 mainwin->prefs_btn = prefs_btn;
2135 mainwin->account_btn = account_btn;
2137 mainwin->next_btn = next_btn;
2138 mainwin->delete_btn = delete_btn;
2139 mainwin->exec_btn = exec_btn;
2141 gtk_widget_show_all(toolbar);
2144 /* callback functions */
2145 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2147 MainWindow *mainwindow = (MainWindow *) data;
2151 if (event->button == 3) {
2152 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2153 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2154 menu_button_position, widget,
2155 event->button, event->time);
2159 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2161 MainWindow *mainwin = (MainWindow *)data;
2163 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2164 manage_window_focus_in(mainwin->window, NULL, NULL);
2167 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2169 MainWindow *mainwindow = (MainWindow *) data;
2173 if (event->button == 3) {
2174 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2175 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2176 menu_button_position, widget,
2177 event->button, event->time);
2181 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2183 MainWindow *mainwin = (MainWindow *)data;
2185 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2186 manage_window_focus_in(mainwin->window, NULL, NULL);
2189 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2191 MainWindow *mainwindow = (MainWindow *) data;
2192 GtkWidget *replysender_menu, *replysender_item;
2196 if (event->button == 3) {
2197 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2198 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2199 menu_button_position, widget,
2200 event->button, event->time);
2204 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2206 MainWindow *mainwin = (MainWindow *)data;
2208 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2209 manage_window_focus_in(mainwin->window, NULL, NULL);
2212 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2214 MainWindow *mainwindow = (MainWindow *) data;
2218 if (event->button == 3) {
2219 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2220 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2221 menu_button_position, widget,
2222 event->button, event->time);
2226 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2228 MainWindow *mainwin = (MainWindow *)data;
2230 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2231 manage_window_focus_in(mainwin->window, NULL, NULL);
2234 static void toolbar_inc_cb (GtkWidget *widget,
2237 MainWindow *mainwin = (MainWindow *)data;
2239 inc_mail_cb(mainwin, 0, NULL);
2242 static void toolbar_inc_all_cb (GtkWidget *widget,
2245 MainWindow *mainwin = (MainWindow *)data;
2247 inc_all_account_mail_cb(mainwin, 0, NULL);
2250 static void toolbar_send_cb (GtkWidget *widget,
2253 MainWindow *mainwin = (MainWindow *)data;
2255 send_queue_cb(mainwin, 0, NULL);
2258 static void toolbar_compose_cb (GtkWidget *widget,
2261 MainWindow *mainwin = (MainWindow *)data;
2263 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2264 compose_cb(mainwin, 0, NULL);
2266 compose_news_cb(mainwin, 0, NULL);
2269 static void toolbar_compose_news_cb (GtkWidget *widget,
2272 MainWindow *mainwin = (MainWindow *)data;
2274 compose_news_cb(mainwin, 0, NULL);
2277 static void toolbar_compose_mail_cb (GtkWidget *widget,
2280 MainWindow *mainwin = (MainWindow *)data;
2282 compose_mail_cb(mainwin, 0, NULL);
2285 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2287 MainWindow *mainwin = (MainWindow *)data;
2290 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2291 : COMPOSE_REPLY_WITHOUT_QUOTE,
2295 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2297 MainWindow *mainwin = (MainWindow *)data;
2300 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2301 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2306 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2308 MainWindow *mainwin = (MainWindow *)data;
2311 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2312 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2316 static void toolbar_forward_cb (GtkWidget *widget,
2319 MainWindow *mainwin = (MainWindow *)data;
2321 if (prefs_common.forward_as_attachment)
2322 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2324 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2327 static void toolbar_delete_cb (GtkWidget *widget,
2330 MainWindow *mainwin = (MainWindow *)data;
2332 summary_delete(mainwin->summaryview);
2335 static void toolbar_exec_cb (GtkWidget *widget,
2338 MainWindow *mainwin = (MainWindow *)data;
2340 summary_execute(mainwin->summaryview);
2343 static void toolbar_next_unread_cb (GtkWidget *widget,
2346 MainWindow *mainwin = (MainWindow *)data;
2348 next_unread_cb(mainwin, 0, NULL);
2351 static void toolbar_prefs_cb (GtkWidget *widget,
2354 prefs_common_open();
2357 static void toolbar_account_cb (GtkWidget *widget,
2360 MainWindow *mainwin = (MainWindow *)data;
2362 prefs_account_open_cb(mainwin, 0, NULL);
2366 static void toolbar_account_button_pressed(GtkWidget *widget,
2367 GdkEventButton *event,
2370 MainWindow *mainwin = (MainWindow *)data;
2373 if (event->button != 3) return;
2375 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2376 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2379 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2380 menu_button_position, widget,
2381 event->button, event->time);
2385 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2388 MainWindow *mainwin = (MainWindow *)data;
2392 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2393 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2396 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2397 menu_button_position, widget,
2398 event->button, event->time);
2401 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2403 MainWindow *mainwin = (MainWindow *)data;
2406 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2407 if (!button) return;
2408 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2409 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2410 manage_window_focus_in(mainwin->window, NULL, NULL);
2413 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2416 MainWindow *mainwin = (MainWindow *)data;
2418 if (mainwin->lock_count == 0)
2419 app_exit_cb(data, 0, widget);
2424 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2427 main_window_add_mailbox(mainwin);
2430 static void add_mbox_cb(MainWindow *mainwin, guint action,
2433 main_window_add_mbox(mainwin);
2436 static void update_folderview_cb(MainWindow *mainwin, guint action,
2439 summary_show(mainwin->summaryview, NULL, FALSE);
2440 folderview_rescan_all();
2443 static void new_folder_cb(MainWindow *mainwin, guint action,
2446 folderview_new_folder(mainwin->folderview);
2449 static void rename_folder_cb(MainWindow *mainwin, guint action,
2452 folderview_rename_folder(mainwin->folderview);
2455 static void delete_folder_cb(MainWindow *mainwin, guint action,
2458 folderview_delete_folder(mainwin->folderview);
2461 static void import_mbox_cb(MainWindow *mainwin, guint action,
2464 import_mbox(mainwin->summaryview->folder_item);
2467 static void export_mbox_cb(MainWindow *mainwin, guint action,
2470 export_mbox(mainwin->summaryview->folder_item);
2473 static void empty_trash_cb(MainWindow *mainwin, guint action,
2476 main_window_empty_trash(mainwin, TRUE);
2479 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2481 summary_save_as(mainwin->summaryview);
2484 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2486 summary_print(mainwin->summaryview);
2489 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2491 if (prefs_common.confirm_on_exit) {
2492 if (alertpanel(_("Exit"), _("Exit this program?"),
2493 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2495 manage_window_focus_in(mainwin->window, NULL, NULL);
2498 app_will_exit(widget, mainwin);
2501 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2504 summary_search(mainwin->summaryview);
2506 message_search(mainwin->messageview);
2509 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2512 switch (mainwin->type) {
2514 case SEPARATE_MESSAGE:
2516 case SEPARATE_FOLDER:
2517 if (GTK_CHECK_MENU_ITEM(widget)->active)
2518 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2520 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2523 if (GTK_CHECK_MENU_ITEM(widget)->active)
2524 gtk_widget_show(mainwin->win.sep_both.folderwin);
2526 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2531 static void toggle_message_cb(MainWindow *mainwin, guint action,
2534 switch (mainwin->type) {
2536 case SEPARATE_FOLDER:
2538 case SEPARATE_MESSAGE:
2539 if (GTK_CHECK_MENU_ITEM(widget)->active)
2540 gtk_widget_show(mainwin->win.sep_message.messagewin);
2542 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2545 if (GTK_CHECK_MENU_ITEM(widget)->active)
2546 gtk_widget_show(mainwin->win.sep_both.messagewin);
2548 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2553 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2556 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2557 mainwin->compose_btn_type);
2558 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2559 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2560 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2561 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2563 mainwin->toolbar_style = (ToolbarStyle)action;
2564 prefs_common.toolbar_style = (ToolbarStyle)action;
2566 set_toolbar_style(mainwin);
2569 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2572 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2573 gtk_widget_show(mainwin->hbox_stat);
2574 prefs_common.show_statusbar = TRUE;
2576 gtk_widget_hide(mainwin->hbox_stat);
2577 prefs_common.show_statusbar = FALSE;
2581 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2583 summary_toggle_view_real(mainwin->summaryview);
2586 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2588 messageview_toggle_view_real(mainwin->messageview);
2591 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2593 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2594 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2596 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2600 static void online_switch_clicked (GtkButton *btn, gpointer data)
2602 MainWindow *mainwin;
2603 GtkItemFactory *ifactory;
2604 GtkCheckMenuItem *menuitem;
2606 mainwin = (MainWindow *) data;
2608 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2609 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2611 g_return_if_fail(mainwin != NULL);
2612 g_return_if_fail(menuitem != NULL);
2614 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2616 gtk_widget_hide (mainwin->online_switch);
2617 gtk_widget_show (mainwin->offline_switch);
2618 menuitem->active = TRUE;
2619 prefs_common.work_offline = TRUE;
2620 inc_autocheck_timer_remove();
2623 gtk_widget_hide (mainwin->offline_switch);
2624 gtk_widget_show (mainwin->online_switch);
2625 menuitem->active = FALSE;
2626 prefs_common.work_offline = FALSE;
2627 inc_autocheck_timer_set();
2631 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2633 MainWindow *mainwin;
2636 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2637 g_return_if_fail(mainwin != NULL);
2639 type = mainwin->type ^ action;
2640 main_window_separation_change(mainwin, type);
2642 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2643 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2646 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2649 addressbook_open(NULL);
2652 static void log_window_show_cb(MainWindow *mainwin, guint action,
2655 log_window_show(mainwin->logwin);
2658 static void sel_download_cb(MainWindow *mainwin, guint action,
2661 selective_download(mainwin);
2664 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2666 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2669 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2672 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2675 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2680 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2684 if (prefs_common.work_offline)
2685 if (alertpanel(_("Offline warning"),
2686 _("You're working offline. Override?"),
2687 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
2690 for (list = folder_get_list(); list != NULL; list = list->next) {
2691 Folder *folder = list->data;
2693 if (folder->queue) {
2694 if (procmsg_send_queue
2695 (folder->queue, prefs_common.savemsg) < 0)
2696 alertpanel_error(_("Some errors occurred while sending queued messages."));
2697 statusbar_pop_all();
2698 folder_item_scan(folder->queue);
2699 folderview_update_item(folder->queue, TRUE);
2704 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2706 if (mainwin->summaryview->folder_item) {
2707 if (mainwin->summaryview->folder_item->folder->account != NULL
2708 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2709 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2711 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2717 static void compose_mail_cb(MainWindow *mainwin, guint action,
2724 if (mainwin->summaryview->folder_item) {
2725 ac = mainwin->summaryview->folder_item->folder->account;
2726 if (ac && ac->protocol != A_NNTP) {
2727 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2732 if(cur_account && (cur_account->protocol != A_NNTP)) {
2733 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2737 list = account_get_list();
2738 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2739 ac = (PrefsAccount *) cur->data;
2740 if (ac->protocol != A_NNTP) {
2741 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2747 static void compose_news_cb(MainWindow *mainwin, guint action,
2750 PrefsAccount * ac = NULL;
2754 if (mainwin->summaryview->folder_item) {
2755 ac = mainwin->summaryview->folder_item->folder->account;
2756 if (ac && ac->protocol == A_NNTP) {
2757 compose_new_with_recipient
2758 (ac, mainwin->summaryview->folder_item->path);
2763 list = account_get_list();
2764 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2765 ac = (PrefsAccount *) cur->data;
2766 if (ac->protocol == A_NNTP) {
2773 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2775 summary_reply(mainwin->summaryview, (ComposeMode)action);
2778 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2780 summary_move_to(mainwin->summaryview);
2783 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2785 summary_copy_to(mainwin->summaryview);
2788 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2790 summary_delete(mainwin->summaryview);
2793 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2795 summary_open_msg(mainwin->summaryview);
2798 static void view_source_cb(MainWindow *mainwin, guint action,
2801 summary_view_source(mainwin->summaryview);
2804 static void show_all_header_cb(MainWindow *mainwin, guint action,
2807 if (mainwin->menu_lock_count) return;
2808 summary_display_msg_selected(mainwin->summaryview,
2809 GTK_CHECK_MENU_ITEM(widget)->active);
2812 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2814 summary_reedit(mainwin->summaryview);
2817 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2819 summary_mark(mainwin->summaryview);
2822 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2824 summary_unmark(mainwin->summaryview);
2827 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2830 summary_mark_as_unread(mainwin->summaryview);
2833 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2836 summary_mark_as_read(mainwin->summaryview);
2839 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2842 summary_mark_all_read(mainwin->summaryview);
2845 static void add_address_cb(MainWindow *mainwin, guint action,
2848 summary_add_address(mainwin->summaryview);
2851 static void set_charset_cb(MainWindow *mainwin, guint action,
2856 str = conv_get_charset_str((CharSet)action);
2857 g_free(prefs_common.force_charset);
2858 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2860 summary_redisplay_msg(mainwin->summaryview);
2862 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2865 static void hide_read_messages (MainWindow *mainwin, guint action,
2868 if (!mainwin->summaryview->folder_item
2869 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2871 summary_toggle_show_read_messages(mainwin->summaryview);
2874 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2876 GtkItemFactory *ifactory;
2878 if (mainwin->menu_lock_count) return;
2879 if (!mainwin->summaryview->folder_item) return;
2881 ifactory = gtk_item_factory_from_widget(widget);
2883 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2884 summary_thread_build(mainwin->summaryview);
2885 mainwin->summaryview->folder_item->threaded = TRUE;
2887 summary_unthread(mainwin->summaryview);
2888 mainwin->summaryview->folder_item->threaded = FALSE;
2892 static void set_display_item_cb(MainWindow *mainwin, guint action,
2895 prefs_summary_column_open();
2898 static void sort_summary_cb(MainWindow *mainwin, guint action,
2901 summary_sort(mainwin->summaryview, (SummarySortType)action);
2904 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2907 summary_attract_by_subject(mainwin->summaryview);
2910 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2913 summary_delete_duplicated(mainwin->summaryview);
2916 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2918 summary_filter(mainwin->summaryview);
2921 static void execute_summary_cb(MainWindow *mainwin, guint action,
2924 summary_execute(mainwin->summaryview);
2927 static void update_summary_cb(MainWindow *mainwin, guint action,
2931 FolderView *folderview = mainwin->folderview;
2933 if (!mainwin->summaryview->folder_item) return;
2934 if (!folderview->opened) return;
2936 folder_update_op_count();
2938 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2939 folderview->opened);
2942 summary_show(mainwin->summaryview, fitem, TRUE);
2945 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2947 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2950 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2952 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2955 static void prev_unread_cb(MainWindow *mainwin, guint action,
2958 summary_select_prev_unread(mainwin->summaryview);
2961 static void next_unread_cb(MainWindow *mainwin, guint action,
2964 summary_select_next_unread(mainwin->summaryview);
2967 static void prev_marked_cb(MainWindow *mainwin, guint action,
2970 summary_select_prev_marked(mainwin->summaryview);
2973 static void next_marked_cb(MainWindow *mainwin, guint action,
2976 summary_select_next_marked(mainwin->summaryview);
2979 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2982 summary_select_prev_labeled(mainwin->summaryview);
2985 static void next_labeled_cb(MainWindow *mainwin, guint action,
2988 summary_select_next_labeled(mainwin->summaryview);
2991 static void goto_folder_cb(MainWindow *mainwin, guint action,
2994 FolderItem *to_folder;
2996 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2999 folderview_select(mainwin->folderview, to_folder);
3002 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3004 messageview_copy_clipboard(mainwin->messageview);
3007 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3009 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3010 summary_select_all(mainwin->summaryview);
3011 else if (mainwin->summaryview->msg_is_toggled_on && (
3012 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text) ||
3013 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->mimeview->ctree) ||
3014 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->mimeview->notebook) ||
3015 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->mimeview->textview->text)))
3016 messageview_select_all(mainwin->messageview);
3019 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3021 if (mainwin->summaryview->msg_is_toggled_on)
3022 summary_select_thread(mainwin->summaryview);
3025 static void create_filter_cb(MainWindow *mainwin, guint action,
3028 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3031 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3034 prefs_common_open();
3037 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
3040 prefs_filter_open(NULL, NULL);
3043 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3046 prefs_scoring_open(NULL);
3049 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3052 prefs_filtering_open(NULL, NULL, NULL);
3055 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3058 prefs_template_open();
3061 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3064 prefs_actions_open(mainwin);
3067 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3071 new_account_cb(mainwin, 0, widget);
3073 gboolean prev_default = cur_account->is_default;
3075 prefs_account_open(cur_account);
3076 if (!prev_default && cur_account->is_default)
3077 account_set_as_default(cur_account);
3078 account_save_config_all();
3080 main_window_reflect_prefs_all();
3084 static void new_account_cb(MainWindow *mainwin, guint action,
3087 account_edit_open();
3088 if (!compose_get_compose_list()) account_add();
3091 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3093 cur_account = (PrefsAccount *)data;
3094 main_window_reflect_prefs_all();
3097 static void manual_open_cb(MainWindow *mainwin, guint action,
3100 manual_open((ManualLang)action);
3103 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3105 faq_open((ManualLang)action);
3108 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3110 MainWindow *mainwin = (MainWindow *)data;
3114 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3115 LOCAL_FOLDER(folder)->rootpath,
3119 str = g_strdup_printf(_("Scanning folder %s ..."),
3120 LOCAL_FOLDER(folder)->rootpath);
3122 STATUSBAR_PUSH(mainwin, str);
3123 STATUSBAR_POP(mainwin);
3127 static void activate_compose_button (MainWindow *mainwin,
3129 ComposeButtonType type)
3131 SensitiveCond state = main_window_get_current_state(mainwin);
3133 if (style == TOOLBAR_NONE)
3136 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
3137 : mainwin->compose_news_btn);
3138 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
3139 : mainwin->compose_mail_btn);
3140 mainwin->compose_btn_type = type;
3143 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
3145 if (mainwin->compose_btn_type != compose_btn_type)
3146 activate_compose_button(mainwin,
3147 prefs_common.toolbar_style,
3151 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
3153 MainWindow *mainwin = (MainWindow*) data;
3155 if (!mainwin) return;
3157 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
3160 #define BREAK_ON_MODIFIER_KEY() \
3161 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3163 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3165 MainWindow *mainwin = (MainWindow*) data;
3167 if (!mainwin || !event) return;
3169 switch (event->keyval) {
3170 case GDK_Q: /* Quit */
3171 BREAK_ON_MODIFIER_KEY();
3173 app_exit_cb(mainwin, 0, NULL);
3180 #undef BREAK_ON_MODIFIER_KEY
3182 static void set_toolbar_style(MainWindow *mainwin)
3184 switch (prefs_common.toolbar_style) {
3186 gtk_widget_hide(mainwin->handlebox);
3189 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3193 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3197 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3202 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3203 gtk_widget_show(mainwin->handlebox);
3204 gtk_widget_queue_resize(mainwin->handlebox);
3206 if (prefs_common.immediate_exec)
3207 gtk_widget_hide(mainwin->exec_btn);
3209 gtk_widget_show(mainwin->exec_btn);
3214 * Harvest addresses for selected folder.
3216 static void addr_harvest_cb( MainWindow *mainwin,
3220 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3224 * Harvest addresses for selected messages in summary view.
3226 static void addr_harvest_msg_cb( MainWindow *mainwin,
3230 summary_harvest_address( mainwin->summaryview );