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)
1081 MainWindow *mainwin;
1083 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1084 mainwin = (MainWindow *)cur->data;
1086 main_window_show_cur_account(mainwin);
1087 main_window_set_menu_sensitive(mainwin);
1088 main_window_set_toolbar_sensitive(mainwin);
1091 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1092 mainwin->toolbar = NULL;
1093 main_window_toolbar_create(mainwin, mainwin->handlebox);
1094 set_toolbar_style(mainwin);
1095 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1096 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1097 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1099 summary_redisplay_msg(mainwin->summaryview);
1100 headerview_set_visibility(mainwin->messageview->headerview,
1101 prefs_common.display_header_pane);
1105 void main_window_set_summary_column(void)
1108 MainWindow *mainwin;
1110 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1111 mainwin = (MainWindow *)cur->data;
1112 summary_set_column_order(mainwin->summaryview);
1116 void main_window_set_account_menu(GList *account_list)
1118 GList *cur, *cur_ac, *cur_item;
1119 GtkWidget *menuitem;
1120 MainWindow *mainwin;
1121 PrefsAccount *ac_prefs;
1123 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1124 mainwin = (MainWindow *)cur->data;
1126 /* destroy all previous menu item */
1127 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1128 while (cur_item != NULL) {
1129 GList *next = cur_item->next;
1130 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1134 for (cur_ac = account_list; cur_ac != NULL;
1135 cur_ac = cur_ac->next) {
1136 ac_prefs = (PrefsAccount *)cur_ac->data;
1138 menuitem = gtk_menu_item_new_with_label
1139 (ac_prefs->account_name
1140 ? ac_prefs->account_name : _("Untitled"));
1141 gtk_widget_show(menuitem);
1142 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1143 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1144 GTK_SIGNAL_FUNC(account_menu_cb),
1150 static void main_window_show_cur_account(MainWindow *mainwin)
1155 ac_name = g_strdup(cur_account
1156 ? (cur_account->account_name
1157 ? cur_account->account_name : _("Untitled"))
1161 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1163 buf = g_strdup(PROG_VERSION);
1164 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1167 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1168 gtk_widget_queue_resize(mainwin->ac_button);
1173 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1175 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1176 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1177 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1179 if (mainwin->type == type) return;
1181 /* remove widgets from those containers */
1182 gtk_widget_ref(folder_wid);
1183 gtk_widget_ref(summary_wid);
1184 gtk_widget_ref(message_wid);
1185 gtkut_container_remove
1186 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1187 gtkut_container_remove
1188 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1189 gtkut_container_remove
1190 (GTK_CONTAINER(message_wid->parent), message_wid);
1192 /* clean containers */
1193 switch (mainwin->type) {
1195 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1197 case SEPARATE_FOLDER:
1198 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1199 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1201 case SEPARATE_MESSAGE:
1202 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1203 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1206 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1207 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1211 gtk_widget_hide(mainwin->window);
1212 main_window_set_widgets(mainwin, type);
1213 gtk_widget_show(mainwin->window);
1215 gtk_widget_unref(folder_wid);
1216 gtk_widget_unref(summary_wid);
1217 gtk_widget_unref(message_wid);
1220 void main_window_get_size(MainWindow *mainwin)
1222 GtkAllocation *allocation;
1224 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1226 prefs_common.summaryview_width = allocation->width;
1228 if (mainwin->summaryview->msg_is_toggled_on)
1229 prefs_common.summaryview_height = allocation->height;
1231 prefs_common.mainview_width = allocation->width;
1233 allocation = &mainwin->window->allocation;
1235 prefs_common.mainview_height = allocation->height;
1236 prefs_common.mainwin_width = allocation->width;
1237 prefs_common.mainwin_height = allocation->height;
1239 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1241 prefs_common.folderview_width = allocation->width;
1242 prefs_common.folderview_height = allocation->height;
1245 void main_window_get_position(MainWindow *mainwin)
1249 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1251 prefs_common.mainview_x = x;
1252 prefs_common.mainview_y = y;
1253 prefs_common.mainwin_x = x;
1254 prefs_common.mainwin_y = y;
1256 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1259 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1265 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1266 folder = FOLDER(list->data);
1267 if (folder && folder->trash && folder->trash->total > 0)
1271 if (!has_trash) return;
1274 if (alertpanel(_("Empty trash"),
1275 _("Empty all messages in trash?"),
1276 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1278 manage_window_focus_in(mainwin->window, NULL, NULL);
1281 procmsg_empty_trash();
1283 for (list = folder_get_list(); list != NULL; list = list->next) {
1284 folder = list->data;
1285 if (folder && folder->trash && folder->trash->total != 0) {
1286 folder_item_scan(folder->trash);
1287 folderview_update_item(folder->trash, TRUE);
1291 if (mainwin->summaryview->folder_item &&
1292 mainwin->summaryview->folder_item->stype == F_TRASH)
1293 gtk_widget_grab_focus(mainwin->folderview->ctree);
1296 void main_window_add_mailbox(MainWindow *mainwin)
1301 path = input_dialog(_("Add mailbox"),
1302 _("Input the location of mailbox.\n"
1303 "If the existing mailbox is specified, it will be\n"
1304 "scanned automatically."),
1307 if (folder_find_from_path(path)) {
1308 alertpanel_error(_("The mailbox `%s' already exists."), path);
1312 if (!strcmp(path, "Mail"))
1313 folder = folder_new(F_MH, _("Mailbox"), path);
1315 folder = folder_new(F_MH, g_basename(path), path);
1318 if (folder->create_tree(folder) < 0) {
1319 alertpanel_error(_("Creation of the mailbox failed.\n"
1320 "Maybe some files already exist, or you don't have the permission to write there."));
1321 folder_destroy(folder);
1326 folder_set_ui_func(folder, scan_tree_func, mainwin);
1327 folder->scan_tree(folder);
1328 folder_set_ui_func(folder, NULL, NULL);
1330 folderview_set(mainwin->folderview);
1333 void main_window_add_mbox(MainWindow *mainwin)
1339 path = input_dialog(_("Add mbox mailbox"),
1340 _("Input the location of mailbox."),
1345 if (folder_find_from_path(path)) {
1346 alertpanel_error(_("The mailbox `%s' already exists."), path);
1352 if (!strcmp(path, "Mail"))
1353 folder = folder_new(F_MBOX, _("Mailbox"), path);
1357 folder = folder_new(F_MBOX, g_basename(path), path);
1360 if (folder->create_tree(folder) < 0) {
1361 alertpanel_error(_("Creation of the mailbox failed."));
1362 folder_destroy(folder);
1368 item = folder_item_new(folder->name, NULL);
1369 item->folder = folder;
1370 folder->node = g_node_new(item);
1372 folder->create_folder(folder, item, "inbox");
1373 folder->create_folder(folder, item, "outbox");
1374 folder->create_folder(folder, item, "queue");
1375 folder->create_folder(folder, item, "draft");
1376 folder->create_folder(folder, item, "trash");
1378 folderview_set(mainwin->folderview);
1383 M_UNLOCKED = 1 << 0,
1384 M_MSG_EXIST = 1 << 1,
1385 M_TARGET_EXIST = 1 << 2,
1386 M_SINGLE_TARGET_EXIST = 1 << 3,
1388 M_ALLOW_REEDIT = 1 << 5,
1389 M_HAVE_ACCOUNT = 1 << 6,
1390 M_THREADED = 1 << 7,
1391 M_UNTHREADED = 1 << 8,
1392 M_ALLOW_DELETE = 1 << 9,
1394 M_HAVE_NEWS_ACCOUNT = 1 << 11,
1395 M_HIDE_READ_MSG = 1 << 12
1398 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1400 SensitiveCond state = 0;
1401 SummarySelection selection;
1402 FolderItem *item = mainwin->summaryview->folder_item;
1403 GList *account_list = account_get_list();
1405 selection = summary_get_selection_type(mainwin->summaryview);
1407 if (mainwin->lock_count == 0)
1408 state |= M_UNLOCKED;
1409 if (selection != SUMMARY_NONE)
1410 state |= M_MSG_EXIST;
1414 state |= M_THREADED;
1416 state |= M_UNTHREADED;
1417 if (item->folder->type != F_NEWS)
1418 state |= M_ALLOW_DELETE;
1420 if (selection == SUMMARY_NONE && item->hide_read_msgs
1421 || selection != SUMMARY_NONE)
1422 state |= M_HIDE_READ_MSG;
1424 if (selection == SUMMARY_SELECTED_SINGLE ||
1425 selection == SUMMARY_SELECTED_MULTIPLE)
1426 state |= M_TARGET_EXIST;
1427 if (selection == SUMMARY_SELECTED_SINGLE)
1428 state |= M_SINGLE_TARGET_EXIST;
1429 if (mainwin->summaryview->folder_item &&
1430 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1432 if (selection == SUMMARY_SELECTED_SINGLE &&
1434 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1435 item->stype == F_QUEUE)))
1436 state |= M_ALLOW_REEDIT;
1438 state |= M_HAVE_ACCOUNT;
1440 for ( ; account_list != NULL; account_list = account_list->next) {
1441 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1442 state |= M_HAVE_NEWS_ACCOUNT;
1450 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1452 SensitiveCond state;
1461 entry[0].widget = mainwin->get_btn;
1462 entry[0].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1463 entry[1].widget = mainwin->getall_btn;
1464 entry[1].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1465 entry[2].widget = mainwin->compose_news_btn;
1466 entry[2].cond = M_HAVE_NEWS_ACCOUNT;
1467 entry[3].widget = mainwin->reply_btn;
1468 entry[3].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1469 entry[4].widget = mainwin->replyall_btn;
1470 entry[4].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1471 entry[5].widget = mainwin->replysender_btn;
1472 entry[5].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1473 entry[6].widget = mainwin->fwd_btn;
1474 entry[6].cond = M_HAVE_ACCOUNT|M_TARGET_EXIST;
1475 /* entry[6].widget = mainwin->prefs_btn;
1476 entry[6].cond = M_UNLOCKED;
1477 entry[7].widget = mainwin->account_btn;
1478 entry[7].cond = M_UNLOCKED; */
1479 entry[7].widget = mainwin->next_btn;
1480 entry[7].cond = M_MSG_EXIST;
1481 entry[8].widget = mainwin->delete_btn;
1482 entry[8].cond = M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED;
1483 entry[9].widget = mainwin->exec_btn;
1484 entry[9].cond = M_MSG_EXIST|M_EXEC|M_UNLOCKED;
1485 entry[10].widget = NULL;
1488 state = main_window_get_current_state(mainwin);
1490 for (i = 0; entry[i].widget != NULL; i++) {
1491 sensitive = ((entry[i].cond & state) == entry[i].cond);
1492 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1495 activate_compose_button(mainwin,
1496 prefs_common.toolbar_style,
1497 mainwin->compose_btn_type);
1500 void main_window_set_menu_sensitive(MainWindow *mainwin)
1502 GtkItemFactory *ifactory;
1503 SensitiveCond state;
1505 GtkWidget *menuitem;
1508 static const struct {
1512 {"/File/Add mailbox..." , M_UNLOCKED},
1513 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1514 {"/File/Rescan folder tree" , M_UNLOCKED},
1515 {"/File/Folder" , M_UNLOCKED},
1516 {"/File/Import mbox file..." , M_UNLOCKED},
1517 {"/File/Export to mbox file...", M_UNLOCKED},
1518 {"/File/Empty trash" , M_UNLOCKED},
1519 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1520 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1521 /* {"/File/Close", M_UNLOCKED}, */
1522 {"/File/Exit" , M_UNLOCKED},
1524 {"/Edit/Actions" , M_MSG_EXIST},
1525 {"/View/Sort" , M_MSG_EXIST},
1526 {"/View/Thread view" , M_EXEC},
1527 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1528 {"/View/Go to/Prev message" , M_MSG_EXIST},
1529 {"/View/Go to/Next message" , M_MSG_EXIST},
1530 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1531 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1532 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1533 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1534 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1535 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1536 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1537 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1538 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1540 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1541 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1542 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1543 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1544 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1545 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1546 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1547 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1548 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1549 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1550 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1551 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1552 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1553 {"/Message/Mark" , M_TARGET_EXIST},
1554 {"/Message/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1556 {"/Tool/Add sender to address book", M_SINGLE_TARGET_EXIST},
1557 {"/Tool/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1558 {"/Tool/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1559 {"/Tool/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1561 {"/Configuration", M_UNLOCKED},
1566 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1567 state = main_window_get_current_state(mainwin);
1569 for (i = 0; entry[i].entry != NULL; i++) {
1570 sensitive = ((entry[i].cond & state) == entry[i].cond);
1571 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1574 main_window_menu_callback_block(mainwin);
1575 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all header");
1576 gtk_check_menu_item_set_active
1577 (GTK_CHECK_MENU_ITEM(menuitem),
1578 mainwin->messageview->textview->show_all_headers);
1579 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1580 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1581 (state & M_THREADED) != 0);
1582 main_window_menu_callback_unblock(mainwin);
1585 void main_window_popup(MainWindow *mainwin)
1591 gdk_window_get_origin(mainwin->window->window, &x, &y);
1592 sx = gdk_screen_width();
1593 sy = gdk_screen_height();
1594 x %= sx; if (x < 0) x = 0;
1595 y %= sy; if (y < 0) y = 0;
1596 gdk_window_move(mainwin->window->window, x, y);
1597 gdk_window_raise(mainwin->window->window);
1598 gdk_window_show(mainwin->window->window);
1600 debug_print("window position: x = %d, y = %d\n", x, y);
1602 switch (mainwin->type) {
1603 case SEPARATE_FOLDER:
1604 widget = mainwin->win.sep_folder.folderwin;
1605 gdk_window_get_origin(widget->window, &x, &y);
1606 x %= sx; if (x < 0) x = 0;
1607 y %= sy; if (y < 0) y = 0;
1608 gdk_window_move(widget->window, x, y);
1609 gdk_window_raise(widget->window);
1611 case SEPARATE_MESSAGE:
1612 widget = mainwin->win.sep_message.messagewin;
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);
1620 widget = mainwin->win.sep_both.folderwin;
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);
1626 widget = mainwin->win.sep_both.messagewin;
1627 gdk_window_get_origin(widget->window, &x, &y);
1628 x %= sx; if (x < 0) x = 0;
1629 y %= sy; if (y < 0) y = 0;
1630 gdk_window_move(widget->window, x, y);
1631 gdk_window_raise(widget->window);
1638 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1640 GtkWidget *folderwin = NULL;
1641 GtkWidget *messagewin = NULL;
1644 GtkWidget *vbox_body = mainwin->vbox_body;
1645 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1646 GtkWidget *menuitem;
1648 debug_print(_("Setting widgets..."));
1650 /* create separated window(s) if needed */
1651 if (type & SEPARATE_FOLDER) {
1652 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1653 gtk_window_set_title(GTK_WINDOW(folderwin),
1654 _("Sylpheed - Folder View"));
1655 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1656 "folder_view", "Sylpheed");
1657 gtk_window_set_policy(GTK_WINDOW(folderwin),
1659 gtk_widget_set_usize(folderwin, -1,
1660 prefs_common.mainview_height);
1661 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1663 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1664 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1667 if (type & SEPARATE_MESSAGE) {
1668 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1669 gtk_window_set_title(GTK_WINDOW(messagewin),
1670 _("Sylpheed - Message View"));
1671 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1672 "message_view", "Sylpheed");
1673 gtk_window_set_policy(GTK_WINDOW(messagewin),
1675 gtk_widget_set_usize
1676 (messagewin, prefs_common.mainview_width,
1677 prefs_common.mainview_height
1678 - prefs_common.summaryview_height
1679 + DEFAULT_HEADERVIEW_HEIGHT);
1680 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1682 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1683 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1689 hpaned = gtk_hpaned_new();
1690 gtk_widget_show(hpaned);
1691 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1692 gtk_paned_add1(GTK_PANED(hpaned),
1693 GTK_WIDGET_PTR(mainwin->folderview));
1695 vpaned = gtk_vpaned_new();
1696 if (mainwin->summaryview->msg_is_toggled_on) {
1697 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1698 gtk_paned_add1(GTK_PANED(vpaned),
1699 GTK_WIDGET_PTR(mainwin->summaryview));
1701 gtk_paned_add2(GTK_PANED(hpaned),
1702 GTK_WIDGET_PTR(mainwin->summaryview));
1703 gtk_widget_ref(vpaned);
1705 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1706 prefs_common.summaryview_width,
1707 prefs_common.summaryview_height);
1708 gtk_paned_add2(GTK_PANED(vpaned),
1709 GTK_WIDGET_PTR(mainwin->messageview));
1710 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1711 prefs_common.mainview_width, -1);
1712 gtk_widget_set_usize(mainwin->window,
1713 prefs_common.folderview_width +
1714 prefs_common.mainview_width,
1715 prefs_common.mainwin_height);
1716 gtk_widget_show_all(vpaned);
1718 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1719 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1720 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1721 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1722 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1723 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1725 mainwin->win.sep_none.hpaned = hpaned;
1726 mainwin->win.sep_none.vpaned = vpaned;
1728 case SEPARATE_FOLDER:
1729 vpaned = gtk_vpaned_new();
1730 if (mainwin->summaryview->msg_is_toggled_on) {
1731 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1733 gtk_paned_add1(GTK_PANED(vpaned),
1734 GTK_WIDGET_PTR(mainwin->summaryview));
1736 gtk_box_pack_start(GTK_BOX(vbox_body),
1737 GTK_WIDGET_PTR(mainwin->summaryview),
1739 gtk_widget_ref(vpaned);
1741 gtk_paned_add2(GTK_PANED(vpaned),
1742 GTK_WIDGET_PTR(mainwin->messageview));
1743 gtk_widget_show_all(vpaned);
1744 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1745 prefs_common.summaryview_width,
1746 prefs_common.summaryview_height);
1747 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1748 prefs_common.mainview_width, -1);
1749 gtk_widget_set_usize(mainwin->window,
1750 prefs_common.mainview_width,
1751 prefs_common.mainview_height);
1753 gtk_container_add(GTK_CONTAINER(folderwin),
1754 GTK_WIDGET_PTR(mainwin->folderview));
1756 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1757 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1759 mainwin->win.sep_folder.folderwin = folderwin;
1760 mainwin->win.sep_folder.vpaned = vpaned;
1762 gtk_widget_show_all(folderwin);
1764 case SEPARATE_MESSAGE:
1765 hpaned = gtk_hpaned_new();
1766 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1768 gtk_paned_add1(GTK_PANED(hpaned),
1769 GTK_WIDGET_PTR(mainwin->folderview));
1770 gtk_paned_add2(GTK_PANED(hpaned),
1771 GTK_WIDGET_PTR(mainwin->summaryview));
1772 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1773 prefs_common.summaryview_width,
1774 prefs_common.summaryview_height);
1775 gtk_widget_set_usize(mainwin->window,
1776 prefs_common.folderview_width +
1777 prefs_common.mainview_width,
1778 prefs_common.mainwin_height);
1779 gtk_widget_show_all(hpaned);
1780 gtk_container_add(GTK_CONTAINER(messagewin),
1781 GTK_WIDGET_PTR(mainwin->messageview));
1783 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1784 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1785 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1786 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1788 mainwin->win.sep_message.messagewin = messagewin;
1789 mainwin->win.sep_message.hpaned = hpaned;
1791 gtk_widget_show_all(messagewin);
1794 gtk_box_pack_start(GTK_BOX(vbox_body),
1795 GTK_WIDGET_PTR(mainwin->summaryview),
1797 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1798 prefs_common.summaryview_width,
1799 prefs_common.summaryview_height);
1800 gtk_widget_set_usize(mainwin->window,
1801 prefs_common.mainview_width,
1802 prefs_common.mainwin_height);
1803 gtk_container_add(GTK_CONTAINER(folderwin),
1804 GTK_WIDGET_PTR(mainwin->folderview));
1805 gtk_container_add(GTK_CONTAINER(messagewin),
1806 GTK_WIDGET_PTR(mainwin->messageview));
1808 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1809 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1811 mainwin->win.sep_both.folderwin = folderwin;
1812 mainwin->win.sep_both.messagewin = messagewin;
1814 gtk_widget_show_all(folderwin);
1815 gtk_widget_show_all(messagewin);
1819 mainwin->type = type;
1821 debug_print(_("done.\n"));
1824 static void main_window_toolbar_create(MainWindow *mainwin,
1825 GtkWidget *container)
1828 GtkWidget *icon_wid;
1830 GtkWidget *getall_btn;
1831 GtkWidget *compose_mail_btn;
1832 GtkWidget *compose_news_btn;
1833 GtkWidget *reply_btn;
1834 GtkWidget *replyall_btn;
1835 GtkWidget *replysender_btn;
1837 GtkWidget *send_btn;
1839 GtkWidget *prefs_btn;
1840 GtkWidget *account_btn;
1842 GtkWidget *next_btn;
1843 GtkWidget *delete_btn;
1844 GtkWidget *exec_btn;
1846 GtkTooltips *tooltips;
1848 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1850 gtk_container_add(GTK_CONTAINER(container), toolbar);
1851 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1852 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1853 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1854 GTK_TOOLBAR_SPACE_LINE);
1856 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1857 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1859 _("Get new mail from current account"),
1861 icon_wid, toolbar_inc_cb, mainwin);
1862 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1863 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1865 _("Get new mail from all accounts"),
1871 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1873 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1874 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1876 _("Send queued message(s)"),
1882 /* insert compose mail button widget */
1883 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1884 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1886 _("Compose an email message"),
1889 toolbar_compose_mail_cb,
1892 /* insert compose news button widget */
1893 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1894 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1896 _("Compose a news message"),
1899 toolbar_compose_news_cb,
1902 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1906 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1907 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1909 _("Reply to the message - Right button: more options"),
1915 /* replyall button */
1917 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1918 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1920 _("Reply to all - Right button: more options"),
1923 toolbar_reply_to_all_cb,
1926 /* reply to sender button */
1927 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1928 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1930 _("Reply to sender - Right button: more options"),
1933 toolbar_reply_to_sender_cb,
1936 /* forward button */
1937 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1938 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1940 _("Forward the message - Right button: more options"),
1946 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1948 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1949 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1951 _("Delete the message"),
1957 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1958 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1960 _("Execute marked process"),
1966 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
1967 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1969 _("Next unread message"),
1972 toolbar_next_unread_cb,
1976 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1978 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
1979 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1981 _("Common preference"),
1986 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
1987 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1989 _("Account setting"),
1994 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1995 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1999 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2000 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2003 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2004 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2007 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2008 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2011 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2012 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2016 mainwin->toolbar = toolbar;
2017 mainwin->get_btn = get_btn;
2018 mainwin->getall_btn = getall_btn;
2019 mainwin->compose_mail_btn = compose_mail_btn;
2020 mainwin->compose_news_btn = compose_news_btn;
2021 mainwin->reply_btn = reply_btn;
2022 mainwin->replyall_btn = replyall_btn;
2023 mainwin->replysender_btn = replysender_btn;
2024 mainwin->fwd_btn = fwd_btn;
2025 mainwin->send_btn = send_btn;
2027 mainwin->prefs_btn = prefs_btn;
2028 mainwin->account_btn = account_btn;
2030 mainwin->next_btn = next_btn;
2031 mainwin->delete_btn = delete_btn;
2032 mainwin->exec_btn = exec_btn;
2034 gtk_widget_show_all(toolbar);
2037 /* callback functions */
2038 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2040 MainWindow *mainwindow = (MainWindow *) data;
2044 if (event->button == 3) {
2045 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2046 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2047 menu_button_position, widget,
2048 event->button, event->time);
2052 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2054 MainWindow *mainwin = (MainWindow *)data;
2056 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2057 manage_window_focus_in(mainwin->window, NULL, NULL);
2060 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2062 MainWindow *mainwindow = (MainWindow *) data;
2066 if (event->button == 3) {
2067 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2068 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2069 menu_button_position, widget,
2070 event->button, event->time);
2074 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2076 MainWindow *mainwin = (MainWindow *)data;
2078 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2079 manage_window_focus_in(mainwin->window, NULL, NULL);
2082 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2084 MainWindow *mainwindow = (MainWindow *) data;
2085 GtkWidget *replysender_menu, *replysender_item;
2089 if (event->button == 3) {
2090 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2091 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2092 menu_button_position, widget,
2093 event->button, event->time);
2097 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2099 MainWindow *mainwin = (MainWindow *)data;
2101 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2102 manage_window_focus_in(mainwin->window, NULL, NULL);
2105 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2107 MainWindow *mainwindow = (MainWindow *) data;
2111 if (event->button == 3) {
2112 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2113 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2114 menu_button_position, widget,
2115 event->button, event->time);
2119 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2121 MainWindow *mainwin = (MainWindow *)data;
2123 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2124 manage_window_focus_in(mainwin->window, NULL, NULL);
2127 static void toolbar_inc_cb (GtkWidget *widget,
2130 MainWindow *mainwin = (MainWindow *)data;
2132 inc_mail_cb(mainwin, 0, NULL);
2135 static void toolbar_inc_all_cb (GtkWidget *widget,
2138 MainWindow *mainwin = (MainWindow *)data;
2140 inc_all_account_mail_cb(mainwin, 0, NULL);
2143 static void toolbar_send_cb (GtkWidget *widget,
2146 MainWindow *mainwin = (MainWindow *)data;
2148 send_queue_cb(mainwin, 0, NULL);
2151 static void toolbar_compose_cb (GtkWidget *widget,
2154 MainWindow *mainwin = (MainWindow *)data;
2156 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2157 compose_cb(mainwin, 0, NULL);
2159 compose_news_cb(mainwin, 0, NULL);
2162 static void toolbar_compose_news_cb (GtkWidget *widget,
2165 MainWindow *mainwin = (MainWindow *)data;
2167 compose_news_cb(mainwin, 0, NULL);
2170 static void toolbar_compose_mail_cb (GtkWidget *widget,
2173 MainWindow *mainwin = (MainWindow *)data;
2175 compose_mail_cb(mainwin, 0, NULL);
2178 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2180 MainWindow *mainwin = (MainWindow *)data;
2183 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2184 : COMPOSE_REPLY_WITHOUT_QUOTE,
2188 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2190 MainWindow *mainwin = (MainWindow *)data;
2193 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2194 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2199 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2201 MainWindow *mainwin = (MainWindow *)data;
2204 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2205 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2209 static void toolbar_forward_cb (GtkWidget *widget,
2212 MainWindow *mainwin = (MainWindow *)data;
2214 if (prefs_common.forward_as_attachment)
2215 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2217 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2220 static void toolbar_delete_cb (GtkWidget *widget,
2223 MainWindow *mainwin = (MainWindow *)data;
2225 summary_delete(mainwin->summaryview);
2228 static void toolbar_exec_cb (GtkWidget *widget,
2231 MainWindow *mainwin = (MainWindow *)data;
2233 summary_execute(mainwin->summaryview);
2236 static void toolbar_next_unread_cb (GtkWidget *widget,
2239 MainWindow *mainwin = (MainWindow *)data;
2241 next_unread_cb(mainwin, 0, NULL);
2244 static void toolbar_prefs_cb (GtkWidget *widget,
2247 prefs_common_open();
2250 static void toolbar_account_cb (GtkWidget *widget,
2253 MainWindow *mainwin = (MainWindow *)data;
2255 prefs_account_open_cb(mainwin, 0, NULL);
2258 static void toolbar_account_button_pressed(GtkWidget *widget,
2259 GdkEventButton *event,
2262 MainWindow *mainwin = (MainWindow *)data;
2265 if (event->button != 3) return;
2267 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2268 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2271 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2272 menu_button_position, widget,
2273 event->button, event->time);
2276 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2279 MainWindow *mainwin = (MainWindow *)data;
2283 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2284 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2287 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2288 menu_button_position, widget,
2289 event->button, event->time);
2292 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2294 MainWindow *mainwin = (MainWindow *)data;
2297 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2298 if (!button) return;
2299 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2300 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2301 manage_window_focus_in(mainwin->window, NULL, NULL);
2304 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2307 MainWindow *mainwin = (MainWindow *)data;
2309 if (mainwin->lock_count == 0)
2310 app_exit_cb(data, 0, widget);
2315 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2318 main_window_add_mailbox(mainwin);
2321 static void add_mbox_cb(MainWindow *mainwin, guint action,
2324 main_window_add_mbox(mainwin);
2327 static void update_folderview_cb(MainWindow *mainwin, guint action,
2330 summary_show(mainwin->summaryview, NULL, FALSE);
2331 folderview_update_all();
2334 static void new_folder_cb(MainWindow *mainwin, guint action,
2337 folderview_new_folder(mainwin->folderview);
2340 static void rename_folder_cb(MainWindow *mainwin, guint action,
2343 folderview_rename_folder(mainwin->folderview);
2346 static void delete_folder_cb(MainWindow *mainwin, guint action,
2349 folderview_delete_folder(mainwin->folderview);
2352 static void import_mbox_cb(MainWindow *mainwin, guint action,
2355 import_mbox(mainwin->summaryview->folder_item);
2358 static void export_mbox_cb(MainWindow *mainwin, guint action,
2361 export_mbox(mainwin->summaryview->folder_item);
2364 static void empty_trash_cb(MainWindow *mainwin, guint action,
2367 main_window_empty_trash(mainwin, TRUE);
2370 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2372 summary_save_as(mainwin->summaryview);
2375 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2377 summary_print(mainwin->summaryview);
2380 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2382 if (prefs_common.confirm_on_exit) {
2383 if (alertpanel(_("Exit"), _("Exit this program?"),
2384 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2386 manage_window_focus_in(mainwin->window, NULL, NULL);
2389 app_will_exit(widget, mainwin);
2392 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2395 summary_search(mainwin->summaryview);
2397 message_search(mainwin->messageview);
2400 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2403 switch (mainwin->type) {
2405 case SEPARATE_MESSAGE:
2407 case SEPARATE_FOLDER:
2408 if (GTK_CHECK_MENU_ITEM(widget)->active)
2409 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2411 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2414 if (GTK_CHECK_MENU_ITEM(widget)->active)
2415 gtk_widget_show(mainwin->win.sep_both.folderwin);
2417 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2422 static void toggle_message_cb(MainWindow *mainwin, guint action,
2425 switch (mainwin->type) {
2427 case SEPARATE_FOLDER:
2429 case SEPARATE_MESSAGE:
2430 if (GTK_CHECK_MENU_ITEM(widget)->active)
2431 gtk_widget_show(mainwin->win.sep_message.messagewin);
2433 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2436 if (GTK_CHECK_MENU_ITEM(widget)->active)
2437 gtk_widget_show(mainwin->win.sep_both.messagewin);
2439 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2444 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2447 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2448 mainwin->compose_btn_type);
2449 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2450 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2451 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2452 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2454 mainwin->toolbar_style = (ToolbarStyle)action;
2455 prefs_common.toolbar_style = (ToolbarStyle)action;
2457 set_toolbar_style(mainwin);
2460 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2463 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2464 gtk_widget_show(mainwin->hbox_stat);
2465 prefs_common.show_statusbar = TRUE;
2467 gtk_widget_hide(mainwin->hbox_stat);
2468 prefs_common.show_statusbar = FALSE;
2472 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2474 summary_toggle_view_real(mainwin->summaryview);
2477 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2479 messageview_toggle_view_real(mainwin->messageview);
2482 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2485 MainWindow *mainwin;
2488 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2489 g_return_if_fail(mainwin != NULL);
2491 type = mainwin->type ^ action;
2492 main_window_separation_change(mainwin, type);
2494 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2495 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2498 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2501 addressbook_open(NULL);
2504 static void log_window_show_cb(MainWindow *mainwin, guint action,
2507 log_window_show(mainwin->logwin);
2510 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2515 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2518 inc_all_account_mail(mainwin);
2521 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2525 if (procmsg_send_queue() < 0)
2526 alertpanel_error(_("Some errors occurred while sending queued messages."));
2528 statusbar_pop_all();
2530 for (list = folder_get_list(); list != NULL; list = list->next) {
2533 folder = list->data;
2534 if (folder->queue) {
2535 folder_item_scan(folder->queue);
2536 folderview_update_item(folder->queue, TRUE);
2541 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2543 if (mainwin->summaryview->folder_item) {
2544 if (mainwin->summaryview->folder_item->folder->account != NULL
2545 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2546 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2548 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2554 static void compose_mail_cb(MainWindow *mainwin, guint action,
2561 if (mainwin->summaryview->folder_item) {
2562 ac = mainwin->summaryview->folder_item->folder->account;
2563 if (ac && ac->protocol != A_NNTP) {
2564 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2569 if(cur_account && (cur_account->protocol != A_NNTP)) {
2570 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2574 list = account_get_list();
2575 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2576 ac = (PrefsAccount *) cur->data;
2577 if (ac->protocol != A_NNTP) {
2578 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2584 static void compose_news_cb(MainWindow *mainwin, guint action,
2587 PrefsAccount * ac = NULL;
2591 if (mainwin->summaryview->folder_item) {
2592 ac = mainwin->summaryview->folder_item->folder->account;
2593 if (ac && ac->protocol == A_NNTP) {
2594 compose_new_with_recipient
2595 (ac, mainwin->summaryview->folder_item->path);
2600 list = account_get_list();
2601 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2602 ac = (PrefsAccount *) cur->data;
2603 if (ac->protocol == A_NNTP) {
2610 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2612 summary_reply(mainwin->summaryview, (ComposeMode)action);
2615 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2617 summary_move_to(mainwin->summaryview);
2620 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2622 summary_copy_to(mainwin->summaryview);
2625 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2627 summary_delete(mainwin->summaryview);
2630 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2632 summary_open_msg(mainwin->summaryview);
2635 static void view_source_cb(MainWindow *mainwin, guint action,
2638 summary_view_source(mainwin->summaryview);
2641 static void show_all_header_cb(MainWindow *mainwin, guint action,
2644 if (mainwin->menu_lock_count) return;
2645 summary_display_msg_selected(mainwin->summaryview,
2646 GTK_CHECK_MENU_ITEM(widget)->active);
2649 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2651 summary_reedit(mainwin->summaryview);
2654 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2656 summary_mark(mainwin->summaryview);
2659 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2661 summary_unmark(mainwin->summaryview);
2664 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2667 summary_mark_as_unread(mainwin->summaryview);
2670 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2673 summary_mark_as_read(mainwin->summaryview);
2676 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2679 summary_mark_all_read(mainwin->summaryview);
2682 static void add_address_cb(MainWindow *mainwin, guint action,
2685 summary_add_address(mainwin->summaryview);
2688 static void set_charset_cb(MainWindow *mainwin, guint action,
2693 str = conv_get_charset_str((CharSet)action);
2694 g_free(prefs_common.force_charset);
2695 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2697 summary_redisplay_msg(mainwin->summaryview);
2699 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2702 static void hide_read_messages (MainWindow *mainwin, guint action,
2705 if (!mainwin->summaryview->folder_item
2706 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2708 summary_toggle_show_read_messages(mainwin->summaryview);
2711 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2713 GtkItemFactory *ifactory;
2715 if (mainwin->menu_lock_count) return;
2716 if (!mainwin->summaryview->folder_item) return;
2718 ifactory = gtk_item_factory_from_widget(widget);
2720 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2721 summary_thread_build(mainwin->summaryview);
2722 mainwin->summaryview->folder_item->threaded = TRUE;
2724 summary_unthread(mainwin->summaryview);
2725 mainwin->summaryview->folder_item->threaded = FALSE;
2729 static void set_display_item_cb(MainWindow *mainwin, guint action,
2732 prefs_summary_column_open();
2735 static void sort_summary_cb(MainWindow *mainwin, guint action,
2738 summary_sort(mainwin->summaryview, (SummarySortType)action);
2741 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2744 summary_attract_by_subject(mainwin->summaryview);
2747 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2750 summary_delete_duplicated(mainwin->summaryview);
2753 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2755 summary_filter(mainwin->summaryview);
2758 static void execute_summary_cb(MainWindow *mainwin, guint action,
2761 summary_execute(mainwin->summaryview);
2764 static void update_summary_cb(MainWindow *mainwin, guint action,
2768 FolderView *folderview = mainwin->folderview;
2770 if (!mainwin->summaryview->folder_item) return;
2771 if (!folderview->opened) return;
2773 folder_update_op_count();
2775 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2776 folderview->opened);
2779 summary_show(mainwin->summaryview, fitem, TRUE);
2782 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2784 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2787 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2789 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2792 static void prev_unread_cb(MainWindow *mainwin, guint action,
2795 summary_select_prev_unread(mainwin->summaryview);
2798 static void next_unread_cb(MainWindow *mainwin, guint action,
2801 summary_select_next_unread(mainwin->summaryview);
2804 static void prev_marked_cb(MainWindow *mainwin, guint action,
2807 summary_select_prev_marked(mainwin->summaryview);
2810 static void next_marked_cb(MainWindow *mainwin, guint action,
2813 summary_select_next_marked(mainwin->summaryview);
2816 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2819 summary_select_prev_labeled(mainwin->summaryview);
2822 static void next_labeled_cb(MainWindow *mainwin, guint action,
2825 summary_select_next_labeled(mainwin->summaryview);
2828 static void goto_folder_cb(MainWindow *mainwin, guint action,
2831 FolderItem *to_folder;
2833 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2836 folderview_select(mainwin->folderview, to_folder);
2839 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2841 messageview_copy_clipboard(mainwin->messageview);
2844 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2846 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2847 summary_select_all(mainwin->summaryview);
2848 else if (mainwin->summaryview->msg_is_toggled_on &&
2849 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2850 messageview_select_all(mainwin->messageview);
2853 static void create_filter_cb(MainWindow *mainwin, guint action,
2856 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2859 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2862 prefs_common_open();
2865 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2868 prefs_filter_open(NULL, NULL);
2871 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2874 prefs_scoring_open(NULL);
2877 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2880 prefs_filtering_open(NULL);
2883 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2886 prefs_template_open();
2889 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2892 prefs_actions_open(mainwin);
2895 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2899 new_account_cb(mainwin, 0, widget);
2901 gboolean prev_default = cur_account->is_default;
2903 prefs_account_open(cur_account);
2904 if (!prev_default && cur_account->is_default)
2905 account_set_as_default(cur_account);
2906 account_save_config_all();
2908 main_window_reflect_prefs_all();
2912 static void new_account_cb(MainWindow *mainwin, guint action,
2915 account_edit_open();
2916 if (!compose_get_compose_list()) account_add();
2919 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2921 cur_account = (PrefsAccount *)data;
2922 main_window_reflect_prefs_all();
2925 static void manual_open_cb(MainWindow *mainwin, guint action,
2928 manual_open((ManualLang)action);
2931 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2933 MainWindow *mainwin = (MainWindow *)data;
2937 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2938 LOCAL_FOLDER(folder)->rootpath,
2942 str = g_strdup_printf(_("Scanning folder %s ..."),
2943 LOCAL_FOLDER(folder)->rootpath);
2945 STATUSBAR_PUSH(mainwin, str);
2946 STATUSBAR_POP(mainwin);
2950 static void activate_compose_button (MainWindow *mainwin,
2952 ComposeButtonType type)
2954 SensitiveCond state = main_window_get_current_state(mainwin);
2956 if (style == TOOLBAR_NONE)
2959 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2960 : mainwin->compose_news_btn);
2961 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2962 : mainwin->compose_mail_btn);
2963 mainwin->compose_btn_type = type;
2966 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2968 if (mainwin->compose_btn_type != compose_btn_type)
2969 activate_compose_button(mainwin,
2970 prefs_common.toolbar_style,
2974 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
2976 MainWindow *mainwin = (MainWindow*) data;
2978 if (!mainwin) return;
2980 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
2983 #define BREAK_ON_MODIFIER_KEY() \
2984 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2986 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
2988 MainWindow *mainwin = (MainWindow*) data;
2990 if (!mainwin || !event) return;
2992 switch (event->keyval) {
2993 case GDK_Q: /* Quit */
2994 BREAK_ON_MODIFIER_KEY();
2996 app_exit_cb(mainwin, 0, NULL);
3003 #undef BREAK_ON_MODIFIER_KEY
3005 static void set_toolbar_style(MainWindow *mainwin)
3007 switch (prefs_common.toolbar_style) {
3009 gtk_widget_hide(mainwin->handlebox);
3012 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3016 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3020 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3025 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3026 gtk_widget_show(mainwin->handlebox);
3027 gtk_widget_queue_resize(mainwin->handlebox);
3029 if (prefs_common.immediate_exec)
3030 gtk_widget_hide(mainwin->exec_btn);
3032 gtk_widget_show(mainwin->exec_btn);