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 static void addr_gather_cb ( MainWindow *mainwin,
464 static void addr_gather_msg_cb ( MainWindow *mainwin,
468 #define SEPARATE_ACTION 667
470 static GtkItemFactoryEntry mainwin_entries[] =
472 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
473 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
474 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
475 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
476 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
477 {N_("/_File/_Folder/Create _new folder..."),
478 NULL, new_folder_cb, 0, NULL},
479 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
480 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
481 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
482 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
483 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
484 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
485 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
486 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
487 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
488 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
490 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
491 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
492 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
493 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
494 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
495 {N_("/_Edit/_Find in current message..."),
496 "<control>F", search_cb, 0, NULL},
497 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
498 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
499 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
500 {N_("/_View/Show or hi_de/_Toolbar"),
501 NULL, NULL, 0, "<Branch>"},
502 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
503 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
504 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
505 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
506 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
507 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
508 {N_("/_View/Show or hi_de/_Toolbar/_None"),
509 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
510 {N_("/_View/Show or hi_de/Status _bar"),
511 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
512 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
513 {N_("/_View/Separate _Folder Tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
514 {N_("/_View/Separate _Message View"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
515 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
516 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
517 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
518 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
519 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
520 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
521 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
522 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
523 {N_("/_View/_Sort/Sort by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
524 {N_("/_View/_Sort/Sort by _color label"),
525 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
526 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
527 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
528 {N_("/_View/_Sort/Sort by a_ttachment"),
529 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
530 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
531 {N_("/_View/_Sort/_Attract by subject"),
532 NULL, attract_by_subject_cb, 0, NULL},
533 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
534 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
535 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
536 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
538 #define CODESET_SEPARATOR \
539 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
540 #define CODESET_ACTION(action) \
541 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
543 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
544 {N_("/_View/_Code set/_Auto detect"),
545 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
546 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
547 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
548 CODESET_ACTION(C_US_ASCII)},
551 {N_("/_View/_Code set/Unicode (_UTF-8)"),
552 CODESET_ACTION(C_UTF_8)},
555 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
556 CODESET_ACTION(C_ISO_8859_1)},
557 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
558 CODESET_ACTION(C_ISO_8859_15)},
561 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
562 CODESET_ACTION(C_ISO_8859_2)},
564 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
565 CODESET_ACTION(C_ISO_8859_13)},
566 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
567 CODESET_ACTION(C_ISO_8859_4)},
569 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
570 CODESET_ACTION(C_ISO_8859_7)},
572 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
573 CODESET_ACTION(C_ISO_8859_9)},
575 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
576 CODESET_ACTION(C_ISO_8859_5)},
577 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
578 CODESET_ACTION(C_KOI8_R)},
579 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
580 CODESET_ACTION(C_CP1251)},
583 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
584 CODESET_ACTION(C_ISO_2022_JP)},
586 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
587 CODESET_ACTION(C_ISO_2022_JP_2)},
589 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
590 CODESET_ACTION(C_EUC_JP)},
591 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
592 CODESET_ACTION(C_SHIFT_JIS)},
595 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
596 CODESET_ACTION(C_GB2312)},
597 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
598 CODESET_ACTION(C_BIG5)},
599 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
600 CODESET_ACTION(C_EUC_TW)},
601 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
602 CODESET_ACTION(C_ISO_2022_CN)},
604 {N_("/_View/_Code set/Korean (EUC-_KR)"),
605 CODESET_ACTION(C_EUC_KR)},
606 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
607 CODESET_ACTION(C_ISO_2022_KR)},
609 {N_("/_View/_Code set/Thai (TIS-620)"),
610 CODESET_ACTION(C_TIS_620)},
611 {N_("/_View/_Code set/Thai (Windows-874)"),
612 CODESET_ACTION(C_WINDOWS_874)},
615 #undef CODESET_SEPARATOR
616 #undef CODESET_ACTION
618 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
619 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
620 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
621 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
622 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
623 {N_("/_View/_Go to/P_rev unread message"),
624 "<shift>P", prev_unread_cb, 0, NULL},
625 {N_("/_View/_Go to/N_ext unread message"),
626 "<shift>N", next_unread_cb, 0, NULL},
627 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
628 {N_("/_View/_Go to/Prev _marked message"),
629 NULL, prev_marked_cb, 0, NULL},
630 {N_("/_View/_Go to/Next m_arked message"),
631 NULL, next_marked_cb, 0, NULL},
632 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
633 {N_("/_View/_Go to/Prev _labeled message"),
634 NULL, prev_labeled_cb, 0, NULL},
635 {N_("/_View/_Go to/Next la_beled message"),
636 NULL, next_labeled_cb, 0, NULL},
637 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
638 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
639 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
640 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
641 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
642 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
643 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
644 {N_("/_View/_Update"), "<control><alt>U", update_summary_cb, 0, NULL},
646 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
647 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
648 {N_("/_Message/Get from _all accounts"),
649 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
650 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
651 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
652 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
653 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
654 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
655 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
656 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
657 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
658 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
659 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
660 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
661 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
662 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
663 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
664 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
665 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
666 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
667 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
668 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
669 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
670 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
671 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
672 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
673 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
674 {N_("/_Message/_Mark/Mark as rea_d"),
675 NULL, mark_as_read_cb, 0, NULL},
676 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
678 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
679 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
680 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
681 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
682 {N_("/_Tools/Add sender to address boo_k"),
683 NULL, add_address_cb, 0, NULL},
684 {N_("/_Tools/_Gather addresses"), NULL, NULL, 0, "<Branch>"},
685 {N_("/_Tools/_Gather addresses/from _Folder..."), NULL, addr_gather_cb, 0, NULL},
686 {N_("/_Tools/_Gather addresses/from _Messages..."), NULL, addr_gather_msg_cb, 0, NULL},
687 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
688 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
689 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
690 {N_("/_Tools/_Create filter rule/_Automatically"),
691 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
692 {N_("/_Tools/_Create filter rule/by _From"),
693 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
694 {N_("/_Tools/_Create filter rule/by _To"),
695 NULL, create_filter_cb, FILTER_BY_TO, NULL},
696 {N_("/_Tools/_Create filter rule/by _Subject"),
697 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
698 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
699 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
700 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
701 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
702 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
703 {N_("/_Tools/Delete du_plicated messages"),
704 NULL, delete_duplicated_cb, 0, NULL},
705 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
706 {N_("/_Tools/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
708 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
709 {N_("/_Configuration/_Common preferences..."),
710 NULL, prefs_common_open_cb, 0, NULL},
711 {N_("/_Configuration/_Filter setting..."),
712 NULL, prefs_filter_open_cb, 0, NULL},
713 {N_("/_Configuration/_Scoring..."),
714 NULL, prefs_scoring_open_cb, 0, NULL},
715 {N_("/_Configuration/_Filtering..."),
716 NULL, prefs_filtering_open_cb, 0, NULL},
717 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
718 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
719 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
720 {N_("/_Configuration/_Preferences for current account..."),
721 NULL, prefs_account_open_cb, 0, NULL},
722 {N_("/_Configuration/Create _new account..."),
723 NULL, new_account_cb, 0, NULL},
724 {N_("/_Configuration/_Edit accounts..."),
725 NULL, account_edit_open, 0, NULL},
726 {N_("/_Configuration/C_hange current account"),
727 NULL, NULL, 0, "<Branch>"},
729 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
730 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
731 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
732 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
733 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
734 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
735 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
736 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
737 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
738 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
739 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
740 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
742 static GtkItemFactoryEntry reply_popup_entries[] =
744 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
745 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
747 static GtkItemFactoryEntry replyall_popup_entries[] =
749 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
750 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
752 static GtkItemFactoryEntry replysender_popup_entries[] =
754 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
755 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
757 static GtkItemFactoryEntry fwd_popup_entries[] =
759 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
760 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
764 MainWindow *main_window_create(SeparateType type)
770 GtkWidget *handlebox;
771 GtkWidget *vbox_body;
772 GtkWidget *hbox_stat;
773 GtkWidget *statusbar;
774 GtkWidget *progressbar;
775 GtkWidget *statuslabel;
776 GtkWidget *ac_button;
779 FolderView *folderview;
780 SummaryView *summaryview;
781 MessageView *messageview;
782 GdkColormap *colormap;
785 guint n_menu_entries;
786 GtkItemFactory *ifactory;
789 GtkWidget *compose_popup;
790 GtkWidget *reply_popup;
791 GtkWidget *replyall_popup;
792 GtkWidget *replysender_popup;
793 GtkWidget *fwd_popup;
796 debug_print(_("Creating main window...\n"));
797 mainwin = g_new0(MainWindow, 1);
800 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
801 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
802 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
803 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
804 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
805 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
806 MANAGE_WINDOW_SIGNALS_CONNECT(window);
807 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
808 GTK_SIGNAL_FUNC(key_pressed), mainwin);
810 gtk_widget_realize(window);
811 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
814 gtkut_widget_set_app_icon(window);
816 vbox = gtk_vbox_new(FALSE, 0);
817 gtk_widget_show(vbox);
818 gtk_container_add(GTK_CONTAINER(window), vbox);
821 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
822 menubar = menubar_create(window, mainwin_entries,
823 n_menu_entries, "<Main>", mainwin);
824 gtk_widget_show(menubar);
825 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
827 handlebox = gtk_handle_box_new();
828 gtk_widget_show(handlebox);
829 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
831 /* create the popup menus for the reply buttons specials */
832 n_menu_entries = sizeof(reply_popup_entries) /
833 sizeof(reply_popup_entries[0]);
834 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
835 "<ReplyPopup>", mainwin);
836 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
837 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
838 n_menu_entries = sizeof(replyall_popup_entries) /
839 sizeof(replyall_popup_entries[0]);
840 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
841 "<ReplyAllPopup>", mainwin);
842 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
843 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
844 n_menu_entries = sizeof(replysender_popup_entries) /
845 sizeof(replysender_popup_entries[0]);
846 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
847 "<ReplySenderPopup>", mainwin);
848 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
849 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
850 /* create the popup menu for the forward button */
851 n_menu_entries = sizeof(fwd_popup_entries) /
852 sizeof(fwd_popup_entries[0]);
853 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
854 "<ForwardPopup>", mainwin);
855 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
856 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
858 main_window_toolbar_create(mainwin, handlebox);
860 /* vbox that contains body */
861 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
862 gtk_widget_show(vbox_body);
863 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
864 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
866 hbox_stat = gtk_hbox_new(FALSE, 2);
867 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
869 statusbar = statusbar_create();
870 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
872 progressbar = gtk_progress_bar_new();
873 gtk_widget_set_usize(progressbar, 120, 1);
874 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
876 statuslabel = gtk_label_new("");
877 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
879 ac_button = gtk_button_new();
880 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
881 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
882 gtk_widget_set_usize(ac_button, -1, 1);
883 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
884 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
885 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
887 ac_label = gtk_label_new("");
888 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
890 gtk_widget_show_all(hbox_stat);
893 mainwin->folderview = folderview = folderview_create();
894 mainwin->summaryview = summaryview = summary_create();
895 mainwin->messageview = messageview = messageview_create();
896 mainwin->logwin = log_window_create();
898 folderview->mainwin = mainwin;
899 folderview->summaryview = summaryview;
901 summaryview->mainwin = mainwin;
902 summaryview->folderview = folderview;
903 summaryview->messageview = messageview;
904 summaryview->window = window;
906 messageview->mainwin = mainwin;
908 mainwin->window = window;
909 mainwin->vbox = vbox;
910 mainwin->menubar = menubar;
911 mainwin->handlebox = handlebox;
912 mainwin->vbox_body = vbox_body;
913 mainwin->hbox_stat = hbox_stat;
914 mainwin->statusbar = statusbar;
915 mainwin->progressbar = progressbar;
916 mainwin->statuslabel = statuslabel;
917 mainwin->ac_button = ac_button;
918 mainwin->ac_label = ac_label;
919 mainwin->reply_popup = reply_popup;
920 mainwin->replyall_popup = replyall_popup;
921 mainwin->replysender_popup = replysender_popup;
922 mainwin->fwd_popup = fwd_popup;
924 /* set context IDs for status bar */
925 mainwin->mainwin_cid = gtk_statusbar_get_context_id
926 (GTK_STATUSBAR(statusbar), "Main Window");
927 mainwin->folderview_cid = gtk_statusbar_get_context_id
928 (GTK_STATUSBAR(statusbar), "Folder View");
929 mainwin->summaryview_cid = gtk_statusbar_get_context_id
930 (GTK_STATUSBAR(statusbar), "Summary View");
932 /* allocate colors for summary view and folder view */
933 summaryview->color_marked.red = summaryview->color_marked.green = 0;
934 summaryview->color_marked.blue = (guint16)65535;
936 summaryview->color_dim.red = summaryview->color_dim.green =
937 summaryview->color_dim.blue = COLOR_DIM;
939 folderview->color_new.red = (guint16)55000;
940 folderview->color_new.green = folderview->color_new.blue = 15000;
942 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
943 &folderview->color_op);
945 summaryview->color_important.red = 0;
946 summaryview->color_important.green = 0;
947 summaryview->color_important.blue = (guint16)65535;
949 color[0] = summaryview->color_marked;
950 color[1] = summaryview->color_dim;
951 color[2] = folderview->color_new;
952 color[3] = folderview->color_op;
954 colormap = gdk_window_get_colormap(window->window);
955 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
956 for (i = 0; i < 4; i++) {
957 if (success[i] == FALSE)
958 g_warning(_("MainWindow: color allocation %d failed\n"), i);
961 debug_print(_("done.\n"));
963 main_window_set_widgets(mainwin, type);
966 ifactory = gtk_item_factory_from_widget(menubar);
967 menuitem = gtk_item_factory_get_item
968 (ifactory, "/View/Code set/Auto detect");
969 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
971 switch (prefs_common.toolbar_style) {
973 menuitem = gtk_item_factory_get_item
974 (ifactory, "/View/Show or hide/Toolbar/None");
977 menuitem = gtk_item_factory_get_item
978 (ifactory, "/View/Show or hide/Toolbar/Icon");
981 menuitem = gtk_item_factory_get_item
982 (ifactory, "/View/Show or hide/Toolbar/Text");
985 menuitem = gtk_item_factory_get_item
986 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
988 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
990 gtk_widget_hide(mainwin->hbox_stat);
991 menuitem = gtk_item_factory_get_item
992 (ifactory, "/View/Show or hide/Status bar");
993 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
994 prefs_common.show_statusbar);
995 #if 0 /* FIXED SEPARATE WINDOWS */
996 /* Message view and Folder tree are always shown at startup
997 * make that in the menu visible */
998 menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Message View");
999 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1000 menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Folder Tree");
1001 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1003 /* set the check of the SEPARATE_xxx menu items. we also need the main window
1004 * as a property and pass the action type to the callback */
1005 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
1007 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
1008 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
1009 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
1010 GUINT_TO_POINTER(SEPARATE_FOLDER));
1012 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
1014 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
1015 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
1016 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
1017 GUINT_TO_POINTER(SEPARATE_MESSAGE));
1019 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
1020 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
1023 /* set account selection menu */
1024 ac_menu = gtk_item_factory_get_widget
1025 (ifactory, "/Configuration/Change current account");
1026 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1027 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1028 mainwin->ac_menu = ac_menu;
1030 main_window_set_toolbar_sensitive(mainwin);
1032 /* Create actions menu */
1033 update_mainwin_actions_menu(ifactory, mainwin);
1035 /* show main window */
1036 gtk_widget_set_uposition(mainwin->window,
1037 prefs_common.mainwin_x,
1038 prefs_common.mainwin_y);
1039 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1040 prefs_common.mainwin_height);
1041 gtk_widget_show(mainwin->window);
1043 /* initialize views */
1044 folderview_init(folderview);
1045 summary_init(summaryview);
1046 messageview_init(messageview);
1047 log_window_init(mainwin->logwin);
1049 mainwin->lock_count = 0;
1050 mainwin->menu_lock_count = 0;
1051 mainwin->cursor_count = 0;
1054 watch_cursor = gdk_cursor_new(GDK_WATCH);
1056 mainwin_list = g_list_append(mainwin_list, mainwin);
1061 void main_window_cursor_wait(MainWindow *mainwin)
1064 if (mainwin->cursor_count == 0)
1065 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1067 mainwin->cursor_count++;
1072 void main_window_cursor_normal(MainWindow *mainwin)
1074 if (mainwin->cursor_count)
1075 mainwin->cursor_count--;
1077 if (mainwin->cursor_count == 0)
1078 gdk_window_set_cursor(mainwin->window->window, NULL);
1083 /* lock / unlock the user-interface */
1084 void main_window_lock(MainWindow *mainwin)
1086 if (mainwin->lock_count == 0)
1087 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1089 mainwin->lock_count++;
1091 main_window_set_menu_sensitive(mainwin);
1092 main_window_set_toolbar_sensitive(mainwin);
1095 void main_window_unlock(MainWindow *mainwin)
1097 if (mainwin->lock_count)
1098 mainwin->lock_count--;
1100 main_window_set_menu_sensitive(mainwin);
1101 main_window_set_toolbar_sensitive(mainwin);
1103 if (mainwin->lock_count == 0)
1104 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1107 static void main_window_menu_callback_block(MainWindow *mainwin)
1109 mainwin->menu_lock_count++;
1112 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1114 if (mainwin->menu_lock_count)
1115 mainwin->menu_lock_count--;
1118 void main_window_reflect_prefs_all(void)
1120 main_window_reflect_prefs_all_real(FALSE);
1123 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1126 MainWindow *mainwin;
1128 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1129 mainwin = (MainWindow *)cur->data;
1131 main_window_show_cur_account(mainwin);
1132 main_window_set_menu_sensitive(mainwin);
1133 main_window_set_toolbar_sensitive(mainwin);
1136 if (pixmap_theme_changed)
1138 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1139 mainwin->toolbar = NULL;
1140 main_window_toolbar_create(mainwin, mainwin->handlebox);
1141 set_toolbar_style(mainwin);
1142 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1143 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1144 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1147 summary_redisplay_msg(mainwin->summaryview);
1148 headerview_set_visibility(mainwin->messageview->headerview,
1149 prefs_common.display_header_pane);
1153 void main_window_set_summary_column(void)
1156 MainWindow *mainwin;
1158 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1159 mainwin = (MainWindow *)cur->data;
1160 summary_set_column_order(mainwin->summaryview);
1164 void main_window_set_account_menu(GList *account_list)
1166 GList *cur, *cur_ac, *cur_item;
1167 GtkWidget *menuitem;
1168 MainWindow *mainwin;
1169 PrefsAccount *ac_prefs;
1171 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1172 mainwin = (MainWindow *)cur->data;
1174 /* destroy all previous menu item */
1175 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1176 while (cur_item != NULL) {
1177 GList *next = cur_item->next;
1178 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1182 for (cur_ac = account_list; cur_ac != NULL;
1183 cur_ac = cur_ac->next) {
1184 ac_prefs = (PrefsAccount *)cur_ac->data;
1186 menuitem = gtk_menu_item_new_with_label
1187 (ac_prefs->account_name
1188 ? ac_prefs->account_name : _("Untitled"));
1189 gtk_widget_show(menuitem);
1190 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1191 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1192 GTK_SIGNAL_FUNC(account_menu_cb),
1198 static void main_window_show_cur_account(MainWindow *mainwin)
1203 ac_name = g_strdup(cur_account
1204 ? (cur_account->account_name
1205 ? cur_account->account_name : _("Untitled"))
1209 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1211 buf = g_strdup(PROG_VERSION);
1212 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1215 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1216 gtk_widget_queue_resize(mainwin->ac_button);
1221 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1223 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1224 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1225 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1227 if (mainwin->type == type) return;
1229 /* remove widgets from those containers */
1230 gtk_widget_ref(folder_wid);
1231 gtk_widget_ref(summary_wid);
1232 gtk_widget_ref(message_wid);
1233 gtkut_container_remove
1234 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1235 gtkut_container_remove
1236 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1237 gtkut_container_remove
1238 (GTK_CONTAINER(message_wid->parent), message_wid);
1240 /* clean containers */
1241 switch (mainwin->type) {
1243 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1245 case SEPARATE_FOLDER:
1246 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1247 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1249 case SEPARATE_MESSAGE:
1250 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1251 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1254 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1255 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1259 gtk_widget_hide(mainwin->window);
1260 main_window_set_widgets(mainwin, type);
1261 gtk_widget_show(mainwin->window);
1263 gtk_widget_unref(folder_wid);
1264 gtk_widget_unref(summary_wid);
1265 gtk_widget_unref(message_wid);
1268 void main_window_get_size(MainWindow *mainwin)
1270 GtkAllocation *allocation;
1272 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1274 prefs_common.summaryview_width = allocation->width;
1276 if (mainwin->summaryview->msg_is_toggled_on)
1277 prefs_common.summaryview_height = allocation->height;
1279 prefs_common.mainview_width = allocation->width;
1281 allocation = &mainwin->window->allocation;
1283 prefs_common.mainview_height = allocation->height;
1284 prefs_common.mainwin_width = allocation->width;
1285 prefs_common.mainwin_height = allocation->height;
1287 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1289 prefs_common.folderview_width = allocation->width;
1290 prefs_common.folderview_height = allocation->height;
1293 void main_window_get_position(MainWindow *mainwin)
1297 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1299 prefs_common.mainview_x = x;
1300 prefs_common.mainview_y = y;
1301 prefs_common.mainwin_x = x;
1302 prefs_common.mainwin_y = y;
1304 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1307 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1313 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1314 folder = FOLDER(list->data);
1315 if (folder && folder->trash && folder->trash->total > 0)
1319 if (!has_trash) return;
1322 if (alertpanel(_("Empty trash"),
1323 _("Empty all messages in trash?"),
1324 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1326 manage_window_focus_in(mainwin->window, NULL, NULL);
1329 procmsg_empty_trash();
1331 for (list = folder_get_list(); list != NULL; list = list->next) {
1332 folder = list->data;
1333 if (folder && folder->trash && folder->trash->total != 0) {
1334 folder_item_scan(folder->trash);
1335 folderview_update_item(folder->trash, TRUE);
1339 if (mainwin->summaryview->folder_item &&
1340 mainwin->summaryview->folder_item->stype == F_TRASH)
1341 gtk_widget_grab_focus(mainwin->folderview->ctree);
1344 void main_window_add_mailbox(MainWindow *mainwin)
1349 path = input_dialog(_("Add mailbox"),
1350 _("Input the location of mailbox.\n"
1351 "If the existing mailbox is specified, it will be\n"
1352 "scanned automatically."),
1355 if (folder_find_from_path(path)) {
1356 alertpanel_error(_("The mailbox `%s' already exists."), path);
1360 if (!strcmp(path, "Mail"))
1361 folder = folder_new(F_MH, _("Mailbox"), path);
1363 folder = folder_new(F_MH, g_basename(path), path);
1366 if (folder->create_tree(folder) < 0) {
1367 alertpanel_error(_("Creation of the mailbox failed.\n"
1368 "Maybe some files already exist, or you don't have the permission to write there."));
1369 folder_destroy(folder);
1374 folder_set_ui_func(folder, scan_tree_func, mainwin);
1375 folder->scan_tree(folder);
1376 folder_set_ui_func(folder, NULL, NULL);
1378 folderview_set(mainwin->folderview);
1381 void main_window_add_mbox(MainWindow *mainwin)
1387 path = input_dialog(_("Add mbox mailbox"),
1388 _("Input the location of mailbox."),
1393 if (folder_find_from_path(path)) {
1394 alertpanel_error(_("The mailbox `%s' already exists."), path);
1400 if (!strcmp(path, "Mail"))
1401 folder = folder_new(F_MBOX, _("Mailbox"), path);
1405 folder = folder_new(F_MBOX, g_basename(path), path);
1408 if (folder->create_tree(folder) < 0) {
1409 alertpanel_error(_("Creation of the mailbox failed."));
1410 folder_destroy(folder);
1416 item = folder_item_new(folder->name, NULL);
1417 item->folder = folder;
1418 folder->node = g_node_new(item);
1420 folder->create_folder(folder, item, "inbox");
1421 folder->create_folder(folder, item, "outbox");
1422 folder->create_folder(folder, item, "queue");
1423 folder->create_folder(folder, item, "draft");
1424 folder->create_folder(folder, item, "trash");
1426 folderview_set(mainwin->folderview);
1431 M_UNLOCKED = 1 << 0,
1432 M_MSG_EXIST = 1 << 1,
1433 M_TARGET_EXIST = 1 << 2,
1434 M_SINGLE_TARGET_EXIST = 1 << 3,
1436 M_ALLOW_REEDIT = 1 << 5,
1437 M_HAVE_ACCOUNT = 1 << 6,
1438 M_THREADED = 1 << 7,
1439 M_UNTHREADED = 1 << 8,
1440 M_ALLOW_DELETE = 1 << 9,
1441 M_INC_ACTIVE = 1 << 10,
1443 M_HAVE_NEWS_ACCOUNT = 1 << 12,
1444 M_HIDE_READ_MSG = 1 << 13
1447 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1449 SensitiveCond state = 0;
1450 SummarySelection selection;
1451 FolderItem *item = mainwin->summaryview->folder_item;
1452 GList *account_list = account_get_list();
1454 selection = summary_get_selection_type(mainwin->summaryview);
1456 if (mainwin->lock_count == 0)
1457 state |= M_UNLOCKED;
1458 if (selection != SUMMARY_NONE)
1459 state |= M_MSG_EXIST;
1463 state |= M_THREADED;
1465 state |= M_UNTHREADED;
1466 /* if (item->folder->type != F_NEWS) */
1467 state |= M_ALLOW_DELETE;
1469 if (selection == SUMMARY_NONE && item->hide_read_msgs
1470 || selection != SUMMARY_NONE)
1471 state |= M_HIDE_READ_MSG;
1473 if (selection == SUMMARY_SELECTED_SINGLE ||
1474 selection == SUMMARY_SELECTED_MULTIPLE)
1475 state |= M_TARGET_EXIST;
1476 if (selection == SUMMARY_SELECTED_SINGLE)
1477 state |= M_SINGLE_TARGET_EXIST;
1478 if (mainwin->summaryview->folder_item &&
1479 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1481 if (selection == SUMMARY_SELECTED_SINGLE &&
1483 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1484 item->stype == F_QUEUE)))
1485 state |= M_ALLOW_REEDIT;
1487 state |= M_HAVE_ACCOUNT;
1489 for ( ; account_list != NULL; account_list = account_list->next) {
1490 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1491 state |= M_HAVE_NEWS_ACCOUNT;
1496 if (inc_is_active())
1497 state |= M_INC_ACTIVE;
1502 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1504 SensitiveCond state;
1513 entry[0].widget = mainwin->get_btn;
1514 entry[0].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1515 entry[1].widget = mainwin->getall_btn;
1516 entry[1].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1517 entry[2].widget = mainwin->compose_news_btn;
1518 entry[2].cond = M_HAVE_NEWS_ACCOUNT;
1519 entry[3].widget = mainwin->reply_btn;
1520 entry[3].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1521 entry[4].widget = mainwin->replyall_btn;
1522 entry[4].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1523 entry[5].widget = mainwin->replysender_btn;
1524 entry[5].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1525 entry[6].widget = mainwin->fwd_btn;
1526 entry[6].cond = M_HAVE_ACCOUNT|M_TARGET_EXIST;
1527 /* entry[6].widget = mainwin->prefs_btn;
1528 entry[6].cond = M_UNLOCKED;
1529 entry[7].widget = mainwin->account_btn;
1530 entry[7].cond = M_UNLOCKED; */
1531 entry[7].widget = mainwin->next_btn;
1532 entry[7].cond = M_MSG_EXIST;
1533 entry[8].widget = mainwin->delete_btn;
1534 entry[8].cond = M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED;
1535 entry[9].widget = mainwin->exec_btn;
1536 entry[9].cond = M_MSG_EXIST|M_EXEC|M_UNLOCKED;
1537 entry[10].widget = NULL;
1540 state = main_window_get_current_state(mainwin);
1542 for (i = 0; entry[i].widget != NULL; i++) {
1543 sensitive = ((entry[i].cond & state) == entry[i].cond);
1544 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1547 activate_compose_button(mainwin,
1548 prefs_common.toolbar_style,
1549 mainwin->compose_btn_type);
1552 void main_window_set_menu_sensitive(MainWindow *mainwin)
1554 GtkItemFactory *ifactory;
1555 SensitiveCond state;
1557 GtkWidget *menuitem;
1560 static const struct {
1564 {"/File/Add mailbox..." , M_UNLOCKED},
1565 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1566 {"/File/Rescan folder tree" , M_UNLOCKED},
1567 {"/File/Folder" , M_UNLOCKED},
1568 {"/File/Import mbox file..." , M_UNLOCKED},
1569 {"/File/Export to mbox file...", M_UNLOCKED},
1570 {"/File/Empty trash" , M_UNLOCKED},
1571 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1572 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1573 /* {"/File/Close", M_UNLOCKED}, */
1574 {"/File/Exit" , M_UNLOCKED},
1576 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1577 {"/View/Sort" , M_MSG_EXIST},
1578 {"/View/Thread view" , M_EXEC},
1579 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1580 {"/View/Go to/Prev message" , M_MSG_EXIST},
1581 {"/View/Go to/Next message" , M_MSG_EXIST},
1582 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1583 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1584 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1585 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1586 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1587 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1588 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1589 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1590 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1592 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1593 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1594 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1595 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1596 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1597 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1598 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1599 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1600 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1601 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1602 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1603 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1604 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1605 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1606 {"/Message/Mark" , M_TARGET_EXIST},
1608 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1609 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1610 {"/Tools/Gather addresses" , M_TARGET_EXIST|M_UNLOCKED},
1611 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1612 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1613 {"/Tools/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1614 {"/Tools/Actions" , M_MSG_EXIST},
1615 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1617 {"/Configuration", M_UNLOCKED},
1622 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1623 state = main_window_get_current_state(mainwin);
1625 for (i = 0; entry[i].entry != NULL; i++) {
1626 sensitive = ((entry[i].cond & state) == entry[i].cond);
1627 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1630 main_window_menu_callback_block(mainwin);
1631 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all header");
1632 gtk_check_menu_item_set_active
1633 (GTK_CHECK_MENU_ITEM(menuitem),
1634 mainwin->messageview->textview->show_all_headers);
1635 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1636 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1637 (state & M_THREADED) != 0);
1638 main_window_menu_callback_unblock(mainwin);
1641 void main_window_popup(MainWindow *mainwin)
1647 gdk_window_get_origin(mainwin->window->window, &x, &y);
1648 sx = gdk_screen_width();
1649 sy = gdk_screen_height();
1650 x %= sx; if (x < 0) x = 0;
1651 y %= sy; if (y < 0) y = 0;
1652 gdk_window_move(mainwin->window->window, x, y);
1653 gdk_window_raise(mainwin->window->window);
1654 gdk_window_show(mainwin->window->window);
1656 debug_print("window position: x = %d, y = %d\n", x, y);
1658 switch (mainwin->type) {
1659 case SEPARATE_FOLDER:
1660 widget = mainwin->win.sep_folder.folderwin;
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);
1667 case SEPARATE_MESSAGE:
1668 widget = mainwin->win.sep_message.messagewin;
1669 gdk_window_get_origin(widget->window, &x, &y);
1670 x %= sx; if (x < 0) x = 0;
1671 y %= sy; if (y < 0) y = 0;
1672 gdk_window_move(widget->window, x, y);
1673 gdk_window_raise(widget->window);
1676 widget = mainwin->win.sep_both.folderwin;
1677 gdk_window_get_origin(widget->window, &x, &y);
1678 x %= sx; if (x < 0) x = 0;
1679 y %= sy; if (y < 0) y = 0;
1680 gdk_window_move(widget->window, x, y);
1681 gdk_window_raise(widget->window);
1682 widget = mainwin->win.sep_both.messagewin;
1683 gdk_window_get_origin(widget->window, &x, &y);
1684 x %= sx; if (x < 0) x = 0;
1685 y %= sy; if (y < 0) y = 0;
1686 gdk_window_move(widget->window, x, y);
1687 gdk_window_raise(widget->window);
1694 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1696 GtkWidget *folderwin = NULL;
1697 GtkWidget *messagewin = NULL;
1700 GtkWidget *vbox_body = mainwin->vbox_body;
1701 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1702 GtkWidget *menuitem;
1704 debug_print(_("Setting widgets..."));
1706 /* create separated window(s) if needed */
1707 if (type & SEPARATE_FOLDER) {
1708 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1709 gtk_window_set_title(GTK_WINDOW(folderwin),
1710 _("Sylpheed - Folder View"));
1711 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1712 "folder_view", "Sylpheed");
1713 gtk_window_set_policy(GTK_WINDOW(folderwin),
1715 gtk_widget_set_usize(folderwin, -1,
1716 prefs_common.mainview_height);
1717 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1719 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1720 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1723 if (type & SEPARATE_MESSAGE) {
1724 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1725 gtk_window_set_title(GTK_WINDOW(messagewin),
1726 _("Sylpheed - Message View"));
1727 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1728 "message_view", "Sylpheed");
1729 gtk_window_set_policy(GTK_WINDOW(messagewin),
1731 gtk_widget_set_usize
1732 (messagewin, prefs_common.mainview_width,
1733 prefs_common.mainview_height
1734 - prefs_common.summaryview_height
1735 + DEFAULT_HEADERVIEW_HEIGHT);
1736 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1738 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1739 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1745 hpaned = gtk_hpaned_new();
1746 gtk_widget_show(hpaned);
1747 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1748 gtk_paned_add1(GTK_PANED(hpaned),
1749 GTK_WIDGET_PTR(mainwin->folderview));
1751 vpaned = gtk_vpaned_new();
1752 if (mainwin->summaryview->msg_is_toggled_on) {
1753 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1754 gtk_paned_add1(GTK_PANED(vpaned),
1755 GTK_WIDGET_PTR(mainwin->summaryview));
1757 gtk_paned_add2(GTK_PANED(hpaned),
1758 GTK_WIDGET_PTR(mainwin->summaryview));
1759 gtk_widget_ref(vpaned);
1761 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1762 prefs_common.summaryview_width,
1763 prefs_common.summaryview_height);
1764 gtk_paned_add2(GTK_PANED(vpaned),
1765 GTK_WIDGET_PTR(mainwin->messageview));
1766 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1767 prefs_common.mainview_width, -1);
1768 gtk_widget_set_usize(mainwin->window,
1769 prefs_common.folderview_width +
1770 prefs_common.mainview_width,
1771 prefs_common.mainwin_height);
1772 gtk_widget_show_all(vpaned);
1774 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1775 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1776 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1777 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1778 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1779 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1781 mainwin->win.sep_none.hpaned = hpaned;
1782 mainwin->win.sep_none.vpaned = vpaned;
1784 case SEPARATE_FOLDER:
1785 vpaned = gtk_vpaned_new();
1786 if (mainwin->summaryview->msg_is_toggled_on) {
1787 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1789 gtk_paned_add1(GTK_PANED(vpaned),
1790 GTK_WIDGET_PTR(mainwin->summaryview));
1792 gtk_box_pack_start(GTK_BOX(vbox_body),
1793 GTK_WIDGET_PTR(mainwin->summaryview),
1795 gtk_widget_ref(vpaned);
1797 gtk_paned_add2(GTK_PANED(vpaned),
1798 GTK_WIDGET_PTR(mainwin->messageview));
1799 gtk_widget_show_all(vpaned);
1800 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1801 prefs_common.summaryview_width,
1802 prefs_common.summaryview_height);
1803 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1804 prefs_common.mainview_width, -1);
1805 gtk_widget_set_usize(mainwin->window,
1806 prefs_common.mainview_width,
1807 prefs_common.mainview_height);
1809 gtk_container_add(GTK_CONTAINER(folderwin),
1810 GTK_WIDGET_PTR(mainwin->folderview));
1812 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1813 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1815 mainwin->win.sep_folder.folderwin = folderwin;
1816 mainwin->win.sep_folder.vpaned = vpaned;
1818 gtk_widget_show_all(folderwin);
1820 case SEPARATE_MESSAGE:
1821 hpaned = gtk_hpaned_new();
1822 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1824 gtk_paned_add1(GTK_PANED(hpaned),
1825 GTK_WIDGET_PTR(mainwin->folderview));
1826 gtk_paned_add2(GTK_PANED(hpaned),
1827 GTK_WIDGET_PTR(mainwin->summaryview));
1828 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1829 prefs_common.summaryview_width,
1830 prefs_common.summaryview_height);
1831 gtk_widget_set_usize(mainwin->window,
1832 prefs_common.folderview_width +
1833 prefs_common.mainview_width,
1834 prefs_common.mainwin_height);
1835 gtk_widget_show_all(hpaned);
1836 gtk_container_add(GTK_CONTAINER(messagewin),
1837 GTK_WIDGET_PTR(mainwin->messageview));
1839 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1840 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1841 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1842 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1844 mainwin->win.sep_message.messagewin = messagewin;
1845 mainwin->win.sep_message.hpaned = hpaned;
1847 gtk_widget_show_all(messagewin);
1850 gtk_box_pack_start(GTK_BOX(vbox_body),
1851 GTK_WIDGET_PTR(mainwin->summaryview),
1853 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1854 prefs_common.summaryview_width,
1855 prefs_common.summaryview_height);
1856 gtk_widget_set_usize(mainwin->window,
1857 prefs_common.mainview_width,
1858 prefs_common.mainwin_height);
1859 gtk_container_add(GTK_CONTAINER(folderwin),
1860 GTK_WIDGET_PTR(mainwin->folderview));
1861 gtk_container_add(GTK_CONTAINER(messagewin),
1862 GTK_WIDGET_PTR(mainwin->messageview));
1864 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1865 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1867 mainwin->win.sep_both.folderwin = folderwin;
1868 mainwin->win.sep_both.messagewin = messagewin;
1870 gtk_widget_show_all(folderwin);
1871 gtk_widget_show_all(messagewin);
1875 mainwin->type = type;
1877 debug_print(_("done.\n"));
1880 static void main_window_toolbar_create(MainWindow *mainwin,
1881 GtkWidget *container)
1884 GtkWidget *icon_wid;
1886 GtkWidget *getall_btn;
1887 GtkWidget *compose_mail_btn;
1888 GtkWidget *compose_news_btn;
1889 GtkWidget *reply_btn;
1890 GtkWidget *replyall_btn;
1891 GtkWidget *replysender_btn;
1893 GtkWidget *send_btn;
1895 GtkWidget *prefs_btn;
1896 GtkWidget *account_btn;
1898 GtkWidget *next_btn;
1899 GtkWidget *delete_btn;
1900 GtkWidget *exec_btn;
1902 GtkTooltips *tooltips;
1904 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1906 gtk_container_add(GTK_CONTAINER(container), toolbar);
1907 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1908 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1909 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1910 GTK_TOOLBAR_SPACE_LINE);
1912 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1913 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1915 _("Get new mail from current account"),
1917 icon_wid, toolbar_inc_cb, mainwin);
1918 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1919 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1921 _("Get new mail from all accounts"),
1927 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1929 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1930 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1932 _("Send queued message(s)"),
1938 /* insert compose mail button widget */
1939 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1940 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1942 _("Compose an email message"),
1945 toolbar_compose_mail_cb,
1948 /* insert compose news button widget */
1949 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1950 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1952 _("Compose a news message"),
1955 toolbar_compose_news_cb,
1958 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1962 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1963 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1965 _("Reply to the message - Right button: more options"),
1971 /* replyall button */
1973 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1974 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1976 _("Reply to all - Right button: more options"),
1979 toolbar_reply_to_all_cb,
1982 /* reply to sender button */
1983 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1984 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1986 _("Reply to sender - Right button: more options"),
1989 toolbar_reply_to_sender_cb,
1992 /* forward button */
1993 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1994 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1996 _("Forward the message - Right button: more options"),
2002 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2004 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
2005 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2007 _("Delete the message"),
2013 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
2014 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2016 _("Execute marked process"),
2022 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
2023 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2025 _("Next unread message"),
2028 toolbar_next_unread_cb,
2032 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2034 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2035 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2037 _("Common preference"),
2042 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2043 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2045 _("Account setting"),
2050 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2051 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2055 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2056 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2059 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2060 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2063 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2064 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2067 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2068 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2072 mainwin->toolbar = toolbar;
2073 mainwin->get_btn = get_btn;
2074 mainwin->getall_btn = getall_btn;
2075 mainwin->compose_mail_btn = compose_mail_btn;
2076 mainwin->compose_news_btn = compose_news_btn;
2077 mainwin->reply_btn = reply_btn;
2078 mainwin->replyall_btn = replyall_btn;
2079 mainwin->replysender_btn = replysender_btn;
2080 mainwin->fwd_btn = fwd_btn;
2081 mainwin->send_btn = send_btn;
2083 mainwin->prefs_btn = prefs_btn;
2084 mainwin->account_btn = account_btn;
2086 mainwin->next_btn = next_btn;
2087 mainwin->delete_btn = delete_btn;
2088 mainwin->exec_btn = exec_btn;
2090 gtk_widget_show_all(toolbar);
2093 /* callback functions */
2094 static void toolbar_reply_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->reply_popup), NULL, NULL,
2103 menu_button_position, widget,
2104 event->button, event->time);
2108 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2110 MainWindow *mainwin = (MainWindow *)data;
2112 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2113 manage_window_focus_in(mainwin->window, NULL, NULL);
2116 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2118 MainWindow *mainwindow = (MainWindow *) data;
2122 if (event->button == 3) {
2123 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2124 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2125 menu_button_position, widget,
2126 event->button, event->time);
2130 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2132 MainWindow *mainwin = (MainWindow *)data;
2134 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2135 manage_window_focus_in(mainwin->window, NULL, NULL);
2138 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2140 MainWindow *mainwindow = (MainWindow *) data;
2141 GtkWidget *replysender_menu, *replysender_item;
2145 if (event->button == 3) {
2146 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2147 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2148 menu_button_position, widget,
2149 event->button, event->time);
2153 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2155 MainWindow *mainwin = (MainWindow *)data;
2157 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2158 manage_window_focus_in(mainwin->window, NULL, NULL);
2161 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2163 MainWindow *mainwindow = (MainWindow *) data;
2167 if (event->button == 3) {
2168 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2169 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2170 menu_button_position, widget,
2171 event->button, event->time);
2175 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2177 MainWindow *mainwin = (MainWindow *)data;
2179 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2180 manage_window_focus_in(mainwin->window, NULL, NULL);
2183 static void toolbar_inc_cb (GtkWidget *widget,
2186 MainWindow *mainwin = (MainWindow *)data;
2188 inc_mail_cb(mainwin, 0, NULL);
2191 static void toolbar_inc_all_cb (GtkWidget *widget,
2194 MainWindow *mainwin = (MainWindow *)data;
2196 inc_all_account_mail_cb(mainwin, 0, NULL);
2199 static void toolbar_send_cb (GtkWidget *widget,
2202 MainWindow *mainwin = (MainWindow *)data;
2204 send_queue_cb(mainwin, 0, NULL);
2207 static void toolbar_compose_cb (GtkWidget *widget,
2210 MainWindow *mainwin = (MainWindow *)data;
2212 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2213 compose_cb(mainwin, 0, NULL);
2215 compose_news_cb(mainwin, 0, NULL);
2218 static void toolbar_compose_news_cb (GtkWidget *widget,
2221 MainWindow *mainwin = (MainWindow *)data;
2223 compose_news_cb(mainwin, 0, NULL);
2226 static void toolbar_compose_mail_cb (GtkWidget *widget,
2229 MainWindow *mainwin = (MainWindow *)data;
2231 compose_mail_cb(mainwin, 0, NULL);
2234 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2236 MainWindow *mainwin = (MainWindow *)data;
2239 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2240 : COMPOSE_REPLY_WITHOUT_QUOTE,
2244 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2246 MainWindow *mainwin = (MainWindow *)data;
2249 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2250 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2255 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2257 MainWindow *mainwin = (MainWindow *)data;
2260 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2261 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2265 static void toolbar_forward_cb (GtkWidget *widget,
2268 MainWindow *mainwin = (MainWindow *)data;
2270 if (prefs_common.forward_as_attachment)
2271 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2273 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2276 static void toolbar_delete_cb (GtkWidget *widget,
2279 MainWindow *mainwin = (MainWindow *)data;
2281 summary_delete(mainwin->summaryview);
2284 static void toolbar_exec_cb (GtkWidget *widget,
2287 MainWindow *mainwin = (MainWindow *)data;
2289 summary_execute(mainwin->summaryview);
2292 static void toolbar_next_unread_cb (GtkWidget *widget,
2295 MainWindow *mainwin = (MainWindow *)data;
2297 next_unread_cb(mainwin, 0, NULL);
2300 static void toolbar_prefs_cb (GtkWidget *widget,
2303 prefs_common_open();
2306 static void toolbar_account_cb (GtkWidget *widget,
2309 MainWindow *mainwin = (MainWindow *)data;
2311 prefs_account_open_cb(mainwin, 0, NULL);
2314 static void toolbar_account_button_pressed(GtkWidget *widget,
2315 GdkEventButton *event,
2318 MainWindow *mainwin = (MainWindow *)data;
2321 if (event->button != 3) return;
2323 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2324 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2327 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2328 menu_button_position, widget,
2329 event->button, event->time);
2332 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2335 MainWindow *mainwin = (MainWindow *)data;
2339 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2340 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2343 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2344 menu_button_position, widget,
2345 event->button, event->time);
2348 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2350 MainWindow *mainwin = (MainWindow *)data;
2353 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2354 if (!button) return;
2355 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2356 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2357 manage_window_focus_in(mainwin->window, NULL, NULL);
2360 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2363 MainWindow *mainwin = (MainWindow *)data;
2365 if (mainwin->lock_count == 0)
2366 app_exit_cb(data, 0, widget);
2371 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2374 main_window_add_mailbox(mainwin);
2377 static void add_mbox_cb(MainWindow *mainwin, guint action,
2380 main_window_add_mbox(mainwin);
2383 static void update_folderview_cb(MainWindow *mainwin, guint action,
2386 summary_show(mainwin->summaryview, NULL, FALSE);
2387 folderview_rescan_all();
2390 static void new_folder_cb(MainWindow *mainwin, guint action,
2393 folderview_new_folder(mainwin->folderview);
2396 static void rename_folder_cb(MainWindow *mainwin, guint action,
2399 folderview_rename_folder(mainwin->folderview);
2402 static void delete_folder_cb(MainWindow *mainwin, guint action,
2405 folderview_delete_folder(mainwin->folderview);
2408 static void import_mbox_cb(MainWindow *mainwin, guint action,
2411 import_mbox(mainwin->summaryview->folder_item);
2414 static void export_mbox_cb(MainWindow *mainwin, guint action,
2417 export_mbox(mainwin->summaryview->folder_item);
2420 static void empty_trash_cb(MainWindow *mainwin, guint action,
2423 main_window_empty_trash(mainwin, TRUE);
2426 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2428 summary_save_as(mainwin->summaryview);
2431 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2433 summary_print(mainwin->summaryview);
2436 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2438 if (prefs_common.confirm_on_exit) {
2439 if (alertpanel(_("Exit"), _("Exit this program?"),
2440 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2442 manage_window_focus_in(mainwin->window, NULL, NULL);
2445 app_will_exit(widget, mainwin);
2448 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2451 summary_search(mainwin->summaryview);
2453 message_search(mainwin->messageview);
2456 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2459 switch (mainwin->type) {
2461 case SEPARATE_MESSAGE:
2463 case SEPARATE_FOLDER:
2464 if (GTK_CHECK_MENU_ITEM(widget)->active)
2465 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2467 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2470 if (GTK_CHECK_MENU_ITEM(widget)->active)
2471 gtk_widget_show(mainwin->win.sep_both.folderwin);
2473 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2478 static void toggle_message_cb(MainWindow *mainwin, guint action,
2481 switch (mainwin->type) {
2483 case SEPARATE_FOLDER:
2485 case SEPARATE_MESSAGE:
2486 if (GTK_CHECK_MENU_ITEM(widget)->active)
2487 gtk_widget_show(mainwin->win.sep_message.messagewin);
2489 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2492 if (GTK_CHECK_MENU_ITEM(widget)->active)
2493 gtk_widget_show(mainwin->win.sep_both.messagewin);
2495 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2500 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2503 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2504 mainwin->compose_btn_type);
2505 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2506 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2507 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2508 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2510 mainwin->toolbar_style = (ToolbarStyle)action;
2511 prefs_common.toolbar_style = (ToolbarStyle)action;
2513 set_toolbar_style(mainwin);
2516 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2519 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2520 gtk_widget_show(mainwin->hbox_stat);
2521 prefs_common.show_statusbar = TRUE;
2523 gtk_widget_hide(mainwin->hbox_stat);
2524 prefs_common.show_statusbar = FALSE;
2528 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2530 summary_toggle_view_real(mainwin->summaryview);
2533 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2535 messageview_toggle_view_real(mainwin->messageview);
2538 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2541 MainWindow *mainwin;
2544 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2545 g_return_if_fail(mainwin != NULL);
2547 type = mainwin->type ^ action;
2548 main_window_separation_change(mainwin, type);
2550 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2551 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2554 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2557 addressbook_open(NULL);
2560 static void log_window_show_cb(MainWindow *mainwin, guint action,
2563 log_window_show(mainwin->logwin);
2566 static void sel_download_cb(MainWindow *mainwin, guint action,
2569 selective_download(mainwin);
2572 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2574 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2577 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2580 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2583 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2588 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2592 for (list = folder_get_list(); list != NULL; list = list->next) {
2593 Folder *folder = list->data;
2595 if (folder->queue) {
2596 if (procmsg_send_queue
2597 (folder->queue, prefs_common.savemsg) < 0)
2598 alertpanel_error(_("Some errors occurred while sending queued messages."));
2599 statusbar_pop_all();
2600 folder_item_scan(folder->queue);
2601 folderview_update_item(folder->queue, TRUE);
2606 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2608 if (mainwin->summaryview->folder_item) {
2609 if (mainwin->summaryview->folder_item->folder->account != NULL
2610 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2611 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2613 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2619 static void compose_mail_cb(MainWindow *mainwin, guint action,
2626 if (mainwin->summaryview->folder_item) {
2627 ac = mainwin->summaryview->folder_item->folder->account;
2628 if (ac && ac->protocol != A_NNTP) {
2629 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2634 if(cur_account && (cur_account->protocol != A_NNTP)) {
2635 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2639 list = account_get_list();
2640 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2641 ac = (PrefsAccount *) cur->data;
2642 if (ac->protocol != A_NNTP) {
2643 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2649 static void compose_news_cb(MainWindow *mainwin, guint action,
2652 PrefsAccount * ac = NULL;
2656 if (mainwin->summaryview->folder_item) {
2657 ac = mainwin->summaryview->folder_item->folder->account;
2658 if (ac && ac->protocol == A_NNTP) {
2659 compose_new_with_recipient
2660 (ac, mainwin->summaryview->folder_item->path);
2665 list = account_get_list();
2666 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2667 ac = (PrefsAccount *) cur->data;
2668 if (ac->protocol == A_NNTP) {
2675 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2677 summary_reply(mainwin->summaryview, (ComposeMode)action);
2680 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2682 summary_move_to(mainwin->summaryview);
2685 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2687 summary_copy_to(mainwin->summaryview);
2690 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2692 summary_delete(mainwin->summaryview);
2695 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2697 summary_open_msg(mainwin->summaryview);
2700 static void view_source_cb(MainWindow *mainwin, guint action,
2703 summary_view_source(mainwin->summaryview);
2706 static void show_all_header_cb(MainWindow *mainwin, guint action,
2709 if (mainwin->menu_lock_count) return;
2710 summary_display_msg_selected(mainwin->summaryview,
2711 GTK_CHECK_MENU_ITEM(widget)->active);
2714 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2716 summary_reedit(mainwin->summaryview);
2719 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2721 summary_mark(mainwin->summaryview);
2724 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2726 summary_unmark(mainwin->summaryview);
2729 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2732 summary_mark_as_unread(mainwin->summaryview);
2735 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2738 summary_mark_as_read(mainwin->summaryview);
2741 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2744 summary_mark_all_read(mainwin->summaryview);
2747 static void add_address_cb(MainWindow *mainwin, guint action,
2750 summary_add_address(mainwin->summaryview);
2753 static void set_charset_cb(MainWindow *mainwin, guint action,
2758 str = conv_get_charset_str((CharSet)action);
2759 g_free(prefs_common.force_charset);
2760 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2762 summary_redisplay_msg(mainwin->summaryview);
2764 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2767 static void hide_read_messages (MainWindow *mainwin, guint action,
2770 if (!mainwin->summaryview->folder_item
2771 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2773 summary_toggle_show_read_messages(mainwin->summaryview);
2776 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2778 GtkItemFactory *ifactory;
2780 if (mainwin->menu_lock_count) return;
2781 if (!mainwin->summaryview->folder_item) return;
2783 ifactory = gtk_item_factory_from_widget(widget);
2785 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2786 summary_thread_build(mainwin->summaryview);
2787 mainwin->summaryview->folder_item->threaded = TRUE;
2789 summary_unthread(mainwin->summaryview);
2790 mainwin->summaryview->folder_item->threaded = FALSE;
2794 static void set_display_item_cb(MainWindow *mainwin, guint action,
2797 prefs_summary_column_open();
2800 static void sort_summary_cb(MainWindow *mainwin, guint action,
2803 summary_sort(mainwin->summaryview, (SummarySortType)action);
2806 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2809 summary_attract_by_subject(mainwin->summaryview);
2812 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2815 summary_delete_duplicated(mainwin->summaryview);
2818 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2820 summary_filter(mainwin->summaryview);
2823 static void execute_summary_cb(MainWindow *mainwin, guint action,
2826 summary_execute(mainwin->summaryview);
2829 static void update_summary_cb(MainWindow *mainwin, guint action,
2833 FolderView *folderview = mainwin->folderview;
2835 if (!mainwin->summaryview->folder_item) return;
2836 if (!folderview->opened) return;
2838 folder_update_op_count();
2840 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2841 folderview->opened);
2844 summary_show(mainwin->summaryview, fitem, TRUE);
2847 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2849 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2852 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2854 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2857 static void prev_unread_cb(MainWindow *mainwin, guint action,
2860 summary_select_prev_unread(mainwin->summaryview);
2863 static void next_unread_cb(MainWindow *mainwin, guint action,
2866 summary_select_next_unread(mainwin->summaryview);
2869 static void prev_marked_cb(MainWindow *mainwin, guint action,
2872 summary_select_prev_marked(mainwin->summaryview);
2875 static void next_marked_cb(MainWindow *mainwin, guint action,
2878 summary_select_next_marked(mainwin->summaryview);
2881 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2884 summary_select_prev_labeled(mainwin->summaryview);
2887 static void next_labeled_cb(MainWindow *mainwin, guint action,
2890 summary_select_next_labeled(mainwin->summaryview);
2893 static void goto_folder_cb(MainWindow *mainwin, guint action,
2896 FolderItem *to_folder;
2898 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2901 folderview_select(mainwin->folderview, to_folder);
2904 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2906 messageview_copy_clipboard(mainwin->messageview);
2909 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2911 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2912 summary_select_all(mainwin->summaryview);
2913 else if (mainwin->summaryview->msg_is_toggled_on &&
2914 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2915 messageview_select_all(mainwin->messageview);
2918 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2920 if (mainwin->summaryview->msg_is_toggled_on)
2921 summary_select_thread(mainwin->summaryview);
2924 static void create_filter_cb(MainWindow *mainwin, guint action,
2927 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2930 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2933 prefs_common_open();
2936 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2939 prefs_filter_open(NULL, NULL);
2942 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2945 prefs_scoring_open(NULL);
2948 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2951 prefs_filtering_open(NULL, NULL, NULL);
2954 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2957 prefs_template_open();
2960 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2963 prefs_actions_open(mainwin);
2966 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2970 new_account_cb(mainwin, 0, widget);
2972 gboolean prev_default = cur_account->is_default;
2974 prefs_account_open(cur_account);
2975 if (!prev_default && cur_account->is_default)
2976 account_set_as_default(cur_account);
2977 account_save_config_all();
2979 main_window_reflect_prefs_all();
2983 static void new_account_cb(MainWindow *mainwin, guint action,
2986 account_edit_open();
2987 if (!compose_get_compose_list()) account_add();
2990 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2992 cur_account = (PrefsAccount *)data;
2993 main_window_reflect_prefs_all();
2996 static void manual_open_cb(MainWindow *mainwin, guint action,
2999 manual_open((ManualLang)action);
3002 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3004 faq_open((ManualLang)action);
3007 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3009 MainWindow *mainwin = (MainWindow *)data;
3013 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3014 LOCAL_FOLDER(folder)->rootpath,
3018 str = g_strdup_printf(_("Scanning folder %s ..."),
3019 LOCAL_FOLDER(folder)->rootpath);
3021 STATUSBAR_PUSH(mainwin, str);
3022 STATUSBAR_POP(mainwin);
3026 static void activate_compose_button (MainWindow *mainwin,
3028 ComposeButtonType type)
3030 SensitiveCond state = main_window_get_current_state(mainwin);
3032 if (style == TOOLBAR_NONE)
3035 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
3036 : mainwin->compose_news_btn);
3037 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
3038 : mainwin->compose_mail_btn);
3039 mainwin->compose_btn_type = type;
3042 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
3044 if (mainwin->compose_btn_type != compose_btn_type)
3045 activate_compose_button(mainwin,
3046 prefs_common.toolbar_style,
3050 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
3052 MainWindow *mainwin = (MainWindow*) data;
3054 if (!mainwin) return;
3056 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
3059 #define BREAK_ON_MODIFIER_KEY() \
3060 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3062 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3064 MainWindow *mainwin = (MainWindow*) data;
3066 if (!mainwin || !event) return;
3068 switch (event->keyval) {
3069 case GDK_Q: /* Quit */
3070 BREAK_ON_MODIFIER_KEY();
3072 app_exit_cb(mainwin, 0, NULL);
3079 #undef BREAK_ON_MODIFIER_KEY
3081 static void set_toolbar_style(MainWindow *mainwin)
3083 switch (prefs_common.toolbar_style) {
3085 gtk_widget_hide(mainwin->handlebox);
3088 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3092 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3096 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3101 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3102 gtk_widget_show(mainwin->handlebox);
3103 gtk_widget_queue_resize(mainwin->handlebox);
3105 if (prefs_common.immediate_exec)
3106 gtk_widget_hide(mainwin->exec_btn);
3108 gtk_widget_show(mainwin->exec_btn);
3113 * Gather addresses for selected folder.
3115 static void addr_gather_cb( MainWindow *mainwin,
3119 addressbook_gather( mainwin->summaryview->folder_item, NULL );
3123 * Gather addresses for selected messages in summary view.
3125 static void addr_gather_msg_cb( MainWindow *mainwin,
3129 summary_gather_address( mainwin->summaryview );