2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2002 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
55 #include "stock_pixmap.h"
62 #include "prefs_common.h"
63 #include "prefs_filter.h"
64 #include "prefs_actions.h"
65 #include "prefs_filtering.h"
66 #include "prefs_scoring.h"
67 #include "prefs_account.h"
68 #include "prefs_folder_item.h"
69 #include "prefs_summary_column.h"
70 #include "prefs_template.h"
72 #include "addressbook.h"
73 #include "logwindow.h"
74 #include "manage_window.h"
75 #include "alertpanel.h"
76 #include "statusbar.h"
77 #include "inputdialog.h"
84 #include "selective_download.h"
86 #define AC_LABEL_WIDTH 240
88 #define STATUSBAR_PUSH(mainwin, str) \
90 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
91 mainwin->mainwin_cid, str); \
92 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
95 #define STATUSBAR_POP(mainwin) \
97 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
98 mainwin->mainwin_cid); \
101 /* list of all instantiated MainWindow */
102 static GList *mainwin_list = NULL;
104 static GdkCursor *watch_cursor;
106 static void main_window_menu_callback_block (MainWindow *mainwin);
107 static void main_window_menu_callback_unblock (MainWindow *mainwin);
109 static void main_window_show_cur_account (MainWindow *mainwin);
111 static void main_window_set_widgets (MainWindow *mainwin,
113 static void main_window_toolbar_create (MainWindow *mainwin,
114 GtkWidget *container);
116 /* callback functions */
117 static void toolbar_inc_cb (GtkWidget *widget,
119 static void toolbar_inc_all_cb (GtkWidget *widget,
121 static void toolbar_send_cb (GtkWidget *widget,
124 static void toolbar_compose_cb (GtkWidget *widget,
126 static void toolbar_compose_news_cb (GtkWidget *widget,
128 static void toolbar_compose_mail_cb (GtkWidget *widget,
130 static void toolbar_reply_cb (GtkWidget *widget,
132 static void toolbar_reply_popup_cb (GtkWidget *widget,
133 GdkEventButton *event,
135 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell,
137 static void toolbar_reply_to_all_cb (GtkWidget *widget,
139 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget,
140 GdkEventButton *event,
142 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell,
144 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
146 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
147 GdkEventButton *event,
149 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell,
151 static void toolbar_forward_cb (GtkWidget *widget,
153 static void toolbar_forward_popup_cb (GtkWidget *widget,
154 GdkEventButton *event,
156 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell,
159 static void toolbar_delete_cb (GtkWidget *widget,
161 static void toolbar_exec_cb (GtkWidget *widget,
164 static void toolbar_next_unread_cb (GtkWidget *widget,
167 static void toolbar_prefs_cb (GtkWidget *widget,
169 static void toolbar_account_cb (GtkWidget *widget,
172 static void toolbar_account_button_pressed (GtkWidget *widget,
173 GdkEventButton *event,
175 static void ac_label_button_pressed (GtkWidget *widget,
176 GdkEventButton *event,
178 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
181 static gint main_window_close_cb (GtkWidget *widget,
185 static void add_mailbox_cb (MainWindow *mainwin,
188 static void add_mbox_cb (MainWindow *mainwin,
191 static void update_folderview_cb (MainWindow *mainwin,
194 static void new_folder_cb (MainWindow *mainwin,
197 static void rename_folder_cb (MainWindow *mainwin,
200 static void delete_folder_cb (MainWindow *mainwin,
203 static void import_mbox_cb (MainWindow *mainwin,
206 static void export_mbox_cb (MainWindow *mainwin,
209 static void empty_trash_cb (MainWindow *mainwin,
213 static void save_as_cb (MainWindow *mainwin,
216 static void print_cb (MainWindow *mainwin,
219 static void app_exit_cb (MainWindow *mainwin,
223 static void search_cb (MainWindow *mainwin,
227 static void toggle_folder_cb (MainWindow *mainwin,
230 static void toggle_message_cb (MainWindow *mainwin,
233 static void toggle_toolbar_cb (MainWindow *mainwin,
236 static void toggle_statusbar_cb (MainWindow *mainwin,
239 static void toggle_expand_summaryview_cb (MainWindow *mainwin,
242 static void toggle_expand_messageview_cb (MainWindow *mainwin,
245 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
249 static void addressbook_open_cb (MainWindow *mainwin,
252 static void log_window_show_cb (MainWindow *mainwin,
255 static void sel_download_cb (MainWindow *mainwin,
259 static void inc_mail_cb (MainWindow *mainwin,
262 static void inc_all_account_mail_cb (MainWindow *mainwin,
265 static void inc_cancel_cb (MainWindow *mainwin,
269 static void send_queue_cb (MainWindow *mainwin,
273 static void compose_cb (MainWindow *mainwin,
276 static void compose_mail_cb(MainWindow *mainwin, guint action,
278 static void compose_news_cb(MainWindow *mainwin, guint action,
280 static void reply_cb (MainWindow *mainwin,
284 static void open_msg_cb (MainWindow *mainwin,
288 static void view_source_cb (MainWindow *mainwin,
292 static void show_all_header_cb (MainWindow *mainwin,
296 static void reedit_cb (MainWindow *mainwin,
300 static void move_to_cb (MainWindow *mainwin,
303 static void copy_to_cb (MainWindow *mainwin,
306 static void delete_cb (MainWindow *mainwin,
310 static void mark_cb (MainWindow *mainwin,
313 static void unmark_cb (MainWindow *mainwin,
317 static void mark_as_unread_cb (MainWindow *mainwin,
320 static void mark_as_read_cb (MainWindow *mainwin,
323 static void mark_all_read_cb (MainWindow *mainwin,
326 static void add_address_cb (MainWindow *mainwin,
330 static void set_charset_cb (MainWindow *mainwin,
334 static void hide_read_messages (MainWindow *mainwin,
338 static void thread_cb (MainWindow *mainwin,
341 static void set_display_item_cb (MainWindow *mainwin,
344 static void sort_summary_cb (MainWindow *mainwin,
347 static void attract_by_subject_cb(MainWindow *mainwin,
351 static void delete_duplicated_cb (MainWindow *mainwin,
354 static void filter_cb (MainWindow *mainwin,
357 static void execute_summary_cb (MainWindow *mainwin,
360 static void update_summary_cb (MainWindow *mainwin,
364 static void prev_cb (MainWindow *mainwin,
367 static void next_cb (MainWindow *mainwin,
371 static void prev_unread_cb (MainWindow *mainwin,
374 static void next_unread_cb (MainWindow *mainwin,
377 static void prev_marked_cb (MainWindow *mainwin,
380 static void next_marked_cb (MainWindow *mainwin,
383 static void prev_labeled_cb (MainWindow *mainwin,
386 static void next_labeled_cb (MainWindow *mainwin,
390 static void goto_folder_cb (MainWindow *mainwin,
394 static void copy_cb (MainWindow *mainwin,
397 static void allsel_cb (MainWindow *mainwin,
400 static void selthread_cb (MainWindow *mainwin,
403 static void create_filter_cb (MainWindow *mainwin,
407 static void prefs_common_open_cb (MainWindow *mainwin,
410 static void prefs_filter_open_cb (MainWindow *mainwin,
413 static void prefs_scoring_open_cb (MainWindow *mainwin,
416 static void prefs_filtering_open_cb (MainWindow *mainwin,
419 static void prefs_account_open_cb(MainWindow *mainwin,
422 static void prefs_template_open_cb (MainWindow *mainwin,
425 static void prefs_actions_open_cb (MainWindow *mainwin,
428 static void new_account_cb (MainWindow *mainwin,
432 static void account_menu_cb (GtkMenuItem *menuitem,
435 static void manual_open_cb (MainWindow *mainwin,
438 static void faq_open_cb (MainWindow *mainwin,
442 static void scan_tree_func (Folder *folder,
446 static void activate_compose_button (MainWindow *mainwin,
448 ComposeButtonType type);
450 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
454 static void key_pressed (GtkWidget *widget,
458 static void set_toolbar_style(MainWindow *mainwin);
460 #define SEPARATE_ACTION 667
462 static GtkItemFactoryEntry mainwin_entries[] =
464 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
465 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
466 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
467 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
468 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
469 {N_("/_File/_Folder/Create _new folder..."),
470 NULL, new_folder_cb, 0, NULL},
471 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
472 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
473 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
474 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
475 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
476 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
477 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
478 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
479 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
480 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
482 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
483 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
484 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
485 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
486 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
487 {N_("/_Edit/_Find in current message..."),
488 "<control>F", search_cb, 0, NULL},
489 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
490 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
491 {N_("/_Edit/Actio_ns"), NULL, NULL, 0, "<Branch>"},
493 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
494 {N_("/_View/Separate _Folder Tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
495 {N_("/_View/Separate _Message View"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
496 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
497 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
498 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
499 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
500 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
501 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
502 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
503 {N_("/_View/Status _bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
504 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
505 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
506 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
507 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
508 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
509 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
510 {N_("/_View/_Sort/Sort by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
511 {N_("/_View/_Sort/Sort by _color label"),
512 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
513 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
514 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
515 {N_("/_View/_Sort/Sort by a_ttachment"),
516 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
517 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
518 {N_("/_View/_Sort/_Attract by subject"),
519 NULL, attract_by_subject_cb, 0, NULL},
520 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
521 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
522 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
523 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
525 #define CODESET_SEPARATOR \
526 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
527 #define CODESET_ACTION(action) \
528 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
530 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
531 {N_("/_View/_Code set/_Auto detect"),
532 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
533 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
534 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
535 CODESET_ACTION(C_US_ASCII)},
538 {N_("/_View/_Code set/Unicode (_UTF-8)"),
539 CODESET_ACTION(C_UTF_8)},
542 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
543 CODESET_ACTION(C_ISO_8859_1)},
544 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
545 CODESET_ACTION(C_ISO_8859_15)},
548 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
549 CODESET_ACTION(C_ISO_8859_2)},
551 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
552 CODESET_ACTION(C_ISO_8859_13)},
553 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
554 CODESET_ACTION(C_ISO_8859_4)},
556 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
557 CODESET_ACTION(C_ISO_8859_7)},
559 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
560 CODESET_ACTION(C_ISO_8859_9)},
562 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
563 CODESET_ACTION(C_ISO_8859_5)},
564 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
565 CODESET_ACTION(C_KOI8_R)},
566 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
567 CODESET_ACTION(C_CP1251)},
570 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
571 CODESET_ACTION(C_ISO_2022_JP)},
573 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
574 CODESET_ACTION(C_ISO_2022_JP_2)},
576 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
577 CODESET_ACTION(C_EUC_JP)},
578 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
579 CODESET_ACTION(C_SHIFT_JIS)},
582 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
583 CODESET_ACTION(C_GB2312)},
584 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
585 CODESET_ACTION(C_BIG5)},
586 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
587 CODESET_ACTION(C_EUC_TW)},
588 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
589 CODESET_ACTION(C_ISO_2022_CN)},
591 {N_("/_View/_Code set/Korean (EUC-_KR)"),
592 CODESET_ACTION(C_EUC_KR)},
593 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
594 CODESET_ACTION(C_ISO_2022_KR)},
596 {N_("/_View/_Code set/Thai (TIS-620)"),
597 CODESET_ACTION(C_TIS_620)},
598 {N_("/_View/_Code set/Thai (Windows-874)"),
599 CODESET_ACTION(C_WINDOWS_874)},
602 #undef CODESET_SEPARATOR
603 #undef CODESET_ACTION
605 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
606 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
607 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
608 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
609 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
610 {N_("/_View/_Go to/P_rev unread message"),
611 "<shift>P", prev_unread_cb, 0, NULL},
612 {N_("/_View/_Go to/N_ext unread message"),
613 "<shift>N", next_unread_cb, 0, NULL},
614 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
615 {N_("/_View/_Go to/Prev _marked message"),
616 NULL, prev_marked_cb, 0, NULL},
617 {N_("/_View/_Go to/Next m_arked message"),
618 NULL, next_marked_cb, 0, NULL},
619 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_View/_Go to/Prev _labeled message"),
621 NULL, prev_labeled_cb, 0, NULL},
622 {N_("/_View/_Go to/Next la_beled message"),
623 NULL, next_labeled_cb, 0, NULL},
624 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
625 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
626 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
627 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
628 {N_("/_View/_View source"), "<control>U", view_source_cb, 0, NULL},
629 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
630 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
631 {N_("/_View/_Update"), "<control><alt>U", update_summary_cb, 0, NULL},
633 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
634 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
635 {N_("/_Message/Get from _all accounts"),
636 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
637 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
638 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
639 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
640 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
641 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
642 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
643 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
644 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
645 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
646 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
647 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
648 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
649 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
650 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
651 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
652 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
653 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
654 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
655 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
656 {N_("/_Message/Delete du_plicated messages"),
657 NULL, delete_duplicated_cb, 0, NULL},
658 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
659 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
660 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
661 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
662 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
663 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
664 {N_("/_Message/_Mark/Mark as rea_d"),
665 NULL, mark_as_read_cb, 0, NULL},
666 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
668 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
669 {N_("/_Tool/_Address book"), "<shift><control>A", addressbook_open_cb, 0, NULL},
670 {N_("/_Tool/Add sender to address boo_k"),
671 NULL, add_address_cb, 0, NULL},
672 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
673 {N_("/_Tool/_Filter messages"), NULL, filter_cb, 0, NULL},
674 {N_("/_Tool/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
675 {N_("/_Tool/_Create filter rule/_Automatically"),
676 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
677 {N_("/_Tool/_Create filter rule/by _From"),
678 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
679 {N_("/_Tool/_Create filter rule/by _To"),
680 NULL, create_filter_cb, FILTER_BY_TO, NULL},
681 {N_("/_Tool/_Create filter rule/by _Subject"),
682 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
683 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
684 {N_("/_Tool/E_xecute"), "X", execute_summary_cb, 0, NULL},
685 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
686 {N_("/_Tool/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
687 {N_("/_Tool/_Selective Download"), "<alt>S", sel_download_cb, 0, NULL},
689 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
690 {N_("/_Configuration/_Common preferences..."),
691 NULL, prefs_common_open_cb, 0, NULL},
692 {N_("/_Configuration/_Filter setting..."),
693 NULL, prefs_filter_open_cb, 0, NULL},
694 {N_("/_Configuration/_Scoring ..."),
695 NULL, prefs_scoring_open_cb, 0, NULL},
696 {N_("/_Configuration/_Filtering ..."),
697 NULL, prefs_filtering_open_cb, 0, NULL},
698 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
699 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
700 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
701 {N_("/_Configuration/_Preferences for current account..."),
702 NULL, prefs_account_open_cb, 0, NULL},
703 {N_("/_Configuration/Create _new account..."),
704 NULL, new_account_cb, 0, NULL},
705 {N_("/_Configuration/_Edit accounts..."),
706 NULL, account_edit_open, 0, NULL},
707 {N_("/_Configuration/C_hange current account"),
708 NULL, NULL, 0, "<Branch>"},
710 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
711 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
712 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
713 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
714 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
715 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
716 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
717 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
718 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
719 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
720 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
721 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
723 static GtkItemFactoryEntry reply_popup_entries[] =
725 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
726 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
728 static GtkItemFactoryEntry replyall_popup_entries[] =
730 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
731 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
733 static GtkItemFactoryEntry replysender_popup_entries[] =
735 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
736 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
738 static GtkItemFactoryEntry fwd_popup_entries[] =
740 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
741 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
745 MainWindow *main_window_create(SeparateType type)
751 GtkWidget *handlebox;
752 GtkWidget *vbox_body;
753 GtkWidget *hbox_stat;
754 GtkWidget *statusbar;
755 GtkWidget *progressbar;
756 GtkWidget *statuslabel;
757 GtkWidget *ac_button;
760 FolderView *folderview;
761 SummaryView *summaryview;
762 MessageView *messageview;
763 GdkColormap *colormap;
766 guint n_menu_entries;
767 GtkItemFactory *ifactory;
770 GtkWidget *compose_popup;
771 GtkWidget *reply_popup;
772 GtkWidget *replyall_popup;
773 GtkWidget *replysender_popup;
774 GtkWidget *fwd_popup;
777 debug_print(_("Creating main window...\n"));
778 mainwin = g_new0(MainWindow, 1);
781 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
782 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
783 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
784 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
785 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
786 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
787 MANAGE_WINDOW_SIGNALS_CONNECT(window);
788 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
789 GTK_SIGNAL_FUNC(key_pressed), mainwin);
791 gtk_widget_realize(window);
792 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
795 gtkut_widget_set_app_icon(window);
797 vbox = gtk_vbox_new(FALSE, 0);
798 gtk_widget_show(vbox);
799 gtk_container_add(GTK_CONTAINER(window), vbox);
802 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
803 menubar = menubar_create(window, mainwin_entries,
804 n_menu_entries, "<Main>", mainwin);
805 gtk_widget_show(menubar);
806 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
808 handlebox = gtk_handle_box_new();
809 gtk_widget_show(handlebox);
810 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
812 /* create the popup menus for the reply buttons specials */
813 n_menu_entries = sizeof(reply_popup_entries) /
814 sizeof(reply_popup_entries[0]);
815 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
816 "<ReplyPopup>", mainwin);
817 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
818 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
819 n_menu_entries = sizeof(replyall_popup_entries) /
820 sizeof(replyall_popup_entries[0]);
821 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
822 "<ReplyAllPopup>", mainwin);
823 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
824 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
825 n_menu_entries = sizeof(replysender_popup_entries) /
826 sizeof(replysender_popup_entries[0]);
827 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
828 "<ReplySenderPopup>", mainwin);
829 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
830 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
831 /* create the popup menu for the forward button */
832 n_menu_entries = sizeof(fwd_popup_entries) /
833 sizeof(fwd_popup_entries[0]);
834 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
835 "<ForwardPopup>", mainwin);
836 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
837 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
839 main_window_toolbar_create(mainwin, handlebox);
841 /* vbox that contains body */
842 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
843 gtk_widget_show(vbox_body);
844 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
845 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
847 hbox_stat = gtk_hbox_new(FALSE, 2);
848 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
850 statusbar = statusbar_create();
851 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
853 progressbar = gtk_progress_bar_new();
854 gtk_widget_set_usize(progressbar, 120, 1);
855 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
857 statuslabel = gtk_label_new("");
858 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
860 ac_button = gtk_button_new();
861 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
862 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
863 gtk_widget_set_usize(ac_button, -1, 1);
864 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
865 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
866 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
868 ac_label = gtk_label_new("");
869 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
871 gtk_widget_show_all(hbox_stat);
874 mainwin->folderview = folderview = folderview_create();
875 mainwin->summaryview = summaryview = summary_create();
876 mainwin->messageview = messageview = messageview_create();
877 mainwin->logwin = log_window_create();
879 folderview->mainwin = mainwin;
880 folderview->summaryview = summaryview;
882 summaryview->mainwin = mainwin;
883 summaryview->folderview = folderview;
884 summaryview->messageview = messageview;
885 summaryview->window = window;
887 messageview->mainwin = mainwin;
889 mainwin->window = window;
890 mainwin->vbox = vbox;
891 mainwin->menubar = menubar;
892 mainwin->handlebox = handlebox;
893 mainwin->vbox_body = vbox_body;
894 mainwin->hbox_stat = hbox_stat;
895 mainwin->statusbar = statusbar;
896 mainwin->progressbar = progressbar;
897 mainwin->statuslabel = statuslabel;
898 mainwin->ac_button = ac_button;
899 mainwin->ac_label = ac_label;
900 mainwin->reply_popup = reply_popup;
901 mainwin->replyall_popup = replyall_popup;
902 mainwin->replysender_popup = replysender_popup;
903 mainwin->fwd_popup = fwd_popup;
905 /* set context IDs for status bar */
906 mainwin->mainwin_cid = gtk_statusbar_get_context_id
907 (GTK_STATUSBAR(statusbar), "Main Window");
908 mainwin->folderview_cid = gtk_statusbar_get_context_id
909 (GTK_STATUSBAR(statusbar), "Folder View");
910 mainwin->summaryview_cid = gtk_statusbar_get_context_id
911 (GTK_STATUSBAR(statusbar), "Summary View");
913 /* allocate colors for summary view and folder view */
914 summaryview->color_marked.red = summaryview->color_marked.green = 0;
915 summaryview->color_marked.blue = (guint16)65535;
917 summaryview->color_dim.red = summaryview->color_dim.green =
918 summaryview->color_dim.blue = COLOR_DIM;
920 folderview->color_new.red = (guint16)55000;
921 folderview->color_new.green = folderview->color_new.blue = 15000;
923 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
924 &folderview->color_op);
926 summaryview->color_important.red = 0;
927 summaryview->color_marked.green = 0;
928 summaryview->color_important.blue = (guint16)65535;
930 color[0] = summaryview->color_marked;
931 color[1] = summaryview->color_dim;
932 color[2] = folderview->color_new;
933 color[3] = folderview->color_op;
935 colormap = gdk_window_get_colormap(window->window);
936 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
937 for (i = 0; i < 4; i++) {
938 if (success[i] == FALSE)
939 g_warning(_("MainWindow: color allocation %d failed\n"), i);
942 debug_print(_("done.\n"));
944 main_window_set_widgets(mainwin, type);
947 ifactory = gtk_item_factory_from_widget(menubar);
948 menuitem = gtk_item_factory_get_item
949 (ifactory, "/View/Code set/Auto detect");
950 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
952 switch (prefs_common.toolbar_style) {
954 menuitem = gtk_item_factory_get_item
955 (ifactory, "/View/Toolbar/None");
958 menuitem = gtk_item_factory_get_item
959 (ifactory, "/View/Toolbar/Icon");
962 menuitem = gtk_item_factory_get_item
963 (ifactory, "/View/Toolbar/Text");
966 menuitem = gtk_item_factory_get_item
967 (ifactory, "/View/Toolbar/Icon and text");
969 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
971 gtk_widget_hide(mainwin->hbox_stat);
972 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
973 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
974 prefs_common.show_statusbar);
975 #if 0 /* FIXED SEPARATE WINDOWS */
976 /* Message view and Folder tree are always shown at startup
977 * make that in the menu visible */
978 menuitem = gtk_item_factory_get_item(ifactory, "/View/Message view");
979 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
980 menuitem = gtk_item_factory_get_item(ifactory, "/View/Folder tree");
981 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
983 /* set the check of the SEPARATE_xxx menu items. we also need the main window
984 * as a property and pass the action type to the callback */
985 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
987 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
988 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
989 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
990 GUINT_TO_POINTER(SEPARATE_FOLDER));
992 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
994 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
995 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
996 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
997 GUINT_TO_POINTER(SEPARATE_MESSAGE));
999 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
1000 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
1003 /* set account selection menu */
1004 ac_menu = gtk_item_factory_get_widget
1005 (ifactory, "/Configuration/Change current account");
1006 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1007 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1008 mainwin->ac_menu = ac_menu;
1010 main_window_set_toolbar_sensitive(mainwin);
1012 /* Create actions menu */
1013 update_mainwin_actions_menu(ifactory, mainwin);
1015 /* show main window */
1016 gtk_widget_set_uposition(mainwin->window,
1017 prefs_common.mainwin_x,
1018 prefs_common.mainwin_y);
1019 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1020 prefs_common.mainwin_height);
1021 gtk_widget_show(mainwin->window);
1023 /* initialize views */
1024 folderview_init(folderview);
1025 summary_init(summaryview);
1026 messageview_init(messageview);
1027 log_window_init(mainwin->logwin);
1029 mainwin->lock_count = 0;
1030 mainwin->menu_lock_count = 0;
1031 mainwin->cursor_count = 0;
1034 watch_cursor = gdk_cursor_new(GDK_WATCH);
1036 mainwin_list = g_list_append(mainwin_list, mainwin);
1041 void main_window_cursor_wait(MainWindow *mainwin)
1044 if (mainwin->cursor_count == 0)
1045 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1047 mainwin->cursor_count++;
1052 void main_window_cursor_normal(MainWindow *mainwin)
1054 if (mainwin->cursor_count)
1055 mainwin->cursor_count--;
1057 if (mainwin->cursor_count == 0)
1058 gdk_window_set_cursor(mainwin->window->window, NULL);
1063 /* lock / unlock the user-interface */
1064 void main_window_lock(MainWindow *mainwin)
1066 if (mainwin->lock_count == 0)
1067 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1069 mainwin->lock_count++;
1071 main_window_set_menu_sensitive(mainwin);
1072 main_window_set_toolbar_sensitive(mainwin);
1075 void main_window_unlock(MainWindow *mainwin)
1077 if (mainwin->lock_count)
1078 mainwin->lock_count--;
1080 main_window_set_menu_sensitive(mainwin);
1081 main_window_set_toolbar_sensitive(mainwin);
1083 if (mainwin->lock_count == 0)
1084 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1087 static void main_window_menu_callback_block(MainWindow *mainwin)
1089 mainwin->menu_lock_count++;
1092 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1094 if (mainwin->menu_lock_count)
1095 mainwin->menu_lock_count--;
1098 void main_window_reflect_prefs_all(void)
1100 main_window_reflect_prefs_all_real(FALSE);
1103 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1106 MainWindow *mainwin;
1108 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1109 mainwin = (MainWindow *)cur->data;
1111 main_window_show_cur_account(mainwin);
1112 main_window_set_menu_sensitive(mainwin);
1113 main_window_set_toolbar_sensitive(mainwin);
1116 if (pixmap_theme_changed)
1118 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1119 mainwin->toolbar = NULL;
1120 main_window_toolbar_create(mainwin, mainwin->handlebox);
1121 set_toolbar_style(mainwin);
1122 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1123 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1124 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1127 summary_redisplay_msg(mainwin->summaryview);
1128 headerview_set_visibility(mainwin->messageview->headerview,
1129 prefs_common.display_header_pane);
1133 void main_window_set_summary_column(void)
1136 MainWindow *mainwin;
1138 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1139 mainwin = (MainWindow *)cur->data;
1140 summary_set_column_order(mainwin->summaryview);
1144 void main_window_set_account_menu(GList *account_list)
1146 GList *cur, *cur_ac, *cur_item;
1147 GtkWidget *menuitem;
1148 MainWindow *mainwin;
1149 PrefsAccount *ac_prefs;
1151 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1152 mainwin = (MainWindow *)cur->data;
1154 /* destroy all previous menu item */
1155 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1156 while (cur_item != NULL) {
1157 GList *next = cur_item->next;
1158 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1162 for (cur_ac = account_list; cur_ac != NULL;
1163 cur_ac = cur_ac->next) {
1164 ac_prefs = (PrefsAccount *)cur_ac->data;
1166 menuitem = gtk_menu_item_new_with_label
1167 (ac_prefs->account_name
1168 ? ac_prefs->account_name : _("Untitled"));
1169 gtk_widget_show(menuitem);
1170 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1171 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1172 GTK_SIGNAL_FUNC(account_menu_cb),
1178 static void main_window_show_cur_account(MainWindow *mainwin)
1183 ac_name = g_strdup(cur_account
1184 ? (cur_account->account_name
1185 ? cur_account->account_name : _("Untitled"))
1189 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1191 buf = g_strdup(PROG_VERSION);
1192 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1195 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1196 gtk_widget_queue_resize(mainwin->ac_button);
1201 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1203 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1204 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1205 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1207 if (mainwin->type == type) return;
1209 /* remove widgets from those containers */
1210 gtk_widget_ref(folder_wid);
1211 gtk_widget_ref(summary_wid);
1212 gtk_widget_ref(message_wid);
1213 gtkut_container_remove
1214 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1215 gtkut_container_remove
1216 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1217 gtkut_container_remove
1218 (GTK_CONTAINER(message_wid->parent), message_wid);
1220 /* clean containers */
1221 switch (mainwin->type) {
1223 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1225 case SEPARATE_FOLDER:
1226 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1227 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1229 case SEPARATE_MESSAGE:
1230 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1231 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1234 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1235 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1239 gtk_widget_hide(mainwin->window);
1240 main_window_set_widgets(mainwin, type);
1241 gtk_widget_show(mainwin->window);
1243 gtk_widget_unref(folder_wid);
1244 gtk_widget_unref(summary_wid);
1245 gtk_widget_unref(message_wid);
1248 void main_window_get_size(MainWindow *mainwin)
1250 GtkAllocation *allocation;
1252 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1254 prefs_common.summaryview_width = allocation->width;
1256 if (mainwin->summaryview->msg_is_toggled_on)
1257 prefs_common.summaryview_height = allocation->height;
1259 prefs_common.mainview_width = allocation->width;
1261 allocation = &mainwin->window->allocation;
1263 prefs_common.mainview_height = allocation->height;
1264 prefs_common.mainwin_width = allocation->width;
1265 prefs_common.mainwin_height = allocation->height;
1267 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1269 prefs_common.folderview_width = allocation->width;
1270 prefs_common.folderview_height = allocation->height;
1273 void main_window_get_position(MainWindow *mainwin)
1277 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1279 prefs_common.mainview_x = x;
1280 prefs_common.mainview_y = y;
1281 prefs_common.mainwin_x = x;
1282 prefs_common.mainwin_y = y;
1284 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1287 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1293 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1294 folder = FOLDER(list->data);
1295 if (folder && folder->trash && folder->trash->total > 0)
1299 if (!has_trash) return;
1302 if (alertpanel(_("Empty trash"),
1303 _("Empty all messages in trash?"),
1304 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1306 manage_window_focus_in(mainwin->window, NULL, NULL);
1309 procmsg_empty_trash();
1311 for (list = folder_get_list(); list != NULL; list = list->next) {
1312 folder = list->data;
1313 if (folder && folder->trash && folder->trash->total != 0) {
1314 folder_item_scan(folder->trash);
1315 folderview_update_item(folder->trash, TRUE);
1319 if (mainwin->summaryview->folder_item &&
1320 mainwin->summaryview->folder_item->stype == F_TRASH)
1321 gtk_widget_grab_focus(mainwin->folderview->ctree);
1324 void main_window_add_mailbox(MainWindow *mainwin)
1329 path = input_dialog(_("Add mailbox"),
1330 _("Input the location of mailbox.\n"
1331 "If the existing mailbox is specified, it will be\n"
1332 "scanned automatically."),
1335 if (folder_find_from_path(path)) {
1336 alertpanel_error(_("The mailbox `%s' already exists."), path);
1340 if (!strcmp(path, "Mail"))
1341 folder = folder_new(F_MH, _("Mailbox"), path);
1343 folder = folder_new(F_MH, g_basename(path), path);
1346 if (folder->create_tree(folder) < 0) {
1347 alertpanel_error(_("Creation of the mailbox failed.\n"
1348 "Maybe some files already exist, or you don't have the permission to write there."));
1349 folder_destroy(folder);
1354 folder_set_ui_func(folder, scan_tree_func, mainwin);
1355 folder->scan_tree(folder);
1356 folder_set_ui_func(folder, NULL, NULL);
1358 folderview_set(mainwin->folderview);
1361 void main_window_add_mbox(MainWindow *mainwin)
1367 path = input_dialog(_("Add mbox mailbox"),
1368 _("Input the location of mailbox."),
1373 if (folder_find_from_path(path)) {
1374 alertpanel_error(_("The mailbox `%s' already exists."), path);
1380 if (!strcmp(path, "Mail"))
1381 folder = folder_new(F_MBOX, _("Mailbox"), path);
1385 folder = folder_new(F_MBOX, g_basename(path), path);
1388 if (folder->create_tree(folder) < 0) {
1389 alertpanel_error(_("Creation of the mailbox failed."));
1390 folder_destroy(folder);
1396 item = folder_item_new(folder->name, NULL);
1397 item->folder = folder;
1398 folder->node = g_node_new(item);
1400 folder->create_folder(folder, item, "inbox");
1401 folder->create_folder(folder, item, "outbox");
1402 folder->create_folder(folder, item, "queue");
1403 folder->create_folder(folder, item, "draft");
1404 folder->create_folder(folder, item, "trash");
1406 folderview_set(mainwin->folderview);
1411 M_UNLOCKED = 1 << 0,
1412 M_MSG_EXIST = 1 << 1,
1413 M_TARGET_EXIST = 1 << 2,
1414 M_SINGLE_TARGET_EXIST = 1 << 3,
1416 M_ALLOW_REEDIT = 1 << 5,
1417 M_HAVE_ACCOUNT = 1 << 6,
1418 M_THREADED = 1 << 7,
1419 M_UNTHREADED = 1 << 8,
1420 M_ALLOW_DELETE = 1 << 9,
1421 M_INC_ACTIVE = 1 << 10,
1423 M_HAVE_NEWS_ACCOUNT = 1 << 12,
1424 M_HIDE_READ_MSG = 1 << 13
1427 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1429 SensitiveCond state = 0;
1430 SummarySelection selection;
1431 FolderItem *item = mainwin->summaryview->folder_item;
1432 GList *account_list = account_get_list();
1434 selection = summary_get_selection_type(mainwin->summaryview);
1436 if (mainwin->lock_count == 0)
1437 state |= M_UNLOCKED;
1438 if (selection != SUMMARY_NONE)
1439 state |= M_MSG_EXIST;
1443 state |= M_THREADED;
1445 state |= M_UNTHREADED;
1446 /* if (item->folder->type != F_NEWS) */
1447 state |= M_ALLOW_DELETE;
1449 if (selection == SUMMARY_NONE && item->hide_read_msgs
1450 || selection != SUMMARY_NONE)
1451 state |= M_HIDE_READ_MSG;
1453 if (selection == SUMMARY_SELECTED_SINGLE ||
1454 selection == SUMMARY_SELECTED_MULTIPLE)
1455 state |= M_TARGET_EXIST;
1456 if (selection == SUMMARY_SELECTED_SINGLE)
1457 state |= M_SINGLE_TARGET_EXIST;
1458 if (mainwin->summaryview->folder_item &&
1459 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1461 if (selection == SUMMARY_SELECTED_SINGLE &&
1463 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1464 item->stype == F_QUEUE)))
1465 state |= M_ALLOW_REEDIT;
1467 state |= M_HAVE_ACCOUNT;
1469 for ( ; account_list != NULL; account_list = account_list->next) {
1470 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1471 state |= M_HAVE_NEWS_ACCOUNT;
1476 if (inc_is_active())
1477 state |= M_INC_ACTIVE;
1482 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1484 SensitiveCond state;
1493 entry[0].widget = mainwin->get_btn;
1494 entry[0].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1495 entry[1].widget = mainwin->getall_btn;
1496 entry[1].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1497 entry[2].widget = mainwin->compose_news_btn;
1498 entry[2].cond = M_HAVE_NEWS_ACCOUNT;
1499 entry[3].widget = mainwin->reply_btn;
1500 entry[3].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1501 entry[4].widget = mainwin->replyall_btn;
1502 entry[4].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1503 entry[5].widget = mainwin->replysender_btn;
1504 entry[5].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1505 entry[6].widget = mainwin->fwd_btn;
1506 entry[6].cond = M_HAVE_ACCOUNT|M_TARGET_EXIST;
1507 /* entry[6].widget = mainwin->prefs_btn;
1508 entry[6].cond = M_UNLOCKED;
1509 entry[7].widget = mainwin->account_btn;
1510 entry[7].cond = M_UNLOCKED; */
1511 entry[7].widget = mainwin->next_btn;
1512 entry[7].cond = M_MSG_EXIST;
1513 entry[8].widget = mainwin->delete_btn;
1514 entry[8].cond = M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED;
1515 entry[9].widget = mainwin->exec_btn;
1516 entry[9].cond = M_MSG_EXIST|M_EXEC|M_UNLOCKED;
1517 entry[10].widget = NULL;
1520 state = main_window_get_current_state(mainwin);
1522 for (i = 0; entry[i].widget != NULL; i++) {
1523 sensitive = ((entry[i].cond & state) == entry[i].cond);
1524 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1527 activate_compose_button(mainwin,
1528 prefs_common.toolbar_style,
1529 mainwin->compose_btn_type);
1532 void main_window_set_menu_sensitive(MainWindow *mainwin)
1534 GtkItemFactory *ifactory;
1535 SensitiveCond state;
1537 GtkWidget *menuitem;
1540 static const struct {
1544 {"/File/Add mailbox..." , M_UNLOCKED},
1545 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1546 {"/File/Rescan folder tree" , M_UNLOCKED},
1547 {"/File/Folder" , M_UNLOCKED},
1548 {"/File/Import mbox file..." , M_UNLOCKED},
1549 {"/File/Export to mbox file...", M_UNLOCKED},
1550 {"/File/Empty trash" , M_UNLOCKED},
1551 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1552 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1553 /* {"/File/Close", M_UNLOCKED}, */
1554 {"/File/Exit" , M_UNLOCKED},
1556 {"/Edit/Actions" , M_MSG_EXIST},
1557 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1558 {"/View/Sort" , M_MSG_EXIST},
1559 {"/View/Thread view" , M_EXEC},
1560 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1561 {"/View/Go to/Prev message" , M_MSG_EXIST},
1562 {"/View/Go to/Next message" , M_MSG_EXIST},
1563 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1564 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1565 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1566 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1567 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1568 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1569 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1570 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1571 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1573 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1574 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1575 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1576 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1577 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1578 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1579 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1580 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1581 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1582 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1583 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1584 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1585 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1586 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1587 {"/Message/Mark" , M_TARGET_EXIST},
1588 {"/Message/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1590 {"/Tool/Add sender to address book", M_SINGLE_TARGET_EXIST},
1591 {"/Tool/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1592 {"/Tool/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1593 {"/Tool/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1595 {"/Configuration", M_UNLOCKED},
1600 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1601 state = main_window_get_current_state(mainwin);
1603 for (i = 0; entry[i].entry != NULL; i++) {
1604 sensitive = ((entry[i].cond & state) == entry[i].cond);
1605 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1608 main_window_menu_callback_block(mainwin);
1609 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all header");
1610 gtk_check_menu_item_set_active
1611 (GTK_CHECK_MENU_ITEM(menuitem),
1612 mainwin->messageview->textview->show_all_headers);
1613 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1614 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1615 (state & M_THREADED) != 0);
1616 main_window_menu_callback_unblock(mainwin);
1619 void main_window_popup(MainWindow *mainwin)
1625 gdk_window_get_origin(mainwin->window->window, &x, &y);
1626 sx = gdk_screen_width();
1627 sy = gdk_screen_height();
1628 x %= sx; if (x < 0) x = 0;
1629 y %= sy; if (y < 0) y = 0;
1630 gdk_window_move(mainwin->window->window, x, y);
1631 gdk_window_raise(mainwin->window->window);
1632 gdk_window_show(mainwin->window->window);
1634 debug_print("window position: x = %d, y = %d\n", x, y);
1636 switch (mainwin->type) {
1637 case SEPARATE_FOLDER:
1638 widget = mainwin->win.sep_folder.folderwin;
1639 gdk_window_get_origin(widget->window, &x, &y);
1640 x %= sx; if (x < 0) x = 0;
1641 y %= sy; if (y < 0) y = 0;
1642 gdk_window_move(widget->window, x, y);
1643 gdk_window_raise(widget->window);
1645 case SEPARATE_MESSAGE:
1646 widget = mainwin->win.sep_message.messagewin;
1647 gdk_window_get_origin(widget->window, &x, &y);
1648 x %= sx; if (x < 0) x = 0;
1649 y %= sy; if (y < 0) y = 0;
1650 gdk_window_move(widget->window, x, y);
1651 gdk_window_raise(widget->window);
1654 widget = mainwin->win.sep_both.folderwin;
1655 gdk_window_get_origin(widget->window, &x, &y);
1656 x %= sx; if (x < 0) x = 0;
1657 y %= sy; if (y < 0) y = 0;
1658 gdk_window_move(widget->window, x, y);
1659 gdk_window_raise(widget->window);
1660 widget = mainwin->win.sep_both.messagewin;
1661 gdk_window_get_origin(widget->window, &x, &y);
1662 x %= sx; if (x < 0) x = 0;
1663 y %= sy; if (y < 0) y = 0;
1664 gdk_window_move(widget->window, x, y);
1665 gdk_window_raise(widget->window);
1672 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1674 GtkWidget *folderwin = NULL;
1675 GtkWidget *messagewin = NULL;
1678 GtkWidget *vbox_body = mainwin->vbox_body;
1679 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1680 GtkWidget *menuitem;
1682 debug_print(_("Setting widgets..."));
1684 /* create separated window(s) if needed */
1685 if (type & SEPARATE_FOLDER) {
1686 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1687 gtk_window_set_title(GTK_WINDOW(folderwin),
1688 _("Sylpheed - Folder View"));
1689 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1690 "folder_view", "Sylpheed");
1691 gtk_window_set_policy(GTK_WINDOW(folderwin),
1693 gtk_widget_set_usize(folderwin, -1,
1694 prefs_common.mainview_height);
1695 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1697 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1698 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1701 if (type & SEPARATE_MESSAGE) {
1702 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1703 gtk_window_set_title(GTK_WINDOW(messagewin),
1704 _("Sylpheed - Message View"));
1705 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1706 "message_view", "Sylpheed");
1707 gtk_window_set_policy(GTK_WINDOW(messagewin),
1709 gtk_widget_set_usize
1710 (messagewin, prefs_common.mainview_width,
1711 prefs_common.mainview_height
1712 - prefs_common.summaryview_height
1713 + DEFAULT_HEADERVIEW_HEIGHT);
1714 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1716 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1717 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1723 hpaned = gtk_hpaned_new();
1724 gtk_widget_show(hpaned);
1725 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1726 gtk_paned_add1(GTK_PANED(hpaned),
1727 GTK_WIDGET_PTR(mainwin->folderview));
1729 vpaned = gtk_vpaned_new();
1730 if (mainwin->summaryview->msg_is_toggled_on) {
1731 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1732 gtk_paned_add1(GTK_PANED(vpaned),
1733 GTK_WIDGET_PTR(mainwin->summaryview));
1735 gtk_paned_add2(GTK_PANED(hpaned),
1736 GTK_WIDGET_PTR(mainwin->summaryview));
1737 gtk_widget_ref(vpaned);
1739 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1740 prefs_common.summaryview_width,
1741 prefs_common.summaryview_height);
1742 gtk_paned_add2(GTK_PANED(vpaned),
1743 GTK_WIDGET_PTR(mainwin->messageview));
1744 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1745 prefs_common.mainview_width, -1);
1746 gtk_widget_set_usize(mainwin->window,
1747 prefs_common.folderview_width +
1748 prefs_common.mainview_width,
1749 prefs_common.mainwin_height);
1750 gtk_widget_show_all(vpaned);
1752 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1753 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1754 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1755 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1756 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1757 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1759 mainwin->win.sep_none.hpaned = hpaned;
1760 mainwin->win.sep_none.vpaned = vpaned;
1762 case SEPARATE_FOLDER:
1763 vpaned = gtk_vpaned_new();
1764 if (mainwin->summaryview->msg_is_toggled_on) {
1765 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1767 gtk_paned_add1(GTK_PANED(vpaned),
1768 GTK_WIDGET_PTR(mainwin->summaryview));
1770 gtk_box_pack_start(GTK_BOX(vbox_body),
1771 GTK_WIDGET_PTR(mainwin->summaryview),
1773 gtk_widget_ref(vpaned);
1775 gtk_paned_add2(GTK_PANED(vpaned),
1776 GTK_WIDGET_PTR(mainwin->messageview));
1777 gtk_widget_show_all(vpaned);
1778 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1779 prefs_common.summaryview_width,
1780 prefs_common.summaryview_height);
1781 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1782 prefs_common.mainview_width, -1);
1783 gtk_widget_set_usize(mainwin->window,
1784 prefs_common.mainview_width,
1785 prefs_common.mainview_height);
1787 gtk_container_add(GTK_CONTAINER(folderwin),
1788 GTK_WIDGET_PTR(mainwin->folderview));
1790 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1791 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1793 mainwin->win.sep_folder.folderwin = folderwin;
1794 mainwin->win.sep_folder.vpaned = vpaned;
1796 gtk_widget_show_all(folderwin);
1798 case SEPARATE_MESSAGE:
1799 hpaned = gtk_hpaned_new();
1800 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1802 gtk_paned_add1(GTK_PANED(hpaned),
1803 GTK_WIDGET_PTR(mainwin->folderview));
1804 gtk_paned_add2(GTK_PANED(hpaned),
1805 GTK_WIDGET_PTR(mainwin->summaryview));
1806 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1807 prefs_common.summaryview_width,
1808 prefs_common.summaryview_height);
1809 gtk_widget_set_usize(mainwin->window,
1810 prefs_common.folderview_width +
1811 prefs_common.mainview_width,
1812 prefs_common.mainwin_height);
1813 gtk_widget_show_all(hpaned);
1814 gtk_container_add(GTK_CONTAINER(messagewin),
1815 GTK_WIDGET_PTR(mainwin->messageview));
1817 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1818 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1819 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1820 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1822 mainwin->win.sep_message.messagewin = messagewin;
1823 mainwin->win.sep_message.hpaned = hpaned;
1825 gtk_widget_show_all(messagewin);
1828 gtk_box_pack_start(GTK_BOX(vbox_body),
1829 GTK_WIDGET_PTR(mainwin->summaryview),
1831 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1832 prefs_common.summaryview_width,
1833 prefs_common.summaryview_height);
1834 gtk_widget_set_usize(mainwin->window,
1835 prefs_common.mainview_width,
1836 prefs_common.mainwin_height);
1837 gtk_container_add(GTK_CONTAINER(folderwin),
1838 GTK_WIDGET_PTR(mainwin->folderview));
1839 gtk_container_add(GTK_CONTAINER(messagewin),
1840 GTK_WIDGET_PTR(mainwin->messageview));
1842 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1843 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1845 mainwin->win.sep_both.folderwin = folderwin;
1846 mainwin->win.sep_both.messagewin = messagewin;
1848 gtk_widget_show_all(folderwin);
1849 gtk_widget_show_all(messagewin);
1853 mainwin->type = type;
1855 debug_print(_("done.\n"));
1858 static void main_window_toolbar_create(MainWindow *mainwin,
1859 GtkWidget *container)
1862 GtkWidget *icon_wid;
1864 GtkWidget *getall_btn;
1865 GtkWidget *compose_mail_btn;
1866 GtkWidget *compose_news_btn;
1867 GtkWidget *reply_btn;
1868 GtkWidget *replyall_btn;
1869 GtkWidget *replysender_btn;
1871 GtkWidget *send_btn;
1873 GtkWidget *prefs_btn;
1874 GtkWidget *account_btn;
1876 GtkWidget *next_btn;
1877 GtkWidget *delete_btn;
1878 GtkWidget *exec_btn;
1880 GtkTooltips *tooltips;
1882 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1884 gtk_container_add(GTK_CONTAINER(container), toolbar);
1885 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1886 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1887 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1888 GTK_TOOLBAR_SPACE_LINE);
1890 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1891 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1893 _("Get new mail from current account"),
1895 icon_wid, toolbar_inc_cb, mainwin);
1896 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1897 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1899 _("Get new mail from all accounts"),
1905 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1907 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1908 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1910 _("Send queued message(s)"),
1916 /* insert compose mail button widget */
1917 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1918 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1920 _("Compose an email message"),
1923 toolbar_compose_mail_cb,
1926 /* insert compose news button widget */
1927 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1928 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1930 _("Compose a news message"),
1933 toolbar_compose_news_cb,
1936 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1940 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1941 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1943 _("Reply to the message - Right button: more options"),
1949 /* replyall button */
1951 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1952 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1954 _("Reply to all - Right button: more options"),
1957 toolbar_reply_to_all_cb,
1960 /* reply to sender button */
1961 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1962 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1964 _("Reply to sender - Right button: more options"),
1967 toolbar_reply_to_sender_cb,
1970 /* forward button */
1971 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1972 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1974 _("Forward the message - Right button: more options"),
1980 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1982 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1983 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1985 _("Delete the message"),
1991 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1992 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1994 _("Execute marked process"),
2000 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
2001 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2003 _("Next unread message"),
2006 toolbar_next_unread_cb,
2010 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2012 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2013 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2015 _("Common preference"),
2020 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2021 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2023 _("Account setting"),
2028 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2029 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2033 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2034 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2037 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2038 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2041 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2042 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2045 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2046 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2050 mainwin->toolbar = toolbar;
2051 mainwin->get_btn = get_btn;
2052 mainwin->getall_btn = getall_btn;
2053 mainwin->compose_mail_btn = compose_mail_btn;
2054 mainwin->compose_news_btn = compose_news_btn;
2055 mainwin->reply_btn = reply_btn;
2056 mainwin->replyall_btn = replyall_btn;
2057 mainwin->replysender_btn = replysender_btn;
2058 mainwin->fwd_btn = fwd_btn;
2059 mainwin->send_btn = send_btn;
2061 mainwin->prefs_btn = prefs_btn;
2062 mainwin->account_btn = account_btn;
2064 mainwin->next_btn = next_btn;
2065 mainwin->delete_btn = delete_btn;
2066 mainwin->exec_btn = exec_btn;
2068 gtk_widget_show_all(toolbar);
2071 /* callback functions */
2072 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2074 MainWindow *mainwindow = (MainWindow *) data;
2078 if (event->button == 3) {
2079 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2080 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2081 menu_button_position, widget,
2082 event->button, event->time);
2086 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2088 MainWindow *mainwin = (MainWindow *)data;
2090 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2091 manage_window_focus_in(mainwin->window, NULL, NULL);
2094 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2096 MainWindow *mainwindow = (MainWindow *) data;
2100 if (event->button == 3) {
2101 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2102 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2103 menu_button_position, widget,
2104 event->button, event->time);
2108 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2110 MainWindow *mainwin = (MainWindow *)data;
2112 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2113 manage_window_focus_in(mainwin->window, NULL, NULL);
2116 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2118 MainWindow *mainwindow = (MainWindow *) data;
2119 GtkWidget *replysender_menu, *replysender_item;
2123 if (event->button == 3) {
2124 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2125 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2126 menu_button_position, widget,
2127 event->button, event->time);
2131 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2133 MainWindow *mainwin = (MainWindow *)data;
2135 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2136 manage_window_focus_in(mainwin->window, NULL, NULL);
2139 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2141 MainWindow *mainwindow = (MainWindow *) data;
2145 if (event->button == 3) {
2146 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2147 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2148 menu_button_position, widget,
2149 event->button, event->time);
2153 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2155 MainWindow *mainwin = (MainWindow *)data;
2157 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2158 manage_window_focus_in(mainwin->window, NULL, NULL);
2161 static void toolbar_inc_cb (GtkWidget *widget,
2164 MainWindow *mainwin = (MainWindow *)data;
2166 inc_mail_cb(mainwin, 0, NULL);
2169 static void toolbar_inc_all_cb (GtkWidget *widget,
2172 MainWindow *mainwin = (MainWindow *)data;
2174 inc_all_account_mail_cb(mainwin, 0, NULL);
2177 static void toolbar_send_cb (GtkWidget *widget,
2180 MainWindow *mainwin = (MainWindow *)data;
2182 send_queue_cb(mainwin, 0, NULL);
2185 static void toolbar_compose_cb (GtkWidget *widget,
2188 MainWindow *mainwin = (MainWindow *)data;
2190 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2191 compose_cb(mainwin, 0, NULL);
2193 compose_news_cb(mainwin, 0, NULL);
2196 static void toolbar_compose_news_cb (GtkWidget *widget,
2199 MainWindow *mainwin = (MainWindow *)data;
2201 compose_news_cb(mainwin, 0, NULL);
2204 static void toolbar_compose_mail_cb (GtkWidget *widget,
2207 MainWindow *mainwin = (MainWindow *)data;
2209 compose_mail_cb(mainwin, 0, NULL);
2212 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2214 MainWindow *mainwin = (MainWindow *)data;
2217 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2218 : COMPOSE_REPLY_WITHOUT_QUOTE,
2222 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2224 MainWindow *mainwin = (MainWindow *)data;
2227 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2228 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2233 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2235 MainWindow *mainwin = (MainWindow *)data;
2238 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2239 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2243 static void toolbar_forward_cb (GtkWidget *widget,
2246 MainWindow *mainwin = (MainWindow *)data;
2248 if (prefs_common.forward_as_attachment)
2249 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2251 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2254 static void toolbar_delete_cb (GtkWidget *widget,
2257 MainWindow *mainwin = (MainWindow *)data;
2259 summary_delete(mainwin->summaryview);
2262 static void toolbar_exec_cb (GtkWidget *widget,
2265 MainWindow *mainwin = (MainWindow *)data;
2267 summary_execute(mainwin->summaryview);
2270 static void toolbar_next_unread_cb (GtkWidget *widget,
2273 MainWindow *mainwin = (MainWindow *)data;
2275 next_unread_cb(mainwin, 0, NULL);
2278 static void toolbar_prefs_cb (GtkWidget *widget,
2281 prefs_common_open();
2284 static void toolbar_account_cb (GtkWidget *widget,
2287 MainWindow *mainwin = (MainWindow *)data;
2289 prefs_account_open_cb(mainwin, 0, NULL);
2292 static void toolbar_account_button_pressed(GtkWidget *widget,
2293 GdkEventButton *event,
2296 MainWindow *mainwin = (MainWindow *)data;
2299 if (event->button != 3) return;
2301 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2302 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2305 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2306 menu_button_position, widget,
2307 event->button, event->time);
2310 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2313 MainWindow *mainwin = (MainWindow *)data;
2317 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2318 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2321 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2322 menu_button_position, widget,
2323 event->button, event->time);
2326 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2328 MainWindow *mainwin = (MainWindow *)data;
2331 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2332 if (!button) return;
2333 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2334 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2335 manage_window_focus_in(mainwin->window, NULL, NULL);
2338 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2341 MainWindow *mainwin = (MainWindow *)data;
2343 if (mainwin->lock_count == 0)
2344 app_exit_cb(data, 0, widget);
2349 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2352 main_window_add_mailbox(mainwin);
2355 static void add_mbox_cb(MainWindow *mainwin, guint action,
2358 main_window_add_mbox(mainwin);
2361 static void update_folderview_cb(MainWindow *mainwin, guint action,
2364 summary_show(mainwin->summaryview, NULL, FALSE);
2365 folderview_rescan_all();
2368 static void new_folder_cb(MainWindow *mainwin, guint action,
2371 folderview_new_folder(mainwin->folderview);
2374 static void rename_folder_cb(MainWindow *mainwin, guint action,
2377 folderview_rename_folder(mainwin->folderview);
2380 static void delete_folder_cb(MainWindow *mainwin, guint action,
2383 folderview_delete_folder(mainwin->folderview);
2386 static void import_mbox_cb(MainWindow *mainwin, guint action,
2389 import_mbox(mainwin->summaryview->folder_item);
2392 static void export_mbox_cb(MainWindow *mainwin, guint action,
2395 export_mbox(mainwin->summaryview->folder_item);
2398 static void empty_trash_cb(MainWindow *mainwin, guint action,
2401 main_window_empty_trash(mainwin, TRUE);
2404 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2406 summary_save_as(mainwin->summaryview);
2409 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2411 summary_print(mainwin->summaryview);
2414 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2416 if (prefs_common.confirm_on_exit) {
2417 if (alertpanel(_("Exit"), _("Exit this program?"),
2418 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2420 manage_window_focus_in(mainwin->window, NULL, NULL);
2423 app_will_exit(widget, mainwin);
2426 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2429 summary_search(mainwin->summaryview);
2431 message_search(mainwin->messageview);
2434 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2437 switch (mainwin->type) {
2439 case SEPARATE_MESSAGE:
2441 case SEPARATE_FOLDER:
2442 if (GTK_CHECK_MENU_ITEM(widget)->active)
2443 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2445 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2448 if (GTK_CHECK_MENU_ITEM(widget)->active)
2449 gtk_widget_show(mainwin->win.sep_both.folderwin);
2451 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2456 static void toggle_message_cb(MainWindow *mainwin, guint action,
2459 switch (mainwin->type) {
2461 case SEPARATE_FOLDER:
2463 case SEPARATE_MESSAGE:
2464 if (GTK_CHECK_MENU_ITEM(widget)->active)
2465 gtk_widget_show(mainwin->win.sep_message.messagewin);
2467 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2470 if (GTK_CHECK_MENU_ITEM(widget)->active)
2471 gtk_widget_show(mainwin->win.sep_both.messagewin);
2473 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2478 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2481 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2482 mainwin->compose_btn_type);
2483 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2484 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2485 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2486 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2488 mainwin->toolbar_style = (ToolbarStyle)action;
2489 prefs_common.toolbar_style = (ToolbarStyle)action;
2491 set_toolbar_style(mainwin);
2494 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2497 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2498 gtk_widget_show(mainwin->hbox_stat);
2499 prefs_common.show_statusbar = TRUE;
2501 gtk_widget_hide(mainwin->hbox_stat);
2502 prefs_common.show_statusbar = FALSE;
2506 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2508 summary_toggle_view_real(mainwin->summaryview);
2511 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2513 messageview_toggle_view_real(mainwin->messageview);
2516 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2519 MainWindow *mainwin;
2522 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2523 g_return_if_fail(mainwin != NULL);
2525 type = mainwin->type ^ action;
2526 main_window_separation_change(mainwin, type);
2528 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2529 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2532 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2535 addressbook_open(NULL);
2538 static void log_window_show_cb(MainWindow *mainwin, guint action,
2541 log_window_show(mainwin->logwin);
2544 static void sel_download_cb(MainWindow *mainwin, guint action,
2547 selective_download(mainwin);
2550 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2552 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2555 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2558 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2561 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2566 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2570 if (procmsg_send_queue() < 0)
2571 alertpanel_error(_("Some errors occurred while sending queued messages."));
2573 statusbar_pop_all();
2575 for (list = folder_get_list(); list != NULL; list = list->next) {
2578 folder = list->data;
2579 if (folder->queue) {
2580 folder_item_scan(folder->queue);
2581 folderview_update_item(folder->queue, TRUE);
2586 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2588 if (mainwin->summaryview->folder_item) {
2589 if (mainwin->summaryview->folder_item->folder->account != NULL
2590 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2591 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2593 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2599 static void compose_mail_cb(MainWindow *mainwin, guint action,
2606 if (mainwin->summaryview->folder_item) {
2607 ac = mainwin->summaryview->folder_item->folder->account;
2608 if (ac && ac->protocol != A_NNTP) {
2609 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2614 if(cur_account && (cur_account->protocol != A_NNTP)) {
2615 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2619 list = account_get_list();
2620 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2621 ac = (PrefsAccount *) cur->data;
2622 if (ac->protocol != A_NNTP) {
2623 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2629 static void compose_news_cb(MainWindow *mainwin, guint action,
2632 PrefsAccount * ac = NULL;
2636 if (mainwin->summaryview->folder_item) {
2637 ac = mainwin->summaryview->folder_item->folder->account;
2638 if (ac && ac->protocol == A_NNTP) {
2639 compose_new_with_recipient
2640 (ac, mainwin->summaryview->folder_item->path);
2645 list = account_get_list();
2646 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2647 ac = (PrefsAccount *) cur->data;
2648 if (ac->protocol == A_NNTP) {
2655 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2657 summary_reply(mainwin->summaryview, (ComposeMode)action);
2660 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2662 summary_move_to(mainwin->summaryview);
2665 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2667 summary_copy_to(mainwin->summaryview);
2670 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2672 summary_delete(mainwin->summaryview);
2675 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2677 summary_open_msg(mainwin->summaryview);
2680 static void view_source_cb(MainWindow *mainwin, guint action,
2683 summary_view_source(mainwin->summaryview);
2686 static void show_all_header_cb(MainWindow *mainwin, guint action,
2689 if (mainwin->menu_lock_count) return;
2690 summary_display_msg_selected(mainwin->summaryview,
2691 GTK_CHECK_MENU_ITEM(widget)->active);
2694 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2696 summary_reedit(mainwin->summaryview);
2699 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2701 summary_mark(mainwin->summaryview);
2704 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2706 summary_unmark(mainwin->summaryview);
2709 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2712 summary_mark_as_unread(mainwin->summaryview);
2715 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2718 summary_mark_as_read(mainwin->summaryview);
2721 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2724 summary_mark_all_read(mainwin->summaryview);
2727 static void add_address_cb(MainWindow *mainwin, guint action,
2730 summary_add_address(mainwin->summaryview);
2733 static void set_charset_cb(MainWindow *mainwin, guint action,
2738 str = conv_get_charset_str((CharSet)action);
2739 g_free(prefs_common.force_charset);
2740 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2742 summary_redisplay_msg(mainwin->summaryview);
2744 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2747 static void hide_read_messages (MainWindow *mainwin, guint action,
2750 if (!mainwin->summaryview->folder_item
2751 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2753 summary_toggle_show_read_messages(mainwin->summaryview);
2756 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2758 GtkItemFactory *ifactory;
2760 if (mainwin->menu_lock_count) return;
2761 if (!mainwin->summaryview->folder_item) return;
2763 ifactory = gtk_item_factory_from_widget(widget);
2765 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2766 summary_thread_build(mainwin->summaryview);
2767 mainwin->summaryview->folder_item->threaded = TRUE;
2769 summary_unthread(mainwin->summaryview);
2770 mainwin->summaryview->folder_item->threaded = FALSE;
2774 static void set_display_item_cb(MainWindow *mainwin, guint action,
2777 prefs_summary_column_open();
2780 static void sort_summary_cb(MainWindow *mainwin, guint action,
2783 summary_sort(mainwin->summaryview, (SummarySortType)action);
2786 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2789 summary_attract_by_subject(mainwin->summaryview);
2792 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2795 summary_delete_duplicated(mainwin->summaryview);
2798 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2800 summary_filter(mainwin->summaryview);
2803 static void execute_summary_cb(MainWindow *mainwin, guint action,
2806 summary_execute(mainwin->summaryview);
2809 static void update_summary_cb(MainWindow *mainwin, guint action,
2813 FolderView *folderview = mainwin->folderview;
2815 if (!mainwin->summaryview->folder_item) return;
2816 if (!folderview->opened) return;
2818 folder_update_op_count();
2820 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2821 folderview->opened);
2824 summary_show(mainwin->summaryview, fitem, TRUE);
2827 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2829 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2832 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2834 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2837 static void prev_unread_cb(MainWindow *mainwin, guint action,
2840 summary_select_prev_unread(mainwin->summaryview);
2843 static void next_unread_cb(MainWindow *mainwin, guint action,
2846 summary_select_next_unread(mainwin->summaryview);
2849 static void prev_marked_cb(MainWindow *mainwin, guint action,
2852 summary_select_prev_marked(mainwin->summaryview);
2855 static void next_marked_cb(MainWindow *mainwin, guint action,
2858 summary_select_next_marked(mainwin->summaryview);
2861 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2864 summary_select_prev_labeled(mainwin->summaryview);
2867 static void next_labeled_cb(MainWindow *mainwin, guint action,
2870 summary_select_next_labeled(mainwin->summaryview);
2873 static void goto_folder_cb(MainWindow *mainwin, guint action,
2876 FolderItem *to_folder;
2878 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2881 folderview_select(mainwin->folderview, to_folder);
2884 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2886 messageview_copy_clipboard(mainwin->messageview);
2889 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2891 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2892 summary_select_all(mainwin->summaryview);
2893 else if (mainwin->summaryview->msg_is_toggled_on &&
2894 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2895 messageview_select_all(mainwin->messageview);
2898 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2900 if (mainwin->summaryview->msg_is_toggled_on)
2901 summary_select_thread(mainwin->summaryview);
2904 static void create_filter_cb(MainWindow *mainwin, guint action,
2907 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2910 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2913 prefs_common_open();
2916 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2919 prefs_filter_open(NULL, NULL);
2922 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2925 prefs_scoring_open(NULL);
2928 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2931 prefs_filtering_open(NULL);
2934 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2937 prefs_template_open();
2940 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2943 prefs_actions_open(mainwin);
2946 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2950 new_account_cb(mainwin, 0, widget);
2952 gboolean prev_default = cur_account->is_default;
2954 prefs_account_open(cur_account);
2955 if (!prev_default && cur_account->is_default)
2956 account_set_as_default(cur_account);
2957 account_save_config_all();
2959 main_window_reflect_prefs_all();
2963 static void new_account_cb(MainWindow *mainwin, guint action,
2966 account_edit_open();
2967 if (!compose_get_compose_list()) account_add();
2970 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2972 cur_account = (PrefsAccount *)data;
2973 main_window_reflect_prefs_all();
2976 static void manual_open_cb(MainWindow *mainwin, guint action,
2979 manual_open((ManualLang)action);
2982 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2984 faq_open((ManualLang)action);
2987 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2989 MainWindow *mainwin = (MainWindow *)data;
2993 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2994 LOCAL_FOLDER(folder)->rootpath,
2998 str = g_strdup_printf(_("Scanning folder %s ..."),
2999 LOCAL_FOLDER(folder)->rootpath);
3001 STATUSBAR_PUSH(mainwin, str);
3002 STATUSBAR_POP(mainwin);
3006 static void activate_compose_button (MainWindow *mainwin,
3008 ComposeButtonType type)
3010 SensitiveCond state = main_window_get_current_state(mainwin);
3012 if (style == TOOLBAR_NONE)
3015 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
3016 : mainwin->compose_news_btn);
3017 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
3018 : mainwin->compose_mail_btn);
3019 mainwin->compose_btn_type = type;
3022 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
3024 if (mainwin->compose_btn_type != compose_btn_type)
3025 activate_compose_button(mainwin,
3026 prefs_common.toolbar_style,
3030 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
3032 MainWindow *mainwin = (MainWindow*) data;
3034 if (!mainwin) return;
3036 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
3039 #define BREAK_ON_MODIFIER_KEY() \
3040 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3042 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3044 MainWindow *mainwin = (MainWindow*) data;
3046 if (!mainwin || !event) return;
3048 switch (event->keyval) {
3049 case GDK_Q: /* Quit */
3050 BREAK_ON_MODIFIER_KEY();
3052 app_exit_cb(mainwin, 0, NULL);
3059 #undef BREAK_ON_MODIFIER_KEY
3061 static void set_toolbar_style(MainWindow *mainwin)
3063 switch (prefs_common.toolbar_style) {
3065 gtk_widget_hide(mainwin->handlebox);
3068 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3072 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3076 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3081 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3082 gtk_widget_show(mainwin->handlebox);
3083 gtk_widget_queue_resize(mainwin->handlebox);
3085 if (prefs_common.immediate_exec)
3086 gtk_widget_hide(mainwin->exec_btn);
3088 gtk_widget_show(mainwin->exec_btn);