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"
85 #define AC_LABEL_WIDTH 240
87 #define STATUSBAR_PUSH(mainwin, str) \
89 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
90 mainwin->mainwin_cid, str); \
91 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
94 #define STATUSBAR_POP(mainwin) \
96 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
97 mainwin->mainwin_cid); \
100 /* list of all instantiated MainWindow */
101 static GList *mainwin_list = NULL;
103 static GdkCursor *watch_cursor;
105 static void main_window_menu_callback_block (MainWindow *mainwin);
106 static void main_window_menu_callback_unblock (MainWindow *mainwin);
108 static void main_window_show_cur_account (MainWindow *mainwin);
110 static void main_window_set_widgets (MainWindow *mainwin,
112 static void main_window_toolbar_create (MainWindow *mainwin,
113 GtkWidget *container);
115 /* callback functions */
116 static void toolbar_inc_cb (GtkWidget *widget,
118 static void toolbar_inc_all_cb (GtkWidget *widget,
120 static void toolbar_send_cb (GtkWidget *widget,
123 static void toolbar_compose_cb (GtkWidget *widget,
125 static void toolbar_compose_news_cb (GtkWidget *widget,
127 static void toolbar_compose_mail_cb (GtkWidget *widget,
129 static void toolbar_reply_cb (GtkWidget *widget,
131 static void toolbar_reply_popup_cb (GtkWidget *widget,
132 GdkEventButton *event,
134 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell,
136 static void toolbar_reply_to_all_cb (GtkWidget *widget,
138 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget,
139 GdkEventButton *event,
141 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell,
143 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
145 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
146 GdkEventButton *event,
148 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell,
150 static void toolbar_forward_cb (GtkWidget *widget,
152 static void toolbar_forward_popup_cb (GtkWidget *widget,
153 GdkEventButton *event,
155 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell,
158 static void toolbar_delete_cb (GtkWidget *widget,
160 static void toolbar_exec_cb (GtkWidget *widget,
163 static void toolbar_next_unread_cb (GtkWidget *widget,
166 static void toolbar_prefs_cb (GtkWidget *widget,
168 static void toolbar_account_cb (GtkWidget *widget,
171 static void toolbar_account_button_pressed (GtkWidget *widget,
172 GdkEventButton *event,
174 static void ac_label_button_pressed (GtkWidget *widget,
175 GdkEventButton *event,
177 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
180 static gint main_window_close_cb (GtkWidget *widget,
184 static void add_mailbox_cb (MainWindow *mainwin,
187 static void add_mbox_cb (MainWindow *mainwin,
190 static void update_folderview_cb (MainWindow *mainwin,
193 static void new_folder_cb (MainWindow *mainwin,
196 static void rename_folder_cb (MainWindow *mainwin,
199 static void delete_folder_cb (MainWindow *mainwin,
202 static void import_mbox_cb (MainWindow *mainwin,
205 static void export_mbox_cb (MainWindow *mainwin,
208 static void empty_trash_cb (MainWindow *mainwin,
212 static void save_as_cb (MainWindow *mainwin,
215 static void print_cb (MainWindow *mainwin,
218 static void app_exit_cb (MainWindow *mainwin,
222 static void search_cb (MainWindow *mainwin,
226 static void toggle_folder_cb (MainWindow *mainwin,
229 static void toggle_message_cb (MainWindow *mainwin,
232 static void toggle_toolbar_cb (MainWindow *mainwin,
235 static void toggle_statusbar_cb (MainWindow *mainwin,
238 static void toggle_expand_summaryview_cb (MainWindow *mainwin,
241 static void toggle_expand_messageview_cb (MainWindow *mainwin,
244 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
248 static void addressbook_open_cb (MainWindow *mainwin,
251 static void log_window_show_cb (MainWindow *mainwin,
255 static void inc_mail_cb (MainWindow *mainwin,
258 static void inc_all_account_mail_cb (MainWindow *mainwin,
262 static void send_queue_cb (MainWindow *mainwin,
266 static void compose_cb (MainWindow *mainwin,
269 static void compose_mail_cb(MainWindow *mainwin, guint action,
271 static void compose_news_cb(MainWindow *mainwin, guint action,
273 static void reply_cb (MainWindow *mainwin,
277 static void open_msg_cb (MainWindow *mainwin,
281 static void view_source_cb (MainWindow *mainwin,
285 static void show_all_header_cb (MainWindow *mainwin,
289 static void reedit_cb (MainWindow *mainwin,
293 static void move_to_cb (MainWindow *mainwin,
296 static void copy_to_cb (MainWindow *mainwin,
299 static void delete_cb (MainWindow *mainwin,
303 static void mark_cb (MainWindow *mainwin,
306 static void unmark_cb (MainWindow *mainwin,
310 static void mark_as_unread_cb (MainWindow *mainwin,
313 static void mark_as_read_cb (MainWindow *mainwin,
316 static void mark_all_read_cb (MainWindow *mainwin,
319 static void add_address_cb (MainWindow *mainwin,
323 static void set_charset_cb (MainWindow *mainwin,
327 static void hide_read_messages (MainWindow *mainwin,
331 static void thread_cb (MainWindow *mainwin,
334 static void set_display_item_cb (MainWindow *mainwin,
337 static void sort_summary_cb (MainWindow *mainwin,
340 static void attract_by_subject_cb(MainWindow *mainwin,
344 static void delete_duplicated_cb (MainWindow *mainwin,
347 static void filter_cb (MainWindow *mainwin,
350 static void execute_summary_cb (MainWindow *mainwin,
353 static void update_summary_cb (MainWindow *mainwin,
357 static void prev_cb (MainWindow *mainwin,
360 static void next_cb (MainWindow *mainwin,
364 static void prev_unread_cb (MainWindow *mainwin,
367 static void next_unread_cb (MainWindow *mainwin,
370 static void prev_marked_cb (MainWindow *mainwin,
373 static void next_marked_cb (MainWindow *mainwin,
376 static void prev_labeled_cb (MainWindow *mainwin,
379 static void next_labeled_cb (MainWindow *mainwin,
383 static void goto_folder_cb (MainWindow *mainwin,
387 static void copy_cb (MainWindow *mainwin,
390 static void allsel_cb (MainWindow *mainwin,
394 static void create_filter_cb (MainWindow *mainwin,
398 static void prefs_common_open_cb (MainWindow *mainwin,
401 static void prefs_filter_open_cb (MainWindow *mainwin,
404 static void prefs_scoring_open_cb (MainWindow *mainwin,
407 static void prefs_filtering_open_cb (MainWindow *mainwin,
410 static void prefs_account_open_cb(MainWindow *mainwin,
413 static void prefs_template_open_cb (MainWindow *mainwin,
416 static void prefs_actions_open_cb (MainWindow *mainwin,
419 static void new_account_cb (MainWindow *mainwin,
423 static void account_menu_cb (GtkMenuItem *menuitem,
426 static void manual_open_cb (MainWindow *mainwin,
430 static void scan_tree_func (Folder *folder,
434 static void activate_compose_button (MainWindow *mainwin,
436 ComposeButtonType type);
438 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
442 static void key_pressed (GtkWidget *widget,
446 static void set_toolbar_style(MainWindow *mainwin);
448 #define SEPARATE_ACTION 667
450 static GtkItemFactoryEntry mainwin_entries[] =
452 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
453 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
454 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
455 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
456 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
457 {N_("/_File/_Folder/Create _new folder..."),
458 NULL, new_folder_cb, 0, NULL},
459 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
460 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
461 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
462 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
463 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
464 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
465 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
466 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
467 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
468 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
470 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
471 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
472 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
473 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
474 {N_("/_Edit/_Find in current message..."),
475 "<control>F", search_cb, 0, NULL},
476 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
477 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
478 {N_("/_Edit/Actio_ns"), NULL, NULL, 0, "<Branch>"},
480 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
481 {N_("/_View/_Folder tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
482 {N_("/_View/_Message view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
483 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
484 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
485 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
486 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
487 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
488 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
489 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
490 {N_("/_View/Status _bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
491 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
492 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
493 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
494 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
495 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
496 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
497 {N_("/_View/_Sort/Sort by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
498 {N_("/_View/_Sort/Sort by _color label"),
499 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
500 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
501 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
502 {N_("/_View/_Sort/Sort by a_ttachment"),
503 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
504 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
505 {N_("/_View/_Sort/_Attract by subject"),
506 NULL, attract_by_subject_cb, 0, NULL},
507 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
508 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
509 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
510 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
512 #define CODESET_SEPARATOR \
513 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
514 #define CODESET_ACTION(action) \
515 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
517 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
518 {N_("/_View/_Code set/_Auto detect"),
519 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
520 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
521 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
522 CODESET_ACTION(C_US_ASCII)},
525 {N_("/_View/_Code set/Unicode (_UTF-8)"),
526 CODESET_ACTION(C_UTF_8)},
529 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
530 CODESET_ACTION(C_ISO_8859_1)},
533 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
534 CODESET_ACTION(C_ISO_8859_2)},
536 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
537 CODESET_ACTION(C_ISO_8859_13)},
538 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
539 CODESET_ACTION(C_ISO_8859_4)},
541 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
542 CODESET_ACTION(C_ISO_8859_7)},
544 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
545 CODESET_ACTION(C_ISO_8859_9)},
547 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
548 CODESET_ACTION(C_ISO_8859_5)},
549 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
550 CODESET_ACTION(C_KOI8_R)},
551 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
552 CODESET_ACTION(C_CP1251)},
555 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
556 CODESET_ACTION(C_ISO_2022_JP)},
558 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
559 CODESET_ACTION(C_ISO_2022_JP_2)},
561 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
562 CODESET_ACTION(C_EUC_JP)},
563 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
564 CODESET_ACTION(C_SHIFT_JIS)},
567 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
568 CODESET_ACTION(C_GB2312)},
569 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
570 CODESET_ACTION(C_BIG5)},
571 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
572 CODESET_ACTION(C_EUC_TW)},
573 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
574 CODESET_ACTION(C_ISO_2022_CN)},
576 {N_("/_View/_Code set/Korean (EUC-_KR)"),
577 CODESET_ACTION(C_EUC_KR)},
578 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
579 CODESET_ACTION(C_ISO_2022_KR)},
581 {N_("/_View/_Code set/Thai (TIS-620)"),
582 CODESET_ACTION(C_TIS_620)},
583 {N_("/_View/_Code set/Thai (Windows-874)"),
584 CODESET_ACTION(C_WINDOWS_874)},
587 #undef CODESET_SEPARATOR
588 #undef CODESET_ACTION
590 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
591 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
592 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
593 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
594 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
595 {N_("/_View/_Go to/P_rev unread message"),
596 "<shift>P", prev_unread_cb, 0, NULL},
597 {N_("/_View/_Go to/N_ext unread message"),
598 "<shift>N", next_unread_cb, 0, NULL},
599 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
600 {N_("/_View/_Go to/Prev _marked message"),
601 NULL, prev_marked_cb, 0, NULL},
602 {N_("/_View/_Go to/Next m_arked message"),
603 NULL, next_marked_cb, 0, NULL},
604 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
605 {N_("/_View/_Go to/Prev _labeled message"),
606 NULL, prev_labeled_cb, 0, NULL},
607 {N_("/_View/_Go to/Next la_beled message"),
608 NULL, next_labeled_cb, 0, NULL},
609 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
610 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
611 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
612 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
613 {N_("/_View/_View source"), "<control>U", view_source_cb, 0, NULL},
614 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
615 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
616 {N_("/_View/_Update"), "<control><alt>U", update_summary_cb, 0, NULL},
618 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
619 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
620 {N_("/_Message/Get from _all accounts"),
621 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
622 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
623 {N_("/_Message/Send queued messa_ges"),
624 NULL, send_queue_cb, 0, NULL},
625 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
626 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
627 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
628 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
629 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
630 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
631 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
632 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
633 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
634 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
635 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
636 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
637 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
638 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
639 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
640 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
641 {N_("/_Message/Delete du_plicated messages"),
642 NULL, delete_duplicated_cb, 0, NULL},
643 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
644 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
645 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
646 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
647 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
648 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
649 {N_("/_Message/_Mark/Mark as rea_d"),
650 NULL, mark_as_read_cb, 0, NULL},
651 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
653 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
654 {N_("/_Tool/_Address book"), "<shift><control>A", addressbook_open_cb, 0, NULL},
655 {N_("/_Tool/Add sender to address boo_k"),
656 NULL, add_address_cb, 0, NULL},
657 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
658 {N_("/_Tool/_Filter messages"), NULL, filter_cb, 0, NULL},
659 {N_("/_Tool/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
660 {N_("/_Tool/_Create filter rule/_Automatically"),
661 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
662 {N_("/_Tool/_Create filter rule/by _From"),
663 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
664 {N_("/_Tool/_Create filter rule/by _To"),
665 NULL, create_filter_cb, FILTER_BY_TO, NULL},
666 {N_("/_Tool/_Create filter rule/by _Subject"),
667 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
668 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
669 {N_("/_Tool/E_xecute"), "X", execute_summary_cb, 0, NULL},
670 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
671 {N_("/_Tool/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
673 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
674 {N_("/_Configuration/_Common preferences..."),
675 NULL, prefs_common_open_cb, 0, NULL},
676 {N_("/_Configuration/_Filter setting..."),
677 NULL, prefs_filter_open_cb, 0, NULL},
678 {N_("/_Configuration/_Scoring ..."),
679 NULL, prefs_scoring_open_cb, 0, NULL},
680 {N_("/_Configuration/_Filtering ..."),
681 NULL, prefs_filtering_open_cb, 0, NULL},
682 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
683 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
684 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
685 {N_("/_Configuration/_Preferences for current account..."),
686 NULL, prefs_account_open_cb, 0, NULL},
687 {N_("/_Configuration/Create _new account..."),
688 NULL, new_account_cb, 0, NULL},
689 {N_("/_Configuration/_Edit accounts..."),
690 NULL, account_edit_open, 0, NULL},
691 {N_("/_Configuration/C_hange current account"),
692 NULL, NULL, 0, "<Branch>"},
694 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
695 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
696 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
697 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
698 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
699 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
701 static GtkItemFactoryEntry reply_popup_entries[] =
703 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
704 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
706 static GtkItemFactoryEntry replyall_popup_entries[] =
708 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
709 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
711 static GtkItemFactoryEntry replysender_popup_entries[] =
713 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
714 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
716 static GtkItemFactoryEntry fwd_popup_entries[] =
718 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
719 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
723 MainWindow *main_window_create(SeparateType type)
729 GtkWidget *handlebox;
730 GtkWidget *vbox_body;
731 GtkWidget *hbox_stat;
732 GtkWidget *statusbar;
733 GtkWidget *progressbar;
734 GtkWidget *statuslabel;
735 GtkWidget *ac_button;
738 FolderView *folderview;
739 SummaryView *summaryview;
740 MessageView *messageview;
741 GdkColormap *colormap;
744 guint n_menu_entries;
745 GtkItemFactory *ifactory;
748 GtkWidget *compose_popup;
749 GtkWidget *reply_popup;
750 GtkWidget *replyall_popup;
751 GtkWidget *replysender_popup;
752 GtkWidget *fwd_popup;
755 debug_print(_("Creating main window...\n"));
756 mainwin = g_new0(MainWindow, 1);
759 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
760 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
761 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
762 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
763 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
764 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
765 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
766 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
767 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
768 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
769 GTK_SIGNAL_FUNC(key_pressed), mainwin);
771 gtk_widget_realize(window);
772 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
775 gtkut_widget_set_app_icon(window);
777 vbox = gtk_vbox_new(FALSE, 0);
778 gtk_widget_show(vbox);
779 gtk_container_add(GTK_CONTAINER(window), vbox);
782 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
783 menubar = menubar_create(window, mainwin_entries,
784 n_menu_entries, "<Main>", mainwin);
785 gtk_widget_show(menubar);
786 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
788 handlebox = gtk_handle_box_new();
789 gtk_widget_show(handlebox);
790 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
792 /* create the popup menus for the reply buttons specials */
793 n_menu_entries = sizeof(reply_popup_entries) /
794 sizeof(reply_popup_entries[0]);
795 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
796 "<ReplyPopup>", mainwin);
797 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
798 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
799 n_menu_entries = sizeof(replyall_popup_entries) /
800 sizeof(replyall_popup_entries[0]);
801 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
802 "<ReplyAllPopup>", mainwin);
803 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
804 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
805 n_menu_entries = sizeof(replysender_popup_entries) /
806 sizeof(replysender_popup_entries[0]);
807 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
808 "<ReplySenderPopup>", mainwin);
809 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
810 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
811 /* create the popup menu for the forward button */
812 n_menu_entries = sizeof(fwd_popup_entries) /
813 sizeof(fwd_popup_entries[0]);
814 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
815 "<ForwardPopup>", mainwin);
816 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
817 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
819 main_window_toolbar_create(mainwin, handlebox);
821 /* vbox that contains body */
822 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
823 gtk_widget_show(vbox_body);
824 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
825 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
827 hbox_stat = gtk_hbox_new(FALSE, 2);
828 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
830 statusbar = statusbar_create();
831 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
833 progressbar = gtk_progress_bar_new();
834 gtk_widget_set_usize(progressbar, 120, 1);
835 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
837 statuslabel = gtk_label_new("");
838 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
840 ac_button = gtk_button_new();
841 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
842 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
843 gtk_widget_set_usize(ac_button, -1, 1);
844 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
845 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
846 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
848 ac_label = gtk_label_new("");
849 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
851 gtk_widget_show_all(hbox_stat);
854 mainwin->folderview = folderview = folderview_create();
855 mainwin->summaryview = summaryview = summary_create();
856 mainwin->messageview = messageview = messageview_create();
857 mainwin->logwin = log_window_create();
859 folderview->mainwin = mainwin;
860 folderview->summaryview = summaryview;
862 summaryview->mainwin = mainwin;
863 summaryview->folderview = folderview;
864 summaryview->messageview = messageview;
865 summaryview->window = window;
867 messageview->mainwin = mainwin;
869 mainwin->window = window;
870 mainwin->vbox = vbox;
871 mainwin->menubar = menubar;
872 mainwin->handlebox = handlebox;
873 mainwin->vbox_body = vbox_body;
874 mainwin->hbox_stat = hbox_stat;
875 mainwin->statusbar = statusbar;
876 mainwin->progressbar = progressbar;
877 mainwin->statuslabel = statuslabel;
878 mainwin->ac_button = ac_button;
879 mainwin->ac_label = ac_label;
880 mainwin->reply_popup = reply_popup;
881 mainwin->replyall_popup = replyall_popup;
882 mainwin->replysender_popup = replysender_popup;
883 mainwin->fwd_popup = fwd_popup;
885 /* set context IDs for status bar */
886 mainwin->mainwin_cid = gtk_statusbar_get_context_id
887 (GTK_STATUSBAR(statusbar), "Main Window");
888 mainwin->folderview_cid = gtk_statusbar_get_context_id
889 (GTK_STATUSBAR(statusbar), "Folder View");
890 mainwin->summaryview_cid = gtk_statusbar_get_context_id
891 (GTK_STATUSBAR(statusbar), "Summary View");
893 /* allocate colors for summary view and folder view */
894 summaryview->color_marked.red = summaryview->color_marked.green = 0;
895 summaryview->color_marked.blue = (guint16)65535;
897 summaryview->color_dim.red = summaryview->color_dim.green =
898 summaryview->color_dim.blue = COLOR_DIM;
900 folderview->color_new.red = (guint16)55000;
901 folderview->color_new.green = folderview->color_new.blue = 15000;
903 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
904 &folderview->color_op);
906 summaryview->color_important.red = 0;
907 summaryview->color_marked.green = 0;
908 summaryview->color_important.blue = (guint16)65535;
910 color[0] = summaryview->color_marked;
911 color[1] = summaryview->color_dim;
912 color[2] = folderview->color_new;
913 color[3] = folderview->color_op;
915 colormap = gdk_window_get_colormap(window->window);
916 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
917 for (i = 0; i < 4; i++) {
918 if (success[i] == FALSE)
919 g_warning(_("MainWindow: color allocation %d failed\n"), i);
922 debug_print(_("done.\n"));
924 main_window_set_widgets(mainwin, type);
927 ifactory = gtk_item_factory_from_widget(menubar);
928 menuitem = gtk_item_factory_get_item
929 (ifactory, "/View/Code set/Auto detect");
930 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
932 switch (prefs_common.toolbar_style) {
934 menuitem = gtk_item_factory_get_item
935 (ifactory, "/View/Toolbar/None");
938 menuitem = gtk_item_factory_get_item
939 (ifactory, "/View/Toolbar/Icon");
942 menuitem = gtk_item_factory_get_item
943 (ifactory, "/View/Toolbar/Text");
946 menuitem = gtk_item_factory_get_item
947 (ifactory, "/View/Toolbar/Icon and text");
949 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
951 gtk_widget_hide(mainwin->hbox_stat);
952 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
953 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
954 prefs_common.show_statusbar);
955 #if 0 /* FIXED SEPARATE WINDOWS */
956 /* Message view and Folder tree are always shown at startup
957 * make that in the menu visible */
958 menuitem = gtk_item_factory_get_item(ifactory, "/View/Message view");
959 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
960 menuitem = gtk_item_factory_get_item(ifactory, "/View/Folder tree");
961 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
963 /* set the check of the SEPARATE_xxx menu items. we also need the main window
964 * as a property and pass the action type to the callback */
965 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
967 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
968 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
969 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
970 GUINT_TO_POINTER(SEPARATE_FOLDER));
972 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
974 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
975 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
976 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
977 GUINT_TO_POINTER(SEPARATE_MESSAGE));
979 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
980 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
983 /* set account selection menu */
984 ac_menu = gtk_item_factory_get_widget
985 (ifactory, "/Configuration/Change current account");
986 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
987 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
988 mainwin->ac_menu = ac_menu;
990 main_window_set_toolbar_sensitive(mainwin);
992 /* Create actions menu */
993 update_mainwin_actions_menu(ifactory, mainwin);
995 /* show main window */
996 gtk_widget_set_uposition(mainwin->window,
997 prefs_common.mainwin_x,
998 prefs_common.mainwin_y);
999 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1000 prefs_common.mainwin_height);
1001 gtk_widget_show(mainwin->window);
1003 /* initialize views */
1004 folderview_init(folderview);
1005 summary_init(summaryview);
1006 messageview_init(messageview);
1007 log_window_init(mainwin->logwin);
1009 mainwin->lock_count = 0;
1010 mainwin->menu_lock_count = 0;
1011 mainwin->cursor_count = 0;
1014 watch_cursor = gdk_cursor_new(GDK_WATCH);
1016 mainwin_list = g_list_append(mainwin_list, mainwin);
1021 void main_window_cursor_wait(MainWindow *mainwin)
1024 if (mainwin->cursor_count == 0)
1025 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1027 mainwin->cursor_count++;
1032 void main_window_cursor_normal(MainWindow *mainwin)
1034 if (mainwin->cursor_count)
1035 mainwin->cursor_count--;
1037 if (mainwin->cursor_count == 0)
1038 gdk_window_set_cursor(mainwin->window->window, NULL);
1043 /* lock / unlock the user-interface */
1044 void main_window_lock(MainWindow *mainwin)
1046 if (mainwin->lock_count == 0)
1047 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1049 mainwin->lock_count++;
1051 main_window_set_menu_sensitive(mainwin);
1052 main_window_set_toolbar_sensitive(mainwin);
1055 void main_window_unlock(MainWindow *mainwin)
1057 if (mainwin->lock_count)
1058 mainwin->lock_count--;
1060 main_window_set_menu_sensitive(mainwin);
1061 main_window_set_toolbar_sensitive(mainwin);
1063 if (mainwin->lock_count == 0)
1064 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1067 static void main_window_menu_callback_block(MainWindow *mainwin)
1069 mainwin->menu_lock_count++;
1072 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1074 if (mainwin->menu_lock_count)
1075 mainwin->menu_lock_count--;
1078 void main_window_reflect_prefs_all(void)
1080 main_window_reflect_prefs_all_real(FALSE);
1083 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1086 MainWindow *mainwin;
1088 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1089 mainwin = (MainWindow *)cur->data;
1091 main_window_show_cur_account(mainwin);
1092 main_window_set_menu_sensitive(mainwin);
1093 main_window_set_toolbar_sensitive(mainwin);
1096 if (pixmap_theme_changed)
1098 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1099 mainwin->toolbar = NULL;
1100 main_window_toolbar_create(mainwin, mainwin->handlebox);
1101 set_toolbar_style(mainwin);
1102 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1103 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1104 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1107 summary_redisplay_msg(mainwin->summaryview);
1108 headerview_set_visibility(mainwin->messageview->headerview,
1109 prefs_common.display_header_pane);
1113 void main_window_set_summary_column(void)
1116 MainWindow *mainwin;
1118 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1119 mainwin = (MainWindow *)cur->data;
1120 summary_set_column_order(mainwin->summaryview);
1124 void main_window_set_account_menu(GList *account_list)
1126 GList *cur, *cur_ac, *cur_item;
1127 GtkWidget *menuitem;
1128 MainWindow *mainwin;
1129 PrefsAccount *ac_prefs;
1131 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1132 mainwin = (MainWindow *)cur->data;
1134 /* destroy all previous menu item */
1135 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1136 while (cur_item != NULL) {
1137 GList *next = cur_item->next;
1138 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1142 for (cur_ac = account_list; cur_ac != NULL;
1143 cur_ac = cur_ac->next) {
1144 ac_prefs = (PrefsAccount *)cur_ac->data;
1146 menuitem = gtk_menu_item_new_with_label
1147 (ac_prefs->account_name
1148 ? ac_prefs->account_name : _("Untitled"));
1149 gtk_widget_show(menuitem);
1150 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1151 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1152 GTK_SIGNAL_FUNC(account_menu_cb),
1158 static void main_window_show_cur_account(MainWindow *mainwin)
1163 ac_name = g_strdup(cur_account
1164 ? (cur_account->account_name
1165 ? cur_account->account_name : _("Untitled"))
1169 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1171 buf = g_strdup(PROG_VERSION);
1172 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1175 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1176 gtk_widget_queue_resize(mainwin->ac_button);
1181 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1183 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1184 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1185 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1187 if (mainwin->type == type) return;
1189 /* remove widgets from those containers */
1190 gtk_widget_ref(folder_wid);
1191 gtk_widget_ref(summary_wid);
1192 gtk_widget_ref(message_wid);
1193 gtkut_container_remove
1194 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1195 gtkut_container_remove
1196 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1197 gtkut_container_remove
1198 (GTK_CONTAINER(message_wid->parent), message_wid);
1200 /* clean containers */
1201 switch (mainwin->type) {
1203 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1205 case SEPARATE_FOLDER:
1206 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1207 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1209 case SEPARATE_MESSAGE:
1210 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1211 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1214 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1215 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1219 gtk_widget_hide(mainwin->window);
1220 main_window_set_widgets(mainwin, type);
1221 gtk_widget_show(mainwin->window);
1223 gtk_widget_unref(folder_wid);
1224 gtk_widget_unref(summary_wid);
1225 gtk_widget_unref(message_wid);
1228 void main_window_get_size(MainWindow *mainwin)
1230 GtkAllocation *allocation;
1232 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1234 prefs_common.summaryview_width = allocation->width;
1236 if (mainwin->summaryview->msg_is_toggled_on)
1237 prefs_common.summaryview_height = allocation->height;
1239 prefs_common.mainview_width = allocation->width;
1241 allocation = &mainwin->window->allocation;
1243 prefs_common.mainview_height = allocation->height;
1244 prefs_common.mainwin_width = allocation->width;
1245 prefs_common.mainwin_height = allocation->height;
1247 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1249 prefs_common.folderview_width = allocation->width;
1250 prefs_common.folderview_height = allocation->height;
1253 void main_window_get_position(MainWindow *mainwin)
1257 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1259 prefs_common.mainview_x = x;
1260 prefs_common.mainview_y = y;
1261 prefs_common.mainwin_x = x;
1262 prefs_common.mainwin_y = y;
1264 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1267 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1273 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1274 folder = FOLDER(list->data);
1275 if (folder && folder->trash && folder->trash->total > 0)
1279 if (!has_trash) return;
1282 if (alertpanel(_("Empty trash"),
1283 _("Empty all messages in trash?"),
1284 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1286 manage_window_focus_in(mainwin->window, NULL, NULL);
1289 procmsg_empty_trash();
1291 for (list = folder_get_list(); list != NULL; list = list->next) {
1292 folder = list->data;
1293 if (folder && folder->trash && folder->trash->total != 0) {
1294 folder_item_scan(folder->trash);
1295 folderview_update_item(folder->trash, TRUE);
1299 if (mainwin->summaryview->folder_item &&
1300 mainwin->summaryview->folder_item->stype == F_TRASH)
1301 gtk_widget_grab_focus(mainwin->folderview->ctree);
1304 void main_window_add_mailbox(MainWindow *mainwin)
1309 path = input_dialog(_("Add mailbox"),
1310 _("Input the location of mailbox.\n"
1311 "If the existing mailbox is specified, it will be\n"
1312 "scanned automatically."),
1315 if (folder_find_from_path(path)) {
1316 alertpanel_error(_("The mailbox `%s' already exists."), path);
1320 if (!strcmp(path, "Mail"))
1321 folder = folder_new(F_MH, _("Mailbox"), path);
1323 folder = folder_new(F_MH, g_basename(path), path);
1326 if (folder->create_tree(folder) < 0) {
1327 alertpanel_error(_("Creation of the mailbox failed.\n"
1328 "Maybe some files already exist, or you don't have the permission to write there."));
1329 folder_destroy(folder);
1334 folder_set_ui_func(folder, scan_tree_func, mainwin);
1335 folder->scan_tree(folder);
1336 folder_set_ui_func(folder, NULL, NULL);
1338 folderview_set(mainwin->folderview);
1341 void main_window_add_mbox(MainWindow *mainwin)
1347 path = input_dialog(_("Add mbox mailbox"),
1348 _("Input the location of mailbox."),
1353 if (folder_find_from_path(path)) {
1354 alertpanel_error(_("The mailbox `%s' already exists."), path);
1360 if (!strcmp(path, "Mail"))
1361 folder = folder_new(F_MBOX, _("Mailbox"), path);
1365 folder = folder_new(F_MBOX, g_basename(path), path);
1368 if (folder->create_tree(folder) < 0) {
1369 alertpanel_error(_("Creation of the mailbox failed."));
1370 folder_destroy(folder);
1376 item = folder_item_new(folder->name, NULL);
1377 item->folder = folder;
1378 folder->node = g_node_new(item);
1380 folder->create_folder(folder, item, "inbox");
1381 folder->create_folder(folder, item, "outbox");
1382 folder->create_folder(folder, item, "queue");
1383 folder->create_folder(folder, item, "draft");
1384 folder->create_folder(folder, item, "trash");
1386 folderview_set(mainwin->folderview);
1391 M_UNLOCKED = 1 << 0,
1392 M_MSG_EXIST = 1 << 1,
1393 M_TARGET_EXIST = 1 << 2,
1394 M_SINGLE_TARGET_EXIST = 1 << 3,
1396 M_ALLOW_REEDIT = 1 << 5,
1397 M_HAVE_ACCOUNT = 1 << 6,
1398 M_THREADED = 1 << 7,
1399 M_UNTHREADED = 1 << 8,
1400 M_ALLOW_DELETE = 1 << 9,
1402 M_HAVE_NEWS_ACCOUNT = 1 << 11,
1403 M_HIDE_READ_MSG = 1 << 12
1406 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1408 SensitiveCond state = 0;
1409 SummarySelection selection;
1410 FolderItem *item = mainwin->summaryview->folder_item;
1411 GList *account_list = account_get_list();
1413 selection = summary_get_selection_type(mainwin->summaryview);
1415 if (mainwin->lock_count == 0)
1416 state |= M_UNLOCKED;
1417 if (selection != SUMMARY_NONE)
1418 state |= M_MSG_EXIST;
1422 state |= M_THREADED;
1424 state |= M_UNTHREADED;
1425 if (item->folder->type != F_NEWS)
1426 state |= M_ALLOW_DELETE;
1428 if (selection == SUMMARY_NONE && item->hide_read_msgs
1429 || selection != SUMMARY_NONE)
1430 state |= M_HIDE_READ_MSG;
1432 if (selection == SUMMARY_SELECTED_SINGLE ||
1433 selection == SUMMARY_SELECTED_MULTIPLE)
1434 state |= M_TARGET_EXIST;
1435 if (selection == SUMMARY_SELECTED_SINGLE)
1436 state |= M_SINGLE_TARGET_EXIST;
1437 if (mainwin->summaryview->folder_item &&
1438 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1440 if (selection == SUMMARY_SELECTED_SINGLE &&
1442 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1443 item->stype == F_QUEUE)))
1444 state |= M_ALLOW_REEDIT;
1446 state |= M_HAVE_ACCOUNT;
1448 for ( ; account_list != NULL; account_list = account_list->next) {
1449 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1450 state |= M_HAVE_NEWS_ACCOUNT;
1458 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1460 SensitiveCond state;
1469 entry[0].widget = mainwin->get_btn;
1470 entry[0].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1471 entry[1].widget = mainwin->getall_btn;
1472 entry[1].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1473 entry[2].widget = mainwin->compose_news_btn;
1474 entry[2].cond = M_HAVE_NEWS_ACCOUNT;
1475 entry[3].widget = mainwin->reply_btn;
1476 entry[3].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1477 entry[4].widget = mainwin->replyall_btn;
1478 entry[4].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1479 entry[5].widget = mainwin->replysender_btn;
1480 entry[5].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1481 entry[6].widget = mainwin->fwd_btn;
1482 entry[6].cond = M_HAVE_ACCOUNT|M_TARGET_EXIST;
1483 /* entry[6].widget = mainwin->prefs_btn;
1484 entry[6].cond = M_UNLOCKED;
1485 entry[7].widget = mainwin->account_btn;
1486 entry[7].cond = M_UNLOCKED; */
1487 entry[7].widget = mainwin->next_btn;
1488 entry[7].cond = M_MSG_EXIST;
1489 entry[8].widget = mainwin->delete_btn;
1490 entry[8].cond = M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED;
1491 entry[9].widget = mainwin->exec_btn;
1492 entry[9].cond = M_MSG_EXIST|M_EXEC|M_UNLOCKED;
1493 entry[10].widget = NULL;
1496 state = main_window_get_current_state(mainwin);
1498 for (i = 0; entry[i].widget != NULL; i++) {
1499 sensitive = ((entry[i].cond & state) == entry[i].cond);
1500 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1503 activate_compose_button(mainwin,
1504 prefs_common.toolbar_style,
1505 mainwin->compose_btn_type);
1508 void main_window_set_menu_sensitive(MainWindow *mainwin)
1510 GtkItemFactory *ifactory;
1511 SensitiveCond state;
1513 GtkWidget *menuitem;
1516 static const struct {
1520 {"/File/Add mailbox..." , M_UNLOCKED},
1521 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1522 {"/File/Rescan folder tree" , M_UNLOCKED},
1523 {"/File/Folder" , M_UNLOCKED},
1524 {"/File/Import mbox file..." , M_UNLOCKED},
1525 {"/File/Export to mbox file...", M_UNLOCKED},
1526 {"/File/Empty trash" , M_UNLOCKED},
1527 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1528 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1529 /* {"/File/Close", M_UNLOCKED}, */
1530 {"/File/Exit" , M_UNLOCKED},
1532 {"/Edit/Actions" , M_MSG_EXIST},
1533 {"/View/Sort" , M_MSG_EXIST},
1534 {"/View/Thread view" , M_EXEC},
1535 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1536 {"/View/Go to/Prev message" , M_MSG_EXIST},
1537 {"/View/Go to/Next message" , M_MSG_EXIST},
1538 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1539 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1540 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1541 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1542 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1543 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1544 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1545 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1546 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1548 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1549 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1550 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1551 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1552 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1553 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1554 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1555 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1556 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1557 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1558 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1559 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1560 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1561 {"/Message/Mark" , M_TARGET_EXIST},
1562 {"/Message/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1564 {"/Tool/Add sender to address book", M_SINGLE_TARGET_EXIST},
1565 {"/Tool/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1566 {"/Tool/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1567 {"/Tool/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1569 {"/Configuration", M_UNLOCKED},
1574 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1575 state = main_window_get_current_state(mainwin);
1577 for (i = 0; entry[i].entry != NULL; i++) {
1578 sensitive = ((entry[i].cond & state) == entry[i].cond);
1579 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1582 main_window_menu_callback_block(mainwin);
1583 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all header");
1584 gtk_check_menu_item_set_active
1585 (GTK_CHECK_MENU_ITEM(menuitem),
1586 mainwin->messageview->textview->show_all_headers);
1587 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1588 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1589 (state & M_THREADED) != 0);
1590 main_window_menu_callback_unblock(mainwin);
1593 void main_window_popup(MainWindow *mainwin)
1599 gdk_window_get_origin(mainwin->window->window, &x, &y);
1600 sx = gdk_screen_width();
1601 sy = gdk_screen_height();
1602 x %= sx; if (x < 0) x = 0;
1603 y %= sy; if (y < 0) y = 0;
1604 gdk_window_move(mainwin->window->window, x, y);
1605 gdk_window_raise(mainwin->window->window);
1606 gdk_window_show(mainwin->window->window);
1608 debug_print("window position: x = %d, y = %d\n", x, y);
1610 switch (mainwin->type) {
1611 case SEPARATE_FOLDER:
1612 widget = mainwin->win.sep_folder.folderwin;
1613 gdk_window_get_origin(widget->window, &x, &y);
1614 x %= sx; if (x < 0) x = 0;
1615 y %= sy; if (y < 0) y = 0;
1616 gdk_window_move(widget->window, x, y);
1617 gdk_window_raise(widget->window);
1619 case SEPARATE_MESSAGE:
1620 widget = mainwin->win.sep_message.messagewin;
1621 gdk_window_get_origin(widget->window, &x, &y);
1622 x %= sx; if (x < 0) x = 0;
1623 y %= sy; if (y < 0) y = 0;
1624 gdk_window_move(widget->window, x, y);
1625 gdk_window_raise(widget->window);
1628 widget = mainwin->win.sep_both.folderwin;
1629 gdk_window_get_origin(widget->window, &x, &y);
1630 x %= sx; if (x < 0) x = 0;
1631 y %= sy; if (y < 0) y = 0;
1632 gdk_window_move(widget->window, x, y);
1633 gdk_window_raise(widget->window);
1634 widget = mainwin->win.sep_both.messagewin;
1635 gdk_window_get_origin(widget->window, &x, &y);
1636 x %= sx; if (x < 0) x = 0;
1637 y %= sy; if (y < 0) y = 0;
1638 gdk_window_move(widget->window, x, y);
1639 gdk_window_raise(widget->window);
1646 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1648 GtkWidget *folderwin = NULL;
1649 GtkWidget *messagewin = NULL;
1652 GtkWidget *vbox_body = mainwin->vbox_body;
1653 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1654 GtkWidget *menuitem;
1656 debug_print(_("Setting widgets..."));
1658 /* create separated window(s) if needed */
1659 if (type & SEPARATE_FOLDER) {
1660 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1661 gtk_window_set_title(GTK_WINDOW(folderwin),
1662 _("Sylpheed - Folder View"));
1663 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1664 "folder_view", "Sylpheed");
1665 gtk_window_set_policy(GTK_WINDOW(folderwin),
1667 gtk_widget_set_usize(folderwin, -1,
1668 prefs_common.mainview_height);
1669 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1671 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1672 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1675 if (type & SEPARATE_MESSAGE) {
1676 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1677 gtk_window_set_title(GTK_WINDOW(messagewin),
1678 _("Sylpheed - Message View"));
1679 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1680 "message_view", "Sylpheed");
1681 gtk_window_set_policy(GTK_WINDOW(messagewin),
1683 gtk_widget_set_usize
1684 (messagewin, prefs_common.mainview_width,
1685 prefs_common.mainview_height
1686 - prefs_common.summaryview_height
1687 + DEFAULT_HEADERVIEW_HEIGHT);
1688 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1690 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1691 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1697 hpaned = gtk_hpaned_new();
1698 gtk_widget_show(hpaned);
1699 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1700 gtk_paned_add1(GTK_PANED(hpaned),
1701 GTK_WIDGET_PTR(mainwin->folderview));
1703 vpaned = gtk_vpaned_new();
1704 if (mainwin->summaryview->msg_is_toggled_on) {
1705 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1706 gtk_paned_add1(GTK_PANED(vpaned),
1707 GTK_WIDGET_PTR(mainwin->summaryview));
1709 gtk_paned_add2(GTK_PANED(hpaned),
1710 GTK_WIDGET_PTR(mainwin->summaryview));
1711 gtk_widget_ref(vpaned);
1713 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1714 prefs_common.summaryview_width,
1715 prefs_common.summaryview_height);
1716 gtk_paned_add2(GTK_PANED(vpaned),
1717 GTK_WIDGET_PTR(mainwin->messageview));
1718 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1719 prefs_common.mainview_width, -1);
1720 gtk_widget_set_usize(mainwin->window,
1721 prefs_common.folderview_width +
1722 prefs_common.mainview_width,
1723 prefs_common.mainwin_height);
1724 gtk_widget_show_all(vpaned);
1726 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1727 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1728 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1729 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1730 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1731 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1733 mainwin->win.sep_none.hpaned = hpaned;
1734 mainwin->win.sep_none.vpaned = vpaned;
1736 case SEPARATE_FOLDER:
1737 vpaned = gtk_vpaned_new();
1738 if (mainwin->summaryview->msg_is_toggled_on) {
1739 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1741 gtk_paned_add1(GTK_PANED(vpaned),
1742 GTK_WIDGET_PTR(mainwin->summaryview));
1744 gtk_box_pack_start(GTK_BOX(vbox_body),
1745 GTK_WIDGET_PTR(mainwin->summaryview),
1747 gtk_widget_ref(vpaned);
1749 gtk_paned_add2(GTK_PANED(vpaned),
1750 GTK_WIDGET_PTR(mainwin->messageview));
1751 gtk_widget_show_all(vpaned);
1752 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1753 prefs_common.summaryview_width,
1754 prefs_common.summaryview_height);
1755 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1756 prefs_common.mainview_width, -1);
1757 gtk_widget_set_usize(mainwin->window,
1758 prefs_common.mainview_width,
1759 prefs_common.mainview_height);
1761 gtk_container_add(GTK_CONTAINER(folderwin),
1762 GTK_WIDGET_PTR(mainwin->folderview));
1764 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1765 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1767 mainwin->win.sep_folder.folderwin = folderwin;
1768 mainwin->win.sep_folder.vpaned = vpaned;
1770 gtk_widget_show_all(folderwin);
1772 case SEPARATE_MESSAGE:
1773 hpaned = gtk_hpaned_new();
1774 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1776 gtk_paned_add1(GTK_PANED(hpaned),
1777 GTK_WIDGET_PTR(mainwin->folderview));
1778 gtk_paned_add2(GTK_PANED(hpaned),
1779 GTK_WIDGET_PTR(mainwin->summaryview));
1780 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1781 prefs_common.summaryview_width,
1782 prefs_common.summaryview_height);
1783 gtk_widget_set_usize(mainwin->window,
1784 prefs_common.folderview_width +
1785 prefs_common.mainview_width,
1786 prefs_common.mainwin_height);
1787 gtk_widget_show_all(hpaned);
1788 gtk_container_add(GTK_CONTAINER(messagewin),
1789 GTK_WIDGET_PTR(mainwin->messageview));
1791 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1792 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1793 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1794 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1796 mainwin->win.sep_message.messagewin = messagewin;
1797 mainwin->win.sep_message.hpaned = hpaned;
1799 gtk_widget_show_all(messagewin);
1802 gtk_box_pack_start(GTK_BOX(vbox_body),
1803 GTK_WIDGET_PTR(mainwin->summaryview),
1805 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1806 prefs_common.summaryview_width,
1807 prefs_common.summaryview_height);
1808 gtk_widget_set_usize(mainwin->window,
1809 prefs_common.mainview_width,
1810 prefs_common.mainwin_height);
1811 gtk_container_add(GTK_CONTAINER(folderwin),
1812 GTK_WIDGET_PTR(mainwin->folderview));
1813 gtk_container_add(GTK_CONTAINER(messagewin),
1814 GTK_WIDGET_PTR(mainwin->messageview));
1816 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1817 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1819 mainwin->win.sep_both.folderwin = folderwin;
1820 mainwin->win.sep_both.messagewin = messagewin;
1822 gtk_widget_show_all(folderwin);
1823 gtk_widget_show_all(messagewin);
1827 mainwin->type = type;
1829 debug_print(_("done.\n"));
1832 static void main_window_toolbar_create(MainWindow *mainwin,
1833 GtkWidget *container)
1836 GtkWidget *icon_wid;
1838 GtkWidget *getall_btn;
1839 GtkWidget *compose_mail_btn;
1840 GtkWidget *compose_news_btn;
1841 GtkWidget *reply_btn;
1842 GtkWidget *replyall_btn;
1843 GtkWidget *replysender_btn;
1845 GtkWidget *send_btn;
1847 GtkWidget *prefs_btn;
1848 GtkWidget *account_btn;
1850 GtkWidget *next_btn;
1851 GtkWidget *delete_btn;
1852 GtkWidget *exec_btn;
1854 GtkTooltips *tooltips;
1856 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1858 gtk_container_add(GTK_CONTAINER(container), toolbar);
1859 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1860 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1861 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1862 GTK_TOOLBAR_SPACE_LINE);
1864 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1865 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1867 _("Get new mail from current account"),
1869 icon_wid, toolbar_inc_cb, mainwin);
1870 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1871 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1873 _("Get new mail from all accounts"),
1879 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1881 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1882 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1884 _("Send queued message(s)"),
1890 /* insert compose mail button widget */
1891 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1892 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1894 _("Compose an email message"),
1897 toolbar_compose_mail_cb,
1900 /* insert compose news button widget */
1901 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1902 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1904 _("Compose a news message"),
1907 toolbar_compose_news_cb,
1910 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1914 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1915 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1917 _("Reply to the message - Right button: more options"),
1923 /* replyall button */
1925 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1926 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1928 _("Reply to all - Right button: more options"),
1931 toolbar_reply_to_all_cb,
1934 /* reply to sender button */
1935 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1936 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1938 _("Reply to sender - Right button: more options"),
1941 toolbar_reply_to_sender_cb,
1944 /* forward button */
1945 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1946 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1948 _("Forward the message - Right button: more options"),
1954 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1956 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1957 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1959 _("Delete the message"),
1965 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1966 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1968 _("Execute marked process"),
1974 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
1975 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1977 _("Next unread message"),
1980 toolbar_next_unread_cb,
1984 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1986 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
1987 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1989 _("Common preference"),
1994 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
1995 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1997 _("Account setting"),
2002 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2003 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2007 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2008 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2011 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2012 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2015 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2016 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2019 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2020 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2024 mainwin->toolbar = toolbar;
2025 mainwin->get_btn = get_btn;
2026 mainwin->getall_btn = getall_btn;
2027 mainwin->compose_mail_btn = compose_mail_btn;
2028 mainwin->compose_news_btn = compose_news_btn;
2029 mainwin->reply_btn = reply_btn;
2030 mainwin->replyall_btn = replyall_btn;
2031 mainwin->replysender_btn = replysender_btn;
2032 mainwin->fwd_btn = fwd_btn;
2033 mainwin->send_btn = send_btn;
2035 mainwin->prefs_btn = prefs_btn;
2036 mainwin->account_btn = account_btn;
2038 mainwin->next_btn = next_btn;
2039 mainwin->delete_btn = delete_btn;
2040 mainwin->exec_btn = exec_btn;
2042 gtk_widget_show_all(toolbar);
2045 /* callback functions */
2046 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2048 MainWindow *mainwindow = (MainWindow *) data;
2052 if (event->button == 3) {
2053 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2054 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2055 menu_button_position, widget,
2056 event->button, event->time);
2060 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2062 MainWindow *mainwin = (MainWindow *)data;
2064 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2065 manage_window_focus_in(mainwin->window, NULL, NULL);
2068 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2070 MainWindow *mainwindow = (MainWindow *) data;
2074 if (event->button == 3) {
2075 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2076 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2077 menu_button_position, widget,
2078 event->button, event->time);
2082 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2084 MainWindow *mainwin = (MainWindow *)data;
2086 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2087 manage_window_focus_in(mainwin->window, NULL, NULL);
2090 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2092 MainWindow *mainwindow = (MainWindow *) data;
2093 GtkWidget *replysender_menu, *replysender_item;
2097 if (event->button == 3) {
2098 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2099 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2100 menu_button_position, widget,
2101 event->button, event->time);
2105 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2107 MainWindow *mainwin = (MainWindow *)data;
2109 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2110 manage_window_focus_in(mainwin->window, NULL, NULL);
2113 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2115 MainWindow *mainwindow = (MainWindow *) data;
2119 if (event->button == 3) {
2120 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2121 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2122 menu_button_position, widget,
2123 event->button, event->time);
2127 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2129 MainWindow *mainwin = (MainWindow *)data;
2131 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2132 manage_window_focus_in(mainwin->window, NULL, NULL);
2135 static void toolbar_inc_cb (GtkWidget *widget,
2138 MainWindow *mainwin = (MainWindow *)data;
2140 inc_mail_cb(mainwin, 0, NULL);
2143 static void toolbar_inc_all_cb (GtkWidget *widget,
2146 MainWindow *mainwin = (MainWindow *)data;
2148 inc_all_account_mail_cb(mainwin, 0, NULL);
2151 static void toolbar_send_cb (GtkWidget *widget,
2154 MainWindow *mainwin = (MainWindow *)data;
2156 send_queue_cb(mainwin, 0, NULL);
2159 static void toolbar_compose_cb (GtkWidget *widget,
2162 MainWindow *mainwin = (MainWindow *)data;
2164 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2165 compose_cb(mainwin, 0, NULL);
2167 compose_news_cb(mainwin, 0, NULL);
2170 static void toolbar_compose_news_cb (GtkWidget *widget,
2173 MainWindow *mainwin = (MainWindow *)data;
2175 compose_news_cb(mainwin, 0, NULL);
2178 static void toolbar_compose_mail_cb (GtkWidget *widget,
2181 MainWindow *mainwin = (MainWindow *)data;
2183 compose_mail_cb(mainwin, 0, NULL);
2186 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2188 MainWindow *mainwin = (MainWindow *)data;
2191 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2192 : COMPOSE_REPLY_WITHOUT_QUOTE,
2196 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2198 MainWindow *mainwin = (MainWindow *)data;
2201 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2202 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2207 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2209 MainWindow *mainwin = (MainWindow *)data;
2212 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2213 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2217 static void toolbar_forward_cb (GtkWidget *widget,
2220 MainWindow *mainwin = (MainWindow *)data;
2222 if (prefs_common.forward_as_attachment)
2223 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2225 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2228 static void toolbar_delete_cb (GtkWidget *widget,
2231 MainWindow *mainwin = (MainWindow *)data;
2233 summary_delete(mainwin->summaryview);
2236 static void toolbar_exec_cb (GtkWidget *widget,
2239 MainWindow *mainwin = (MainWindow *)data;
2241 summary_execute(mainwin->summaryview);
2244 static void toolbar_next_unread_cb (GtkWidget *widget,
2247 MainWindow *mainwin = (MainWindow *)data;
2249 next_unread_cb(mainwin, 0, NULL);
2252 static void toolbar_prefs_cb (GtkWidget *widget,
2255 prefs_common_open();
2258 static void toolbar_account_cb (GtkWidget *widget,
2261 MainWindow *mainwin = (MainWindow *)data;
2263 prefs_account_open_cb(mainwin, 0, NULL);
2266 static void toolbar_account_button_pressed(GtkWidget *widget,
2267 GdkEventButton *event,
2270 MainWindow *mainwin = (MainWindow *)data;
2273 if (event->button != 3) return;
2275 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2276 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2279 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2280 menu_button_position, widget,
2281 event->button, event->time);
2284 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2287 MainWindow *mainwin = (MainWindow *)data;
2291 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2292 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2295 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2296 menu_button_position, widget,
2297 event->button, event->time);
2300 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2302 MainWindow *mainwin = (MainWindow *)data;
2305 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2306 if (!button) return;
2307 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2308 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2309 manage_window_focus_in(mainwin->window, NULL, NULL);
2312 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2315 MainWindow *mainwin = (MainWindow *)data;
2317 if (mainwin->lock_count == 0)
2318 app_exit_cb(data, 0, widget);
2323 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2326 main_window_add_mailbox(mainwin);
2329 static void add_mbox_cb(MainWindow *mainwin, guint action,
2332 main_window_add_mbox(mainwin);
2335 static void update_folderview_cb(MainWindow *mainwin, guint action,
2338 summary_show(mainwin->summaryview, NULL, FALSE);
2339 folderview_update_all();
2342 static void new_folder_cb(MainWindow *mainwin, guint action,
2345 folderview_new_folder(mainwin->folderview);
2348 static void rename_folder_cb(MainWindow *mainwin, guint action,
2351 folderview_rename_folder(mainwin->folderview);
2354 static void delete_folder_cb(MainWindow *mainwin, guint action,
2357 folderview_delete_folder(mainwin->folderview);
2360 static void import_mbox_cb(MainWindow *mainwin, guint action,
2363 import_mbox(mainwin->summaryview->folder_item);
2366 static void export_mbox_cb(MainWindow *mainwin, guint action,
2369 export_mbox(mainwin->summaryview->folder_item);
2372 static void empty_trash_cb(MainWindow *mainwin, guint action,
2375 main_window_empty_trash(mainwin, TRUE);
2378 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2380 summary_save_as(mainwin->summaryview);
2383 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2385 summary_print(mainwin->summaryview);
2388 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2390 if (prefs_common.confirm_on_exit) {
2391 if (alertpanel(_("Exit"), _("Exit this program?"),
2392 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2394 manage_window_focus_in(mainwin->window, NULL, NULL);
2397 app_will_exit(widget, mainwin);
2400 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2403 summary_search(mainwin->summaryview);
2405 message_search(mainwin->messageview);
2408 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2411 switch (mainwin->type) {
2413 case SEPARATE_MESSAGE:
2415 case SEPARATE_FOLDER:
2416 if (GTK_CHECK_MENU_ITEM(widget)->active)
2417 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2419 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2422 if (GTK_CHECK_MENU_ITEM(widget)->active)
2423 gtk_widget_show(mainwin->win.sep_both.folderwin);
2425 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2430 static void toggle_message_cb(MainWindow *mainwin, guint action,
2433 switch (mainwin->type) {
2435 case SEPARATE_FOLDER:
2437 case SEPARATE_MESSAGE:
2438 if (GTK_CHECK_MENU_ITEM(widget)->active)
2439 gtk_widget_show(mainwin->win.sep_message.messagewin);
2441 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2444 if (GTK_CHECK_MENU_ITEM(widget)->active)
2445 gtk_widget_show(mainwin->win.sep_both.messagewin);
2447 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2452 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2455 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2456 mainwin->compose_btn_type);
2457 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2458 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2459 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2460 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2462 mainwin->toolbar_style = (ToolbarStyle)action;
2463 prefs_common.toolbar_style = (ToolbarStyle)action;
2465 set_toolbar_style(mainwin);
2468 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2471 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2472 gtk_widget_show(mainwin->hbox_stat);
2473 prefs_common.show_statusbar = TRUE;
2475 gtk_widget_hide(mainwin->hbox_stat);
2476 prefs_common.show_statusbar = FALSE;
2480 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2482 summary_toggle_view_real(mainwin->summaryview);
2485 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2487 messageview_toggle_view_real(mainwin->messageview);
2490 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2493 MainWindow *mainwin;
2496 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2497 g_return_if_fail(mainwin != NULL);
2499 type = mainwin->type ^ action;
2500 main_window_separation_change(mainwin, type);
2502 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2503 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2506 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2509 addressbook_open(NULL);
2512 static void log_window_show_cb(MainWindow *mainwin, guint action,
2515 log_window_show(mainwin->logwin);
2518 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2523 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2526 inc_all_account_mail(mainwin);
2529 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2533 if (procmsg_send_queue() < 0)
2534 alertpanel_error(_("Some errors occurred while sending queued messages."));
2536 statusbar_pop_all();
2538 for (list = folder_get_list(); list != NULL; list = list->next) {
2541 folder = list->data;
2542 if (folder->queue) {
2543 folder_item_scan(folder->queue);
2544 folderview_update_item(folder->queue, TRUE);
2549 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2551 if (mainwin->summaryview->folder_item) {
2552 if (mainwin->summaryview->folder_item->folder->account != NULL
2553 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2554 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2556 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2562 static void compose_mail_cb(MainWindow *mainwin, guint action,
2569 if (mainwin->summaryview->folder_item) {
2570 ac = mainwin->summaryview->folder_item->folder->account;
2571 if (ac && ac->protocol != A_NNTP) {
2572 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2577 if(cur_account && (cur_account->protocol != A_NNTP)) {
2578 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2582 list = account_get_list();
2583 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2584 ac = (PrefsAccount *) cur->data;
2585 if (ac->protocol != A_NNTP) {
2586 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2592 static void compose_news_cb(MainWindow *mainwin, guint action,
2595 PrefsAccount * ac = NULL;
2599 if (mainwin->summaryview->folder_item) {
2600 ac = mainwin->summaryview->folder_item->folder->account;
2601 if (ac && ac->protocol == A_NNTP) {
2602 compose_new_with_recipient
2603 (ac, mainwin->summaryview->folder_item->path);
2608 list = account_get_list();
2609 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2610 ac = (PrefsAccount *) cur->data;
2611 if (ac->protocol == A_NNTP) {
2618 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2620 summary_reply(mainwin->summaryview, (ComposeMode)action);
2623 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2625 summary_move_to(mainwin->summaryview);
2628 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2630 summary_copy_to(mainwin->summaryview);
2633 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2635 summary_delete(mainwin->summaryview);
2638 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2640 summary_open_msg(mainwin->summaryview);
2643 static void view_source_cb(MainWindow *mainwin, guint action,
2646 summary_view_source(mainwin->summaryview);
2649 static void show_all_header_cb(MainWindow *mainwin, guint action,
2652 if (mainwin->menu_lock_count) return;
2653 summary_display_msg_selected(mainwin->summaryview,
2654 GTK_CHECK_MENU_ITEM(widget)->active);
2657 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2659 summary_reedit(mainwin->summaryview);
2662 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2664 summary_mark(mainwin->summaryview);
2667 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2669 summary_unmark(mainwin->summaryview);
2672 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2675 summary_mark_as_unread(mainwin->summaryview);
2678 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2681 summary_mark_as_read(mainwin->summaryview);
2684 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2687 summary_mark_all_read(mainwin->summaryview);
2690 static void add_address_cb(MainWindow *mainwin, guint action,
2693 summary_add_address(mainwin->summaryview);
2696 static void set_charset_cb(MainWindow *mainwin, guint action,
2701 str = conv_get_charset_str((CharSet)action);
2702 g_free(prefs_common.force_charset);
2703 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2705 summary_redisplay_msg(mainwin->summaryview);
2707 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2710 static void hide_read_messages (MainWindow *mainwin, guint action,
2713 if (!mainwin->summaryview->folder_item
2714 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2716 summary_toggle_show_read_messages(mainwin->summaryview);
2719 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2721 GtkItemFactory *ifactory;
2723 if (mainwin->menu_lock_count) return;
2724 if (!mainwin->summaryview->folder_item) return;
2726 ifactory = gtk_item_factory_from_widget(widget);
2728 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2729 summary_thread_build(mainwin->summaryview);
2730 mainwin->summaryview->folder_item->threaded = TRUE;
2732 summary_unthread(mainwin->summaryview);
2733 mainwin->summaryview->folder_item->threaded = FALSE;
2737 static void set_display_item_cb(MainWindow *mainwin, guint action,
2740 prefs_summary_column_open();
2743 static void sort_summary_cb(MainWindow *mainwin, guint action,
2746 summary_sort(mainwin->summaryview, (SummarySortType)action);
2749 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2752 summary_attract_by_subject(mainwin->summaryview);
2755 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2758 summary_delete_duplicated(mainwin->summaryview);
2761 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2763 summary_filter(mainwin->summaryview);
2766 static void execute_summary_cb(MainWindow *mainwin, guint action,
2769 summary_execute(mainwin->summaryview);
2772 static void update_summary_cb(MainWindow *mainwin, guint action,
2776 FolderView *folderview = mainwin->folderview;
2778 if (!mainwin->summaryview->folder_item) return;
2779 if (!folderview->opened) return;
2781 folder_update_op_count();
2783 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2784 folderview->opened);
2787 summary_show(mainwin->summaryview, fitem, TRUE);
2790 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2792 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2795 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2797 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2800 static void prev_unread_cb(MainWindow *mainwin, guint action,
2803 summary_select_prev_unread(mainwin->summaryview);
2806 static void next_unread_cb(MainWindow *mainwin, guint action,
2809 summary_select_next_unread(mainwin->summaryview);
2812 static void prev_marked_cb(MainWindow *mainwin, guint action,
2815 summary_select_prev_marked(mainwin->summaryview);
2818 static void next_marked_cb(MainWindow *mainwin, guint action,
2821 summary_select_next_marked(mainwin->summaryview);
2824 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2827 summary_select_prev_labeled(mainwin->summaryview);
2830 static void next_labeled_cb(MainWindow *mainwin, guint action,
2833 summary_select_next_labeled(mainwin->summaryview);
2836 static void goto_folder_cb(MainWindow *mainwin, guint action,
2839 FolderItem *to_folder;
2841 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2844 folderview_select(mainwin->folderview, to_folder);
2847 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2849 messageview_copy_clipboard(mainwin->messageview);
2852 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2854 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2855 summary_select_all(mainwin->summaryview);
2856 else if (mainwin->summaryview->msg_is_toggled_on &&
2857 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2858 messageview_select_all(mainwin->messageview);
2861 static void create_filter_cb(MainWindow *mainwin, guint action,
2864 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2867 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2870 prefs_common_open();
2873 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2876 prefs_filter_open(NULL, NULL);
2879 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2882 prefs_scoring_open(NULL);
2885 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2888 prefs_filtering_open(NULL);
2891 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2894 prefs_template_open();
2897 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2900 prefs_actions_open(mainwin);
2903 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2907 new_account_cb(mainwin, 0, widget);
2909 gboolean prev_default = cur_account->is_default;
2911 prefs_account_open(cur_account);
2912 if (!prev_default && cur_account->is_default)
2913 account_set_as_default(cur_account);
2914 account_save_config_all();
2916 main_window_reflect_prefs_all();
2920 static void new_account_cb(MainWindow *mainwin, guint action,
2923 account_edit_open();
2924 if (!compose_get_compose_list()) account_add();
2927 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2929 cur_account = (PrefsAccount *)data;
2930 main_window_reflect_prefs_all();
2933 static void manual_open_cb(MainWindow *mainwin, guint action,
2936 manual_open((ManualLang)action);
2939 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2941 MainWindow *mainwin = (MainWindow *)data;
2945 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2946 LOCAL_FOLDER(folder)->rootpath,
2950 str = g_strdup_printf(_("Scanning folder %s ..."),
2951 LOCAL_FOLDER(folder)->rootpath);
2953 STATUSBAR_PUSH(mainwin, str);
2954 STATUSBAR_POP(mainwin);
2958 static void activate_compose_button (MainWindow *mainwin,
2960 ComposeButtonType type)
2962 SensitiveCond state = main_window_get_current_state(mainwin);
2964 if (style == TOOLBAR_NONE)
2967 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2968 : mainwin->compose_news_btn);
2969 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2970 : mainwin->compose_mail_btn);
2971 mainwin->compose_btn_type = type;
2974 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2976 if (mainwin->compose_btn_type != compose_btn_type)
2977 activate_compose_button(mainwin,
2978 prefs_common.toolbar_style,
2982 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
2984 MainWindow *mainwin = (MainWindow*) data;
2986 if (!mainwin) return;
2988 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
2991 #define BREAK_ON_MODIFIER_KEY() \
2992 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2994 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
2996 MainWindow *mainwin = (MainWindow*) data;
2998 if (!mainwin || !event) return;
3000 switch (event->keyval) {
3001 case GDK_Q: /* Quit */
3002 BREAK_ON_MODIFIER_KEY();
3004 app_exit_cb(mainwin, 0, NULL);
3011 #undef BREAK_ON_MODIFIER_KEY
3013 static void set_toolbar_style(MainWindow *mainwin)
3015 switch (prefs_common.toolbar_style) {
3017 gtk_widget_hide(mainwin->handlebox);
3020 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3024 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3028 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3033 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3034 gtk_widget_show(mainwin->handlebox);
3035 gtk_widget_queue_resize(mainwin->handlebox);
3037 if (prefs_common.immediate_exec)
3038 gtk_widget_hide(mainwin->exec_btn);
3040 gtk_widget_show(mainwin->exec_btn);