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(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1577 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1578 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1579 (state & M_THREADED) != 0);
1580 main_window_menu_callback_unblock(mainwin);
1583 void main_window_popup(MainWindow *mainwin)
1589 gdk_window_get_origin(mainwin->window->window, &x, &y);
1590 sx = gdk_screen_width();
1591 sy = gdk_screen_height();
1592 x %= sx; if (x < 0) x = 0;
1593 y %= sy; if (y < 0) y = 0;
1594 gdk_window_move(mainwin->window->window, x, y);
1595 gdk_window_raise(mainwin->window->window);
1596 gdk_window_show(mainwin->window->window);
1598 debug_print("window position: x = %d, y = %d\n", x, y);
1600 switch (mainwin->type) {
1601 case SEPARATE_FOLDER:
1602 widget = mainwin->win.sep_folder.folderwin;
1603 gdk_window_get_origin(widget->window, &x, &y);
1604 x %= sx; if (x < 0) x = 0;
1605 y %= sy; if (y < 0) y = 0;
1606 gdk_window_move(widget->window, x, y);
1607 gdk_window_raise(widget->window);
1609 case SEPARATE_MESSAGE:
1610 widget = mainwin->win.sep_message.messagewin;
1611 gdk_window_get_origin(widget->window, &x, &y);
1612 x %= sx; if (x < 0) x = 0;
1613 y %= sy; if (y < 0) y = 0;
1614 gdk_window_move(widget->window, x, y);
1615 gdk_window_raise(widget->window);
1618 widget = mainwin->win.sep_both.folderwin;
1619 gdk_window_get_origin(widget->window, &x, &y);
1620 x %= sx; if (x < 0) x = 0;
1621 y %= sy; if (y < 0) y = 0;
1622 gdk_window_move(widget->window, x, y);
1623 gdk_window_raise(widget->window);
1624 widget = mainwin->win.sep_both.messagewin;
1625 gdk_window_get_origin(widget->window, &x, &y);
1626 x %= sx; if (x < 0) x = 0;
1627 y %= sy; if (y < 0) y = 0;
1628 gdk_window_move(widget->window, x, y);
1629 gdk_window_raise(widget->window);
1636 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1638 GtkWidget *folderwin = NULL;
1639 GtkWidget *messagewin = NULL;
1642 GtkWidget *vbox_body = mainwin->vbox_body;
1643 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1644 GtkWidget *menuitem;
1646 debug_print(_("Setting widgets..."));
1648 /* create separated window(s) if needed */
1649 if (type & SEPARATE_FOLDER) {
1650 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1651 gtk_window_set_title(GTK_WINDOW(folderwin),
1652 _("Sylpheed - Folder View"));
1653 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1654 "folder_view", "Sylpheed");
1655 gtk_window_set_policy(GTK_WINDOW(folderwin),
1657 gtk_widget_set_usize(folderwin, -1,
1658 prefs_common.mainview_height);
1659 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1661 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1662 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1665 if (type & SEPARATE_MESSAGE) {
1666 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1667 gtk_window_set_title(GTK_WINDOW(messagewin),
1668 _("Sylpheed - Message View"));
1669 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1670 "message_view", "Sylpheed");
1671 gtk_window_set_policy(GTK_WINDOW(messagewin),
1673 gtk_widget_set_usize
1674 (messagewin, prefs_common.mainview_width,
1675 prefs_common.mainview_height
1676 - prefs_common.summaryview_height
1677 + DEFAULT_HEADERVIEW_HEIGHT);
1678 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1680 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1681 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1687 hpaned = gtk_hpaned_new();
1688 gtk_widget_show(hpaned);
1689 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1690 gtk_paned_add1(GTK_PANED(hpaned),
1691 GTK_WIDGET_PTR(mainwin->folderview));
1693 vpaned = gtk_vpaned_new();
1694 if (mainwin->summaryview->msg_is_toggled_on) {
1695 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1696 gtk_paned_add1(GTK_PANED(vpaned),
1697 GTK_WIDGET_PTR(mainwin->summaryview));
1699 gtk_paned_add2(GTK_PANED(hpaned),
1700 GTK_WIDGET_PTR(mainwin->summaryview));
1701 gtk_widget_ref(vpaned);
1703 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1704 prefs_common.summaryview_width,
1705 prefs_common.summaryview_height);
1706 gtk_paned_add2(GTK_PANED(vpaned),
1707 GTK_WIDGET_PTR(mainwin->messageview));
1708 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1709 prefs_common.mainview_width, -1);
1710 gtk_widget_set_usize(mainwin->window,
1711 prefs_common.folderview_width +
1712 prefs_common.mainview_width,
1713 prefs_common.mainwin_height);
1714 gtk_widget_show_all(vpaned);
1716 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1717 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1718 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1719 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1720 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1721 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1723 mainwin->win.sep_none.hpaned = hpaned;
1724 mainwin->win.sep_none.vpaned = vpaned;
1726 case SEPARATE_FOLDER:
1727 vpaned = gtk_vpaned_new();
1728 if (mainwin->summaryview->msg_is_toggled_on) {
1729 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1731 gtk_paned_add1(GTK_PANED(vpaned),
1732 GTK_WIDGET_PTR(mainwin->summaryview));
1734 gtk_box_pack_start(GTK_BOX(vbox_body),
1735 GTK_WIDGET_PTR(mainwin->summaryview),
1737 gtk_widget_ref(vpaned);
1739 gtk_paned_add2(GTK_PANED(vpaned),
1740 GTK_WIDGET_PTR(mainwin->messageview));
1741 gtk_widget_show_all(vpaned);
1742 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1743 prefs_common.summaryview_width,
1744 prefs_common.summaryview_height);
1745 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1746 prefs_common.mainview_width, -1);
1747 gtk_widget_set_usize(mainwin->window,
1748 prefs_common.mainview_width,
1749 prefs_common.mainview_height);
1751 gtk_container_add(GTK_CONTAINER(folderwin),
1752 GTK_WIDGET_PTR(mainwin->folderview));
1754 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1755 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1757 mainwin->win.sep_folder.folderwin = folderwin;
1758 mainwin->win.sep_folder.vpaned = vpaned;
1760 gtk_widget_show_all(folderwin);
1762 case SEPARATE_MESSAGE:
1763 hpaned = gtk_hpaned_new();
1764 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1766 gtk_paned_add1(GTK_PANED(hpaned),
1767 GTK_WIDGET_PTR(mainwin->folderview));
1768 gtk_paned_add2(GTK_PANED(hpaned),
1769 GTK_WIDGET_PTR(mainwin->summaryview));
1770 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1771 prefs_common.summaryview_width,
1772 prefs_common.summaryview_height);
1773 gtk_widget_set_usize(mainwin->window,
1774 prefs_common.folderview_width +
1775 prefs_common.mainview_width,
1776 prefs_common.mainwin_height);
1777 gtk_widget_show_all(hpaned);
1778 gtk_container_add(GTK_CONTAINER(messagewin),
1779 GTK_WIDGET_PTR(mainwin->messageview));
1781 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1782 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1783 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1784 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1786 mainwin->win.sep_message.messagewin = messagewin;
1787 mainwin->win.sep_message.hpaned = hpaned;
1789 gtk_widget_show_all(messagewin);
1792 gtk_box_pack_start(GTK_BOX(vbox_body),
1793 GTK_WIDGET_PTR(mainwin->summaryview),
1795 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1796 prefs_common.summaryview_width,
1797 prefs_common.summaryview_height);
1798 gtk_widget_set_usize(mainwin->window,
1799 prefs_common.mainview_width,
1800 prefs_common.mainwin_height);
1801 gtk_container_add(GTK_CONTAINER(folderwin),
1802 GTK_WIDGET_PTR(mainwin->folderview));
1803 gtk_container_add(GTK_CONTAINER(messagewin),
1804 GTK_WIDGET_PTR(mainwin->messageview));
1806 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1807 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1809 mainwin->win.sep_both.folderwin = folderwin;
1810 mainwin->win.sep_both.messagewin = messagewin;
1812 gtk_widget_show_all(folderwin);
1813 gtk_widget_show_all(messagewin);
1817 mainwin->type = type;
1819 debug_print(_("done.\n"));
1822 static void main_window_toolbar_create(MainWindow *mainwin,
1823 GtkWidget *container)
1826 GtkWidget *icon_wid;
1828 GtkWidget *getall_btn;
1829 GtkWidget *compose_mail_btn;
1830 GtkWidget *compose_news_btn;
1831 GtkWidget *reply_btn;
1832 GtkWidget *replyall_btn;
1833 GtkWidget *replysender_btn;
1835 GtkWidget *send_btn;
1837 GtkWidget *prefs_btn;
1838 GtkWidget *account_btn;
1840 GtkWidget *next_btn;
1841 GtkWidget *delete_btn;
1842 GtkWidget *exec_btn;
1844 GtkTooltips *tooltips;
1846 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1848 gtk_container_add(GTK_CONTAINER(container), toolbar);
1849 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1850 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1851 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1852 GTK_TOOLBAR_SPACE_LINE);
1854 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1855 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1857 _("Get new mail from current account"),
1859 icon_wid, toolbar_inc_cb, mainwin);
1860 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1861 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1863 _("Get new mail from all accounts"),
1869 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1871 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1872 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1874 _("Send queued message(s)"),
1880 /* insert compose mail button widget */
1881 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1882 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1884 _("Compose an email message"),
1887 toolbar_compose_mail_cb,
1890 /* insert compose news button widget */
1891 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1892 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1894 _("Compose a news message"),
1897 toolbar_compose_news_cb,
1900 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1904 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1905 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1907 _("Reply to the message - Right button: more options"),
1913 /* replyall button */
1915 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1916 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1918 _("Reply to all - Right button: more options"),
1921 toolbar_reply_to_all_cb,
1924 /* reply to sender button */
1925 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1926 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1928 _("Reply to sender - Right button: more options"),
1931 toolbar_reply_to_sender_cb,
1934 /* forward button */
1935 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1936 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1938 _("Forward the message - Right button: more options"),
1944 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1946 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1947 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1949 _("Delete the message"),
1955 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1956 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1958 _("Execute marked process"),
1964 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
1965 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1967 _("Next unread message"),
1970 toolbar_next_unread_cb,
1974 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1976 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
1977 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1979 _("Common preference"),
1984 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
1985 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1987 _("Account setting"),
1992 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1993 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1997 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
1998 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2001 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2002 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2005 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2006 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2009 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2010 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2014 mainwin->toolbar = toolbar;
2015 mainwin->get_btn = get_btn;
2016 mainwin->getall_btn = getall_btn;
2017 mainwin->compose_mail_btn = compose_mail_btn;
2018 mainwin->compose_news_btn = compose_news_btn;
2019 mainwin->reply_btn = reply_btn;
2020 mainwin->replyall_btn = replyall_btn;
2021 mainwin->replysender_btn = replysender_btn;
2022 mainwin->fwd_btn = fwd_btn;
2023 mainwin->send_btn = send_btn;
2025 mainwin->prefs_btn = prefs_btn;
2026 mainwin->account_btn = account_btn;
2028 mainwin->next_btn = next_btn;
2029 mainwin->delete_btn = delete_btn;
2030 mainwin->exec_btn = exec_btn;
2032 gtk_widget_show_all(toolbar);
2035 /* callback functions */
2036 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2038 MainWindow *mainwindow = (MainWindow *) data;
2042 if (event->button == 3) {
2043 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2044 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2045 menu_button_position, widget,
2046 event->button, event->time);
2050 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2052 MainWindow *mainwin = (MainWindow *)data;
2054 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2055 manage_window_focus_in(mainwin->window, NULL, NULL);
2058 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2060 MainWindow *mainwindow = (MainWindow *) data;
2064 if (event->button == 3) {
2065 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2066 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2067 menu_button_position, widget,
2068 event->button, event->time);
2072 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2074 MainWindow *mainwin = (MainWindow *)data;
2076 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2077 manage_window_focus_in(mainwin->window, NULL, NULL);
2080 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2082 MainWindow *mainwindow = (MainWindow *) data;
2083 GtkWidget *replysender_menu, *replysender_item;
2087 if (event->button == 3) {
2088 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2089 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2090 menu_button_position, widget,
2091 event->button, event->time);
2095 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2097 MainWindow *mainwin = (MainWindow *)data;
2099 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2100 manage_window_focus_in(mainwin->window, NULL, NULL);
2103 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2105 MainWindow *mainwindow = (MainWindow *) data;
2109 if (event->button == 3) {
2110 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2111 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2112 menu_button_position, widget,
2113 event->button, event->time);
2117 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2119 MainWindow *mainwin = (MainWindow *)data;
2121 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2122 manage_window_focus_in(mainwin->window, NULL, NULL);
2125 static void toolbar_inc_cb (GtkWidget *widget,
2128 MainWindow *mainwin = (MainWindow *)data;
2130 inc_mail_cb(mainwin, 0, NULL);
2133 static void toolbar_inc_all_cb (GtkWidget *widget,
2136 MainWindow *mainwin = (MainWindow *)data;
2138 inc_all_account_mail_cb(mainwin, 0, NULL);
2141 static void toolbar_send_cb (GtkWidget *widget,
2144 MainWindow *mainwin = (MainWindow *)data;
2146 send_queue_cb(mainwin, 0, NULL);
2149 static void toolbar_compose_cb (GtkWidget *widget,
2152 MainWindow *mainwin = (MainWindow *)data;
2154 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2155 compose_cb(mainwin, 0, NULL);
2157 compose_news_cb(mainwin, 0, NULL);
2160 static void toolbar_compose_news_cb (GtkWidget *widget,
2163 MainWindow *mainwin = (MainWindow *)data;
2165 compose_news_cb(mainwin, 0, NULL);
2168 static void toolbar_compose_mail_cb (GtkWidget *widget,
2171 MainWindow *mainwin = (MainWindow *)data;
2173 compose_mail_cb(mainwin, 0, NULL);
2176 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2178 MainWindow *mainwin = (MainWindow *)data;
2181 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2182 : COMPOSE_REPLY_WITHOUT_QUOTE,
2186 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2188 MainWindow *mainwin = (MainWindow *)data;
2191 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2192 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2197 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2199 MainWindow *mainwin = (MainWindow *)data;
2202 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2203 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2207 static void toolbar_forward_cb (GtkWidget *widget,
2210 MainWindow *mainwin = (MainWindow *)data;
2212 if (prefs_common.forward_as_attachment)
2213 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2215 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2218 static void toolbar_delete_cb (GtkWidget *widget,
2221 MainWindow *mainwin = (MainWindow *)data;
2223 summary_delete(mainwin->summaryview);
2226 static void toolbar_exec_cb (GtkWidget *widget,
2229 MainWindow *mainwin = (MainWindow *)data;
2231 summary_execute(mainwin->summaryview);
2234 static void toolbar_next_unread_cb (GtkWidget *widget,
2237 MainWindow *mainwin = (MainWindow *)data;
2239 next_unread_cb(mainwin, 0, NULL);
2242 static void toolbar_prefs_cb (GtkWidget *widget,
2245 prefs_common_open();
2248 static void toolbar_account_cb (GtkWidget *widget,
2251 MainWindow *mainwin = (MainWindow *)data;
2253 prefs_account_open_cb(mainwin, 0, NULL);
2256 static void toolbar_account_button_pressed(GtkWidget *widget,
2257 GdkEventButton *event,
2260 MainWindow *mainwin = (MainWindow *)data;
2263 if (event->button != 3) return;
2265 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2266 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2269 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2270 menu_button_position, widget,
2271 event->button, event->time);
2274 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2277 MainWindow *mainwin = (MainWindow *)data;
2281 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2282 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2285 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2286 menu_button_position, widget,
2287 event->button, event->time);
2290 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2292 MainWindow *mainwin = (MainWindow *)data;
2295 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2296 if (!button) return;
2297 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2298 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2299 manage_window_focus_in(mainwin->window, NULL, NULL);
2302 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2305 MainWindow *mainwin = (MainWindow *)data;
2307 if (mainwin->lock_count == 0)
2308 app_exit_cb(data, 0, widget);
2313 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2316 main_window_add_mailbox(mainwin);
2319 static void add_mbox_cb(MainWindow *mainwin, guint action,
2322 main_window_add_mbox(mainwin);
2325 static void update_folderview_cb(MainWindow *mainwin, guint action,
2328 summary_show(mainwin->summaryview, NULL, FALSE);
2329 folderview_update_all();
2332 static void new_folder_cb(MainWindow *mainwin, guint action,
2335 folderview_new_folder(mainwin->folderview);
2338 static void rename_folder_cb(MainWindow *mainwin, guint action,
2341 folderview_rename_folder(mainwin->folderview);
2344 static void delete_folder_cb(MainWindow *mainwin, guint action,
2347 folderview_delete_folder(mainwin->folderview);
2350 static void import_mbox_cb(MainWindow *mainwin, guint action,
2353 import_mbox(mainwin->summaryview->folder_item);
2356 static void export_mbox_cb(MainWindow *mainwin, guint action,
2359 export_mbox(mainwin->summaryview->folder_item);
2362 static void empty_trash_cb(MainWindow *mainwin, guint action,
2365 main_window_empty_trash(mainwin, TRUE);
2368 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2370 summary_save_as(mainwin->summaryview);
2373 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2375 summary_print(mainwin->summaryview);
2378 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2380 if (prefs_common.confirm_on_exit) {
2381 if (alertpanel(_("Exit"), _("Exit this program?"),
2382 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2384 manage_window_focus_in(mainwin->window, NULL, NULL);
2387 app_will_exit(widget, mainwin);
2390 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2393 summary_search(mainwin->summaryview);
2395 message_search(mainwin->messageview);
2398 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2401 switch (mainwin->type) {
2403 case SEPARATE_MESSAGE:
2405 case SEPARATE_FOLDER:
2406 if (GTK_CHECK_MENU_ITEM(widget)->active)
2407 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2409 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2412 if (GTK_CHECK_MENU_ITEM(widget)->active)
2413 gtk_widget_show(mainwin->win.sep_both.folderwin);
2415 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2420 static void toggle_message_cb(MainWindow *mainwin, guint action,
2423 switch (mainwin->type) {
2425 case SEPARATE_FOLDER:
2427 case SEPARATE_MESSAGE:
2428 if (GTK_CHECK_MENU_ITEM(widget)->active)
2429 gtk_widget_show(mainwin->win.sep_message.messagewin);
2431 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2434 if (GTK_CHECK_MENU_ITEM(widget)->active)
2435 gtk_widget_show(mainwin->win.sep_both.messagewin);
2437 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2442 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2445 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2446 mainwin->compose_btn_type);
2447 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2448 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2449 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2450 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2452 mainwin->toolbar_style = (ToolbarStyle)action;
2453 prefs_common.toolbar_style = (ToolbarStyle)action;
2455 set_toolbar_style(mainwin);
2458 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2461 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2462 gtk_widget_show(mainwin->hbox_stat);
2463 prefs_common.show_statusbar = TRUE;
2465 gtk_widget_hide(mainwin->hbox_stat);
2466 prefs_common.show_statusbar = FALSE;
2470 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2472 summary_toggle_view_real(mainwin->summaryview);
2475 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2477 messageview_toggle_view_real(mainwin->messageview);
2480 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2483 MainWindow *mainwin;
2486 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2487 g_return_if_fail(mainwin != NULL);
2489 type = mainwin->type ^ action;
2490 main_window_separation_change(mainwin, type);
2492 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2493 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2496 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2499 addressbook_open(NULL);
2502 static void log_window_show_cb(MainWindow *mainwin, guint action,
2505 log_window_show(mainwin->logwin);
2508 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2513 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2516 inc_all_account_mail(mainwin);
2519 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2523 if (procmsg_send_queue() < 0)
2524 alertpanel_error(_("Some errors occurred while sending queued messages."));
2526 statusbar_pop_all();
2528 for (list = folder_get_list(); list != NULL; list = list->next) {
2531 folder = list->data;
2532 if (folder->queue) {
2533 folder_item_scan(folder->queue);
2534 folderview_update_item(folder->queue, TRUE);
2539 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2541 if (mainwin->summaryview->folder_item) {
2542 if (mainwin->summaryview->folder_item->folder->account != NULL
2543 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2544 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2546 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2552 static void compose_mail_cb(MainWindow *mainwin, guint action,
2559 if (mainwin->summaryview->folder_item) {
2560 ac = mainwin->summaryview->folder_item->folder->account;
2561 if (ac && ac->protocol != A_NNTP) {
2562 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2567 if(cur_account && (cur_account->protocol != A_NNTP)) {
2568 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2572 list = account_get_list();
2573 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2574 ac = (PrefsAccount *) cur->data;
2575 if (ac->protocol != A_NNTP) {
2576 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2582 static void compose_news_cb(MainWindow *mainwin, guint action,
2585 PrefsAccount * ac = NULL;
2589 if (mainwin->summaryview->folder_item) {
2590 ac = mainwin->summaryview->folder_item->folder->account;
2591 if (ac && ac->protocol == A_NNTP) {
2592 compose_new_with_recipient
2593 (ac, mainwin->summaryview->folder_item->path);
2598 list = account_get_list();
2599 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2600 ac = (PrefsAccount *) cur->data;
2601 if (ac->protocol == A_NNTP) {
2608 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2610 summary_reply(mainwin->summaryview, (ComposeMode)action);
2613 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2615 summary_move_to(mainwin->summaryview);
2618 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2620 summary_copy_to(mainwin->summaryview);
2623 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2625 summary_delete(mainwin->summaryview);
2628 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2630 summary_open_msg(mainwin->summaryview);
2633 static void view_source_cb(MainWindow *mainwin, guint action,
2636 summary_view_source(mainwin->summaryview);
2639 static void show_all_header_cb(MainWindow *mainwin, guint action,
2642 if (mainwin->menu_lock_count) return;
2643 summary_display_msg_selected(mainwin->summaryview,
2644 GTK_CHECK_MENU_ITEM(widget)->active);
2647 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2649 summary_reedit(mainwin->summaryview);
2652 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2654 summary_mark(mainwin->summaryview);
2657 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2659 summary_unmark(mainwin->summaryview);
2662 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2665 summary_mark_as_unread(mainwin->summaryview);
2668 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2671 summary_mark_as_read(mainwin->summaryview);
2674 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2677 summary_mark_all_read(mainwin->summaryview);
2680 static void add_address_cb(MainWindow *mainwin, guint action,
2683 summary_add_address(mainwin->summaryview);
2686 static void set_charset_cb(MainWindow *mainwin, guint action,
2691 str = conv_get_charset_str((CharSet)action);
2692 g_free(prefs_common.force_charset);
2693 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2695 summary_redisplay_msg(mainwin->summaryview);
2697 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2700 static void hide_read_messages (MainWindow *mainwin, guint action,
2703 if (!mainwin->summaryview->folder_item
2704 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2706 summary_toggle_show_read_messages(mainwin->summaryview);
2709 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2711 GtkItemFactory *ifactory;
2713 if (mainwin->menu_lock_count) return;
2714 if (!mainwin->summaryview->folder_item) return;
2716 ifactory = gtk_item_factory_from_widget(widget);
2718 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2719 summary_thread_build(mainwin->summaryview);
2720 mainwin->summaryview->folder_item->threaded = TRUE;
2722 summary_unthread(mainwin->summaryview);
2723 mainwin->summaryview->folder_item->threaded = FALSE;
2727 static void set_display_item_cb(MainWindow *mainwin, guint action,
2730 prefs_summary_column_open();
2733 static void sort_summary_cb(MainWindow *mainwin, guint action,
2736 summary_sort(mainwin->summaryview, (SummarySortType)action);
2739 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2742 summary_attract_by_subject(mainwin->summaryview);
2745 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2748 summary_delete_duplicated(mainwin->summaryview);
2751 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2753 summary_filter(mainwin->summaryview);
2756 static void execute_summary_cb(MainWindow *mainwin, guint action,
2759 summary_execute(mainwin->summaryview);
2762 static void update_summary_cb(MainWindow *mainwin, guint action,
2766 FolderView *folderview = mainwin->folderview;
2768 if (!mainwin->summaryview->folder_item) return;
2769 if (!folderview->opened) return;
2771 folder_update_op_count();
2773 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2774 folderview->opened);
2777 summary_show(mainwin->summaryview, fitem, TRUE);
2780 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2782 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2785 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2787 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2790 static void prev_unread_cb(MainWindow *mainwin, guint action,
2793 summary_select_prev_unread(mainwin->summaryview);
2796 static void next_unread_cb(MainWindow *mainwin, guint action,
2799 summary_select_next_unread(mainwin->summaryview);
2802 static void prev_marked_cb(MainWindow *mainwin, guint action,
2805 summary_select_prev_marked(mainwin->summaryview);
2808 static void next_marked_cb(MainWindow *mainwin, guint action,
2811 summary_select_next_marked(mainwin->summaryview);
2814 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2817 summary_select_prev_labeled(mainwin->summaryview);
2820 static void next_labeled_cb(MainWindow *mainwin, guint action,
2823 summary_select_next_labeled(mainwin->summaryview);
2826 static void goto_folder_cb(MainWindow *mainwin, guint action,
2829 FolderItem *to_folder;
2831 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2834 folderview_select(mainwin->folderview, to_folder);
2837 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2839 messageview_copy_clipboard(mainwin->messageview);
2842 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2844 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2845 summary_select_all(mainwin->summaryview);
2846 else if (mainwin->summaryview->msg_is_toggled_on &&
2847 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2848 messageview_select_all(mainwin->messageview);
2851 static void create_filter_cb(MainWindow *mainwin, guint action,
2854 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2857 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2860 prefs_common_open();
2863 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2866 prefs_filter_open(NULL, NULL);
2869 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2872 prefs_scoring_open(NULL);
2875 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2878 prefs_filtering_open(NULL);
2881 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2884 prefs_template_open();
2887 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2890 prefs_actions_open(mainwin);
2893 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2897 new_account_cb(mainwin, 0, widget);
2899 gboolean prev_default = cur_account->is_default;
2901 prefs_account_open(cur_account);
2902 if (!prev_default && cur_account->is_default)
2903 account_set_as_default(cur_account);
2904 account_save_config_all();
2906 main_window_reflect_prefs_all();
2910 static void new_account_cb(MainWindow *mainwin, guint action,
2913 account_edit_open();
2914 if (!compose_get_compose_list()) account_add();
2917 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2919 cur_account = (PrefsAccount *)data;
2920 main_window_reflect_prefs_all();
2923 static void manual_open_cb(MainWindow *mainwin, guint action,
2926 manual_open((ManualLang)action);
2929 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2931 MainWindow *mainwin = (MainWindow *)data;
2935 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2936 LOCAL_FOLDER(folder)->rootpath,
2940 str = g_strdup_printf(_("Scanning folder %s ..."),
2941 LOCAL_FOLDER(folder)->rootpath);
2943 STATUSBAR_PUSH(mainwin, str);
2944 STATUSBAR_POP(mainwin);
2948 static void activate_compose_button (MainWindow *mainwin,
2950 ComposeButtonType type)
2952 SensitiveCond state = main_window_get_current_state(mainwin);
2954 if (style == TOOLBAR_NONE)
2957 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2958 : mainwin->compose_news_btn);
2959 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2960 : mainwin->compose_mail_btn);
2961 mainwin->compose_btn_type = type;
2964 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2966 if (mainwin->compose_btn_type != compose_btn_type)
2967 activate_compose_button(mainwin,
2968 prefs_common.toolbar_style,
2972 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
2974 MainWindow *mainwin = (MainWindow*) data;
2976 if (!mainwin) return;
2978 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
2981 #define BREAK_ON_MODIFIER_KEY() \
2982 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2984 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
2986 MainWindow *mainwin = (MainWindow*) data;
2988 if (!mainwin || !event) return;
2990 switch (event->keyval) {
2991 case GDK_Q: /* Quit */
2992 BREAK_ON_MODIFIER_KEY();
2994 app_exit_cb(mainwin, 0, NULL);
3001 #undef BREAK_ON_MODIFIER_KEY
3003 static void set_toolbar_style(MainWindow *mainwin)
3005 switch (prefs_common.toolbar_style) {
3007 gtk_widget_hide(mainwin->handlebox);
3010 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3014 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3018 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3023 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3024 gtk_widget_show(mainwin->handlebox);
3025 gtk_widget_queue_resize(mainwin->handlebox);
3027 if (prefs_common.immediate_exec)
3028 gtk_widget_hide(mainwin->exec_btn);
3030 gtk_widget_show(mainwin->exec_btn);