2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2001 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 prefs_common_open_cb (MainWindow *mainwin,
390 static void prefs_filter_open_cb (MainWindow *mainwin,
393 static void prefs_scoring_open_cb (MainWindow *mainwin,
396 static void prefs_filtering_open_cb (MainWindow *mainwin,
399 static void prefs_account_open_cb(MainWindow *mainwin,
402 static void prefs_template_open_cb (MainWindow *mainwin,
405 static void new_account_cb (MainWindow *mainwin,
409 static void account_menu_cb (GtkMenuItem *menuitem,
412 static void manual_open_cb (MainWindow *mainwin,
416 static void scan_tree_func (Folder *folder,
420 static void activate_compose_button (MainWindow *mainwin,
422 ComposeButtonType type);
424 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
428 static void key_pressed (GtkWidget *widget,
432 #define SEPARATE_ACTION 667
434 static GtkItemFactoryEntry mainwin_entries[] =
436 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
437 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
438 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
439 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
440 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
441 {N_("/_File/_Folder/Create _new folder..."),
442 NULL, new_folder_cb, 0, NULL},
443 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
444 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
445 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
446 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
447 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
448 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
449 {N_("/_File/_Save as..."), "y", save_as_cb, 0, NULL},
450 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
451 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
452 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
454 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
455 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
456 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
457 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
458 {N_("/_Edit/_Find in current message..."),
459 "<control>F", search_cb, 0, NULL},
460 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
462 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
463 {N_("/_View/_Folder tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
464 {N_("/_View/_Message view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
465 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
466 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
467 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
468 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
469 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
470 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
471 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
472 {N_("/_View/Status _bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
473 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
474 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
475 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
476 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
477 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
478 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
479 {N_("/_View/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
480 {N_("/_View/_Sort/Sort by _color label"),
481 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
482 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
483 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
484 {N_("/_View/_Sort/Sort by a_ttachment"),
485 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
486 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
487 {N_("/_View/_Sort/_Attract by subject"),
488 NULL, attract_by_subject_cb, 0, NULL},
489 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, NULL},
490 {N_("/_View/U_nthread view"), "<shift><control>T", thread_cb, 1, NULL},
491 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
492 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
493 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
495 #define CODESET_SEPARATOR \
496 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
497 #define CODESET_ACTION(action) \
498 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
500 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
501 {N_("/_View/_Code set/_Auto detect"),
502 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
503 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
504 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
505 CODESET_ACTION(C_US_ASCII)},
508 {N_("/_View/_Code set/Unicode (_UTF-8)"),
509 CODESET_ACTION(C_UTF_8)},
512 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
513 CODESET_ACTION(C_ISO_8859_1)},
516 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
517 CODESET_ACTION(C_ISO_8859_2)},
519 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
520 CODESET_ACTION(C_ISO_8859_13)},
521 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
522 CODESET_ACTION(C_ISO_8859_4)},
524 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
525 CODESET_ACTION(C_ISO_8859_7)},
527 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
528 CODESET_ACTION(C_ISO_8859_9)},
530 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
531 CODESET_ACTION(C_ISO_8859_5)},
532 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
533 CODESET_ACTION(C_KOI8_R)},
534 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
535 CODESET_ACTION(C_CP1251)},
538 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
539 CODESET_ACTION(C_ISO_2022_JP)},
541 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
542 CODESET_ACTION(C_ISO_2022_JP_2)},
544 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
545 CODESET_ACTION(C_EUC_JP)},
546 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
547 CODESET_ACTION(C_SHIFT_JIS)},
550 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
551 CODESET_ACTION(C_GB2312)},
552 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
553 CODESET_ACTION(C_BIG5)},
554 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
555 CODESET_ACTION(C_EUC_TW)},
556 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
557 CODESET_ACTION(C_ISO_2022_CN)},
559 {N_("/_View/_Code set/Korean (EUC-_KR)"),
560 CODESET_ACTION(C_EUC_KR)},
561 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
562 CODESET_ACTION(C_ISO_2022_KR)},
564 {N_("/_View/_Code set/Thai (TIS-620)"),
565 CODESET_ACTION(C_TIS_620)},
566 {N_("/_View/_Code set/Thai (Windows-874)"),
567 CODESET_ACTION(C_WINDOWS_874)},
570 #undef CODESET_SEPARATOR
571 #undef CODESET_ACTION
573 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
574 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
575 {N_("/_View/_Go to/_Prev message"), "p", prev_cb, 0, NULL},
576 {N_("/_View/_Go to/_Next message"), "n", next_cb, 0, NULL},
577 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
578 {N_("/_View/_Go to/P_rev unread message"),
579 "<shift>P", prev_unread_cb, 0, NULL},
580 {N_("/_View/_Go to/N_ext unread message"),
581 "<shift>N", next_unread_cb, 0, NULL},
582 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
583 {N_("/_View/_Go to/Prev _marked message"),
584 NULL, prev_marked_cb, 0, NULL},
585 {N_("/_View/_Go to/Next m_arked message"),
586 NULL, next_marked_cb, 0, NULL},
587 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
588 {N_("/_View/_Go to/Prev _labeled message"),
589 NULL, prev_labeled_cb, 0, NULL},
590 {N_("/_View/_Go to/Next la_beled message"),
591 NULL, next_labeled_cb, 0, NULL},
592 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
593 {N_("/_View/_Go to/Other _folder..."), "<alt>G", goto_folder_cb, 0, NULL},
594 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
595 {N_("/_View/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
596 {N_("/_View/_View source"), "<control>U", view_source_cb, 0, NULL},
597 {N_("/_View/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
598 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
599 {N_("/_View/_Update"), "<control><alt>U", update_summary_cb, 0, NULL},
601 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
602 {N_("/_Message/Get new ma_il"), "<control><alt>I", inc_mail_cb, 0, NULL},
603 {N_("/_Message/Get from _all accounts"),
604 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
605 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
606 {N_("/_Message/Send queued messa_ges"),
607 NULL, send_queue_cb, 0, NULL},
608 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
609 {N_("/_Message/Compose a_n email message"), "w", compose_mail_cb, 0, NULL},
610 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
611 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
612 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
613 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
614 {N_("/_Message/Reply to a_ll"), "<control><shift>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
615 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
616 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
617 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
618 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
619 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_Message/M_ove..."), "o", move_to_cb, 0, NULL},
621 {N_("/_Message/_Copy..."), "<shift>O", copy_to_cb, 0, NULL},
622 {N_("/_Message/_Delete"), "d", delete_cb, 0, NULL},
623 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
624 {N_("/_Message/Delete du_plicated messages"),
625 NULL, delete_duplicated_cb, 0, NULL},
626 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
627 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
628 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
629 {N_("/_Message/_Mark/_Unmark"), "u", unmark_cb, 0, NULL},
630 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
631 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
632 {N_("/_Message/_Mark/Mark as rea_d"),
633 NULL, mark_as_read_cb, 0, NULL},
634 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
636 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
637 {N_("/_Tool/_Address book"), "<control><alt>A", addressbook_open_cb, 0, NULL},
638 {N_("/_Tool/Add sender to address boo_k"),
639 NULL, add_address_cb, 0, NULL},
640 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
641 {N_("/_Tool/_Filter messages"), NULL, filter_cb, 0, NULL},
642 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
643 {N_("/_Tool/E_xecute"), "x", execute_summary_cb, 0, NULL},
644 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
645 {N_("/_Tool/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
647 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
648 {N_("/_Configuration/_Common preferences..."),
649 NULL, prefs_common_open_cb, 0, NULL},
650 {N_("/_Configuration/_Filter setting..."),
651 NULL, prefs_filter_open_cb, 0, NULL},
652 {N_("/_Configuration/_Scoring ..."),
653 NULL, prefs_scoring_open_cb, 0, NULL},
654 {N_("/_Configuration/_Filtering ..."),
655 NULL, prefs_filtering_open_cb, 0, NULL},
656 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
657 {N_("/_Configuration/_Preferences for current account..."),
658 NULL, prefs_account_open_cb, 0, NULL},
659 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
660 {N_("/_Configuration/Create _new account..."),
661 NULL, new_account_cb, 0, NULL},
662 {N_("/_Configuration/_Edit accounts..."),
663 NULL, account_edit_open, 0, NULL},
664 {N_("/_Configuration/C_hange current account"),
665 NULL, NULL, 0, "<Branch>"},
667 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
668 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
669 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
670 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
671 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
672 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
674 static GtkItemFactoryEntry reply_popup_entries[] =
676 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
677 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
679 static GtkItemFactoryEntry replyall_popup_entries[] =
681 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
682 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
684 static GtkItemFactoryEntry replysender_popup_entries[] =
686 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
687 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
689 static GtkItemFactoryEntry fwd_popup_entries[] =
691 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
692 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
696 MainWindow *main_window_create(SeparateType type)
702 GtkWidget *handlebox;
703 GtkWidget *vbox_body;
704 GtkWidget *hbox_stat;
705 GtkWidget *statusbar;
706 GtkWidget *progressbar;
707 GtkWidget *statuslabel;
708 GtkWidget *ac_button;
711 FolderView *folderview;
712 SummaryView *summaryview;
713 MessageView *messageview;
714 GdkColormap *colormap;
717 guint n_menu_entries;
718 GtkItemFactory *ifactory;
721 GtkWidget *compose_popup;
722 GtkWidget *reply_popup;
723 GtkWidget *replyall_popup;
724 GtkWidget *replysender_popup;
725 GtkWidget *fwd_popup;
728 debug_print(_("Creating main window...\n"));
729 mainwin = g_new0(MainWindow, 1);
732 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
733 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
734 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
735 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
736 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
737 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
738 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
739 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
740 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
741 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
742 GTK_SIGNAL_FUNC(key_pressed), mainwin);
744 gtk_widget_realize(window);
745 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
747 gtkut_widget_set_app_icon(window);
749 vbox = gtk_vbox_new(FALSE, 0);
750 gtk_widget_show(vbox);
751 gtk_container_add(GTK_CONTAINER(window), vbox);
754 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
755 menubar = menubar_create(window, mainwin_entries,
756 n_menu_entries, "<Main>", mainwin);
757 gtk_widget_show(menubar);
758 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
760 handlebox = gtk_handle_box_new();
761 gtk_widget_show(handlebox);
762 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
764 /* create the popup menus for the reply buttons specials */
765 n_menu_entries = sizeof(reply_popup_entries) /
766 sizeof(reply_popup_entries[0]);
767 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
768 "<ReplyPopup>", mainwin);
769 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
770 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
771 n_menu_entries = sizeof(replyall_popup_entries) /
772 sizeof(replyall_popup_entries[0]);
773 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
774 "<ReplyAllPopup>", mainwin);
775 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
776 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
777 n_menu_entries = sizeof(replysender_popup_entries) /
778 sizeof(replysender_popup_entries[0]);
779 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
780 "<ReplySenderPopup>", mainwin);
781 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
782 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
783 /* create the popup menu for the forward button */
784 n_menu_entries = sizeof(fwd_popup_entries) /
785 sizeof(fwd_popup_entries[0]);
786 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
787 "<ForwardPopup>", mainwin);
788 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
789 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
791 main_window_toolbar_create(mainwin, handlebox);
793 /* vbox that contains body */
794 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
795 gtk_widget_show(vbox_body);
796 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
797 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
799 hbox_stat = gtk_hbox_new(FALSE, 2);
800 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
802 statusbar = statusbar_create();
803 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
805 progressbar = gtk_progress_bar_new();
806 gtk_widget_set_usize(progressbar, 120, 1);
807 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
809 statuslabel = gtk_label_new("");
810 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
812 ac_button = gtk_button_new();
813 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
814 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
815 gtk_widget_set_usize(ac_button, -1, 1);
816 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
817 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
818 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
820 ac_label = gtk_label_new("");
821 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
823 gtk_widget_show_all(hbox_stat);
826 mainwin->folderview = folderview = folderview_create();
827 mainwin->summaryview = summaryview = summary_create();
828 mainwin->messageview = messageview = messageview_create();
829 mainwin->headerwin = header_window_create();
830 mainwin->logwin = log_window_create();
832 folderview->mainwin = mainwin;
833 folderview->summaryview = summaryview;
835 summaryview->mainwin = mainwin;
836 summaryview->folderview = folderview;
837 summaryview->messageview = messageview;
838 summaryview->headerwin = mainwin->headerwin;
839 summaryview->window = window;
841 messageview->mainwin = mainwin;
843 mainwin->window = window;
844 mainwin->vbox = vbox;
845 mainwin->menubar = menubar;
846 mainwin->handlebox = handlebox;
847 mainwin->vbox_body = vbox_body;
848 mainwin->hbox_stat = hbox_stat;
849 mainwin->statusbar = statusbar;
850 mainwin->progressbar = progressbar;
851 mainwin->statuslabel = statuslabel;
852 mainwin->ac_button = ac_button;
853 mainwin->ac_label = ac_label;
854 mainwin->reply_popup = reply_popup;
855 mainwin->replyall_popup = replyall_popup;
856 mainwin->replysender_popup = replysender_popup;
857 mainwin->fwd_popup = fwd_popup;
859 /* set context IDs for status bar */
860 mainwin->mainwin_cid = gtk_statusbar_get_context_id
861 (GTK_STATUSBAR(statusbar), "Main Window");
862 mainwin->folderview_cid = gtk_statusbar_get_context_id
863 (GTK_STATUSBAR(statusbar), "Folder View");
864 mainwin->summaryview_cid = gtk_statusbar_get_context_id
865 (GTK_STATUSBAR(statusbar), "Summary View");
867 /* allocate colors for summary view and folder view */
868 summaryview->color_marked.red = summaryview->color_marked.green = 0;
869 summaryview->color_marked.blue = (guint16)65535;
871 summaryview->color_dim.red = summaryview->color_dim.green =
872 summaryview->color_dim.blue = COLOR_DIM;
874 folderview->color_new.red = (guint16)55000;
875 folderview->color_new.green = folderview->color_new.blue = 15000;
877 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
878 &folderview->color_op);
880 summaryview->color_important.red = 0;
881 summaryview->color_marked.green = 0;
882 summaryview->color_important.blue = (guint16)65535;
884 color[0] = summaryview->color_marked;
885 color[1] = summaryview->color_dim;
886 color[2] = folderview->color_new;
887 color[3] = folderview->color_op;
889 colormap = gdk_window_get_colormap(window->window);
890 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
891 for (i = 0; i < 4; i++) {
892 if (success[i] == FALSE)
893 g_warning(_("MainWindow: color allocation %d failed\n"), i);
896 debug_print(_("done.\n"));
898 main_window_set_widgets(mainwin, type);
901 ifactory = gtk_item_factory_from_widget(menubar);
902 menuitem = gtk_item_factory_get_item
903 (ifactory, "/View/Code set/Auto detect");
904 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
906 switch (prefs_common.toolbar_style) {
908 menuitem = gtk_item_factory_get_item
909 (ifactory, "/View/Toolbar/None");
912 menuitem = gtk_item_factory_get_item
913 (ifactory, "/View/Toolbar/Icon");
916 menuitem = gtk_item_factory_get_item
917 (ifactory, "/View/Toolbar/Text");
920 menuitem = gtk_item_factory_get_item
921 (ifactory, "/View/Toolbar/Icon and text");
923 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
925 gtk_widget_hide(mainwin->hbox_stat);
926 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
927 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
928 prefs_common.show_statusbar);
929 #if 0 /* FIXED SEPARATE WINDOWS */
930 /* Message view and Folder tree are always shown at startup
931 * make that in the menu visible */
932 menuitem = gtk_item_factory_get_item(ifactory, "/View/Message view");
933 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
934 menuitem = gtk_item_factory_get_item(ifactory, "/View/Folder tree");
935 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
937 /* set the check of the SEPARATE_xxx menu items. we also need the main window
938 * as a property and pass the action type to the callback */
939 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
941 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
942 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
943 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
944 GUINT_TO_POINTER(SEPARATE_FOLDER));
946 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
948 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
949 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
950 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
951 GUINT_TO_POINTER(SEPARATE_MESSAGE));
953 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
954 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
957 menu_set_sensitive(ifactory, "/View/Thread view",
958 prefs_common.enable_thread ? FALSE : TRUE);
959 menu_set_sensitive(ifactory, "/View/Unthread view",
960 prefs_common.enable_thread ? TRUE : FALSE);
962 /* set account selection menu */
963 ac_menu = gtk_item_factory_get_widget
964 (ifactory, "/Configuration/Change current account");
965 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
966 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
967 mainwin->ac_menu = ac_menu;
969 main_window_set_toolbar_sensitive(mainwin);
971 /* show main window */
972 gtk_widget_set_uposition(mainwin->window,
973 prefs_common.mainwin_x,
974 prefs_common.mainwin_y);
975 gtk_widget_set_usize(window, prefs_common.mainwin_width,
976 prefs_common.mainwin_height);
977 gtk_widget_show(mainwin->window);
979 /* initialize views */
980 folderview_init(folderview);
981 summary_init(summaryview);
982 messageview_init(messageview);
983 header_window_init(mainwin->headerwin);
984 log_window_init(mainwin->logwin);
986 mainwin->lock_count = 0;
987 mainwin->cursor_count = 0;
990 watch_cursor = gdk_cursor_new(GDK_WATCH);
992 mainwin_list = g_list_append(mainwin_list, mainwin);
997 void main_window_cursor_wait(MainWindow *mainwin)
1000 if (mainwin->cursor_count == 0)
1001 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1003 mainwin->cursor_count++;
1008 void main_window_cursor_normal(MainWindow *mainwin)
1010 if (mainwin->cursor_count)
1011 mainwin->cursor_count--;
1013 if (mainwin->cursor_count == 0)
1014 gdk_window_set_cursor(mainwin->window->window, NULL);
1019 /* lock / unlock the user-interface */
1020 void main_window_lock(MainWindow *mainwin)
1022 if (mainwin->lock_count == 0)
1023 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1025 mainwin->lock_count++;
1027 main_window_set_menu_sensitive(mainwin);
1028 main_window_set_toolbar_sensitive(mainwin);
1031 void main_window_unlock(MainWindow *mainwin)
1033 if (mainwin->lock_count)
1034 mainwin->lock_count--;
1036 main_window_set_menu_sensitive(mainwin);
1037 main_window_set_toolbar_sensitive(mainwin);
1039 if (mainwin->lock_count == 0)
1040 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1043 void main_window_reflect_prefs_all(void)
1046 MainWindow *mainwin;
1048 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1049 mainwin = (MainWindow *)cur->data;
1051 main_window_show_cur_account(mainwin);
1052 main_window_set_menu_sensitive(mainwin);
1053 main_window_set_toolbar_sensitive(mainwin);
1055 if (prefs_common.immediate_exec)
1056 gtk_widget_hide(mainwin->exec_btn);
1058 gtk_widget_show(mainwin->exec_btn);
1060 summary_redisplay_msg(mainwin->summaryview);
1061 headerview_set_visibility(mainwin->messageview->headerview,
1062 prefs_common.display_header_pane);
1066 void main_window_set_summary_column(void)
1069 MainWindow *mainwin;
1071 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1072 mainwin = (MainWindow *)cur->data;
1073 summary_set_column_order(mainwin->summaryview);
1077 void main_window_set_account_menu(GList *account_list)
1079 GList *cur, *cur_ac, *cur_item;
1080 GtkWidget *menuitem;
1081 MainWindow *mainwin;
1082 PrefsAccount *ac_prefs;
1084 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1085 mainwin = (MainWindow *)cur->data;
1087 /* destroy all previous menu item */
1088 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1089 while (cur_item != NULL) {
1090 GList *next = cur_item->next;
1091 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1095 for (cur_ac = account_list; cur_ac != NULL;
1096 cur_ac = cur_ac->next) {
1097 ac_prefs = (PrefsAccount *)cur_ac->data;
1099 menuitem = gtk_menu_item_new_with_label
1100 (ac_prefs->account_name
1101 ? ac_prefs->account_name : _("Untitled"));
1102 gtk_widget_show(menuitem);
1103 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1104 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1105 GTK_SIGNAL_FUNC(account_menu_cb),
1111 static void main_window_show_cur_account(MainWindow *mainwin)
1116 ac_name = g_strdup(cur_account
1117 ? (cur_account->account_name
1118 ? cur_account->account_name : _("Untitled"))
1122 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1124 buf = g_strdup(PROG_VERSION);
1125 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1128 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1129 gtk_widget_queue_resize(mainwin->ac_button);
1134 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1136 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1137 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1138 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1140 if (mainwin->type == type) return;
1142 /* remove widgets from those containers */
1143 gtk_widget_ref(folder_wid);
1144 gtk_widget_ref(summary_wid);
1145 gtk_widget_ref(message_wid);
1146 gtkut_container_remove
1147 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1148 gtkut_container_remove
1149 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1150 gtkut_container_remove
1151 (GTK_CONTAINER(message_wid->parent), message_wid);
1153 /* clean containers */
1154 switch (mainwin->type) {
1156 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1158 case SEPARATE_FOLDER:
1159 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1160 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1162 case SEPARATE_MESSAGE:
1163 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1164 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1167 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1168 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1172 gtk_widget_hide(mainwin->window);
1173 main_window_set_widgets(mainwin, type);
1174 gtk_widget_show(mainwin->window);
1176 gtk_widget_unref(folder_wid);
1177 gtk_widget_unref(summary_wid);
1178 gtk_widget_unref(message_wid);
1181 void main_window_get_size(MainWindow *mainwin)
1183 GtkAllocation *allocation;
1185 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1187 prefs_common.summaryview_width = allocation->width;
1189 if (mainwin->summaryview->msg_is_toggled_on)
1190 prefs_common.summaryview_height = allocation->height;
1192 prefs_common.mainview_width = allocation->width;
1194 allocation = &mainwin->window->allocation;
1196 prefs_common.mainview_height = allocation->height;
1197 prefs_common.mainwin_width = allocation->width;
1198 prefs_common.mainwin_height = allocation->height;
1200 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1202 prefs_common.folderview_width = allocation->width;
1203 prefs_common.folderview_height = allocation->height;
1206 void main_window_get_position(MainWindow *mainwin)
1210 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1212 prefs_common.mainview_x = x;
1213 prefs_common.mainview_y = y;
1214 prefs_common.mainwin_x = x;
1215 prefs_common.mainwin_y = y;
1217 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1220 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1226 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1227 folder = FOLDER(list->data);
1228 if (folder && folder->trash && folder->trash->total > 0)
1232 if (!has_trash) return;
1235 if (alertpanel(_("Empty trash"),
1236 _("Empty all messages in trash?"),
1237 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1239 manage_window_focus_in(mainwin->window, NULL, NULL);
1242 procmsg_empty_trash();
1244 for (list = folder_get_list(); list != NULL; list = list->next) {
1245 folder = list->data;
1246 if (folder && folder->trash && folder->trash->total != 0) {
1247 folder_item_scan(folder->trash);
1248 folderview_update_item(folder->trash, TRUE);
1252 if (mainwin->summaryview->folder_item &&
1253 mainwin->summaryview->folder_item->stype == F_TRASH)
1254 gtk_widget_grab_focus(mainwin->folderview->ctree);
1257 void main_window_add_mailbox(MainWindow *mainwin)
1262 path = input_dialog(_("Add mailbox"),
1263 _("Input the location of mailbox.\n"
1264 "If the existing mailbox is specified, it will be\n"
1265 "scanned automatically."),
1268 if (folder_find_from_path(path)) {
1269 alertpanel_error(_("The mailbox `%s' already exists."), path);
1273 if (!strcmp(path, "Mail"))
1274 folder = folder_new(F_MH, _("Mailbox"), path);
1276 folder = folder_new(F_MH, g_basename(path), path);
1279 if (folder->create_tree(folder) < 0) {
1280 alertpanel_error(_("Creation of the mailbox failed.\n"
1281 "Maybe some files already exist, or you don't have the permission to write there."));
1282 folder_destroy(folder);
1287 folder_set_ui_func(folder, scan_tree_func, mainwin);
1288 folder->scan_tree(folder);
1289 folder_set_ui_func(folder, NULL, NULL);
1291 folderview_set(mainwin->folderview);
1294 void main_window_add_mbox(MainWindow *mainwin)
1300 path = input_dialog(_("Add mbox mailbox"),
1301 _("Input the location of mailbox."),
1306 if (folder_find_from_path(path)) {
1307 alertpanel_error(_("The mailbox `%s' already exists."), path);
1313 if (!strcmp(path, "Mail"))
1314 folder = folder_new(F_MBOX, _("Mailbox"), path);
1318 folder = folder_new(F_MBOX, g_basename(path), path);
1321 if (folder->create_tree(folder) < 0) {
1322 alertpanel_error(_("Creation of the mailbox failed."));
1323 folder_destroy(folder);
1329 item = folder_item_new(folder->name, NULL);
1330 item->folder = folder;
1331 folder->node = g_node_new(item);
1333 folder->create_folder(folder, item, "inbox");
1334 folder->create_folder(folder, item, "outbox");
1335 folder->create_folder(folder, item, "queue");
1336 folder->create_folder(folder, item, "draft");
1337 folder->create_folder(folder, item, "trash");
1339 folderview_set(mainwin->folderview);
1344 M_UNLOCKED = 1 << 0,
1345 M_MSG_EXIST = 1 << 1,
1346 M_TARGET_EXIST = 1 << 2,
1347 M_SINGLE_TARGET_EXIST = 1 << 3,
1349 M_ALLOW_REEDIT = 1 << 5,
1350 M_HAVE_ACCOUNT = 1 << 6,
1351 M_THREADED = 1 << 7,
1352 M_UNTHREADED = 1 << 8,
1354 M_HAVE_NEWS_ACCOUNT = 1 << 10
1357 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1359 SensitiveCond state = 0;
1360 SummarySelection selection;
1361 FolderItem *item = mainwin->summaryview->folder_item;
1362 GList *account_list = account_get_list();
1364 selection = summary_get_selection_type(mainwin->summaryview);
1366 if (mainwin->lock_count == 0)
1367 state |= M_UNLOCKED;
1368 if (selection != SUMMARY_NONE)
1369 state |= M_MSG_EXIST;
1372 state |= M_THREADED;
1374 state |= M_UNTHREADED;
1376 if (selection == SUMMARY_SELECTED_SINGLE ||
1377 selection == SUMMARY_SELECTED_MULTIPLE)
1378 state |= M_TARGET_EXIST;
1379 if (selection == SUMMARY_SELECTED_SINGLE)
1380 state |= M_SINGLE_TARGET_EXIST;
1381 if (item && item->folder->type != F_NEWS)
1383 if (mainwin->summaryview->folder_item &&
1384 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1386 if (selection == SUMMARY_SELECTED_SINGLE &&
1388 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1389 item->stype == F_QUEUE)))
1390 state |= M_ALLOW_REEDIT;
1392 state |= M_HAVE_ACCOUNT;
1394 for ( ; account_list != NULL; account_list = account_list->next) {
1395 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1396 state |= M_HAVE_NEWS_ACCOUNT;
1404 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1406 SensitiveCond state;
1414 {mainwin->get_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1415 {mainwin->getall_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1416 {mainwin->compose_mail_btn, M_HAVE_ACCOUNT},
1417 {mainwin->compose_news_btn, M_HAVE_NEWS_ACCOUNT},
1418 {mainwin->reply_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1419 {mainwin->replyall_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1420 {mainwin->replysender_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1421 {mainwin->fwd_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1422 /* {mainwin->prefs_btn , M_UNLOCKED},
1423 {mainwin->account_btn , M_UNLOCKED}, */
1424 {mainwin->next_btn , M_MSG_EXIST},
1425 {mainwin->delete_btn , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1426 {mainwin->exec_btn , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1430 state = main_window_get_current_state(mainwin);
1432 for (i = 0; entry[i].widget != NULL; i++) {
1433 sensitive = ((entry[i].cond & state) == entry[i].cond);
1434 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1437 activate_compose_button(mainwin,
1438 prefs_common.toolbar_style,
1439 mainwin->compose_btn_type);
1442 void main_window_set_menu_sensitive(MainWindow *mainwin)
1444 GtkItemFactory *ifactory;
1445 SensitiveCond state;
1449 static const struct {
1453 {"/File/Add mailbox..." , M_UNLOCKED},
1454 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1455 {"/File/Rescan folder tree" , M_UNLOCKED},
1456 {"/File/Folder" , M_UNLOCKED},
1457 {"/File/Import mbox file..." , M_UNLOCKED},
1458 {"/File/Export to mbox file...", M_UNLOCKED},
1459 {"/File/Empty trash" , M_UNLOCKED},
1460 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1461 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1462 /* {"/File/Close", M_UNLOCKED}, */
1463 {"/File/Exit" , M_UNLOCKED},
1465 {"/View/Sort" , M_MSG_EXIST},
1466 {"/View/Thread view" , M_UNTHREADED},
1467 {"/View/Unthread view" , M_THREADED},
1468 {"/View/Go to" , M_MSG_EXIST},
1469 {"/View/Go to/Prev message" , M_MSG_EXIST},
1470 {"/View/Go to/Next message" , M_MSG_EXIST},
1471 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1472 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1473 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1474 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1475 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1476 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1477 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1478 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1480 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1481 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1482 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1483 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1484 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1485 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1486 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1487 {"/Message/Forward" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1488 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1489 {"/Message/Re-edit", M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1490 {"/Message/Move...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1491 {"/Message/Copy...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1492 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1493 {"/Message/Mark" , M_TARGET_EXIST},
1494 {"/Message/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1496 {"/Tool/Add sender to address book", M_SINGLE_TARGET_EXIST},
1497 {"/Tool/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1498 {"/Tool/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1500 {"/Configuration", M_UNLOCKED},
1505 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1506 state = main_window_get_current_state(mainwin);
1508 for (i = 0; entry[i].entry != NULL; i++) {
1509 sensitive = ((entry[i].cond & state) == entry[i].cond);
1510 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1514 void main_window_popup(MainWindow *mainwin)
1520 gdk_window_get_origin(mainwin->window->window, &x, &y);
1521 sx = gdk_screen_width();
1522 sy = gdk_screen_height();
1523 x %= sx; if (x < 0) x = 0;
1524 y %= sy; if (y < 0) y = 0;
1525 gdk_window_move(mainwin->window->window, x, y);
1526 gdk_window_raise(mainwin->window->window);
1527 gdk_window_show(mainwin->window->window);
1529 debug_print("window position: x = %d, y = %d\n", x, y);
1531 switch (mainwin->type) {
1532 case SEPARATE_FOLDER:
1533 widget = mainwin->win.sep_folder.folderwin;
1534 gdk_window_get_origin(widget->window, &x, &y);
1535 x %= sx; if (x < 0) x = 0;
1536 y %= sy; if (y < 0) y = 0;
1537 gdk_window_move(widget->window, x, y);
1538 gdk_window_raise(widget->window);
1540 case SEPARATE_MESSAGE:
1541 widget = mainwin->win.sep_message.messagewin;
1542 gdk_window_get_origin(widget->window, &x, &y);
1543 x %= sx; if (x < 0) x = 0;
1544 y %= sy; if (y < 0) y = 0;
1545 gdk_window_move(widget->window, x, y);
1546 gdk_window_raise(widget->window);
1549 widget = mainwin->win.sep_both.folderwin;
1550 gdk_window_get_origin(widget->window, &x, &y);
1551 x %= sx; if (x < 0) x = 0;
1552 y %= sy; if (y < 0) y = 0;
1553 gdk_window_move(widget->window, x, y);
1554 gdk_window_raise(widget->window);
1555 widget = mainwin->win.sep_both.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);
1567 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1569 GtkWidget *folderwin = NULL;
1570 GtkWidget *messagewin = NULL;
1573 GtkWidget *vbox_body = mainwin->vbox_body;
1574 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1575 GtkWidget *menuitem;
1577 debug_print(_("Setting widgets..."));
1579 /* create separated window(s) if needed */
1580 if (type & SEPARATE_FOLDER) {
1581 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1582 gtk_window_set_title(GTK_WINDOW(folderwin),
1583 _("Sylpheed - Folder View"));
1584 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1585 "folder_view", "Sylpheed");
1586 gtk_window_set_policy(GTK_WINDOW(folderwin),
1588 gtk_widget_set_usize(folderwin, -1,
1589 prefs_common.mainview_height);
1590 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1592 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1593 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1596 if (type & SEPARATE_MESSAGE) {
1597 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1598 gtk_window_set_title(GTK_WINDOW(messagewin),
1599 _("Sylpheed - Message View"));
1600 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1601 "message_view", "Sylpheed");
1602 gtk_window_set_policy(GTK_WINDOW(messagewin),
1604 gtk_widget_set_usize
1605 (messagewin, prefs_common.mainview_width,
1606 prefs_common.mainview_height
1607 - prefs_common.summaryview_height
1608 + DEFAULT_HEADERVIEW_HEIGHT);
1609 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1611 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1612 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1618 hpaned = gtk_hpaned_new();
1619 gtk_widget_show(hpaned);
1620 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1621 gtk_paned_add1(GTK_PANED(hpaned),
1622 GTK_WIDGET_PTR(mainwin->folderview));
1624 vpaned = gtk_vpaned_new();
1625 if (mainwin->summaryview->msg_is_toggled_on) {
1626 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1627 gtk_paned_add1(GTK_PANED(vpaned),
1628 GTK_WIDGET_PTR(mainwin->summaryview));
1630 gtk_paned_add2(GTK_PANED(hpaned),
1631 GTK_WIDGET_PTR(mainwin->summaryview));
1632 gtk_widget_ref(vpaned);
1634 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1635 prefs_common.summaryview_width,
1636 prefs_common.summaryview_height);
1637 gtk_paned_add2(GTK_PANED(vpaned),
1638 GTK_WIDGET_PTR(mainwin->messageview));
1639 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1640 prefs_common.mainview_width, -1);
1641 gtk_widget_set_usize(mainwin->window,
1642 prefs_common.folderview_width +
1643 prefs_common.mainview_width,
1644 prefs_common.mainwin_height);
1645 gtk_widget_show_all(vpaned);
1647 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1648 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1649 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1650 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1651 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1652 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1654 mainwin->win.sep_none.hpaned = hpaned;
1655 mainwin->win.sep_none.vpaned = vpaned;
1657 case SEPARATE_FOLDER:
1658 vpaned = gtk_vpaned_new();
1659 if (mainwin->summaryview->msg_is_toggled_on) {
1660 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1662 gtk_paned_add1(GTK_PANED(vpaned),
1663 GTK_WIDGET_PTR(mainwin->summaryview));
1665 gtk_box_pack_start(GTK_BOX(vbox_body),
1666 GTK_WIDGET_PTR(mainwin->summaryview),
1668 gtk_widget_ref(vpaned);
1670 gtk_paned_add2(GTK_PANED(vpaned),
1671 GTK_WIDGET_PTR(mainwin->messageview));
1672 gtk_widget_show_all(vpaned);
1673 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1674 prefs_common.summaryview_width,
1675 prefs_common.summaryview_height);
1676 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1677 prefs_common.mainview_width, -1);
1678 gtk_widget_set_usize(mainwin->window,
1679 prefs_common.mainview_width,
1680 prefs_common.mainview_height);
1682 gtk_container_add(GTK_CONTAINER(folderwin),
1683 GTK_WIDGET_PTR(mainwin->folderview));
1685 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1686 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1688 mainwin->win.sep_folder.folderwin = folderwin;
1689 mainwin->win.sep_folder.vpaned = vpaned;
1691 gtk_widget_show_all(folderwin);
1693 case SEPARATE_MESSAGE:
1694 hpaned = gtk_hpaned_new();
1695 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1697 gtk_paned_add1(GTK_PANED(hpaned),
1698 GTK_WIDGET_PTR(mainwin->folderview));
1699 gtk_paned_add2(GTK_PANED(hpaned),
1700 GTK_WIDGET_PTR(mainwin->summaryview));
1701 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1702 prefs_common.summaryview_width,
1703 prefs_common.summaryview_height);
1704 gtk_widget_set_usize(mainwin->window,
1705 prefs_common.folderview_width +
1706 prefs_common.mainview_width,
1707 prefs_common.mainwin_height);
1708 gtk_widget_show_all(hpaned);
1709 gtk_container_add(GTK_CONTAINER(messagewin),
1710 GTK_WIDGET_PTR(mainwin->messageview));
1712 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1713 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1714 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1715 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1717 mainwin->win.sep_message.messagewin = messagewin;
1718 mainwin->win.sep_message.hpaned = hpaned;
1720 gtk_widget_show_all(messagewin);
1723 gtk_box_pack_start(GTK_BOX(vbox_body),
1724 GTK_WIDGET_PTR(mainwin->summaryview),
1726 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1727 prefs_common.summaryview_width,
1728 prefs_common.summaryview_height);
1729 gtk_widget_set_usize(mainwin->window,
1730 prefs_common.mainview_width,
1731 prefs_common.mainwin_height);
1732 gtk_container_add(GTK_CONTAINER(folderwin),
1733 GTK_WIDGET_PTR(mainwin->folderview));
1734 gtk_container_add(GTK_CONTAINER(messagewin),
1735 GTK_WIDGET_PTR(mainwin->messageview));
1737 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1738 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1740 mainwin->win.sep_both.folderwin = folderwin;
1741 mainwin->win.sep_both.messagewin = messagewin;
1743 gtk_widget_show_all(folderwin);
1744 gtk_widget_show_all(messagewin);
1748 mainwin->type = type;
1750 debug_print(_("done.\n"));
1753 static void main_window_toolbar_create(MainWindow *mainwin,
1754 GtkWidget *container)
1757 GtkWidget *icon_wid;
1759 GtkWidget *getall_btn;
1760 GtkWidget *compose_mail_btn;
1761 GtkWidget *compose_news_btn;
1762 GtkWidget *reply_btn;
1763 GtkWidget *replyall_btn;
1764 GtkWidget *replysender_btn;
1766 GtkWidget *send_btn;
1768 GtkWidget *prefs_btn;
1769 GtkWidget *account_btn;
1771 GtkWidget *next_btn;
1772 GtkWidget *delete_btn;
1773 GtkWidget *exec_btn;
1775 GtkTooltips *tooltips;
1777 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1779 gtk_container_add(GTK_CONTAINER(container), toolbar);
1780 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1781 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1782 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1783 GTK_TOOLBAR_SPACE_LINE);
1785 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1786 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1788 _("Get new mail from current account"),
1790 icon_wid, toolbar_inc_cb, mainwin);
1791 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1792 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1794 _("Get new mail from all accounts"),
1800 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1802 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1803 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1805 _("Send queued message(s)"),
1811 /* insert compose mail button widget */
1812 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1813 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1815 _("Compose an email message"),
1818 toolbar_compose_mail_cb,
1821 /* insert compose news button widget */
1822 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1823 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1825 _("Compose a news message"),
1828 toolbar_compose_news_cb,
1831 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1835 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1836 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1838 _("Reply to the message - Right button: more options"),
1844 /* replyall button */
1846 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1847 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1849 _("Reply to all - Right button: more options"),
1852 toolbar_reply_to_all_cb,
1855 /* reply to sender button */
1856 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1857 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1859 _("Reply to sender - Right button: more options"),
1862 toolbar_reply_to_sender_cb,
1865 /* forward button */
1866 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1867 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1869 _("Forward the message - Right button: more options"),
1875 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1877 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1878 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1880 _("Delete the message"),
1886 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1887 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1889 _("Execute marked process"),
1895 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
1896 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1898 _("Next unread message"),
1901 toolbar_next_unread_cb,
1905 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1907 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
1908 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1910 _("Common preference"),
1915 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
1916 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1918 _("Account setting"),
1923 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1924 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1928 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
1929 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
1932 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
1933 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
1936 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
1937 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
1940 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
1941 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
1945 mainwin->toolbar = toolbar;
1946 mainwin->get_btn = get_btn;
1947 mainwin->getall_btn = getall_btn;
1948 mainwin->compose_mail_btn = compose_mail_btn;
1949 mainwin->compose_news_btn = compose_news_btn;
1950 mainwin->reply_btn = reply_btn;
1951 mainwin->replyall_btn = replyall_btn;
1952 mainwin->replysender_btn = replysender_btn;
1953 mainwin->fwd_btn = fwd_btn;
1954 mainwin->send_btn = send_btn;
1956 mainwin->prefs_btn = prefs_btn;
1957 mainwin->account_btn = account_btn;
1959 mainwin->next_btn = next_btn;
1960 mainwin->delete_btn = delete_btn;
1961 mainwin->exec_btn = exec_btn;
1963 gtk_widget_show_all(toolbar);
1966 /* callback functions */
1967 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1969 MainWindow *mainwindow = (MainWindow *) data;
1973 if (event->button == 3) {
1974 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1975 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
1976 menu_button_position, widget,
1977 event->button, event->time);
1981 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
1983 MainWindow *mainwin = (MainWindow *)data;
1985 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
1986 manage_window_focus_in(mainwin->window, NULL, NULL);
1989 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1991 MainWindow *mainwindow = (MainWindow *) data;
1995 if (event->button == 3) {
1996 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1997 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
1998 menu_button_position, widget,
1999 event->button, event->time);
2003 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2005 MainWindow *mainwin = (MainWindow *)data;
2007 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2008 manage_window_focus_in(mainwin->window, NULL, NULL);
2011 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2013 MainWindow *mainwindow = (MainWindow *) data;
2014 GtkWidget *replysender_menu, *replysender_item;
2018 if (event->button == 3) {
2019 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2020 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2021 menu_button_position, widget,
2022 event->button, event->time);
2026 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2028 MainWindow *mainwin = (MainWindow *)data;
2030 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2031 manage_window_focus_in(mainwin->window, NULL, NULL);
2034 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2036 MainWindow *mainwindow = (MainWindow *) data;
2040 if (event->button == 3) {
2041 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2042 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2043 menu_button_position, widget,
2044 event->button, event->time);
2048 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2050 MainWindow *mainwin = (MainWindow *)data;
2052 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2053 manage_window_focus_in(mainwin->window, NULL, NULL);
2056 static void toolbar_inc_cb (GtkWidget *widget,
2059 MainWindow *mainwin = (MainWindow *)data;
2061 inc_mail_cb(mainwin, 0, NULL);
2064 static void toolbar_inc_all_cb (GtkWidget *widget,
2067 MainWindow *mainwin = (MainWindow *)data;
2069 inc_all_account_mail_cb(mainwin, 0, NULL);
2072 static void toolbar_send_cb (GtkWidget *widget,
2075 MainWindow *mainwin = (MainWindow *)data;
2077 send_queue_cb(mainwin, 0, NULL);
2080 static void toolbar_compose_cb (GtkWidget *widget,
2083 MainWindow *mainwin = (MainWindow *)data;
2085 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2086 compose_cb(mainwin, 0, NULL);
2088 compose_news_cb(mainwin, 0, NULL);
2091 static void toolbar_compose_news_cb (GtkWidget *widget,
2094 MainWindow *mainwin = (MainWindow *)data;
2096 compose_news_cb(mainwin, 0, NULL);
2099 static void toolbar_compose_mail_cb (GtkWidget *widget,
2102 MainWindow *mainwin = (MainWindow *)data;
2104 compose_mail_cb(mainwin, 0, NULL);
2107 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2109 MainWindow *mainwin = (MainWindow *)data;
2112 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2113 : COMPOSE_REPLY_WITHOUT_QUOTE,
2117 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2119 MainWindow *mainwin = (MainWindow *)data;
2122 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2123 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2128 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2130 MainWindow *mainwin = (MainWindow *)data;
2133 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2134 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2138 static void toolbar_forward_cb (GtkWidget *widget,
2141 MainWindow *mainwin = (MainWindow *)data;
2143 if (prefs_common.forward_as_attachment)
2144 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2146 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2149 static void toolbar_delete_cb (GtkWidget *widget,
2152 MainWindow *mainwin = (MainWindow *)data;
2154 summary_delete(mainwin->summaryview);
2157 static void toolbar_exec_cb (GtkWidget *widget,
2160 MainWindow *mainwin = (MainWindow *)data;
2162 summary_execute(mainwin->summaryview);
2165 static void toolbar_next_unread_cb (GtkWidget *widget,
2168 MainWindow *mainwin = (MainWindow *)data;
2170 next_unread_cb(mainwin, 0, NULL);
2173 static void toolbar_prefs_cb (GtkWidget *widget,
2176 prefs_common_open();
2179 static void toolbar_account_cb (GtkWidget *widget,
2182 MainWindow *mainwin = (MainWindow *)data;
2184 prefs_account_open_cb(mainwin, 0, NULL);
2187 static void toolbar_account_button_pressed(GtkWidget *widget,
2188 GdkEventButton *event,
2191 MainWindow *mainwin = (MainWindow *)data;
2194 if (event->button != 3) return;
2196 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2197 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2200 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2201 menu_button_position, widget,
2202 event->button, event->time);
2205 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2208 MainWindow *mainwin = (MainWindow *)data;
2212 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2213 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2216 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2217 menu_button_position, widget,
2218 event->button, event->time);
2221 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2223 MainWindow *mainwin = (MainWindow *)data;
2226 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2227 if (!button) return;
2228 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2229 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2230 manage_window_focus_in(mainwin->window, NULL, NULL);
2233 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2236 MainWindow *mainwin = (MainWindow *)data;
2238 if (mainwin->lock_count == 0)
2239 app_exit_cb(data, 0, widget);
2244 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2247 main_window_add_mailbox(mainwin);
2250 static void add_mbox_cb(MainWindow *mainwin, guint action,
2253 main_window_add_mbox(mainwin);
2256 static void update_folderview_cb(MainWindow *mainwin, guint action,
2259 summary_show(mainwin->summaryview, NULL, FALSE);
2260 folderview_update_all();
2263 static void new_folder_cb(MainWindow *mainwin, guint action,
2266 folderview_new_folder(mainwin->folderview);
2269 static void rename_folder_cb(MainWindow *mainwin, guint action,
2272 folderview_rename_folder(mainwin->folderview);
2275 static void delete_folder_cb(MainWindow *mainwin, guint action,
2278 folderview_delete_folder(mainwin->folderview);
2281 static void import_mbox_cb(MainWindow *mainwin, guint action,
2284 import_mbox(mainwin->summaryview->folder_item);
2287 static void export_mbox_cb(MainWindow *mainwin, guint action,
2290 export_mbox(mainwin->summaryview->folder_item);
2293 static void empty_trash_cb(MainWindow *mainwin, guint action,
2296 main_window_empty_trash(mainwin, TRUE);
2299 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2301 summary_save_as(mainwin->summaryview);
2304 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2306 summary_print(mainwin->summaryview);
2309 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2311 if (prefs_common.confirm_on_exit) {
2312 if (alertpanel(_("Exit"), _("Exit this program?"),
2313 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2315 manage_window_focus_in(mainwin->window, NULL, NULL);
2318 app_will_exit(widget, mainwin);
2321 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2324 summary_search(mainwin->summaryview);
2326 message_search(mainwin->messageview);
2329 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2332 switch (mainwin->type) {
2334 case SEPARATE_MESSAGE:
2336 case SEPARATE_FOLDER:
2337 if (GTK_CHECK_MENU_ITEM(widget)->active)
2338 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2340 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2343 if (GTK_CHECK_MENU_ITEM(widget)->active)
2344 gtk_widget_show(mainwin->win.sep_both.folderwin);
2346 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2351 static void toggle_message_cb(MainWindow *mainwin, guint action,
2354 switch (mainwin->type) {
2356 case SEPARATE_FOLDER:
2358 case SEPARATE_MESSAGE:
2359 if (GTK_CHECK_MENU_ITEM(widget)->active)
2360 gtk_widget_show(mainwin->win.sep_message.messagewin);
2362 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2365 if (GTK_CHECK_MENU_ITEM(widget)->active)
2366 gtk_widget_show(mainwin->win.sep_both.messagewin);
2368 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2373 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2376 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2377 mainwin->compose_btn_type);
2378 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2379 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2380 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2381 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2383 switch ((ToolbarStyle)action) {
2385 gtk_widget_hide(mainwin->handlebox);
2387 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2391 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2395 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2400 if (action != TOOLBAR_NONE) {
2401 gtk_widget_show(mainwin->handlebox);
2402 gtk_widget_queue_resize(mainwin->handlebox);
2405 mainwin->toolbar_style = (ToolbarStyle)action;
2406 prefs_common.toolbar_style = (ToolbarStyle)action;
2409 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2412 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2413 gtk_widget_show(mainwin->hbox_stat);
2414 prefs_common.show_statusbar = TRUE;
2416 gtk_widget_hide(mainwin->hbox_stat);
2417 prefs_common.show_statusbar = FALSE;
2421 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2423 summary_toggle_view_real(mainwin->summaryview);
2426 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2428 messageview_toggle_view_real(mainwin->messageview);
2431 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2434 MainWindow *mainwin;
2437 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2438 g_return_if_fail(mainwin != NULL);
2440 type = mainwin->type ^ action;
2441 main_window_separation_change(mainwin, type);
2443 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2444 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2447 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2450 addressbook_open(NULL);
2453 static void log_window_show_cb(MainWindow *mainwin, guint action,
2456 log_window_show(mainwin->logwin);
2459 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2464 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2467 inc_all_account_mail(mainwin);
2470 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2474 if (procmsg_send_queue() < 0)
2475 alertpanel_error(_("Some errors occurred while sending queued messages."));
2477 statusbar_pop_all();
2479 for (list = folder_get_list(); list != NULL; list = list->next) {
2482 folder = list->data;
2483 if (folder->queue) {
2484 folder_item_scan(folder->queue);
2485 folderview_update_item(folder->queue, TRUE);
2490 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2492 if (mainwin->summaryview->folder_item) {
2493 if (mainwin->summaryview->folder_item->folder->account != NULL
2494 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2495 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2497 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2503 static void compose_mail_cb(MainWindow *mainwin, guint action,
2510 if (mainwin->summaryview->folder_item) {
2511 ac = mainwin->summaryview->folder_item->folder->account;
2512 if (ac && ac->protocol != A_NNTP) {
2513 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2518 if(cur_account && (cur_account->protocol != A_NNTP)) {
2519 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2523 list = account_get_list();
2524 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2525 ac = (PrefsAccount *) cur->data;
2526 if (ac->protocol != A_NNTP) {
2527 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2533 static void compose_news_cb(MainWindow *mainwin, guint action,
2536 PrefsAccount * ac = NULL;
2540 if (mainwin->summaryview->folder_item) {
2541 ac = mainwin->summaryview->folder_item->folder->account;
2542 if (ac && ac->protocol == A_NNTP) {
2543 compose_new_with_recipient
2544 (ac, mainwin->summaryview->folder_item->path);
2549 list = account_get_list();
2550 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2551 ac = (PrefsAccount *) cur->data;
2552 if (ac->protocol == A_NNTP) {
2559 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2561 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2564 msginfo = gtk_ctree_node_get_row_data
2565 (GTK_CTREE(mainwin->summaryview->ctree),
2566 mainwin->summaryview->selected);
2568 if (!msginfo) return;
2572 compose_reply(msginfo, prefs_common.reply_with_quote,
2575 case COMPOSE_REPLY_WITH_QUOTE:
2576 compose_reply(msginfo, TRUE, FALSE, FALSE);
2578 case COMPOSE_REPLY_WITHOUT_QUOTE:
2579 compose_reply(msginfo, FALSE, FALSE, FALSE);
2581 case COMPOSE_REPLY_TO_SENDER:
2582 compose_reply(msginfo, prefs_common.reply_with_quote,
2585 case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE:
2586 compose_reply(msginfo, TRUE, FALSE, TRUE);
2588 case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE:
2589 compose_reply(msginfo, FALSE, FALSE, TRUE);
2591 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2592 compose_followup_and_reply_to(msginfo,
2593 prefs_common.reply_with_quote,
2596 case COMPOSE_REPLY_TO_ALL:
2597 compose_reply(msginfo, prefs_common.reply_with_quote,
2600 case COMPOSE_REPLY_TO_ALL_WITH_QUOTE:
2601 compose_reply(msginfo, TRUE, TRUE, TRUE);
2603 case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE:
2604 compose_reply(msginfo, FALSE, TRUE, TRUE);
2606 case COMPOSE_FORWARD:
2607 if (prefs_common.forward_as_attachment) {
2608 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, widget);
2611 reply_cb(mainwin, COMPOSE_FORWARD_INLINE, widget);
2615 case COMPOSE_FORWARD_INLINE:
2617 compose_forward(NULL, msginfo, FALSE);
2620 /* if (sel->next) FALL_THROUGH */
2621 case COMPOSE_FORWARD_AS_ATTACH:
2623 GSList *msginfo_list = NULL;
2624 for ( ; sel != NULL; sel = sel->next)
2625 msginfo_list = g_slist_append(msginfo_list,
2626 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2627 GTK_CTREE_NODE(sel->data)));
2628 compose_forward_multiple(NULL, msginfo_list);
2629 g_slist_free(msginfo_list);
2632 case COMPOSE_BOUNCE:
2633 compose_bounce(NULL, msginfo);
2636 g_warning("reply_cb(): invalid action type: %d\n", action);
2639 summary_set_marks_selected(mainwin->summaryview);
2642 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2644 summary_move_to(mainwin->summaryview);
2647 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2649 summary_copy_to(mainwin->summaryview);
2652 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2654 summary_delete(mainwin->summaryview);
2657 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2659 summary_open_msg(mainwin->summaryview);
2662 static void view_source_cb(MainWindow *mainwin, guint action,
2665 summary_view_source(mainwin->summaryview);
2668 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2670 summary_reedit(mainwin->summaryview);
2673 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2675 summary_mark(mainwin->summaryview);
2678 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2680 summary_unmark(mainwin->summaryview);
2683 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2686 summary_mark_as_unread(mainwin->summaryview);
2689 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2692 summary_mark_as_read(mainwin->summaryview);
2695 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2698 summary_mark_all_read(mainwin->summaryview);
2701 static void add_address_cb(MainWindow *mainwin, guint action,
2704 summary_add_address(mainwin->summaryview);
2707 static void set_charset_cb(MainWindow *mainwin, guint action,
2712 str = conv_get_charset_str((CharSet)action);
2713 g_free(prefs_common.force_charset);
2714 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2716 summary_redisplay_msg(mainwin->summaryview);
2718 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2721 static void hide_read_messages (MainWindow *mainwin, guint action,
2724 if (!mainwin->summaryview->folder_item
2725 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2727 summary_toggle_show_read_messages(mainwin->summaryview);
2730 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2732 GtkItemFactory *ifactory;
2734 if (!mainwin->summaryview->folder_item) return;
2736 ifactory = gtk_item_factory_from_widget(widget);
2739 summary_thread_build(mainwin->summaryview);
2740 mainwin->summaryview->folder_item->threaded = TRUE;
2741 menu_set_sensitive(ifactory, "/View/Thread view", FALSE);
2742 menu_set_sensitive(ifactory, "/View/Unthread view", TRUE);
2744 summary_unthread(mainwin->summaryview);
2745 mainwin->summaryview->folder_item->threaded = FALSE;
2746 menu_set_sensitive(ifactory, "/View/Thread view", TRUE);
2747 menu_set_sensitive(ifactory, "/View/Unthread view", FALSE);
2751 static void set_display_item_cb(MainWindow *mainwin, guint action,
2754 prefs_summary_column_open();
2757 static void sort_summary_cb(MainWindow *mainwin, guint action,
2760 summary_sort(mainwin->summaryview, (SummarySortType)action);
2763 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2766 summary_attract_by_subject(mainwin->summaryview);
2769 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2772 summary_delete_duplicated(mainwin->summaryview);
2775 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2777 summary_filter(mainwin->summaryview);
2780 static void execute_summary_cb(MainWindow *mainwin, guint action,
2783 summary_execute(mainwin->summaryview);
2786 static void update_summary_cb(MainWindow *mainwin, guint action,
2790 FolderView *folderview = mainwin->folderview;
2792 if (!mainwin->summaryview->folder_item) return;
2793 if (!folderview->opened) return;
2795 folder_update_op_count();
2797 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2798 folderview->opened);
2801 summary_show(mainwin->summaryview, fitem, TRUE);
2804 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2806 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2809 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2811 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2814 static void prev_unread_cb(MainWindow *mainwin, guint action,
2817 summary_select_prev_unread(mainwin->summaryview);
2820 static void next_unread_cb(MainWindow *mainwin, guint action,
2823 summary_select_next_unread(mainwin->summaryview);
2826 static void prev_marked_cb(MainWindow *mainwin, guint action,
2829 summary_select_prev_marked(mainwin->summaryview);
2832 static void next_marked_cb(MainWindow *mainwin, guint action,
2835 summary_select_next_marked(mainwin->summaryview);
2838 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2841 summary_select_prev_labeled(mainwin->summaryview);
2844 static void next_labeled_cb(MainWindow *mainwin, guint action,
2847 summary_select_next_labeled(mainwin->summaryview);
2850 static void goto_folder_cb(MainWindow *mainwin, guint action,
2853 FolderItem *to_folder;
2855 to_folder = foldersel_folder_sel(NULL, NULL);
2858 folderview_select(mainwin->folderview, to_folder);
2861 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2863 messageview_copy_clipboard(mainwin->messageview);
2866 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2868 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2869 summary_select_all(mainwin->summaryview);
2870 else if (mainwin->summaryview->msg_is_toggled_on &&
2871 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2872 messageview_select_all(mainwin->messageview);
2875 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2878 prefs_common_open();
2881 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2884 prefs_filter_open();
2887 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2890 prefs_scoring_open(NULL);
2893 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2896 prefs_filtering_open(NULL);
2899 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2902 prefs_template_open();
2905 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2909 new_account_cb(mainwin, 0, widget);
2911 gboolean prev_default = cur_account->is_default;
2913 prefs_account_open(cur_account);
2914 if (!prev_default && cur_account->is_default)
2915 account_set_as_default(cur_account);
2916 account_save_config_all();
2918 main_window_reflect_prefs_all();
2922 static void new_account_cb(MainWindow *mainwin, guint action,
2925 account_edit_open();
2926 if (!compose_get_compose_list()) account_add();
2929 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2931 cur_account = (PrefsAccount *)data;
2932 main_window_reflect_prefs_all();
2935 static void manual_open_cb(MainWindow *mainwin, guint action,
2938 manual_open((ManualLang)action);
2941 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2943 MainWindow *mainwin = (MainWindow *)data;
2947 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2948 LOCAL_FOLDER(folder)->rootpath,
2952 str = g_strdup_printf(_("Scanning folder %s ..."),
2953 LOCAL_FOLDER(folder)->rootpath);
2955 STATUSBAR_PUSH(mainwin, str);
2956 STATUSBAR_POP(mainwin);
2960 static void activate_compose_button (MainWindow *mainwin,
2962 ComposeButtonType type)
2964 SensitiveCond state = main_window_get_current_state(mainwin);
2966 if (style == TOOLBAR_NONE)
2969 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2970 : mainwin->compose_news_btn);
2971 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2972 : mainwin->compose_mail_btn);
2973 mainwin->compose_btn_type = type;
2976 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2978 if (mainwin->compose_btn_type != compose_btn_type)
2979 activate_compose_button(mainwin,
2980 prefs_common.toolbar_style,
2984 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
2986 MainWindow *mainwin = (MainWindow*) data;
2988 if (!mainwin) return;
2990 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
2993 #define BREAK_ON_MODIFIER_KEY() \
2994 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2996 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
2998 MainWindow *mainwin = (MainWindow*) data;
3000 if (!mainwin || !event) return;
3002 switch (event->keyval) {
3003 case GDK_Q: /* Quit */
3004 BREAK_ON_MODIFIER_KEY();
3006 app_exit_cb(mainwin, 0, NULL);
3013 #undef BREAK_ON_MODIFIER_KEY