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_filtering.h"
65 #include "prefs_scoring.h"
66 #include "prefs_account.h"
67 #include "prefs_folder_item.h"
68 #include "prefs_summary_column.h"
69 #include "prefs_template.h"
71 #include "addressbook.h"
72 #include "headerwindow.h"
73 #include "logwindow.h"
74 #include "manage_window.h"
75 #include "alertpanel.h"
76 #include "statusbar.h"
77 #include "inputdialog.h"
85 #define AC_LABEL_WIDTH 240
87 #define STATUSBAR_PUSH(mainwin, str) \
89 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
90 mainwin->mainwin_cid, str); \
91 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
94 #define STATUSBAR_POP(mainwin) \
96 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
97 mainwin->mainwin_cid); \
100 /* list of all instantiated MainWindow */
101 static GList *mainwin_list = NULL;
103 static GdkCursor *watch_cursor;
105 static void main_window_show_cur_account (MainWindow *mainwin);
107 static void main_window_set_widgets (MainWindow *mainwin,
109 static void main_window_toolbar_create (MainWindow *mainwin,
110 GtkWidget *container);
112 /* callback functions */
113 static void toolbar_inc_cb (GtkWidget *widget,
115 static void toolbar_inc_all_cb (GtkWidget *widget,
117 static void toolbar_send_cb (GtkWidget *widget,
120 static void toolbar_compose_cb (GtkWidget *widget,
122 static void toolbar_compose_news_cb (GtkWidget *widget,
124 static void toolbar_compose_mail_cb (GtkWidget *widget,
126 static void toolbar_reply_cb (GtkWidget *widget,
128 static void toolbar_reply_popup_cb (GtkWidget *widget,
129 GdkEventButton *event,
131 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell,
133 static void toolbar_reply_to_all_cb (GtkWidget *widget,
135 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget,
136 GdkEventButton *event,
138 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell,
140 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
142 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
143 GdkEventButton *event,
145 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell,
147 static void toolbar_forward_cb (GtkWidget *widget,
149 static void toolbar_forward_popup_cb (GtkWidget *widget,
150 GdkEventButton *event,
152 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell,
155 static void toolbar_delete_cb (GtkWidget *widget,
157 static void toolbar_exec_cb (GtkWidget *widget,
160 static void toolbar_next_unread_cb (GtkWidget *widget,
163 static void toolbar_prefs_cb (GtkWidget *widget,
165 static void toolbar_account_cb (GtkWidget *widget,
168 static void toolbar_account_button_pressed (GtkWidget *widget,
169 GdkEventButton *event,
171 static void ac_label_button_pressed (GtkWidget *widget,
172 GdkEventButton *event,
174 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
177 static gint main_window_close_cb (GtkWidget *widget,
181 static void add_mailbox_cb (MainWindow *mainwin,
184 static void add_mbox_cb (MainWindow *mainwin,
187 static void update_folderview_cb (MainWindow *mainwin,
190 static void new_folder_cb (MainWindow *mainwin,
193 static void rename_folder_cb (MainWindow *mainwin,
196 static void delete_folder_cb (MainWindow *mainwin,
199 static void import_mbox_cb (MainWindow *mainwin,
202 static void export_mbox_cb (MainWindow *mainwin,
205 static void empty_trash_cb (MainWindow *mainwin,
209 static void save_as_cb (MainWindow *mainwin,
212 static void print_cb (MainWindow *mainwin,
215 static void app_exit_cb (MainWindow *mainwin,
219 static void search_cb (MainWindow *mainwin,
223 static void toggle_folder_cb (MainWindow *mainwin,
226 static void toggle_message_cb (MainWindow *mainwin,
229 static void toggle_toolbar_cb (MainWindow *mainwin,
232 static void toggle_statusbar_cb (MainWindow *mainwin,
235 static void toggle_expand_summaryview_cb (MainWindow *mainwin,
238 static void toggle_expand_messageview_cb (MainWindow *mainwin,
241 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
245 static void addressbook_open_cb (MainWindow *mainwin,
248 static void log_window_show_cb (MainWindow *mainwin,
252 static void inc_mail_cb (MainWindow *mainwin,
255 static void inc_all_account_mail_cb (MainWindow *mainwin,
259 static void send_queue_cb (MainWindow *mainwin,
263 static void compose_cb (MainWindow *mainwin,
266 static void compose_mail_cb(MainWindow *mainwin, guint action,
268 static void compose_news_cb(MainWindow *mainwin, guint action,
270 static void reply_cb (MainWindow *mainwin,
274 static void open_msg_cb (MainWindow *mainwin,
278 static void view_source_cb (MainWindow *mainwin,
282 static void reedit_cb (MainWindow *mainwin,
286 static void move_to_cb (MainWindow *mainwin,
289 static void copy_to_cb (MainWindow *mainwin,
292 static void delete_cb (MainWindow *mainwin,
296 static void mark_cb (MainWindow *mainwin,
299 static void unmark_cb (MainWindow *mainwin,
303 static void mark_as_unread_cb (MainWindow *mainwin,
306 static void mark_as_read_cb (MainWindow *mainwin,
309 static void mark_all_read_cb (MainWindow *mainwin,
312 static void add_address_cb (MainWindow *mainwin,
316 static void set_charset_cb (MainWindow *mainwin,
320 static void hide_read_messages (MainWindow *mainwin,
324 static void thread_cb (MainWindow *mainwin,
327 static void set_display_item_cb (MainWindow *mainwin,
330 static void sort_summary_cb (MainWindow *mainwin,
333 static void attract_by_subject_cb(MainWindow *mainwin,
337 static void delete_duplicated_cb (MainWindow *mainwin,
340 static void filter_cb (MainWindow *mainwin,
343 static void execute_summary_cb (MainWindow *mainwin,
346 static void update_summary_cb (MainWindow *mainwin,
350 static void prev_cb (MainWindow *mainwin,
353 static void next_cb (MainWindow *mainwin,
357 static void prev_unread_cb (MainWindow *mainwin,
360 static void next_unread_cb (MainWindow *mainwin,
363 static void prev_marked_cb (MainWindow *mainwin,
366 static void next_marked_cb (MainWindow *mainwin,
369 static void prev_labeled_cb (MainWindow *mainwin,
372 static void next_labeled_cb (MainWindow *mainwin,
376 static void goto_folder_cb (MainWindow *mainwin,
380 static void copy_cb (MainWindow *mainwin,
383 static void allsel_cb (MainWindow *mainwin,
387 static void create_filter_cb (MainWindow *mainwin,
391 static void prefs_common_open_cb (MainWindow *mainwin,
394 static void prefs_filter_open_cb (MainWindow *mainwin,
397 static void prefs_scoring_open_cb (MainWindow *mainwin,
400 static void prefs_filtering_open_cb (MainWindow *mainwin,
403 static void prefs_account_open_cb(MainWindow *mainwin,
406 static void prefs_template_open_cb (MainWindow *mainwin,
409 static void new_account_cb (MainWindow *mainwin,
413 static void account_menu_cb (GtkMenuItem *menuitem,
416 static void manual_open_cb (MainWindow *mainwin,
420 static void scan_tree_func (Folder *folder,
424 static void activate_compose_button (MainWindow *mainwin,
426 ComposeButtonType type);
428 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
432 static void key_pressed (GtkWidget *widget,
436 #define SEPARATE_ACTION 667
438 static GtkItemFactoryEntry mainwin_entries[] =
440 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
441 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
442 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
443 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
444 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
445 {N_("/_File/_Folder/Create _new folder..."),
446 NULL, new_folder_cb, 0, NULL},
447 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
448 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
449 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
450 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
451 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
452 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
453 {N_("/_File/_Save as..."), "y", save_as_cb, 0, NULL},
454 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
455 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
456 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
458 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
459 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
460 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
461 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
462 {N_("/_Edit/_Find in current message..."),
463 "<control>F", search_cb, 0, NULL},
464 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
466 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
467 {N_("/_View/_Folder tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
468 {N_("/_View/_Message view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
469 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
470 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
471 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
472 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
473 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
474 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
475 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
476 {N_("/_View/Status _bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
477 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
478 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
479 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
480 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
481 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
482 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
483 {N_("/_View/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
484 {N_("/_View/_Sort/Sort by _color label"),
485 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
486 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
487 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
488 {N_("/_View/_Sort/Sort by a_ttachment"),
489 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
490 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
491 {N_("/_View/_Sort/_Attract by subject"),
492 NULL, attract_by_subject_cb, 0, NULL},
493 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, NULL},
494 {N_("/_View/U_nthread view"), "<shift><control>T", thread_cb, 1, NULL},
495 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
496 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
497 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
499 #define CODESET_SEPARATOR \
500 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
501 #define CODESET_ACTION(action) \
502 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
504 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
505 {N_("/_View/_Code set/_Auto detect"),
506 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
507 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
508 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
509 CODESET_ACTION(C_US_ASCII)},
512 {N_("/_View/_Code set/Unicode (_UTF-8)"),
513 CODESET_ACTION(C_UTF_8)},
516 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
517 CODESET_ACTION(C_ISO_8859_1)},
520 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
521 CODESET_ACTION(C_ISO_8859_2)},
523 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
524 CODESET_ACTION(C_ISO_8859_13)},
525 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
526 CODESET_ACTION(C_ISO_8859_4)},
528 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
529 CODESET_ACTION(C_ISO_8859_7)},
531 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
532 CODESET_ACTION(C_ISO_8859_9)},
534 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
535 CODESET_ACTION(C_ISO_8859_5)},
536 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
537 CODESET_ACTION(C_KOI8_R)},
538 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
539 CODESET_ACTION(C_CP1251)},
542 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
543 CODESET_ACTION(C_ISO_2022_JP)},
545 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
546 CODESET_ACTION(C_ISO_2022_JP_2)},
548 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
549 CODESET_ACTION(C_EUC_JP)},
550 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
551 CODESET_ACTION(C_SHIFT_JIS)},
554 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
555 CODESET_ACTION(C_GB2312)},
556 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
557 CODESET_ACTION(C_BIG5)},
558 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
559 CODESET_ACTION(C_EUC_TW)},
560 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
561 CODESET_ACTION(C_ISO_2022_CN)},
563 {N_("/_View/_Code set/Korean (EUC-_KR)"),
564 CODESET_ACTION(C_EUC_KR)},
565 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
566 CODESET_ACTION(C_ISO_2022_KR)},
568 {N_("/_View/_Code set/Thai (TIS-620)"),
569 CODESET_ACTION(C_TIS_620)},
570 {N_("/_View/_Code set/Thai (Windows-874)"),
571 CODESET_ACTION(C_WINDOWS_874)},
574 #undef CODESET_SEPARATOR
575 #undef CODESET_ACTION
577 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
578 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
579 {N_("/_View/_Go to/_Prev message"), "p", prev_cb, 0, NULL},
580 {N_("/_View/_Go to/_Next message"), "n", next_cb, 0, NULL},
581 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
582 {N_("/_View/_Go to/P_rev unread message"),
583 "<shift>P", prev_unread_cb, 0, NULL},
584 {N_("/_View/_Go to/N_ext unread message"),
585 "<shift>N", next_unread_cb, 0, NULL},
586 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
587 {N_("/_View/_Go to/Prev _marked message"),
588 NULL, prev_marked_cb, 0, NULL},
589 {N_("/_View/_Go to/Next m_arked message"),
590 NULL, next_marked_cb, 0, NULL},
591 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
592 {N_("/_View/_Go to/Prev _labeled message"),
593 NULL, prev_labeled_cb, 0, NULL},
594 {N_("/_View/_Go to/Next la_beled message"),
595 NULL, next_labeled_cb, 0, NULL},
596 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
597 {N_("/_View/_Go to/Other _folder..."), "<alt>G", goto_folder_cb, 0, NULL},
598 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
599 {N_("/_View/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
600 {N_("/_View/_View source"), "<control>U", view_source_cb, 0, NULL},
601 {N_("/_View/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
602 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
603 {N_("/_View/_Update"), "<control><alt>U", update_summary_cb, 0, NULL},
605 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
606 {N_("/_Message/Get new ma_il"), "<control><alt>I", inc_mail_cb, 0, NULL},
607 {N_("/_Message/Get from _all accounts"),
608 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
609 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
610 {N_("/_Message/Send queued messa_ges"),
611 NULL, send_queue_cb, 0, NULL},
612 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
613 {N_("/_Message/Compose a_n email message"), "w", compose_mail_cb, 0, NULL},
614 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
615 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
616 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
617 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
618 {N_("/_Message/Reply to a_ll"), "<control><shift>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
619 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
620 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
621 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
622 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
623 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
624 {N_("/_Message/M_ove..."), "o", move_to_cb, 0, NULL},
625 {N_("/_Message/_Copy..."), "<shift>O", copy_to_cb, 0, NULL},
626 {N_("/_Message/_Delete"), "d", delete_cb, 0, NULL},
627 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
628 {N_("/_Message/Delete du_plicated messages"),
629 NULL, delete_duplicated_cb, 0, NULL},
630 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
631 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
632 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
633 {N_("/_Message/_Mark/_Unmark"), "u", unmark_cb, 0, NULL},
634 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
635 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
636 {N_("/_Message/_Mark/Mark as rea_d"),
637 NULL, mark_as_read_cb, 0, NULL},
638 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
640 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
641 {N_("/_Tool/_Address book"), "<control><alt>A", addressbook_open_cb, 0, NULL},
642 {N_("/_Tool/Add sender to address boo_k"),
643 NULL, add_address_cb, 0, NULL},
644 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
645 {N_("/_Tool/_Filter messages"), NULL, filter_cb, 0, NULL},
646 {N_("/_Tool/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
647 {N_("/_Tool/_Create filter rule/_Automatically"),
648 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
649 {N_("/_Tool/_Create filter rule/by _From"),
650 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
651 {N_("/_Tool/_Create filter rule/by _To"),
652 NULL, create_filter_cb, FILTER_BY_TO, NULL},
653 {N_("/_Tool/_Create filter rule/by _Subject"),
654 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
655 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
656 {N_("/_Tool/E_xecute"), "x", execute_summary_cb, 0, NULL},
657 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
658 {N_("/_Tool/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
660 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
661 {N_("/_Configuration/_Common preferences..."),
662 NULL, prefs_common_open_cb, 0, NULL},
663 {N_("/_Configuration/_Filter setting..."),
664 NULL, prefs_filter_open_cb, 0, NULL},
665 {N_("/_Configuration/_Scoring ..."),
666 NULL, prefs_scoring_open_cb, 0, NULL},
667 {N_("/_Configuration/_Filtering ..."),
668 NULL, prefs_filtering_open_cb, 0, NULL},
669 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
670 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
671 {N_("/_Configuration/_Preferences for current account..."),
672 NULL, prefs_account_open_cb, 0, NULL},
673 {N_("/_Configuration/Create _new account..."),
674 NULL, new_account_cb, 0, NULL},
675 {N_("/_Configuration/_Edit accounts..."),
676 NULL, account_edit_open, 0, NULL},
677 {N_("/_Configuration/C_hange current account"),
678 NULL, NULL, 0, "<Branch>"},
680 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
681 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
682 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
683 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
684 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
685 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
687 static GtkItemFactoryEntry reply_popup_entries[] =
689 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
690 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
692 static GtkItemFactoryEntry replyall_popup_entries[] =
694 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
695 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
697 static GtkItemFactoryEntry replysender_popup_entries[] =
699 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
700 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
702 static GtkItemFactoryEntry fwd_popup_entries[] =
704 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
705 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
709 MainWindow *main_window_create(SeparateType type)
715 GtkWidget *handlebox;
716 GtkWidget *vbox_body;
717 GtkWidget *hbox_stat;
718 GtkWidget *statusbar;
719 GtkWidget *progressbar;
720 GtkWidget *statuslabel;
721 GtkWidget *ac_button;
724 FolderView *folderview;
725 SummaryView *summaryview;
726 MessageView *messageview;
727 GdkColormap *colormap;
730 guint n_menu_entries;
731 GtkItemFactory *ifactory;
734 GtkWidget *compose_popup;
735 GtkWidget *reply_popup;
736 GtkWidget *replyall_popup;
737 GtkWidget *replysender_popup;
738 GtkWidget *fwd_popup;
741 debug_print(_("Creating main window...\n"));
742 mainwin = g_new0(MainWindow, 1);
745 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
746 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
747 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
748 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
749 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
750 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
751 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
752 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
753 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
754 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
755 GTK_SIGNAL_FUNC(key_pressed), mainwin);
757 gtk_widget_realize(window);
758 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
760 gtkut_widget_set_app_icon(window);
762 vbox = gtk_vbox_new(FALSE, 0);
763 gtk_widget_show(vbox);
764 gtk_container_add(GTK_CONTAINER(window), vbox);
767 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
768 menubar = menubar_create(window, mainwin_entries,
769 n_menu_entries, "<Main>", mainwin);
770 gtk_widget_show(menubar);
771 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
773 handlebox = gtk_handle_box_new();
774 gtk_widget_show(handlebox);
775 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
777 /* create the popup menus for the reply buttons specials */
778 n_menu_entries = sizeof(reply_popup_entries) /
779 sizeof(reply_popup_entries[0]);
780 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
781 "<ReplyPopup>", mainwin);
782 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
783 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
784 n_menu_entries = sizeof(replyall_popup_entries) /
785 sizeof(replyall_popup_entries[0]);
786 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
787 "<ReplyAllPopup>", mainwin);
788 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
789 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
790 n_menu_entries = sizeof(replysender_popup_entries) /
791 sizeof(replysender_popup_entries[0]);
792 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
793 "<ReplySenderPopup>", mainwin);
794 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
795 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
796 /* create the popup menu for the forward button */
797 n_menu_entries = sizeof(fwd_popup_entries) /
798 sizeof(fwd_popup_entries[0]);
799 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
800 "<ForwardPopup>", mainwin);
801 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
802 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
804 main_window_toolbar_create(mainwin, handlebox);
806 /* vbox that contains body */
807 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
808 gtk_widget_show(vbox_body);
809 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
810 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
812 hbox_stat = gtk_hbox_new(FALSE, 2);
813 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
815 statusbar = statusbar_create();
816 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
818 progressbar = gtk_progress_bar_new();
819 gtk_widget_set_usize(progressbar, 120, 1);
820 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
822 statuslabel = gtk_label_new("");
823 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
825 ac_button = gtk_button_new();
826 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
827 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
828 gtk_widget_set_usize(ac_button, -1, 1);
829 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
830 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
831 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
833 ac_label = gtk_label_new("");
834 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
836 gtk_widget_show_all(hbox_stat);
839 mainwin->folderview = folderview = folderview_create();
840 mainwin->summaryview = summaryview = summary_create();
841 mainwin->messageview = messageview = messageview_create();
842 mainwin->headerwin = header_window_create();
843 mainwin->logwin = log_window_create();
845 folderview->mainwin = mainwin;
846 folderview->summaryview = summaryview;
848 summaryview->mainwin = mainwin;
849 summaryview->folderview = folderview;
850 summaryview->messageview = messageview;
851 summaryview->headerwin = mainwin->headerwin;
852 summaryview->window = window;
854 messageview->mainwin = mainwin;
856 mainwin->window = window;
857 mainwin->vbox = vbox;
858 mainwin->menubar = menubar;
859 mainwin->handlebox = handlebox;
860 mainwin->vbox_body = vbox_body;
861 mainwin->hbox_stat = hbox_stat;
862 mainwin->statusbar = statusbar;
863 mainwin->progressbar = progressbar;
864 mainwin->statuslabel = statuslabel;
865 mainwin->ac_button = ac_button;
866 mainwin->ac_label = ac_label;
867 mainwin->reply_popup = reply_popup;
868 mainwin->replyall_popup = replyall_popup;
869 mainwin->replysender_popup = replysender_popup;
870 mainwin->fwd_popup = fwd_popup;
872 /* set context IDs for status bar */
873 mainwin->mainwin_cid = gtk_statusbar_get_context_id
874 (GTK_STATUSBAR(statusbar), "Main Window");
875 mainwin->folderview_cid = gtk_statusbar_get_context_id
876 (GTK_STATUSBAR(statusbar), "Folder View");
877 mainwin->summaryview_cid = gtk_statusbar_get_context_id
878 (GTK_STATUSBAR(statusbar), "Summary View");
880 /* allocate colors for summary view and folder view */
881 summaryview->color_marked.red = summaryview->color_marked.green = 0;
882 summaryview->color_marked.blue = (guint16)65535;
884 summaryview->color_dim.red = summaryview->color_dim.green =
885 summaryview->color_dim.blue = COLOR_DIM;
887 folderview->color_new.red = (guint16)55000;
888 folderview->color_new.green = folderview->color_new.blue = 15000;
890 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
891 &folderview->color_op);
893 summaryview->color_important.red = 0;
894 summaryview->color_marked.green = 0;
895 summaryview->color_important.blue = (guint16)65535;
897 color[0] = summaryview->color_marked;
898 color[1] = summaryview->color_dim;
899 color[2] = folderview->color_new;
900 color[3] = folderview->color_op;
902 colormap = gdk_window_get_colormap(window->window);
903 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
904 for (i = 0; i < 4; i++) {
905 if (success[i] == FALSE)
906 g_warning(_("MainWindow: color allocation %d failed\n"), i);
909 debug_print(_("done.\n"));
911 main_window_set_widgets(mainwin, type);
914 ifactory = gtk_item_factory_from_widget(menubar);
915 menuitem = gtk_item_factory_get_item
916 (ifactory, "/View/Code set/Auto detect");
917 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
919 switch (prefs_common.toolbar_style) {
921 menuitem = gtk_item_factory_get_item
922 (ifactory, "/View/Toolbar/None");
925 menuitem = gtk_item_factory_get_item
926 (ifactory, "/View/Toolbar/Icon");
929 menuitem = gtk_item_factory_get_item
930 (ifactory, "/View/Toolbar/Text");
933 menuitem = gtk_item_factory_get_item
934 (ifactory, "/View/Toolbar/Icon and text");
936 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
938 gtk_widget_hide(mainwin->hbox_stat);
939 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
940 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
941 prefs_common.show_statusbar);
942 #if 0 /* FIXED SEPARATE WINDOWS */
943 /* Message view and Folder tree are always shown at startup
944 * make that in the menu visible */
945 menuitem = gtk_item_factory_get_item(ifactory, "/View/Message view");
946 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
947 menuitem = gtk_item_factory_get_item(ifactory, "/View/Folder tree");
948 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
950 /* set the check of the SEPARATE_xxx menu items. we also need the main window
951 * as a property and pass the action type to the callback */
952 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
954 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
955 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
956 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
957 GUINT_TO_POINTER(SEPARATE_FOLDER));
959 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
961 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
962 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
963 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
964 GUINT_TO_POINTER(SEPARATE_MESSAGE));
966 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
967 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
970 menu_set_sensitive(ifactory, "/View/Thread view",
971 prefs_common.enable_thread ? FALSE : TRUE);
972 menu_set_sensitive(ifactory, "/View/Unthread view",
973 prefs_common.enable_thread ? TRUE : FALSE);
975 /* set account selection menu */
976 ac_menu = gtk_item_factory_get_widget
977 (ifactory, "/Configuration/Change current account");
978 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
979 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
980 mainwin->ac_menu = ac_menu;
982 main_window_set_toolbar_sensitive(mainwin);
984 /* show main window */
985 gtk_widget_set_uposition(mainwin->window,
986 prefs_common.mainwin_x,
987 prefs_common.mainwin_y);
988 gtk_widget_set_usize(window, prefs_common.mainwin_width,
989 prefs_common.mainwin_height);
990 gtk_widget_show(mainwin->window);
992 /* initialize views */
993 folderview_init(folderview);
994 summary_init(summaryview);
995 messageview_init(messageview);
996 header_window_init(mainwin->headerwin);
997 log_window_init(mainwin->logwin);
999 mainwin->lock_count = 0;
1000 mainwin->cursor_count = 0;
1003 watch_cursor = gdk_cursor_new(GDK_WATCH);
1005 mainwin_list = g_list_append(mainwin_list, mainwin);
1010 void main_window_cursor_wait(MainWindow *mainwin)
1013 if (mainwin->cursor_count == 0)
1014 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1016 mainwin->cursor_count++;
1021 void main_window_cursor_normal(MainWindow *mainwin)
1023 if (mainwin->cursor_count)
1024 mainwin->cursor_count--;
1026 if (mainwin->cursor_count == 0)
1027 gdk_window_set_cursor(mainwin->window->window, NULL);
1032 /* lock / unlock the user-interface */
1033 void main_window_lock(MainWindow *mainwin)
1035 if (mainwin->lock_count == 0)
1036 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1038 mainwin->lock_count++;
1040 main_window_set_menu_sensitive(mainwin);
1041 main_window_set_toolbar_sensitive(mainwin);
1044 void main_window_unlock(MainWindow *mainwin)
1046 if (mainwin->lock_count)
1047 mainwin->lock_count--;
1049 main_window_set_menu_sensitive(mainwin);
1050 main_window_set_toolbar_sensitive(mainwin);
1052 if (mainwin->lock_count == 0)
1053 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1056 void main_window_reflect_prefs_all(void)
1059 MainWindow *mainwin;
1061 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1062 mainwin = (MainWindow *)cur->data;
1064 main_window_show_cur_account(mainwin);
1065 main_window_set_menu_sensitive(mainwin);
1066 main_window_set_toolbar_sensitive(mainwin);
1068 if (prefs_common.immediate_exec)
1069 gtk_widget_hide(mainwin->exec_btn);
1071 gtk_widget_show(mainwin->exec_btn);
1073 summary_redisplay_msg(mainwin->summaryview);
1074 headerview_set_visibility(mainwin->messageview->headerview,
1075 prefs_common.display_header_pane);
1079 void main_window_set_summary_column(void)
1082 MainWindow *mainwin;
1084 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1085 mainwin = (MainWindow *)cur->data;
1086 summary_set_column_order(mainwin->summaryview);
1090 void main_window_set_account_menu(GList *account_list)
1092 GList *cur, *cur_ac, *cur_item;
1093 GtkWidget *menuitem;
1094 MainWindow *mainwin;
1095 PrefsAccount *ac_prefs;
1097 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1098 mainwin = (MainWindow *)cur->data;
1100 /* destroy all previous menu item */
1101 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1102 while (cur_item != NULL) {
1103 GList *next = cur_item->next;
1104 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1108 for (cur_ac = account_list; cur_ac != NULL;
1109 cur_ac = cur_ac->next) {
1110 ac_prefs = (PrefsAccount *)cur_ac->data;
1112 menuitem = gtk_menu_item_new_with_label
1113 (ac_prefs->account_name
1114 ? ac_prefs->account_name : _("Untitled"));
1115 gtk_widget_show(menuitem);
1116 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1117 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1118 GTK_SIGNAL_FUNC(account_menu_cb),
1124 static void main_window_show_cur_account(MainWindow *mainwin)
1129 ac_name = g_strdup(cur_account
1130 ? (cur_account->account_name
1131 ? cur_account->account_name : _("Untitled"))
1135 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1137 buf = g_strdup(PROG_VERSION);
1138 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1141 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1142 gtk_widget_queue_resize(mainwin->ac_button);
1147 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1149 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1150 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1151 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1153 if (mainwin->type == type) return;
1155 /* remove widgets from those containers */
1156 gtk_widget_ref(folder_wid);
1157 gtk_widget_ref(summary_wid);
1158 gtk_widget_ref(message_wid);
1159 gtkut_container_remove
1160 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1161 gtkut_container_remove
1162 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1163 gtkut_container_remove
1164 (GTK_CONTAINER(message_wid->parent), message_wid);
1166 /* clean containers */
1167 switch (mainwin->type) {
1169 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1171 case SEPARATE_FOLDER:
1172 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1173 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1175 case SEPARATE_MESSAGE:
1176 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1177 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1180 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1181 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1185 gtk_widget_hide(mainwin->window);
1186 main_window_set_widgets(mainwin, type);
1187 gtk_widget_show(mainwin->window);
1189 gtk_widget_unref(folder_wid);
1190 gtk_widget_unref(summary_wid);
1191 gtk_widget_unref(message_wid);
1194 void main_window_get_size(MainWindow *mainwin)
1196 GtkAllocation *allocation;
1198 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1200 prefs_common.summaryview_width = allocation->width;
1202 if (mainwin->summaryview->msg_is_toggled_on)
1203 prefs_common.summaryview_height = allocation->height;
1205 prefs_common.mainview_width = allocation->width;
1207 allocation = &mainwin->window->allocation;
1209 prefs_common.mainview_height = allocation->height;
1210 prefs_common.mainwin_width = allocation->width;
1211 prefs_common.mainwin_height = allocation->height;
1213 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1215 prefs_common.folderview_width = allocation->width;
1216 prefs_common.folderview_height = allocation->height;
1219 void main_window_get_position(MainWindow *mainwin)
1223 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1225 prefs_common.mainview_x = x;
1226 prefs_common.mainview_y = y;
1227 prefs_common.mainwin_x = x;
1228 prefs_common.mainwin_y = y;
1230 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1233 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1239 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1240 folder = FOLDER(list->data);
1241 if (folder && folder->trash && folder->trash->total > 0)
1245 if (!has_trash) return;
1248 if (alertpanel(_("Empty trash"),
1249 _("Empty all messages in trash?"),
1250 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1252 manage_window_focus_in(mainwin->window, NULL, NULL);
1255 procmsg_empty_trash();
1257 for (list = folder_get_list(); list != NULL; list = list->next) {
1258 folder = list->data;
1259 if (folder && folder->trash && folder->trash->total != 0) {
1260 folder_item_scan(folder->trash);
1261 folderview_update_item(folder->trash, TRUE);
1265 if (mainwin->summaryview->folder_item &&
1266 mainwin->summaryview->folder_item->stype == F_TRASH)
1267 gtk_widget_grab_focus(mainwin->folderview->ctree);
1270 void main_window_add_mailbox(MainWindow *mainwin)
1275 path = input_dialog(_("Add mailbox"),
1276 _("Input the location of mailbox.\n"
1277 "If the existing mailbox is specified, it will be\n"
1278 "scanned automatically."),
1281 if (folder_find_from_path(path)) {
1282 alertpanel_error(_("The mailbox `%s' already exists."), path);
1286 if (!strcmp(path, "Mail"))
1287 folder = folder_new(F_MH, _("Mailbox"), path);
1289 folder = folder_new(F_MH, g_basename(path), path);
1292 if (folder->create_tree(folder) < 0) {
1293 alertpanel_error(_("Creation of the mailbox failed.\n"
1294 "Maybe some files already exist, or you don't have the permission to write there."));
1295 folder_destroy(folder);
1300 folder_set_ui_func(folder, scan_tree_func, mainwin);
1301 folder->scan_tree(folder);
1302 folder_set_ui_func(folder, NULL, NULL);
1304 folderview_set(mainwin->folderview);
1307 void main_window_add_mbox(MainWindow *mainwin)
1313 path = input_dialog(_("Add mbox mailbox"),
1314 _("Input the location of mailbox."),
1319 if (folder_find_from_path(path)) {
1320 alertpanel_error(_("The mailbox `%s' already exists."), path);
1326 if (!strcmp(path, "Mail"))
1327 folder = folder_new(F_MBOX, _("Mailbox"), path);
1331 folder = folder_new(F_MBOX, g_basename(path), path);
1334 if (folder->create_tree(folder) < 0) {
1335 alertpanel_error(_("Creation of the mailbox failed."));
1336 folder_destroy(folder);
1342 item = folder_item_new(folder->name, NULL);
1343 item->folder = folder;
1344 folder->node = g_node_new(item);
1346 folder->create_folder(folder, item, "inbox");
1347 folder->create_folder(folder, item, "outbox");
1348 folder->create_folder(folder, item, "queue");
1349 folder->create_folder(folder, item, "draft");
1350 folder->create_folder(folder, item, "trash");
1352 folderview_set(mainwin->folderview);
1357 M_UNLOCKED = 1 << 0,
1358 M_MSG_EXIST = 1 << 1,
1359 M_TARGET_EXIST = 1 << 2,
1360 M_SINGLE_TARGET_EXIST = 1 << 3,
1362 M_ALLOW_REEDIT = 1 << 5,
1363 M_HAVE_ACCOUNT = 1 << 6,
1364 M_THREADED = 1 << 7,
1365 M_UNTHREADED = 1 << 8,
1367 M_HAVE_NEWS_ACCOUNT = 1 << 10
1370 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1372 SensitiveCond state = 0;
1373 SummarySelection selection;
1374 FolderItem *item = mainwin->summaryview->folder_item;
1375 GList *account_list = account_get_list();
1377 selection = summary_get_selection_type(mainwin->summaryview);
1379 if (mainwin->lock_count == 0)
1380 state |= M_UNLOCKED;
1381 if (selection != SUMMARY_NONE)
1382 state |= M_MSG_EXIST;
1385 state |= M_THREADED;
1387 state |= M_UNTHREADED;
1389 if (selection == SUMMARY_SELECTED_SINGLE ||
1390 selection == SUMMARY_SELECTED_MULTIPLE)
1391 state |= M_TARGET_EXIST;
1392 if (selection == SUMMARY_SELECTED_SINGLE)
1393 state |= M_SINGLE_TARGET_EXIST;
1394 if (item && item->folder->type != F_NEWS)
1396 if (mainwin->summaryview->folder_item &&
1397 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1399 if (selection == SUMMARY_SELECTED_SINGLE &&
1401 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1402 item->stype == F_QUEUE)))
1403 state |= M_ALLOW_REEDIT;
1405 state |= M_HAVE_ACCOUNT;
1407 for ( ; account_list != NULL; account_list = account_list->next) {
1408 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1409 state |= M_HAVE_NEWS_ACCOUNT;
1417 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1419 SensitiveCond state;
1427 {mainwin->get_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1428 {mainwin->getall_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1429 {mainwin->compose_mail_btn, M_HAVE_ACCOUNT},
1430 {mainwin->compose_news_btn, M_HAVE_NEWS_ACCOUNT},
1431 {mainwin->reply_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1432 {mainwin->replyall_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1433 {mainwin->replysender_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1434 {mainwin->fwd_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1435 /* {mainwin->prefs_btn , M_UNLOCKED},
1436 {mainwin->account_btn , M_UNLOCKED}, */
1437 {mainwin->next_btn , M_MSG_EXIST},
1438 {mainwin->delete_btn , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1439 {mainwin->exec_btn , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1443 state = main_window_get_current_state(mainwin);
1445 for (i = 0; entry[i].widget != NULL; i++) {
1446 sensitive = ((entry[i].cond & state) == entry[i].cond);
1447 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1450 activate_compose_button(mainwin,
1451 prefs_common.toolbar_style,
1452 mainwin->compose_btn_type);
1455 void main_window_set_menu_sensitive(MainWindow *mainwin)
1457 GtkItemFactory *ifactory;
1458 SensitiveCond state;
1462 static const struct {
1466 {"/File/Add mailbox..." , M_UNLOCKED},
1467 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1468 {"/File/Rescan folder tree" , M_UNLOCKED},
1469 {"/File/Folder" , M_UNLOCKED},
1470 {"/File/Import mbox file..." , M_UNLOCKED},
1471 {"/File/Export to mbox file...", M_UNLOCKED},
1472 {"/File/Empty trash" , M_UNLOCKED},
1473 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1474 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1475 /* {"/File/Close", M_UNLOCKED}, */
1476 {"/File/Exit" , M_UNLOCKED},
1478 {"/View/Sort" , M_MSG_EXIST},
1479 {"/View/Thread view" , M_UNTHREADED},
1480 {"/View/Unthread view" , M_THREADED},
1481 {"/View/Go to" , M_MSG_EXIST},
1482 {"/View/Go to/Prev message" , M_MSG_EXIST},
1483 {"/View/Go to/Next message" , M_MSG_EXIST},
1484 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1485 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1486 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1487 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1488 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1489 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1490 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1491 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1493 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1494 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1495 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1496 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1497 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1498 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1499 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1500 {"/Message/Forward" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1501 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1502 {"/Message/Re-edit", M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1503 {"/Message/Move...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1504 {"/Message/Copy...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1505 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1506 {"/Message/Mark" , M_TARGET_EXIST},
1507 {"/Message/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1509 {"/Tool/Add sender to address book", M_SINGLE_TARGET_EXIST},
1510 {"/Tool/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1511 {"/Tool/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1512 {"/Tool/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1514 {"/Configuration", M_UNLOCKED},
1519 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1520 state = main_window_get_current_state(mainwin);
1522 for (i = 0; entry[i].entry != NULL; i++) {
1523 sensitive = ((entry[i].cond & state) == entry[i].cond);
1524 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1528 void main_window_popup(MainWindow *mainwin)
1534 gdk_window_get_origin(mainwin->window->window, &x, &y);
1535 sx = gdk_screen_width();
1536 sy = gdk_screen_height();
1537 x %= sx; if (x < 0) x = 0;
1538 y %= sy; if (y < 0) y = 0;
1539 gdk_window_move(mainwin->window->window, x, y);
1540 gdk_window_raise(mainwin->window->window);
1541 gdk_window_show(mainwin->window->window);
1543 debug_print("window position: x = %d, y = %d\n", x, y);
1545 switch (mainwin->type) {
1546 case SEPARATE_FOLDER:
1547 widget = mainwin->win.sep_folder.folderwin;
1548 gdk_window_get_origin(widget->window, &x, &y);
1549 x %= sx; if (x < 0) x = 0;
1550 y %= sy; if (y < 0) y = 0;
1551 gdk_window_move(widget->window, x, y);
1552 gdk_window_raise(widget->window);
1554 case SEPARATE_MESSAGE:
1555 widget = mainwin->win.sep_message.messagewin;
1556 gdk_window_get_origin(widget->window, &x, &y);
1557 x %= sx; if (x < 0) x = 0;
1558 y %= sy; if (y < 0) y = 0;
1559 gdk_window_move(widget->window, x, y);
1560 gdk_window_raise(widget->window);
1563 widget = mainwin->win.sep_both.folderwin;
1564 gdk_window_get_origin(widget->window, &x, &y);
1565 x %= sx; if (x < 0) x = 0;
1566 y %= sy; if (y < 0) y = 0;
1567 gdk_window_move(widget->window, x, y);
1568 gdk_window_raise(widget->window);
1569 widget = mainwin->win.sep_both.messagewin;
1570 gdk_window_get_origin(widget->window, &x, &y);
1571 x %= sx; if (x < 0) x = 0;
1572 y %= sy; if (y < 0) y = 0;
1573 gdk_window_move(widget->window, x, y);
1574 gdk_window_raise(widget->window);
1581 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1583 GtkWidget *folderwin = NULL;
1584 GtkWidget *messagewin = NULL;
1587 GtkWidget *vbox_body = mainwin->vbox_body;
1588 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1589 GtkWidget *menuitem;
1591 debug_print(_("Setting widgets..."));
1593 /* create separated window(s) if needed */
1594 if (type & SEPARATE_FOLDER) {
1595 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1596 gtk_window_set_title(GTK_WINDOW(folderwin),
1597 _("Sylpheed - Folder View"));
1598 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1599 "folder_view", "Sylpheed");
1600 gtk_window_set_policy(GTK_WINDOW(folderwin),
1602 gtk_widget_set_usize(folderwin, -1,
1603 prefs_common.mainview_height);
1604 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1606 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1607 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1610 if (type & SEPARATE_MESSAGE) {
1611 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1612 gtk_window_set_title(GTK_WINDOW(messagewin),
1613 _("Sylpheed - Message View"));
1614 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1615 "message_view", "Sylpheed");
1616 gtk_window_set_policy(GTK_WINDOW(messagewin),
1618 gtk_widget_set_usize
1619 (messagewin, prefs_common.mainview_width,
1620 prefs_common.mainview_height
1621 - prefs_common.summaryview_height
1622 + DEFAULT_HEADERVIEW_HEIGHT);
1623 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1625 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1626 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1632 hpaned = gtk_hpaned_new();
1633 gtk_widget_show(hpaned);
1634 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1635 gtk_paned_add1(GTK_PANED(hpaned),
1636 GTK_WIDGET_PTR(mainwin->folderview));
1638 vpaned = gtk_vpaned_new();
1639 if (mainwin->summaryview->msg_is_toggled_on) {
1640 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1641 gtk_paned_add1(GTK_PANED(vpaned),
1642 GTK_WIDGET_PTR(mainwin->summaryview));
1644 gtk_paned_add2(GTK_PANED(hpaned),
1645 GTK_WIDGET_PTR(mainwin->summaryview));
1646 gtk_widget_ref(vpaned);
1648 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1649 prefs_common.summaryview_width,
1650 prefs_common.summaryview_height);
1651 gtk_paned_add2(GTK_PANED(vpaned),
1652 GTK_WIDGET_PTR(mainwin->messageview));
1653 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1654 prefs_common.mainview_width, -1);
1655 gtk_widget_set_usize(mainwin->window,
1656 prefs_common.folderview_width +
1657 prefs_common.mainview_width,
1658 prefs_common.mainwin_height);
1659 gtk_widget_show_all(vpaned);
1661 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1662 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1663 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1664 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1665 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1666 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1668 mainwin->win.sep_none.hpaned = hpaned;
1669 mainwin->win.sep_none.vpaned = vpaned;
1671 case SEPARATE_FOLDER:
1672 vpaned = gtk_vpaned_new();
1673 if (mainwin->summaryview->msg_is_toggled_on) {
1674 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1676 gtk_paned_add1(GTK_PANED(vpaned),
1677 GTK_WIDGET_PTR(mainwin->summaryview));
1679 gtk_box_pack_start(GTK_BOX(vbox_body),
1680 GTK_WIDGET_PTR(mainwin->summaryview),
1682 gtk_widget_ref(vpaned);
1684 gtk_paned_add2(GTK_PANED(vpaned),
1685 GTK_WIDGET_PTR(mainwin->messageview));
1686 gtk_widget_show_all(vpaned);
1687 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1688 prefs_common.summaryview_width,
1689 prefs_common.summaryview_height);
1690 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1691 prefs_common.mainview_width, -1);
1692 gtk_widget_set_usize(mainwin->window,
1693 prefs_common.mainview_width,
1694 prefs_common.mainview_height);
1696 gtk_container_add(GTK_CONTAINER(folderwin),
1697 GTK_WIDGET_PTR(mainwin->folderview));
1699 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1700 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1702 mainwin->win.sep_folder.folderwin = folderwin;
1703 mainwin->win.sep_folder.vpaned = vpaned;
1705 gtk_widget_show_all(folderwin);
1707 case SEPARATE_MESSAGE:
1708 hpaned = gtk_hpaned_new();
1709 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1711 gtk_paned_add1(GTK_PANED(hpaned),
1712 GTK_WIDGET_PTR(mainwin->folderview));
1713 gtk_paned_add2(GTK_PANED(hpaned),
1714 GTK_WIDGET_PTR(mainwin->summaryview));
1715 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1716 prefs_common.summaryview_width,
1717 prefs_common.summaryview_height);
1718 gtk_widget_set_usize(mainwin->window,
1719 prefs_common.folderview_width +
1720 prefs_common.mainview_width,
1721 prefs_common.mainwin_height);
1722 gtk_widget_show_all(hpaned);
1723 gtk_container_add(GTK_CONTAINER(messagewin),
1724 GTK_WIDGET_PTR(mainwin->messageview));
1726 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1727 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1728 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1729 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1731 mainwin->win.sep_message.messagewin = messagewin;
1732 mainwin->win.sep_message.hpaned = hpaned;
1734 gtk_widget_show_all(messagewin);
1737 gtk_box_pack_start(GTK_BOX(vbox_body),
1738 GTK_WIDGET_PTR(mainwin->summaryview),
1740 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1741 prefs_common.summaryview_width,
1742 prefs_common.summaryview_height);
1743 gtk_widget_set_usize(mainwin->window,
1744 prefs_common.mainview_width,
1745 prefs_common.mainwin_height);
1746 gtk_container_add(GTK_CONTAINER(folderwin),
1747 GTK_WIDGET_PTR(mainwin->folderview));
1748 gtk_container_add(GTK_CONTAINER(messagewin),
1749 GTK_WIDGET_PTR(mainwin->messageview));
1751 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1752 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1754 mainwin->win.sep_both.folderwin = folderwin;
1755 mainwin->win.sep_both.messagewin = messagewin;
1757 gtk_widget_show_all(folderwin);
1758 gtk_widget_show_all(messagewin);
1762 mainwin->type = type;
1764 debug_print(_("done.\n"));
1767 static void main_window_toolbar_create(MainWindow *mainwin,
1768 GtkWidget *container)
1771 GtkWidget *icon_wid;
1773 GtkWidget *getall_btn;
1774 GtkWidget *compose_mail_btn;
1775 GtkWidget *compose_news_btn;
1776 GtkWidget *reply_btn;
1777 GtkWidget *replyall_btn;
1778 GtkWidget *replysender_btn;
1780 GtkWidget *send_btn;
1782 GtkWidget *prefs_btn;
1783 GtkWidget *account_btn;
1785 GtkWidget *next_btn;
1786 GtkWidget *delete_btn;
1787 GtkWidget *exec_btn;
1789 GtkTooltips *tooltips;
1791 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1793 gtk_container_add(GTK_CONTAINER(container), toolbar);
1794 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1795 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1796 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1797 GTK_TOOLBAR_SPACE_LINE);
1799 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1800 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1802 _("Get new mail from current account"),
1804 icon_wid, toolbar_inc_cb, mainwin);
1805 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1806 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1808 _("Get new mail from all accounts"),
1814 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1816 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1817 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1819 _("Send queued message(s)"),
1825 /* insert compose mail button widget */
1826 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1827 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1829 _("Compose an email message"),
1832 toolbar_compose_mail_cb,
1835 /* insert compose news button widget */
1836 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1837 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1839 _("Compose a news message"),
1842 toolbar_compose_news_cb,
1845 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1849 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1850 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1852 _("Reply to the message - Right button: more options"),
1858 /* replyall button */
1860 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1861 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1863 _("Reply to all - Right button: more options"),
1866 toolbar_reply_to_all_cb,
1869 /* reply to sender button */
1870 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1871 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1873 _("Reply to sender - Right button: more options"),
1876 toolbar_reply_to_sender_cb,
1879 /* forward button */
1880 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1881 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1883 _("Forward the message - Right button: more options"),
1889 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1891 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1892 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1894 _("Delete the message"),
1900 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1901 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1903 _("Execute marked process"),
1909 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
1910 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1912 _("Next unread message"),
1915 toolbar_next_unread_cb,
1919 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1921 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
1922 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1924 _("Common preference"),
1929 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
1930 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1932 _("Account setting"),
1937 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1938 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1942 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
1943 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
1946 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
1947 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
1950 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
1951 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
1954 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
1955 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
1959 mainwin->toolbar = toolbar;
1960 mainwin->get_btn = get_btn;
1961 mainwin->getall_btn = getall_btn;
1962 mainwin->compose_mail_btn = compose_mail_btn;
1963 mainwin->compose_news_btn = compose_news_btn;
1964 mainwin->reply_btn = reply_btn;
1965 mainwin->replyall_btn = replyall_btn;
1966 mainwin->replysender_btn = replysender_btn;
1967 mainwin->fwd_btn = fwd_btn;
1968 mainwin->send_btn = send_btn;
1970 mainwin->prefs_btn = prefs_btn;
1971 mainwin->account_btn = account_btn;
1973 mainwin->next_btn = next_btn;
1974 mainwin->delete_btn = delete_btn;
1975 mainwin->exec_btn = exec_btn;
1977 gtk_widget_show_all(toolbar);
1980 /* callback functions */
1981 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1983 MainWindow *mainwindow = (MainWindow *) data;
1987 if (event->button == 3) {
1988 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1989 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
1990 menu_button_position, widget,
1991 event->button, event->time);
1995 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
1997 MainWindow *mainwin = (MainWindow *)data;
1999 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2000 manage_window_focus_in(mainwin->window, NULL, NULL);
2003 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2005 MainWindow *mainwindow = (MainWindow *) data;
2009 if (event->button == 3) {
2010 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2011 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2012 menu_button_position, widget,
2013 event->button, event->time);
2017 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2019 MainWindow *mainwin = (MainWindow *)data;
2021 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2022 manage_window_focus_in(mainwin->window, NULL, NULL);
2025 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2027 MainWindow *mainwindow = (MainWindow *) data;
2028 GtkWidget *replysender_menu, *replysender_item;
2032 if (event->button == 3) {
2033 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2034 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2035 menu_button_position, widget,
2036 event->button, event->time);
2040 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2042 MainWindow *mainwin = (MainWindow *)data;
2044 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2045 manage_window_focus_in(mainwin->window, NULL, NULL);
2048 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2050 MainWindow *mainwindow = (MainWindow *) data;
2054 if (event->button == 3) {
2055 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2056 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2057 menu_button_position, widget,
2058 event->button, event->time);
2062 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2064 MainWindow *mainwin = (MainWindow *)data;
2066 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2067 manage_window_focus_in(mainwin->window, NULL, NULL);
2070 static void toolbar_inc_cb (GtkWidget *widget,
2073 MainWindow *mainwin = (MainWindow *)data;
2075 inc_mail_cb(mainwin, 0, NULL);
2078 static void toolbar_inc_all_cb (GtkWidget *widget,
2081 MainWindow *mainwin = (MainWindow *)data;
2083 inc_all_account_mail_cb(mainwin, 0, NULL);
2086 static void toolbar_send_cb (GtkWidget *widget,
2089 MainWindow *mainwin = (MainWindow *)data;
2091 send_queue_cb(mainwin, 0, NULL);
2094 static void toolbar_compose_cb (GtkWidget *widget,
2097 MainWindow *mainwin = (MainWindow *)data;
2099 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2100 compose_cb(mainwin, 0, NULL);
2102 compose_news_cb(mainwin, 0, NULL);
2105 static void toolbar_compose_news_cb (GtkWidget *widget,
2108 MainWindow *mainwin = (MainWindow *)data;
2110 compose_news_cb(mainwin, 0, NULL);
2113 static void toolbar_compose_mail_cb (GtkWidget *widget,
2116 MainWindow *mainwin = (MainWindow *)data;
2118 compose_mail_cb(mainwin, 0, NULL);
2121 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2123 MainWindow *mainwin = (MainWindow *)data;
2126 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2127 : COMPOSE_REPLY_WITHOUT_QUOTE,
2131 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2133 MainWindow *mainwin = (MainWindow *)data;
2136 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2137 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2142 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2144 MainWindow *mainwin = (MainWindow *)data;
2147 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2148 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2152 static void toolbar_forward_cb (GtkWidget *widget,
2155 MainWindow *mainwin = (MainWindow *)data;
2157 if (prefs_common.forward_as_attachment)
2158 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2160 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2163 static void toolbar_delete_cb (GtkWidget *widget,
2166 MainWindow *mainwin = (MainWindow *)data;
2168 summary_delete(mainwin->summaryview);
2171 static void toolbar_exec_cb (GtkWidget *widget,
2174 MainWindow *mainwin = (MainWindow *)data;
2176 summary_execute(mainwin->summaryview);
2179 static void toolbar_next_unread_cb (GtkWidget *widget,
2182 MainWindow *mainwin = (MainWindow *)data;
2184 next_unread_cb(mainwin, 0, NULL);
2187 static void toolbar_prefs_cb (GtkWidget *widget,
2190 prefs_common_open();
2193 static void toolbar_account_cb (GtkWidget *widget,
2196 MainWindow *mainwin = (MainWindow *)data;
2198 prefs_account_open_cb(mainwin, 0, NULL);
2201 static void toolbar_account_button_pressed(GtkWidget *widget,
2202 GdkEventButton *event,
2205 MainWindow *mainwin = (MainWindow *)data;
2208 if (event->button != 3) return;
2210 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2211 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2214 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2215 menu_button_position, widget,
2216 event->button, event->time);
2219 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2222 MainWindow *mainwin = (MainWindow *)data;
2226 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2227 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2230 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2231 menu_button_position, widget,
2232 event->button, event->time);
2235 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2237 MainWindow *mainwin = (MainWindow *)data;
2240 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2241 if (!button) return;
2242 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2243 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2244 manage_window_focus_in(mainwin->window, NULL, NULL);
2247 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2250 MainWindow *mainwin = (MainWindow *)data;
2252 if (mainwin->lock_count == 0)
2253 app_exit_cb(data, 0, widget);
2258 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2261 main_window_add_mailbox(mainwin);
2264 static void add_mbox_cb(MainWindow *mainwin, guint action,
2267 main_window_add_mbox(mainwin);
2270 static void update_folderview_cb(MainWindow *mainwin, guint action,
2273 summary_show(mainwin->summaryview, NULL, FALSE);
2274 folderview_update_all();
2277 static void new_folder_cb(MainWindow *mainwin, guint action,
2280 folderview_new_folder(mainwin->folderview);
2283 static void rename_folder_cb(MainWindow *mainwin, guint action,
2286 folderview_rename_folder(mainwin->folderview);
2289 static void delete_folder_cb(MainWindow *mainwin, guint action,
2292 folderview_delete_folder(mainwin->folderview);
2295 static void import_mbox_cb(MainWindow *mainwin, guint action,
2298 import_mbox(mainwin->summaryview->folder_item);
2301 static void export_mbox_cb(MainWindow *mainwin, guint action,
2304 export_mbox(mainwin->summaryview->folder_item);
2307 static void empty_trash_cb(MainWindow *mainwin, guint action,
2310 main_window_empty_trash(mainwin, TRUE);
2313 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2315 summary_save_as(mainwin->summaryview);
2318 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2320 summary_print(mainwin->summaryview);
2323 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2325 if (prefs_common.confirm_on_exit) {
2326 if (alertpanel(_("Exit"), _("Exit this program?"),
2327 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2329 manage_window_focus_in(mainwin->window, NULL, NULL);
2332 app_will_exit(widget, mainwin);
2335 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2338 summary_search(mainwin->summaryview);
2340 message_search(mainwin->messageview);
2343 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2346 switch (mainwin->type) {
2348 case SEPARATE_MESSAGE:
2350 case SEPARATE_FOLDER:
2351 if (GTK_CHECK_MENU_ITEM(widget)->active)
2352 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2354 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2357 if (GTK_CHECK_MENU_ITEM(widget)->active)
2358 gtk_widget_show(mainwin->win.sep_both.folderwin);
2360 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2365 static void toggle_message_cb(MainWindow *mainwin, guint action,
2368 switch (mainwin->type) {
2370 case SEPARATE_FOLDER:
2372 case SEPARATE_MESSAGE:
2373 if (GTK_CHECK_MENU_ITEM(widget)->active)
2374 gtk_widget_show(mainwin->win.sep_message.messagewin);
2376 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2379 if (GTK_CHECK_MENU_ITEM(widget)->active)
2380 gtk_widget_show(mainwin->win.sep_both.messagewin);
2382 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2387 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2390 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2391 mainwin->compose_btn_type);
2392 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2393 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2394 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2395 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2397 switch ((ToolbarStyle)action) {
2399 gtk_widget_hide(mainwin->handlebox);
2401 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2405 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2409 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2414 if (action != TOOLBAR_NONE) {
2415 gtk_widget_show(mainwin->handlebox);
2416 gtk_widget_queue_resize(mainwin->handlebox);
2419 mainwin->toolbar_style = (ToolbarStyle)action;
2420 prefs_common.toolbar_style = (ToolbarStyle)action;
2423 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2426 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2427 gtk_widget_show(mainwin->hbox_stat);
2428 prefs_common.show_statusbar = TRUE;
2430 gtk_widget_hide(mainwin->hbox_stat);
2431 prefs_common.show_statusbar = FALSE;
2435 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2437 summary_toggle_view_real(mainwin->summaryview);
2440 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2442 messageview_toggle_view_real(mainwin->messageview);
2445 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2448 MainWindow *mainwin;
2451 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2452 g_return_if_fail(mainwin != NULL);
2454 type = mainwin->type ^ action;
2455 main_window_separation_change(mainwin, type);
2457 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2458 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2461 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2464 addressbook_open(NULL);
2467 static void log_window_show_cb(MainWindow *mainwin, guint action,
2470 log_window_show(mainwin->logwin);
2473 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2478 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2481 inc_all_account_mail(mainwin);
2484 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2488 if (procmsg_send_queue() < 0)
2489 alertpanel_error(_("Some errors occurred while sending queued messages."));
2491 statusbar_pop_all();
2493 for (list = folder_get_list(); list != NULL; list = list->next) {
2496 folder = list->data;
2497 if (folder->queue) {
2498 folder_item_scan(folder->queue);
2499 folderview_update_item(folder->queue, TRUE);
2504 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2506 if (mainwin->summaryview->folder_item) {
2507 if (mainwin->summaryview->folder_item->folder->account != NULL
2508 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2509 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2511 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2517 static void compose_mail_cb(MainWindow *mainwin, guint action,
2524 if (mainwin->summaryview->folder_item) {
2525 ac = mainwin->summaryview->folder_item->folder->account;
2526 if (ac && ac->protocol != A_NNTP) {
2527 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2532 if(cur_account && (cur_account->protocol != A_NNTP)) {
2533 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2537 list = account_get_list();
2538 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2539 ac = (PrefsAccount *) cur->data;
2540 if (ac->protocol != A_NNTP) {
2541 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2547 static void compose_news_cb(MainWindow *mainwin, guint action,
2550 PrefsAccount * ac = NULL;
2554 if (mainwin->summaryview->folder_item) {
2555 ac = mainwin->summaryview->folder_item->folder->account;
2556 if (ac && ac->protocol == A_NNTP) {
2557 compose_new_with_recipient
2558 (ac, mainwin->summaryview->folder_item->path);
2563 list = account_get_list();
2564 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2565 ac = (PrefsAccount *) cur->data;
2566 if (ac->protocol == A_NNTP) {
2573 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2575 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2578 msginfo = gtk_ctree_node_get_row_data
2579 (GTK_CTREE(mainwin->summaryview->ctree),
2580 mainwin->summaryview->selected);
2582 if (!msginfo) return;
2586 compose_reply(msginfo, prefs_common.reply_with_quote,
2589 case COMPOSE_REPLY_WITH_QUOTE:
2590 compose_reply(msginfo, TRUE, FALSE, FALSE);
2592 case COMPOSE_REPLY_WITHOUT_QUOTE:
2593 compose_reply(msginfo, FALSE, FALSE, FALSE);
2595 case COMPOSE_REPLY_TO_SENDER:
2596 compose_reply(msginfo, prefs_common.reply_with_quote,
2599 case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE:
2600 compose_reply(msginfo, TRUE, FALSE, TRUE);
2602 case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE:
2603 compose_reply(msginfo, FALSE, FALSE, TRUE);
2605 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2606 compose_followup_and_reply_to(msginfo,
2607 prefs_common.reply_with_quote,
2610 case COMPOSE_REPLY_TO_ALL:
2611 compose_reply(msginfo, prefs_common.reply_with_quote,
2614 case COMPOSE_REPLY_TO_ALL_WITH_QUOTE:
2615 compose_reply(msginfo, TRUE, TRUE, TRUE);
2617 case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE:
2618 compose_reply(msginfo, FALSE, TRUE, TRUE);
2620 case COMPOSE_FORWARD:
2621 if (prefs_common.forward_as_attachment) {
2622 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, widget);
2625 reply_cb(mainwin, COMPOSE_FORWARD_INLINE, widget);
2629 case COMPOSE_FORWARD_INLINE:
2631 compose_forward(NULL, msginfo, FALSE);
2634 /* if (sel->next) FALL_THROUGH */
2635 case COMPOSE_FORWARD_AS_ATTACH:
2637 GSList *msginfo_list = NULL;
2638 for ( ; sel != NULL; sel = sel->next)
2639 msginfo_list = g_slist_append(msginfo_list,
2640 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2641 GTK_CTREE_NODE(sel->data)));
2642 compose_forward_multiple(NULL, msginfo_list);
2643 g_slist_free(msginfo_list);
2646 case COMPOSE_BOUNCE:
2647 compose_bounce(NULL, msginfo);
2650 g_warning("reply_cb(): invalid action type: %d\n", action);
2653 summary_set_marks_selected(mainwin->summaryview);
2656 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2658 summary_move_to(mainwin->summaryview);
2661 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2663 summary_copy_to(mainwin->summaryview);
2666 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2668 summary_delete(mainwin->summaryview);
2671 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2673 summary_open_msg(mainwin->summaryview);
2676 static void view_source_cb(MainWindow *mainwin, guint action,
2679 summary_view_source(mainwin->summaryview);
2682 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2684 summary_reedit(mainwin->summaryview);
2687 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2689 summary_mark(mainwin->summaryview);
2692 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2694 summary_unmark(mainwin->summaryview);
2697 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2700 summary_mark_as_unread(mainwin->summaryview);
2703 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2706 summary_mark_as_read(mainwin->summaryview);
2709 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2712 summary_mark_all_read(mainwin->summaryview);
2715 static void add_address_cb(MainWindow *mainwin, guint action,
2718 summary_add_address(mainwin->summaryview);
2721 static void set_charset_cb(MainWindow *mainwin, guint action,
2726 str = conv_get_charset_str((CharSet)action);
2727 g_free(prefs_common.force_charset);
2728 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2730 summary_redisplay_msg(mainwin->summaryview);
2732 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2735 static void hide_read_messages (MainWindow *mainwin, guint action,
2738 if (!mainwin->summaryview->folder_item
2739 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2741 summary_toggle_show_read_messages(mainwin->summaryview);
2744 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2746 GtkItemFactory *ifactory;
2748 if (!mainwin->summaryview->folder_item) return;
2750 ifactory = gtk_item_factory_from_widget(widget);
2753 summary_thread_build(mainwin->summaryview);
2754 mainwin->summaryview->folder_item->threaded = TRUE;
2755 menu_set_sensitive(ifactory, "/View/Thread view", FALSE);
2756 menu_set_sensitive(ifactory, "/View/Unthread view", TRUE);
2758 summary_unthread(mainwin->summaryview);
2759 mainwin->summaryview->folder_item->threaded = FALSE;
2760 menu_set_sensitive(ifactory, "/View/Thread view", TRUE);
2761 menu_set_sensitive(ifactory, "/View/Unthread view", FALSE);
2765 static void set_display_item_cb(MainWindow *mainwin, guint action,
2768 prefs_summary_column_open();
2771 static void sort_summary_cb(MainWindow *mainwin, guint action,
2774 summary_sort(mainwin->summaryview, (SummarySortType)action);
2777 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2780 summary_attract_by_subject(mainwin->summaryview);
2783 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2786 summary_delete_duplicated(mainwin->summaryview);
2789 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2791 summary_filter(mainwin->summaryview);
2794 static void execute_summary_cb(MainWindow *mainwin, guint action,
2797 summary_execute(mainwin->summaryview);
2800 static void update_summary_cb(MainWindow *mainwin, guint action,
2804 FolderView *folderview = mainwin->folderview;
2806 if (!mainwin->summaryview->folder_item) return;
2807 if (!folderview->opened) return;
2809 folder_update_op_count();
2811 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2812 folderview->opened);
2815 summary_show(mainwin->summaryview, fitem, TRUE);
2818 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2820 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2823 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2825 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2828 static void prev_unread_cb(MainWindow *mainwin, guint action,
2831 summary_select_prev_unread(mainwin->summaryview);
2834 static void next_unread_cb(MainWindow *mainwin, guint action,
2837 summary_select_next_unread(mainwin->summaryview);
2840 static void prev_marked_cb(MainWindow *mainwin, guint action,
2843 summary_select_prev_marked(mainwin->summaryview);
2846 static void next_marked_cb(MainWindow *mainwin, guint action,
2849 summary_select_next_marked(mainwin->summaryview);
2852 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2855 summary_select_prev_labeled(mainwin->summaryview);
2858 static void next_labeled_cb(MainWindow *mainwin, guint action,
2861 summary_select_next_labeled(mainwin->summaryview);
2864 static void goto_folder_cb(MainWindow *mainwin, guint action,
2867 FolderItem *to_folder;
2869 to_folder = foldersel_folder_sel(NULL, NULL);
2872 folderview_select(mainwin->folderview, to_folder);
2875 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2877 messageview_copy_clipboard(mainwin->messageview);
2880 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2882 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2883 summary_select_all(mainwin->summaryview);
2884 else if (mainwin->summaryview->msg_is_toggled_on &&
2885 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2886 messageview_select_all(mainwin->messageview);
2889 static void create_filter_cb(MainWindow *mainwin, guint action,
2892 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2895 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2898 prefs_common_open();
2901 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2904 prefs_filter_open(NULL, NULL);
2907 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2910 prefs_scoring_open(NULL);
2913 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2916 prefs_filtering_open(NULL);
2919 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2922 prefs_template_open();
2925 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2929 new_account_cb(mainwin, 0, widget);
2931 gboolean prev_default = cur_account->is_default;
2933 prefs_account_open(cur_account);
2934 if (!prev_default && cur_account->is_default)
2935 account_set_as_default(cur_account);
2936 account_save_config_all();
2938 main_window_reflect_prefs_all();
2942 static void new_account_cb(MainWindow *mainwin, guint action,
2945 account_edit_open();
2946 if (!compose_get_compose_list()) account_add();
2949 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2951 cur_account = (PrefsAccount *)data;
2952 main_window_reflect_prefs_all();
2955 static void manual_open_cb(MainWindow *mainwin, guint action,
2958 manual_open((ManualLang)action);
2961 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2963 MainWindow *mainwin = (MainWindow *)data;
2967 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2968 LOCAL_FOLDER(folder)->rootpath,
2972 str = g_strdup_printf(_("Scanning folder %s ..."),
2973 LOCAL_FOLDER(folder)->rootpath);
2975 STATUSBAR_PUSH(mainwin, str);
2976 STATUSBAR_POP(mainwin);
2980 static void activate_compose_button (MainWindow *mainwin,
2982 ComposeButtonType type)
2984 SensitiveCond state = main_window_get_current_state(mainwin);
2986 if (style == TOOLBAR_NONE)
2989 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2990 : mainwin->compose_news_btn);
2991 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2992 : mainwin->compose_mail_btn);
2993 mainwin->compose_btn_type = type;
2996 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2998 if (mainwin->compose_btn_type != compose_btn_type)
2999 activate_compose_button(mainwin,
3000 prefs_common.toolbar_style,
3004 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
3006 MainWindow *mainwin = (MainWindow*) data;
3008 if (!mainwin) return;
3010 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
3013 #define BREAK_ON_MODIFIER_KEY() \
3014 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3016 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3018 MainWindow *mainwin = (MainWindow*) data;
3020 if (!mainwin || !event) return;
3022 switch (event->keyval) {
3023 case GDK_Q: /* Quit */
3024 BREAK_ON_MODIFIER_KEY();
3026 app_exit_cb(mainwin, 0, NULL);
3033 #undef BREAK_ON_MODIFIER_KEY