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..."), "<control>S", save_as_cb, 0, NULL},
454 {N_("/_File/_Print..."), NULL, 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..."), "G", goto_folder_cb, 0, NULL},
598 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
599 {N_("/_View/Open in new _window"), "<control><alt>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>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"), "<shift><control>N", 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"), "<shift><control>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..."), "<control>O", move_to_cb, 0, NULL},
625 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
626 {N_("/_Message/_Delete"), "<control>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"), "<shift><control>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_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/Hide read messages" , M_MSG_EXIST},
1482 {"/View/Go to" , M_MSG_EXIST},
1483 {"/View/Go to/Prev message" , M_MSG_EXIST},
1484 {"/View/Go to/Next message" , M_MSG_EXIST},
1485 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1486 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1487 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1488 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1489 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1490 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1491 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1492 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1494 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1495 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1496 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1497 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1498 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1499 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1500 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1501 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1502 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1503 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1504 {"/Message/Move..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1505 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1506 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1507 {"/Message/Mark" , M_TARGET_EXIST},
1508 {"/Message/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1510 {"/Tool/Add sender to address book", M_SINGLE_TARGET_EXIST},
1511 {"/Tool/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1512 {"/Tool/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1513 {"/Tool/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1515 {"/Configuration", M_UNLOCKED},
1520 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1521 state = main_window_get_current_state(mainwin);
1523 for (i = 0; entry[i].entry != NULL; i++) {
1524 sensitive = ((entry[i].cond & state) == entry[i].cond);
1525 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1529 void main_window_popup(MainWindow *mainwin)
1535 gdk_window_get_origin(mainwin->window->window, &x, &y);
1536 sx = gdk_screen_width();
1537 sy = gdk_screen_height();
1538 x %= sx; if (x < 0) x = 0;
1539 y %= sy; if (y < 0) y = 0;
1540 gdk_window_move(mainwin->window->window, x, y);
1541 gdk_window_raise(mainwin->window->window);
1542 gdk_window_show(mainwin->window->window);
1544 debug_print("window position: x = %d, y = %d\n", x, y);
1546 switch (mainwin->type) {
1547 case SEPARATE_FOLDER:
1548 widget = mainwin->win.sep_folder.folderwin;
1549 gdk_window_get_origin(widget->window, &x, &y);
1550 x %= sx; if (x < 0) x = 0;
1551 y %= sy; if (y < 0) y = 0;
1552 gdk_window_move(widget->window, x, y);
1553 gdk_window_raise(widget->window);
1555 case SEPARATE_MESSAGE:
1556 widget = mainwin->win.sep_message.messagewin;
1557 gdk_window_get_origin(widget->window, &x, &y);
1558 x %= sx; if (x < 0) x = 0;
1559 y %= sy; if (y < 0) y = 0;
1560 gdk_window_move(widget->window, x, y);
1561 gdk_window_raise(widget->window);
1564 widget = mainwin->win.sep_both.folderwin;
1565 gdk_window_get_origin(widget->window, &x, &y);
1566 x %= sx; if (x < 0) x = 0;
1567 y %= sy; if (y < 0) y = 0;
1568 gdk_window_move(widget->window, x, y);
1569 gdk_window_raise(widget->window);
1570 widget = mainwin->win.sep_both.messagewin;
1571 gdk_window_get_origin(widget->window, &x, &y);
1572 x %= sx; if (x < 0) x = 0;
1573 y %= sy; if (y < 0) y = 0;
1574 gdk_window_move(widget->window, x, y);
1575 gdk_window_raise(widget->window);
1582 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1584 GtkWidget *folderwin = NULL;
1585 GtkWidget *messagewin = NULL;
1588 GtkWidget *vbox_body = mainwin->vbox_body;
1589 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1590 GtkWidget *menuitem;
1592 debug_print(_("Setting widgets..."));
1594 /* create separated window(s) if needed */
1595 if (type & SEPARATE_FOLDER) {
1596 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1597 gtk_window_set_title(GTK_WINDOW(folderwin),
1598 _("Sylpheed - Folder View"));
1599 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1600 "folder_view", "Sylpheed");
1601 gtk_window_set_policy(GTK_WINDOW(folderwin),
1603 gtk_widget_set_usize(folderwin, -1,
1604 prefs_common.mainview_height);
1605 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1607 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1608 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1611 if (type & SEPARATE_MESSAGE) {
1612 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1613 gtk_window_set_title(GTK_WINDOW(messagewin),
1614 _("Sylpheed - Message View"));
1615 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1616 "message_view", "Sylpheed");
1617 gtk_window_set_policy(GTK_WINDOW(messagewin),
1619 gtk_widget_set_usize
1620 (messagewin, prefs_common.mainview_width,
1621 prefs_common.mainview_height
1622 - prefs_common.summaryview_height
1623 + DEFAULT_HEADERVIEW_HEIGHT);
1624 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1626 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1627 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1633 hpaned = gtk_hpaned_new();
1634 gtk_widget_show(hpaned);
1635 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1636 gtk_paned_add1(GTK_PANED(hpaned),
1637 GTK_WIDGET_PTR(mainwin->folderview));
1639 vpaned = gtk_vpaned_new();
1640 if (mainwin->summaryview->msg_is_toggled_on) {
1641 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1642 gtk_paned_add1(GTK_PANED(vpaned),
1643 GTK_WIDGET_PTR(mainwin->summaryview));
1645 gtk_paned_add2(GTK_PANED(hpaned),
1646 GTK_WIDGET_PTR(mainwin->summaryview));
1647 gtk_widget_ref(vpaned);
1649 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1650 prefs_common.summaryview_width,
1651 prefs_common.summaryview_height);
1652 gtk_paned_add2(GTK_PANED(vpaned),
1653 GTK_WIDGET_PTR(mainwin->messageview));
1654 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1655 prefs_common.mainview_width, -1);
1656 gtk_widget_set_usize(mainwin->window,
1657 prefs_common.folderview_width +
1658 prefs_common.mainview_width,
1659 prefs_common.mainwin_height);
1660 gtk_widget_show_all(vpaned);
1662 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1663 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1664 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1665 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1666 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1667 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1669 mainwin->win.sep_none.hpaned = hpaned;
1670 mainwin->win.sep_none.vpaned = vpaned;
1672 case SEPARATE_FOLDER:
1673 vpaned = gtk_vpaned_new();
1674 if (mainwin->summaryview->msg_is_toggled_on) {
1675 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1677 gtk_paned_add1(GTK_PANED(vpaned),
1678 GTK_WIDGET_PTR(mainwin->summaryview));
1680 gtk_box_pack_start(GTK_BOX(vbox_body),
1681 GTK_WIDGET_PTR(mainwin->summaryview),
1683 gtk_widget_ref(vpaned);
1685 gtk_paned_add2(GTK_PANED(vpaned),
1686 GTK_WIDGET_PTR(mainwin->messageview));
1687 gtk_widget_show_all(vpaned);
1688 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1689 prefs_common.summaryview_width,
1690 prefs_common.summaryview_height);
1691 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1692 prefs_common.mainview_width, -1);
1693 gtk_widget_set_usize(mainwin->window,
1694 prefs_common.mainview_width,
1695 prefs_common.mainview_height);
1697 gtk_container_add(GTK_CONTAINER(folderwin),
1698 GTK_WIDGET_PTR(mainwin->folderview));
1700 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1701 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1703 mainwin->win.sep_folder.folderwin = folderwin;
1704 mainwin->win.sep_folder.vpaned = vpaned;
1706 gtk_widget_show_all(folderwin);
1708 case SEPARATE_MESSAGE:
1709 hpaned = gtk_hpaned_new();
1710 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1712 gtk_paned_add1(GTK_PANED(hpaned),
1713 GTK_WIDGET_PTR(mainwin->folderview));
1714 gtk_paned_add2(GTK_PANED(hpaned),
1715 GTK_WIDGET_PTR(mainwin->summaryview));
1716 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1717 prefs_common.summaryview_width,
1718 prefs_common.summaryview_height);
1719 gtk_widget_set_usize(mainwin->window,
1720 prefs_common.folderview_width +
1721 prefs_common.mainview_width,
1722 prefs_common.mainwin_height);
1723 gtk_widget_show_all(hpaned);
1724 gtk_container_add(GTK_CONTAINER(messagewin),
1725 GTK_WIDGET_PTR(mainwin->messageview));
1727 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1728 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1729 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1730 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1732 mainwin->win.sep_message.messagewin = messagewin;
1733 mainwin->win.sep_message.hpaned = hpaned;
1735 gtk_widget_show_all(messagewin);
1738 gtk_box_pack_start(GTK_BOX(vbox_body),
1739 GTK_WIDGET_PTR(mainwin->summaryview),
1741 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1742 prefs_common.summaryview_width,
1743 prefs_common.summaryview_height);
1744 gtk_widget_set_usize(mainwin->window,
1745 prefs_common.mainview_width,
1746 prefs_common.mainwin_height);
1747 gtk_container_add(GTK_CONTAINER(folderwin),
1748 GTK_WIDGET_PTR(mainwin->folderview));
1749 gtk_container_add(GTK_CONTAINER(messagewin),
1750 GTK_WIDGET_PTR(mainwin->messageview));
1752 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1753 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1755 mainwin->win.sep_both.folderwin = folderwin;
1756 mainwin->win.sep_both.messagewin = messagewin;
1758 gtk_widget_show_all(folderwin);
1759 gtk_widget_show_all(messagewin);
1763 mainwin->type = type;
1765 debug_print(_("done.\n"));
1768 static void main_window_toolbar_create(MainWindow *mainwin,
1769 GtkWidget *container)
1772 GtkWidget *icon_wid;
1774 GtkWidget *getall_btn;
1775 GtkWidget *compose_mail_btn;
1776 GtkWidget *compose_news_btn;
1777 GtkWidget *reply_btn;
1778 GtkWidget *replyall_btn;
1779 GtkWidget *replysender_btn;
1781 GtkWidget *send_btn;
1783 GtkWidget *prefs_btn;
1784 GtkWidget *account_btn;
1786 GtkWidget *next_btn;
1787 GtkWidget *delete_btn;
1788 GtkWidget *exec_btn;
1790 GtkTooltips *tooltips;
1792 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1794 gtk_container_add(GTK_CONTAINER(container), toolbar);
1795 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1796 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1797 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1798 GTK_TOOLBAR_SPACE_LINE);
1800 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1801 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1803 _("Get new mail from current account"),
1805 icon_wid, toolbar_inc_cb, mainwin);
1806 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1807 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1809 _("Get new mail from all accounts"),
1815 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1817 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1818 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1820 _("Send queued message(s)"),
1826 /* insert compose mail button widget */
1827 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1828 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1830 _("Compose an email message"),
1833 toolbar_compose_mail_cb,
1836 /* insert compose news button widget */
1837 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1838 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1840 _("Compose a news message"),
1843 toolbar_compose_news_cb,
1846 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1850 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1851 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1853 _("Reply to the message - Right button: more options"),
1859 /* replyall button */
1861 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1862 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1864 _("Reply to all - Right button: more options"),
1867 toolbar_reply_to_all_cb,
1870 /* reply to sender button */
1871 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1872 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1874 _("Reply to sender - Right button: more options"),
1877 toolbar_reply_to_sender_cb,
1880 /* forward button */
1881 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1882 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1884 _("Forward the message - Right button: more options"),
1890 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1892 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1893 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1895 _("Delete the message"),
1901 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1902 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1904 _("Execute marked process"),
1910 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
1911 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1913 _("Next unread message"),
1916 toolbar_next_unread_cb,
1920 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1922 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
1923 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1925 _("Common preference"),
1930 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
1931 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1933 _("Account setting"),
1938 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1939 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1943 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
1944 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
1947 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
1948 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
1951 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
1952 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
1955 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
1956 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
1960 mainwin->toolbar = toolbar;
1961 mainwin->get_btn = get_btn;
1962 mainwin->getall_btn = getall_btn;
1963 mainwin->compose_mail_btn = compose_mail_btn;
1964 mainwin->compose_news_btn = compose_news_btn;
1965 mainwin->reply_btn = reply_btn;
1966 mainwin->replyall_btn = replyall_btn;
1967 mainwin->replysender_btn = replysender_btn;
1968 mainwin->fwd_btn = fwd_btn;
1969 mainwin->send_btn = send_btn;
1971 mainwin->prefs_btn = prefs_btn;
1972 mainwin->account_btn = account_btn;
1974 mainwin->next_btn = next_btn;
1975 mainwin->delete_btn = delete_btn;
1976 mainwin->exec_btn = exec_btn;
1978 gtk_widget_show_all(toolbar);
1981 /* callback functions */
1982 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1984 MainWindow *mainwindow = (MainWindow *) data;
1988 if (event->button == 3) {
1989 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1990 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
1991 menu_button_position, widget,
1992 event->button, event->time);
1996 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
1998 MainWindow *mainwin = (MainWindow *)data;
2000 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2001 manage_window_focus_in(mainwin->window, NULL, NULL);
2004 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2006 MainWindow *mainwindow = (MainWindow *) data;
2010 if (event->button == 3) {
2011 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2012 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2013 menu_button_position, widget,
2014 event->button, event->time);
2018 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2020 MainWindow *mainwin = (MainWindow *)data;
2022 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2023 manage_window_focus_in(mainwin->window, NULL, NULL);
2026 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2028 MainWindow *mainwindow = (MainWindow *) data;
2029 GtkWidget *replysender_menu, *replysender_item;
2033 if (event->button == 3) {
2034 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2035 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2036 menu_button_position, widget,
2037 event->button, event->time);
2041 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2043 MainWindow *mainwin = (MainWindow *)data;
2045 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2046 manage_window_focus_in(mainwin->window, NULL, NULL);
2049 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2051 MainWindow *mainwindow = (MainWindow *) data;
2055 if (event->button == 3) {
2056 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2057 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2058 menu_button_position, widget,
2059 event->button, event->time);
2063 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2065 MainWindow *mainwin = (MainWindow *)data;
2067 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2068 manage_window_focus_in(mainwin->window, NULL, NULL);
2071 static void toolbar_inc_cb (GtkWidget *widget,
2074 MainWindow *mainwin = (MainWindow *)data;
2076 inc_mail_cb(mainwin, 0, NULL);
2079 static void toolbar_inc_all_cb (GtkWidget *widget,
2082 MainWindow *mainwin = (MainWindow *)data;
2084 inc_all_account_mail_cb(mainwin, 0, NULL);
2087 static void toolbar_send_cb (GtkWidget *widget,
2090 MainWindow *mainwin = (MainWindow *)data;
2092 send_queue_cb(mainwin, 0, NULL);
2095 static void toolbar_compose_cb (GtkWidget *widget,
2098 MainWindow *mainwin = (MainWindow *)data;
2100 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2101 compose_cb(mainwin, 0, NULL);
2103 compose_news_cb(mainwin, 0, NULL);
2106 static void toolbar_compose_news_cb (GtkWidget *widget,
2109 MainWindow *mainwin = (MainWindow *)data;
2111 compose_news_cb(mainwin, 0, NULL);
2114 static void toolbar_compose_mail_cb (GtkWidget *widget,
2117 MainWindow *mainwin = (MainWindow *)data;
2119 compose_mail_cb(mainwin, 0, NULL);
2122 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2124 MainWindow *mainwin = (MainWindow *)data;
2127 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2128 : COMPOSE_REPLY_WITHOUT_QUOTE,
2132 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2134 MainWindow *mainwin = (MainWindow *)data;
2137 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2138 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2143 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2145 MainWindow *mainwin = (MainWindow *)data;
2148 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2149 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2153 static void toolbar_forward_cb (GtkWidget *widget,
2156 MainWindow *mainwin = (MainWindow *)data;
2158 if (prefs_common.forward_as_attachment)
2159 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2161 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2164 static void toolbar_delete_cb (GtkWidget *widget,
2167 MainWindow *mainwin = (MainWindow *)data;
2169 summary_delete(mainwin->summaryview);
2172 static void toolbar_exec_cb (GtkWidget *widget,
2175 MainWindow *mainwin = (MainWindow *)data;
2177 summary_execute(mainwin->summaryview);
2180 static void toolbar_next_unread_cb (GtkWidget *widget,
2183 MainWindow *mainwin = (MainWindow *)data;
2185 next_unread_cb(mainwin, 0, NULL);
2188 static void toolbar_prefs_cb (GtkWidget *widget,
2191 prefs_common_open();
2194 static void toolbar_account_cb (GtkWidget *widget,
2197 MainWindow *mainwin = (MainWindow *)data;
2199 prefs_account_open_cb(mainwin, 0, NULL);
2202 static void toolbar_account_button_pressed(GtkWidget *widget,
2203 GdkEventButton *event,
2206 MainWindow *mainwin = (MainWindow *)data;
2209 if (event->button != 3) return;
2211 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2212 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2215 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2216 menu_button_position, widget,
2217 event->button, event->time);
2220 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2223 MainWindow *mainwin = (MainWindow *)data;
2227 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2228 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2231 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2232 menu_button_position, widget,
2233 event->button, event->time);
2236 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2238 MainWindow *mainwin = (MainWindow *)data;
2241 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2242 if (!button) return;
2243 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2244 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2245 manage_window_focus_in(mainwin->window, NULL, NULL);
2248 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2251 MainWindow *mainwin = (MainWindow *)data;
2253 if (mainwin->lock_count == 0)
2254 app_exit_cb(data, 0, widget);
2259 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2262 main_window_add_mailbox(mainwin);
2265 static void add_mbox_cb(MainWindow *mainwin, guint action,
2268 main_window_add_mbox(mainwin);
2271 static void update_folderview_cb(MainWindow *mainwin, guint action,
2274 summary_show(mainwin->summaryview, NULL, FALSE);
2275 folderview_update_all();
2278 static void new_folder_cb(MainWindow *mainwin, guint action,
2281 folderview_new_folder(mainwin->folderview);
2284 static void rename_folder_cb(MainWindow *mainwin, guint action,
2287 folderview_rename_folder(mainwin->folderview);
2290 static void delete_folder_cb(MainWindow *mainwin, guint action,
2293 folderview_delete_folder(mainwin->folderview);
2296 static void import_mbox_cb(MainWindow *mainwin, guint action,
2299 import_mbox(mainwin->summaryview->folder_item);
2302 static void export_mbox_cb(MainWindow *mainwin, guint action,
2305 export_mbox(mainwin->summaryview->folder_item);
2308 static void empty_trash_cb(MainWindow *mainwin, guint action,
2311 main_window_empty_trash(mainwin, TRUE);
2314 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2316 summary_save_as(mainwin->summaryview);
2319 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2321 summary_print(mainwin->summaryview);
2324 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2326 if (prefs_common.confirm_on_exit) {
2327 if (alertpanel(_("Exit"), _("Exit this program?"),
2328 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2330 manage_window_focus_in(mainwin->window, NULL, NULL);
2333 app_will_exit(widget, mainwin);
2336 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2339 summary_search(mainwin->summaryview);
2341 message_search(mainwin->messageview);
2344 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2347 switch (mainwin->type) {
2349 case SEPARATE_MESSAGE:
2351 case SEPARATE_FOLDER:
2352 if (GTK_CHECK_MENU_ITEM(widget)->active)
2353 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2355 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2358 if (GTK_CHECK_MENU_ITEM(widget)->active)
2359 gtk_widget_show(mainwin->win.sep_both.folderwin);
2361 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2366 static void toggle_message_cb(MainWindow *mainwin, guint action,
2369 switch (mainwin->type) {
2371 case SEPARATE_FOLDER:
2373 case SEPARATE_MESSAGE:
2374 if (GTK_CHECK_MENU_ITEM(widget)->active)
2375 gtk_widget_show(mainwin->win.sep_message.messagewin);
2377 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2380 if (GTK_CHECK_MENU_ITEM(widget)->active)
2381 gtk_widget_show(mainwin->win.sep_both.messagewin);
2383 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2388 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2391 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2392 mainwin->compose_btn_type);
2393 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2394 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2395 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2396 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2398 switch ((ToolbarStyle)action) {
2400 gtk_widget_hide(mainwin->handlebox);
2402 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2406 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2410 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2415 if (action != TOOLBAR_NONE) {
2416 gtk_widget_show(mainwin->handlebox);
2417 gtk_widget_queue_resize(mainwin->handlebox);
2420 mainwin->toolbar_style = (ToolbarStyle)action;
2421 prefs_common.toolbar_style = (ToolbarStyle)action;
2424 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2427 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2428 gtk_widget_show(mainwin->hbox_stat);
2429 prefs_common.show_statusbar = TRUE;
2431 gtk_widget_hide(mainwin->hbox_stat);
2432 prefs_common.show_statusbar = FALSE;
2436 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2438 summary_toggle_view_real(mainwin->summaryview);
2441 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2443 messageview_toggle_view_real(mainwin->messageview);
2446 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2449 MainWindow *mainwin;
2452 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2453 g_return_if_fail(mainwin != NULL);
2455 type = mainwin->type ^ action;
2456 main_window_separation_change(mainwin, type);
2458 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2459 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2462 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2465 addressbook_open(NULL);
2468 static void log_window_show_cb(MainWindow *mainwin, guint action,
2471 log_window_show(mainwin->logwin);
2474 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2479 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2482 inc_all_account_mail(mainwin);
2485 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2489 if (procmsg_send_queue() < 0)
2490 alertpanel_error(_("Some errors occurred while sending queued messages."));
2492 statusbar_pop_all();
2494 for (list = folder_get_list(); list != NULL; list = list->next) {
2497 folder = list->data;
2498 if (folder->queue) {
2499 folder_item_scan(folder->queue);
2500 folderview_update_item(folder->queue, TRUE);
2505 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2507 if (mainwin->summaryview->folder_item) {
2508 if (mainwin->summaryview->folder_item->folder->account != NULL
2509 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2510 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2512 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2518 static void compose_mail_cb(MainWindow *mainwin, guint action,
2525 if (mainwin->summaryview->folder_item) {
2526 ac = mainwin->summaryview->folder_item->folder->account;
2527 if (ac && ac->protocol != A_NNTP) {
2528 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2533 if(cur_account && (cur_account->protocol != A_NNTP)) {
2534 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2538 list = account_get_list();
2539 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2540 ac = (PrefsAccount *) cur->data;
2541 if (ac->protocol != A_NNTP) {
2542 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2548 static void compose_news_cb(MainWindow *mainwin, guint action,
2551 PrefsAccount * ac = NULL;
2555 if (mainwin->summaryview->folder_item) {
2556 ac = mainwin->summaryview->folder_item->folder->account;
2557 if (ac && ac->protocol == A_NNTP) {
2558 compose_new_with_recipient
2559 (ac, mainwin->summaryview->folder_item->path);
2564 list = account_get_list();
2565 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2566 ac = (PrefsAccount *) cur->data;
2567 if (ac->protocol == A_NNTP) {
2574 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2576 summary_reply(mainwin->summaryview, (ComposeMode)action);
2579 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2581 summary_move_to(mainwin->summaryview);
2584 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2586 summary_copy_to(mainwin->summaryview);
2589 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2591 summary_delete(mainwin->summaryview);
2594 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2596 summary_open_msg(mainwin->summaryview);
2599 static void view_source_cb(MainWindow *mainwin, guint action,
2602 summary_view_source(mainwin->summaryview);
2605 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2607 summary_reedit(mainwin->summaryview);
2610 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2612 summary_mark(mainwin->summaryview);
2615 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2617 summary_unmark(mainwin->summaryview);
2620 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2623 summary_mark_as_unread(mainwin->summaryview);
2626 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2629 summary_mark_as_read(mainwin->summaryview);
2632 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2635 summary_mark_all_read(mainwin->summaryview);
2638 static void add_address_cb(MainWindow *mainwin, guint action,
2641 summary_add_address(mainwin->summaryview);
2644 static void set_charset_cb(MainWindow *mainwin, guint action,
2649 str = conv_get_charset_str((CharSet)action);
2650 g_free(prefs_common.force_charset);
2651 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2653 summary_redisplay_msg(mainwin->summaryview);
2655 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2658 static void hide_read_messages (MainWindow *mainwin, guint action,
2661 if (!mainwin->summaryview->folder_item
2662 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2664 summary_toggle_show_read_messages(mainwin->summaryview);
2667 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2669 GtkItemFactory *ifactory;
2671 if (!mainwin->summaryview->folder_item) return;
2673 ifactory = gtk_item_factory_from_widget(widget);
2676 summary_thread_build(mainwin->summaryview);
2677 mainwin->summaryview->folder_item->threaded = TRUE;
2678 menu_set_sensitive(ifactory, "/View/Thread view", FALSE);
2679 menu_set_sensitive(ifactory, "/View/Unthread view", TRUE);
2681 summary_unthread(mainwin->summaryview);
2682 mainwin->summaryview->folder_item->threaded = FALSE;
2683 menu_set_sensitive(ifactory, "/View/Thread view", TRUE);
2684 menu_set_sensitive(ifactory, "/View/Unthread view", FALSE);
2688 static void set_display_item_cb(MainWindow *mainwin, guint action,
2691 prefs_summary_column_open();
2694 static void sort_summary_cb(MainWindow *mainwin, guint action,
2697 summary_sort(mainwin->summaryview, (SummarySortType)action);
2700 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2703 summary_attract_by_subject(mainwin->summaryview);
2706 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2709 summary_delete_duplicated(mainwin->summaryview);
2712 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2714 summary_filter(mainwin->summaryview);
2717 static void execute_summary_cb(MainWindow *mainwin, guint action,
2720 summary_execute(mainwin->summaryview);
2723 static void update_summary_cb(MainWindow *mainwin, guint action,
2727 FolderView *folderview = mainwin->folderview;
2729 if (!mainwin->summaryview->folder_item) return;
2730 if (!folderview->opened) return;
2732 folder_update_op_count();
2734 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2735 folderview->opened);
2738 summary_show(mainwin->summaryview, fitem, TRUE);
2741 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2743 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2746 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2748 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2751 static void prev_unread_cb(MainWindow *mainwin, guint action,
2754 summary_select_prev_unread(mainwin->summaryview);
2757 static void next_unread_cb(MainWindow *mainwin, guint action,
2760 summary_select_next_unread(mainwin->summaryview);
2763 static void prev_marked_cb(MainWindow *mainwin, guint action,
2766 summary_select_prev_marked(mainwin->summaryview);
2769 static void next_marked_cb(MainWindow *mainwin, guint action,
2772 summary_select_next_marked(mainwin->summaryview);
2775 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2778 summary_select_prev_labeled(mainwin->summaryview);
2781 static void next_labeled_cb(MainWindow *mainwin, guint action,
2784 summary_select_next_labeled(mainwin->summaryview);
2787 static void goto_folder_cb(MainWindow *mainwin, guint action,
2790 FolderItem *to_folder;
2792 to_folder = foldersel_folder_sel(NULL, NULL);
2795 folderview_select(mainwin->folderview, to_folder);
2798 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2800 messageview_copy_clipboard(mainwin->messageview);
2803 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2805 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2806 summary_select_all(mainwin->summaryview);
2807 else if (mainwin->summaryview->msg_is_toggled_on &&
2808 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2809 messageview_select_all(mainwin->messageview);
2812 static void create_filter_cb(MainWindow *mainwin, guint action,
2815 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2818 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2821 prefs_common_open();
2824 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2827 prefs_filter_open(NULL, NULL);
2830 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2833 prefs_scoring_open(NULL);
2836 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2839 prefs_filtering_open(NULL);
2842 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2845 prefs_template_open();
2848 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2852 new_account_cb(mainwin, 0, widget);
2854 gboolean prev_default = cur_account->is_default;
2856 prefs_account_open(cur_account);
2857 if (!prev_default && cur_account->is_default)
2858 account_set_as_default(cur_account);
2859 account_save_config_all();
2861 main_window_reflect_prefs_all();
2865 static void new_account_cb(MainWindow *mainwin, guint action,
2868 account_edit_open();
2869 if (!compose_get_compose_list()) account_add();
2872 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2874 cur_account = (PrefsAccount *)data;
2875 main_window_reflect_prefs_all();
2878 static void manual_open_cb(MainWindow *mainwin, guint action,
2881 manual_open((ManualLang)action);
2884 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2886 MainWindow *mainwin = (MainWindow *)data;
2890 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2891 LOCAL_FOLDER(folder)->rootpath,
2895 str = g_strdup_printf(_("Scanning folder %s ..."),
2896 LOCAL_FOLDER(folder)->rootpath);
2898 STATUSBAR_PUSH(mainwin, str);
2899 STATUSBAR_POP(mainwin);
2903 static void activate_compose_button (MainWindow *mainwin,
2905 ComposeButtonType type)
2907 SensitiveCond state = main_window_get_current_state(mainwin);
2909 if (style == TOOLBAR_NONE)
2912 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2913 : mainwin->compose_news_btn);
2914 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2915 : mainwin->compose_mail_btn);
2916 mainwin->compose_btn_type = type;
2919 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2921 if (mainwin->compose_btn_type != compose_btn_type)
2922 activate_compose_button(mainwin,
2923 prefs_common.toolbar_style,
2927 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
2929 MainWindow *mainwin = (MainWindow*) data;
2931 if (!mainwin) return;
2933 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
2936 #define BREAK_ON_MODIFIER_KEY() \
2937 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2939 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
2941 MainWindow *mainwin = (MainWindow*) data;
2943 if (!mainwin || !event) return;
2945 switch (event->keyval) {
2946 case GDK_Q: /* Quit */
2947 BREAK_ON_MODIFIER_KEY();
2949 app_exit_cb(mainwin, 0, NULL);
2956 #undef BREAK_ON_MODIFIER_KEY