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,
1368 M_HIDE_READ_MSG = 1 << 11
1371 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1373 SensitiveCond state = 0;
1374 SummarySelection selection;
1375 FolderItem *item = mainwin->summaryview->folder_item;
1376 GList *account_list = account_get_list();
1378 selection = summary_get_selection_type(mainwin->summaryview);
1380 if (mainwin->lock_count == 0)
1381 state |= M_UNLOCKED;
1382 if (selection != SUMMARY_NONE)
1383 state |= M_MSG_EXIST;
1386 state |= M_THREADED;
1388 state |= M_UNTHREADED;
1390 if (selection == SUMMARY_NONE && item->hide_read_msgs
1391 || selection != SUMMARY_NONE)
1392 state |= M_HIDE_READ_MSG;
1394 if (selection == SUMMARY_SELECTED_SINGLE ||
1395 selection == SUMMARY_SELECTED_MULTIPLE)
1396 state |= M_TARGET_EXIST;
1397 if (selection == SUMMARY_SELECTED_SINGLE)
1398 state |= M_SINGLE_TARGET_EXIST;
1399 if (item && item->folder->type != F_NEWS)
1401 if (mainwin->summaryview->folder_item &&
1402 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1404 if (selection == SUMMARY_SELECTED_SINGLE &&
1406 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1407 item->stype == F_QUEUE)))
1408 state |= M_ALLOW_REEDIT;
1410 state |= M_HAVE_ACCOUNT;
1412 for ( ; account_list != NULL; account_list = account_list->next) {
1413 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1414 state |= M_HAVE_NEWS_ACCOUNT;
1422 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1424 SensitiveCond state;
1432 {mainwin->get_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1433 {mainwin->getall_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1434 {mainwin->compose_mail_btn, M_HAVE_ACCOUNT},
1435 {mainwin->compose_news_btn, M_HAVE_NEWS_ACCOUNT},
1436 {mainwin->reply_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1437 {mainwin->replyall_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1438 {mainwin->replysender_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1439 {mainwin->fwd_btn , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1440 /* {mainwin->prefs_btn , M_UNLOCKED},
1441 {mainwin->account_btn , M_UNLOCKED}, */
1442 {mainwin->next_btn , M_MSG_EXIST},
1443 {mainwin->delete_btn , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1444 {mainwin->exec_btn , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1448 state = main_window_get_current_state(mainwin);
1450 for (i = 0; entry[i].widget != NULL; i++) {
1451 sensitive = ((entry[i].cond & state) == entry[i].cond);
1452 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1455 activate_compose_button(mainwin,
1456 prefs_common.toolbar_style,
1457 mainwin->compose_btn_type);
1460 void main_window_set_menu_sensitive(MainWindow *mainwin)
1462 GtkItemFactory *ifactory;
1463 SensitiveCond state;
1467 static const struct {
1471 {"/File/Add mailbox..." , M_UNLOCKED},
1472 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1473 {"/File/Rescan folder tree" , M_UNLOCKED},
1474 {"/File/Folder" , M_UNLOCKED},
1475 {"/File/Import mbox file..." , M_UNLOCKED},
1476 {"/File/Export to mbox file...", M_UNLOCKED},
1477 {"/File/Empty trash" , M_UNLOCKED},
1478 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1479 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1480 /* {"/File/Close", M_UNLOCKED}, */
1481 {"/File/Exit" , M_UNLOCKED},
1483 {"/View/Sort" , M_MSG_EXIST},
1484 {"/View/Thread view" , M_UNTHREADED},
1485 {"/View/Unthread view" , M_THREADED},
1486 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1487 {"/View/Go to" , M_MSG_EXIST},
1488 {"/View/Go to/Prev message" , M_MSG_EXIST},
1489 {"/View/Go to/Next message" , M_MSG_EXIST},
1490 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1491 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1492 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1493 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1494 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1495 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1496 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1497 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1499 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1500 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1501 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1502 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1503 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1504 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1505 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1506 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1507 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1508 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1509 {"/Message/Move..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1510 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1511 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1512 {"/Message/Mark" , M_TARGET_EXIST},
1513 {"/Message/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1515 {"/Tool/Add sender to address book", M_SINGLE_TARGET_EXIST},
1516 {"/Tool/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1517 {"/Tool/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1518 {"/Tool/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1520 {"/Configuration", M_UNLOCKED},
1525 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1526 state = main_window_get_current_state(mainwin);
1528 for (i = 0; entry[i].entry != NULL; i++) {
1529 sensitive = ((entry[i].cond & state) == entry[i].cond);
1530 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1534 void main_window_popup(MainWindow *mainwin)
1540 gdk_window_get_origin(mainwin->window->window, &x, &y);
1541 sx = gdk_screen_width();
1542 sy = gdk_screen_height();
1543 x %= sx; if (x < 0) x = 0;
1544 y %= sy; if (y < 0) y = 0;
1545 gdk_window_move(mainwin->window->window, x, y);
1546 gdk_window_raise(mainwin->window->window);
1547 gdk_window_show(mainwin->window->window);
1549 debug_print("window position: x = %d, y = %d\n", x, y);
1551 switch (mainwin->type) {
1552 case SEPARATE_FOLDER:
1553 widget = mainwin->win.sep_folder.folderwin;
1554 gdk_window_get_origin(widget->window, &x, &y);
1555 x %= sx; if (x < 0) x = 0;
1556 y %= sy; if (y < 0) y = 0;
1557 gdk_window_move(widget->window, x, y);
1558 gdk_window_raise(widget->window);
1560 case SEPARATE_MESSAGE:
1561 widget = mainwin->win.sep_message.messagewin;
1562 gdk_window_get_origin(widget->window, &x, &y);
1563 x %= sx; if (x < 0) x = 0;
1564 y %= sy; if (y < 0) y = 0;
1565 gdk_window_move(widget->window, x, y);
1566 gdk_window_raise(widget->window);
1569 widget = mainwin->win.sep_both.folderwin;
1570 gdk_window_get_origin(widget->window, &x, &y);
1571 x %= sx; if (x < 0) x = 0;
1572 y %= sy; if (y < 0) y = 0;
1573 gdk_window_move(widget->window, x, y);
1574 gdk_window_raise(widget->window);
1575 widget = mainwin->win.sep_both.messagewin;
1576 gdk_window_get_origin(widget->window, &x, &y);
1577 x %= sx; if (x < 0) x = 0;
1578 y %= sy; if (y < 0) y = 0;
1579 gdk_window_move(widget->window, x, y);
1580 gdk_window_raise(widget->window);
1587 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1589 GtkWidget *folderwin = NULL;
1590 GtkWidget *messagewin = NULL;
1593 GtkWidget *vbox_body = mainwin->vbox_body;
1594 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1595 GtkWidget *menuitem;
1597 debug_print(_("Setting widgets..."));
1599 /* create separated window(s) if needed */
1600 if (type & SEPARATE_FOLDER) {
1601 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1602 gtk_window_set_title(GTK_WINDOW(folderwin),
1603 _("Sylpheed - Folder View"));
1604 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1605 "folder_view", "Sylpheed");
1606 gtk_window_set_policy(GTK_WINDOW(folderwin),
1608 gtk_widget_set_usize(folderwin, -1,
1609 prefs_common.mainview_height);
1610 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1612 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1613 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1616 if (type & SEPARATE_MESSAGE) {
1617 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1618 gtk_window_set_title(GTK_WINDOW(messagewin),
1619 _("Sylpheed - Message View"));
1620 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1621 "message_view", "Sylpheed");
1622 gtk_window_set_policy(GTK_WINDOW(messagewin),
1624 gtk_widget_set_usize
1625 (messagewin, prefs_common.mainview_width,
1626 prefs_common.mainview_height
1627 - prefs_common.summaryview_height
1628 + DEFAULT_HEADERVIEW_HEIGHT);
1629 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1631 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1632 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1638 hpaned = gtk_hpaned_new();
1639 gtk_widget_show(hpaned);
1640 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1641 gtk_paned_add1(GTK_PANED(hpaned),
1642 GTK_WIDGET_PTR(mainwin->folderview));
1644 vpaned = gtk_vpaned_new();
1645 if (mainwin->summaryview->msg_is_toggled_on) {
1646 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1647 gtk_paned_add1(GTK_PANED(vpaned),
1648 GTK_WIDGET_PTR(mainwin->summaryview));
1650 gtk_paned_add2(GTK_PANED(hpaned),
1651 GTK_WIDGET_PTR(mainwin->summaryview));
1652 gtk_widget_ref(vpaned);
1654 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1655 prefs_common.summaryview_width,
1656 prefs_common.summaryview_height);
1657 gtk_paned_add2(GTK_PANED(vpaned),
1658 GTK_WIDGET_PTR(mainwin->messageview));
1659 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1660 prefs_common.mainview_width, -1);
1661 gtk_widget_set_usize(mainwin->window,
1662 prefs_common.folderview_width +
1663 prefs_common.mainview_width,
1664 prefs_common.mainwin_height);
1665 gtk_widget_show_all(vpaned);
1667 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1668 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1669 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1670 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1671 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1672 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1674 mainwin->win.sep_none.hpaned = hpaned;
1675 mainwin->win.sep_none.vpaned = vpaned;
1677 case SEPARATE_FOLDER:
1678 vpaned = gtk_vpaned_new();
1679 if (mainwin->summaryview->msg_is_toggled_on) {
1680 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1682 gtk_paned_add1(GTK_PANED(vpaned),
1683 GTK_WIDGET_PTR(mainwin->summaryview));
1685 gtk_box_pack_start(GTK_BOX(vbox_body),
1686 GTK_WIDGET_PTR(mainwin->summaryview),
1688 gtk_widget_ref(vpaned);
1690 gtk_paned_add2(GTK_PANED(vpaned),
1691 GTK_WIDGET_PTR(mainwin->messageview));
1692 gtk_widget_show_all(vpaned);
1693 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1694 prefs_common.summaryview_width,
1695 prefs_common.summaryview_height);
1696 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1697 prefs_common.mainview_width, -1);
1698 gtk_widget_set_usize(mainwin->window,
1699 prefs_common.mainview_width,
1700 prefs_common.mainview_height);
1702 gtk_container_add(GTK_CONTAINER(folderwin),
1703 GTK_WIDGET_PTR(mainwin->folderview));
1705 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1706 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1708 mainwin->win.sep_folder.folderwin = folderwin;
1709 mainwin->win.sep_folder.vpaned = vpaned;
1711 gtk_widget_show_all(folderwin);
1713 case SEPARATE_MESSAGE:
1714 hpaned = gtk_hpaned_new();
1715 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1717 gtk_paned_add1(GTK_PANED(hpaned),
1718 GTK_WIDGET_PTR(mainwin->folderview));
1719 gtk_paned_add2(GTK_PANED(hpaned),
1720 GTK_WIDGET_PTR(mainwin->summaryview));
1721 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1722 prefs_common.summaryview_width,
1723 prefs_common.summaryview_height);
1724 gtk_widget_set_usize(mainwin->window,
1725 prefs_common.folderview_width +
1726 prefs_common.mainview_width,
1727 prefs_common.mainwin_height);
1728 gtk_widget_show_all(hpaned);
1729 gtk_container_add(GTK_CONTAINER(messagewin),
1730 GTK_WIDGET_PTR(mainwin->messageview));
1732 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1733 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1734 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1735 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1737 mainwin->win.sep_message.messagewin = messagewin;
1738 mainwin->win.sep_message.hpaned = hpaned;
1740 gtk_widget_show_all(messagewin);
1743 gtk_box_pack_start(GTK_BOX(vbox_body),
1744 GTK_WIDGET_PTR(mainwin->summaryview),
1746 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1747 prefs_common.summaryview_width,
1748 prefs_common.summaryview_height);
1749 gtk_widget_set_usize(mainwin->window,
1750 prefs_common.mainview_width,
1751 prefs_common.mainwin_height);
1752 gtk_container_add(GTK_CONTAINER(folderwin),
1753 GTK_WIDGET_PTR(mainwin->folderview));
1754 gtk_container_add(GTK_CONTAINER(messagewin),
1755 GTK_WIDGET_PTR(mainwin->messageview));
1757 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1758 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1760 mainwin->win.sep_both.folderwin = folderwin;
1761 mainwin->win.sep_both.messagewin = messagewin;
1763 gtk_widget_show_all(folderwin);
1764 gtk_widget_show_all(messagewin);
1768 mainwin->type = type;
1770 debug_print(_("done.\n"));
1773 static void main_window_toolbar_create(MainWindow *mainwin,
1774 GtkWidget *container)
1777 GtkWidget *icon_wid;
1779 GtkWidget *getall_btn;
1780 GtkWidget *compose_mail_btn;
1781 GtkWidget *compose_news_btn;
1782 GtkWidget *reply_btn;
1783 GtkWidget *replyall_btn;
1784 GtkWidget *replysender_btn;
1786 GtkWidget *send_btn;
1788 GtkWidget *prefs_btn;
1789 GtkWidget *account_btn;
1791 GtkWidget *next_btn;
1792 GtkWidget *delete_btn;
1793 GtkWidget *exec_btn;
1795 GtkTooltips *tooltips;
1797 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1799 gtk_container_add(GTK_CONTAINER(container), toolbar);
1800 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1801 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1802 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1803 GTK_TOOLBAR_SPACE_LINE);
1805 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1806 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1808 _("Get new mail from current account"),
1810 icon_wid, toolbar_inc_cb, mainwin);
1811 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1812 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1814 _("Get new mail from all accounts"),
1820 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1822 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1823 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1825 _("Send queued message(s)"),
1831 /* insert compose mail button widget */
1832 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1833 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1835 _("Compose an email message"),
1838 toolbar_compose_mail_cb,
1841 /* insert compose news button widget */
1842 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1843 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1845 _("Compose a news message"),
1848 toolbar_compose_news_cb,
1851 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1855 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1856 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1858 _("Reply to the message - Right button: more options"),
1864 /* replyall button */
1866 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1867 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1869 _("Reply to all - Right button: more options"),
1872 toolbar_reply_to_all_cb,
1875 /* reply to sender button */
1876 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1877 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1879 _("Reply to sender - Right button: more options"),
1882 toolbar_reply_to_sender_cb,
1885 /* forward button */
1886 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1887 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1889 _("Forward the message - Right button: more options"),
1895 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1897 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1898 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1900 _("Delete the message"),
1906 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1907 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1909 _("Execute marked process"),
1915 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
1916 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1918 _("Next unread message"),
1921 toolbar_next_unread_cb,
1925 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1927 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
1928 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1930 _("Common preference"),
1935 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
1936 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1938 _("Account setting"),
1943 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1944 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1948 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
1949 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
1952 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
1953 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
1956 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
1957 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
1960 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
1961 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
1965 mainwin->toolbar = toolbar;
1966 mainwin->get_btn = get_btn;
1967 mainwin->getall_btn = getall_btn;
1968 mainwin->compose_mail_btn = compose_mail_btn;
1969 mainwin->compose_news_btn = compose_news_btn;
1970 mainwin->reply_btn = reply_btn;
1971 mainwin->replyall_btn = replyall_btn;
1972 mainwin->replysender_btn = replysender_btn;
1973 mainwin->fwd_btn = fwd_btn;
1974 mainwin->send_btn = send_btn;
1976 mainwin->prefs_btn = prefs_btn;
1977 mainwin->account_btn = account_btn;
1979 mainwin->next_btn = next_btn;
1980 mainwin->delete_btn = delete_btn;
1981 mainwin->exec_btn = exec_btn;
1983 gtk_widget_show_all(toolbar);
1986 /* callback functions */
1987 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1989 MainWindow *mainwindow = (MainWindow *) data;
1993 if (event->button == 3) {
1994 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1995 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
1996 menu_button_position, widget,
1997 event->button, event->time);
2001 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2003 MainWindow *mainwin = (MainWindow *)data;
2005 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2006 manage_window_focus_in(mainwin->window, NULL, NULL);
2009 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2011 MainWindow *mainwindow = (MainWindow *) data;
2015 if (event->button == 3) {
2016 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2017 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2018 menu_button_position, widget,
2019 event->button, event->time);
2023 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2025 MainWindow *mainwin = (MainWindow *)data;
2027 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2028 manage_window_focus_in(mainwin->window, NULL, NULL);
2031 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2033 MainWindow *mainwindow = (MainWindow *) data;
2034 GtkWidget *replysender_menu, *replysender_item;
2038 if (event->button == 3) {
2039 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2040 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2041 menu_button_position, widget,
2042 event->button, event->time);
2046 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2048 MainWindow *mainwin = (MainWindow *)data;
2050 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2051 manage_window_focus_in(mainwin->window, NULL, NULL);
2054 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2056 MainWindow *mainwindow = (MainWindow *) data;
2060 if (event->button == 3) {
2061 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2062 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2063 menu_button_position, widget,
2064 event->button, event->time);
2068 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2070 MainWindow *mainwin = (MainWindow *)data;
2072 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2073 manage_window_focus_in(mainwin->window, NULL, NULL);
2076 static void toolbar_inc_cb (GtkWidget *widget,
2079 MainWindow *mainwin = (MainWindow *)data;
2081 inc_mail_cb(mainwin, 0, NULL);
2084 static void toolbar_inc_all_cb (GtkWidget *widget,
2087 MainWindow *mainwin = (MainWindow *)data;
2089 inc_all_account_mail_cb(mainwin, 0, NULL);
2092 static void toolbar_send_cb (GtkWidget *widget,
2095 MainWindow *mainwin = (MainWindow *)data;
2097 send_queue_cb(mainwin, 0, NULL);
2100 static void toolbar_compose_cb (GtkWidget *widget,
2103 MainWindow *mainwin = (MainWindow *)data;
2105 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2106 compose_cb(mainwin, 0, NULL);
2108 compose_news_cb(mainwin, 0, NULL);
2111 static void toolbar_compose_news_cb (GtkWidget *widget,
2114 MainWindow *mainwin = (MainWindow *)data;
2116 compose_news_cb(mainwin, 0, NULL);
2119 static void toolbar_compose_mail_cb (GtkWidget *widget,
2122 MainWindow *mainwin = (MainWindow *)data;
2124 compose_mail_cb(mainwin, 0, NULL);
2127 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2129 MainWindow *mainwin = (MainWindow *)data;
2132 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2133 : COMPOSE_REPLY_WITHOUT_QUOTE,
2137 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2139 MainWindow *mainwin = (MainWindow *)data;
2142 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2143 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2148 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2150 MainWindow *mainwin = (MainWindow *)data;
2153 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2154 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2158 static void toolbar_forward_cb (GtkWidget *widget,
2161 MainWindow *mainwin = (MainWindow *)data;
2163 if (prefs_common.forward_as_attachment)
2164 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2166 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2169 static void toolbar_delete_cb (GtkWidget *widget,
2172 MainWindow *mainwin = (MainWindow *)data;
2174 summary_delete(mainwin->summaryview);
2177 static void toolbar_exec_cb (GtkWidget *widget,
2180 MainWindow *mainwin = (MainWindow *)data;
2182 summary_execute(mainwin->summaryview);
2185 static void toolbar_next_unread_cb (GtkWidget *widget,
2188 MainWindow *mainwin = (MainWindow *)data;
2190 next_unread_cb(mainwin, 0, NULL);
2193 static void toolbar_prefs_cb (GtkWidget *widget,
2196 prefs_common_open();
2199 static void toolbar_account_cb (GtkWidget *widget,
2202 MainWindow *mainwin = (MainWindow *)data;
2204 prefs_account_open_cb(mainwin, 0, NULL);
2207 static void toolbar_account_button_pressed(GtkWidget *widget,
2208 GdkEventButton *event,
2211 MainWindow *mainwin = (MainWindow *)data;
2214 if (event->button != 3) return;
2216 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2217 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2220 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2221 menu_button_position, widget,
2222 event->button, event->time);
2225 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2228 MainWindow *mainwin = (MainWindow *)data;
2232 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2233 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2236 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2237 menu_button_position, widget,
2238 event->button, event->time);
2241 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2243 MainWindow *mainwin = (MainWindow *)data;
2246 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2247 if (!button) return;
2248 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2249 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2250 manage_window_focus_in(mainwin->window, NULL, NULL);
2253 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2256 MainWindow *mainwin = (MainWindow *)data;
2258 if (mainwin->lock_count == 0)
2259 app_exit_cb(data, 0, widget);
2264 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2267 main_window_add_mailbox(mainwin);
2270 static void add_mbox_cb(MainWindow *mainwin, guint action,
2273 main_window_add_mbox(mainwin);
2276 static void update_folderview_cb(MainWindow *mainwin, guint action,
2279 summary_show(mainwin->summaryview, NULL, FALSE);
2280 folderview_update_all();
2283 static void new_folder_cb(MainWindow *mainwin, guint action,
2286 folderview_new_folder(mainwin->folderview);
2289 static void rename_folder_cb(MainWindow *mainwin, guint action,
2292 folderview_rename_folder(mainwin->folderview);
2295 static void delete_folder_cb(MainWindow *mainwin, guint action,
2298 folderview_delete_folder(mainwin->folderview);
2301 static void import_mbox_cb(MainWindow *mainwin, guint action,
2304 import_mbox(mainwin->summaryview->folder_item);
2307 static void export_mbox_cb(MainWindow *mainwin, guint action,
2310 export_mbox(mainwin->summaryview->folder_item);
2313 static void empty_trash_cb(MainWindow *mainwin, guint action,
2316 main_window_empty_trash(mainwin, TRUE);
2319 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2321 summary_save_as(mainwin->summaryview);
2324 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2326 summary_print(mainwin->summaryview);
2329 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2331 if (prefs_common.confirm_on_exit) {
2332 if (alertpanel(_("Exit"), _("Exit this program?"),
2333 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2335 manage_window_focus_in(mainwin->window, NULL, NULL);
2338 app_will_exit(widget, mainwin);
2341 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2344 summary_search(mainwin->summaryview);
2346 message_search(mainwin->messageview);
2349 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2352 switch (mainwin->type) {
2354 case SEPARATE_MESSAGE:
2356 case SEPARATE_FOLDER:
2357 if (GTK_CHECK_MENU_ITEM(widget)->active)
2358 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2360 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2363 if (GTK_CHECK_MENU_ITEM(widget)->active)
2364 gtk_widget_show(mainwin->win.sep_both.folderwin);
2366 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2371 static void toggle_message_cb(MainWindow *mainwin, guint action,
2374 switch (mainwin->type) {
2376 case SEPARATE_FOLDER:
2378 case SEPARATE_MESSAGE:
2379 if (GTK_CHECK_MENU_ITEM(widget)->active)
2380 gtk_widget_show(mainwin->win.sep_message.messagewin);
2382 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2385 if (GTK_CHECK_MENU_ITEM(widget)->active)
2386 gtk_widget_show(mainwin->win.sep_both.messagewin);
2388 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2393 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2396 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2397 mainwin->compose_btn_type);
2398 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2399 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2400 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2401 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2403 switch ((ToolbarStyle)action) {
2405 gtk_widget_hide(mainwin->handlebox);
2407 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2411 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2415 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2420 if (action != TOOLBAR_NONE) {
2421 gtk_widget_show(mainwin->handlebox);
2422 gtk_widget_queue_resize(mainwin->handlebox);
2425 mainwin->toolbar_style = (ToolbarStyle)action;
2426 prefs_common.toolbar_style = (ToolbarStyle)action;
2429 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2432 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2433 gtk_widget_show(mainwin->hbox_stat);
2434 prefs_common.show_statusbar = TRUE;
2436 gtk_widget_hide(mainwin->hbox_stat);
2437 prefs_common.show_statusbar = FALSE;
2441 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2443 summary_toggle_view_real(mainwin->summaryview);
2446 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2448 messageview_toggle_view_real(mainwin->messageview);
2451 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2454 MainWindow *mainwin;
2457 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2458 g_return_if_fail(mainwin != NULL);
2460 type = mainwin->type ^ action;
2461 main_window_separation_change(mainwin, type);
2463 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2464 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2467 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2470 addressbook_open(NULL);
2473 static void log_window_show_cb(MainWindow *mainwin, guint action,
2476 log_window_show(mainwin->logwin);
2479 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2484 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2487 inc_all_account_mail(mainwin);
2490 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2494 if (procmsg_send_queue() < 0)
2495 alertpanel_error(_("Some errors occurred while sending queued messages."));
2497 statusbar_pop_all();
2499 for (list = folder_get_list(); list != NULL; list = list->next) {
2502 folder = list->data;
2503 if (folder->queue) {
2504 folder_item_scan(folder->queue);
2505 folderview_update_item(folder->queue, TRUE);
2510 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2512 if (mainwin->summaryview->folder_item) {
2513 if (mainwin->summaryview->folder_item->folder->account != NULL
2514 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2515 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2517 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2523 static void compose_mail_cb(MainWindow *mainwin, guint action,
2530 if (mainwin->summaryview->folder_item) {
2531 ac = mainwin->summaryview->folder_item->folder->account;
2532 if (ac && ac->protocol != A_NNTP) {
2533 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2538 if(cur_account && (cur_account->protocol != A_NNTP)) {
2539 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2543 list = account_get_list();
2544 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2545 ac = (PrefsAccount *) cur->data;
2546 if (ac->protocol != A_NNTP) {
2547 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2553 static void compose_news_cb(MainWindow *mainwin, guint action,
2556 PrefsAccount * ac = NULL;
2560 if (mainwin->summaryview->folder_item) {
2561 ac = mainwin->summaryview->folder_item->folder->account;
2562 if (ac && ac->protocol == A_NNTP) {
2563 compose_new_with_recipient
2564 (ac, mainwin->summaryview->folder_item->path);
2569 list = account_get_list();
2570 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2571 ac = (PrefsAccount *) cur->data;
2572 if (ac->protocol == A_NNTP) {
2579 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2581 summary_reply(mainwin->summaryview, (ComposeMode)action);
2584 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2586 summary_move_to(mainwin->summaryview);
2589 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2591 summary_copy_to(mainwin->summaryview);
2594 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2596 summary_delete(mainwin->summaryview);
2599 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2601 summary_open_msg(mainwin->summaryview);
2604 static void view_source_cb(MainWindow *mainwin, guint action,
2607 summary_view_source(mainwin->summaryview);
2610 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2612 summary_reedit(mainwin->summaryview);
2615 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2617 summary_mark(mainwin->summaryview);
2620 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2622 summary_unmark(mainwin->summaryview);
2625 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2628 summary_mark_as_unread(mainwin->summaryview);
2631 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2634 summary_mark_as_read(mainwin->summaryview);
2637 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2640 summary_mark_all_read(mainwin->summaryview);
2643 static void add_address_cb(MainWindow *mainwin, guint action,
2646 summary_add_address(mainwin->summaryview);
2649 static void set_charset_cb(MainWindow *mainwin, guint action,
2654 str = conv_get_charset_str((CharSet)action);
2655 g_free(prefs_common.force_charset);
2656 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2658 summary_redisplay_msg(mainwin->summaryview);
2660 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2663 static void hide_read_messages (MainWindow *mainwin, guint action,
2666 if (!mainwin->summaryview->folder_item
2667 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2669 summary_toggle_show_read_messages(mainwin->summaryview);
2672 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2674 GtkItemFactory *ifactory;
2676 if (!mainwin->summaryview->folder_item) return;
2678 ifactory = gtk_item_factory_from_widget(widget);
2681 summary_thread_build(mainwin->summaryview);
2682 mainwin->summaryview->folder_item->threaded = TRUE;
2683 menu_set_sensitive(ifactory, "/View/Thread view", FALSE);
2684 menu_set_sensitive(ifactory, "/View/Unthread view", TRUE);
2686 summary_unthread(mainwin->summaryview);
2687 mainwin->summaryview->folder_item->threaded = FALSE;
2688 menu_set_sensitive(ifactory, "/View/Thread view", TRUE);
2689 menu_set_sensitive(ifactory, "/View/Unthread view", FALSE);
2693 static void set_display_item_cb(MainWindow *mainwin, guint action,
2696 prefs_summary_column_open();
2699 static void sort_summary_cb(MainWindow *mainwin, guint action,
2702 summary_sort(mainwin->summaryview, (SummarySortType)action);
2705 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2708 summary_attract_by_subject(mainwin->summaryview);
2711 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2714 summary_delete_duplicated(mainwin->summaryview);
2717 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2719 summary_filter(mainwin->summaryview);
2722 static void execute_summary_cb(MainWindow *mainwin, guint action,
2725 summary_execute(mainwin->summaryview);
2728 static void update_summary_cb(MainWindow *mainwin, guint action,
2732 FolderView *folderview = mainwin->folderview;
2734 if (!mainwin->summaryview->folder_item) return;
2735 if (!folderview->opened) return;
2737 folder_update_op_count();
2739 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2740 folderview->opened);
2743 summary_show(mainwin->summaryview, fitem, TRUE);
2746 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2748 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2751 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2753 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2756 static void prev_unread_cb(MainWindow *mainwin, guint action,
2759 summary_select_prev_unread(mainwin->summaryview);
2762 static void next_unread_cb(MainWindow *mainwin, guint action,
2765 summary_select_next_unread(mainwin->summaryview);
2768 static void prev_marked_cb(MainWindow *mainwin, guint action,
2771 summary_select_prev_marked(mainwin->summaryview);
2774 static void next_marked_cb(MainWindow *mainwin, guint action,
2777 summary_select_next_marked(mainwin->summaryview);
2780 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2783 summary_select_prev_labeled(mainwin->summaryview);
2786 static void next_labeled_cb(MainWindow *mainwin, guint action,
2789 summary_select_next_labeled(mainwin->summaryview);
2792 static void goto_folder_cb(MainWindow *mainwin, guint action,
2795 FolderItem *to_folder;
2797 to_folder = foldersel_folder_sel(NULL, NULL);
2800 folderview_select(mainwin->folderview, to_folder);
2803 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2805 messageview_copy_clipboard(mainwin->messageview);
2808 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2810 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2811 summary_select_all(mainwin->summaryview);
2812 else if (mainwin->summaryview->msg_is_toggled_on &&
2813 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2814 messageview_select_all(mainwin->messageview);
2817 static void create_filter_cb(MainWindow *mainwin, guint action,
2820 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2823 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2826 prefs_common_open();
2829 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2832 prefs_filter_open(NULL, NULL);
2835 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2838 prefs_scoring_open(NULL);
2841 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2844 prefs_filtering_open(NULL);
2847 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2850 prefs_template_open();
2853 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2857 new_account_cb(mainwin, 0, widget);
2859 gboolean prev_default = cur_account->is_default;
2861 prefs_account_open(cur_account);
2862 if (!prev_default && cur_account->is_default)
2863 account_set_as_default(cur_account);
2864 account_save_config_all();
2866 main_window_reflect_prefs_all();
2870 static void new_account_cb(MainWindow *mainwin, guint action,
2873 account_edit_open();
2874 if (!compose_get_compose_list()) account_add();
2877 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2879 cur_account = (PrefsAccount *)data;
2880 main_window_reflect_prefs_all();
2883 static void manual_open_cb(MainWindow *mainwin, guint action,
2886 manual_open((ManualLang)action);
2889 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2891 MainWindow *mainwin = (MainWindow *)data;
2895 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2896 LOCAL_FOLDER(folder)->rootpath,
2900 str = g_strdup_printf(_("Scanning folder %s ..."),
2901 LOCAL_FOLDER(folder)->rootpath);
2903 STATUSBAR_PUSH(mainwin, str);
2904 STATUSBAR_POP(mainwin);
2908 static void activate_compose_button (MainWindow *mainwin,
2910 ComposeButtonType type)
2912 SensitiveCond state = main_window_get_current_state(mainwin);
2914 if (style == TOOLBAR_NONE)
2917 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2918 : mainwin->compose_news_btn);
2919 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2920 : mainwin->compose_mail_btn);
2921 mainwin->compose_btn_type = type;
2924 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2926 if (mainwin->compose_btn_type != compose_btn_type)
2927 activate_compose_button(mainwin,
2928 prefs_common.toolbar_style,
2932 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
2934 MainWindow *mainwin = (MainWindow*) data;
2936 if (!mainwin) return;
2938 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
2941 #define BREAK_ON_MODIFIER_KEY() \
2942 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2944 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
2946 MainWindow *mainwin = (MainWindow*) data;
2948 if (!mainwin || !event) return;
2950 switch (event->keyval) {
2951 case GDK_Q: /* Quit */
2952 BREAK_ON_MODIFIER_KEY();
2954 app_exit_cb(mainwin, 0, NULL);
2961 #undef BREAK_ON_MODIFIER_KEY