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 "headerwindow.h"
74 #include "logwindow.h"
75 #include "manage_window.h"
76 #include "alertpanel.h"
77 #include "statusbar.h"
78 #include "inputdialog.h"
86 #define AC_LABEL_WIDTH 240
88 #define STATUSBAR_PUSH(mainwin, str) \
90 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
91 mainwin->mainwin_cid, str); \
92 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
95 #define STATUSBAR_POP(mainwin) \
97 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
98 mainwin->mainwin_cid); \
101 /* list of all instantiated MainWindow */
102 static GList *mainwin_list = NULL;
104 static GdkCursor *watch_cursor;
106 static void main_window_show_cur_account (MainWindow *mainwin);
108 static void main_window_set_widgets (MainWindow *mainwin,
110 static void main_window_toolbar_create (MainWindow *mainwin,
111 GtkWidget *container);
113 /* callback functions */
114 static void toolbar_inc_cb (GtkWidget *widget,
116 static void toolbar_inc_all_cb (GtkWidget *widget,
118 static void toolbar_send_cb (GtkWidget *widget,
121 static void toolbar_compose_cb (GtkWidget *widget,
123 static void toolbar_compose_news_cb (GtkWidget *widget,
125 static void toolbar_compose_mail_cb (GtkWidget *widget,
127 static void toolbar_reply_cb (GtkWidget *widget,
129 static void toolbar_reply_popup_cb (GtkWidget *widget,
130 GdkEventButton *event,
132 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell,
134 static void toolbar_reply_to_all_cb (GtkWidget *widget,
136 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget,
137 GdkEventButton *event,
139 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell,
141 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
143 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
144 GdkEventButton *event,
146 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell,
148 static void toolbar_forward_cb (GtkWidget *widget,
150 static void toolbar_forward_popup_cb (GtkWidget *widget,
151 GdkEventButton *event,
153 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell,
156 static void toolbar_delete_cb (GtkWidget *widget,
158 static void toolbar_exec_cb (GtkWidget *widget,
161 static void toolbar_next_unread_cb (GtkWidget *widget,
164 static void toolbar_prefs_cb (GtkWidget *widget,
166 static void toolbar_account_cb (GtkWidget *widget,
169 static void toolbar_account_button_pressed (GtkWidget *widget,
170 GdkEventButton *event,
172 static void ac_label_button_pressed (GtkWidget *widget,
173 GdkEventButton *event,
175 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
178 static gint main_window_close_cb (GtkWidget *widget,
182 static void add_mailbox_cb (MainWindow *mainwin,
185 static void add_mbox_cb (MainWindow *mainwin,
188 static void update_folderview_cb (MainWindow *mainwin,
191 static void new_folder_cb (MainWindow *mainwin,
194 static void rename_folder_cb (MainWindow *mainwin,
197 static void delete_folder_cb (MainWindow *mainwin,
200 static void import_mbox_cb (MainWindow *mainwin,
203 static void export_mbox_cb (MainWindow *mainwin,
206 static void empty_trash_cb (MainWindow *mainwin,
210 static void save_as_cb (MainWindow *mainwin,
213 static void print_cb (MainWindow *mainwin,
216 static void app_exit_cb (MainWindow *mainwin,
220 static void search_cb (MainWindow *mainwin,
224 static void toggle_folder_cb (MainWindow *mainwin,
227 static void toggle_message_cb (MainWindow *mainwin,
230 static void toggle_toolbar_cb (MainWindow *mainwin,
233 static void toggle_statusbar_cb (MainWindow *mainwin,
236 static void toggle_expand_summaryview_cb (MainWindow *mainwin,
239 static void toggle_expand_messageview_cb (MainWindow *mainwin,
242 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
246 static void addressbook_open_cb (MainWindow *mainwin,
249 static void log_window_show_cb (MainWindow *mainwin,
253 static void inc_mail_cb (MainWindow *mainwin,
256 static void inc_all_account_mail_cb (MainWindow *mainwin,
260 static void send_queue_cb (MainWindow *mainwin,
264 static void compose_cb (MainWindow *mainwin,
267 static void compose_mail_cb(MainWindow *mainwin, guint action,
269 static void compose_news_cb(MainWindow *mainwin, guint action,
271 static void reply_cb (MainWindow *mainwin,
275 static void open_msg_cb (MainWindow *mainwin,
279 static void view_source_cb (MainWindow *mainwin,
283 static void show_all_header_cb (MainWindow *mainwin,
287 static void reedit_cb (MainWindow *mainwin,
291 static void move_to_cb (MainWindow *mainwin,
294 static void copy_to_cb (MainWindow *mainwin,
297 static void delete_cb (MainWindow *mainwin,
301 static void mark_cb (MainWindow *mainwin,
304 static void unmark_cb (MainWindow *mainwin,
308 static void mark_as_unread_cb (MainWindow *mainwin,
311 static void mark_as_read_cb (MainWindow *mainwin,
314 static void mark_all_read_cb (MainWindow *mainwin,
317 static void add_address_cb (MainWindow *mainwin,
321 static void set_charset_cb (MainWindow *mainwin,
325 static void hide_read_messages (MainWindow *mainwin,
329 static void thread_cb (MainWindow *mainwin,
332 static void set_display_item_cb (MainWindow *mainwin,
335 static void sort_summary_cb (MainWindow *mainwin,
338 static void attract_by_subject_cb(MainWindow *mainwin,
342 static void delete_duplicated_cb (MainWindow *mainwin,
345 static void filter_cb (MainWindow *mainwin,
348 static void execute_summary_cb (MainWindow *mainwin,
351 static void update_summary_cb (MainWindow *mainwin,
355 static void prev_cb (MainWindow *mainwin,
358 static void next_cb (MainWindow *mainwin,
362 static void prev_unread_cb (MainWindow *mainwin,
365 static void next_unread_cb (MainWindow *mainwin,
368 static void prev_marked_cb (MainWindow *mainwin,
371 static void next_marked_cb (MainWindow *mainwin,
374 static void prev_labeled_cb (MainWindow *mainwin,
377 static void next_labeled_cb (MainWindow *mainwin,
381 static void goto_folder_cb (MainWindow *mainwin,
385 static void copy_cb (MainWindow *mainwin,
388 static void allsel_cb (MainWindow *mainwin,
392 static void create_filter_cb (MainWindow *mainwin,
396 static void prefs_common_open_cb (MainWindow *mainwin,
399 static void prefs_filter_open_cb (MainWindow *mainwin,
402 static void prefs_scoring_open_cb (MainWindow *mainwin,
405 static void prefs_filtering_open_cb (MainWindow *mainwin,
408 static void prefs_account_open_cb(MainWindow *mainwin,
411 static void prefs_template_open_cb (MainWindow *mainwin,
414 static void prefs_actions_open_cb (MainWindow *mainwin,
417 static void new_account_cb (MainWindow *mainwin,
421 static void account_menu_cb (GtkMenuItem *menuitem,
424 static void manual_open_cb (MainWindow *mainwin,
428 static void scan_tree_func (Folder *folder,
432 static void activate_compose_button (MainWindow *mainwin,
434 ComposeButtonType type);
436 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
440 static void key_pressed (GtkWidget *widget,
444 static void set_toolbar_style(MainWindow *mainwin);
446 #define SEPARATE_ACTION 667
448 static GtkItemFactoryEntry mainwin_entries[] =
450 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
451 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
452 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
453 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
454 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
455 {N_("/_File/_Folder/Create _new folder..."),
456 NULL, new_folder_cb, 0, NULL},
457 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
458 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
459 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
460 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
461 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
462 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
463 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
464 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
465 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
466 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
468 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
469 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
470 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
471 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
472 {N_("/_Edit/_Find in current message..."),
473 "<control>F", search_cb, 0, NULL},
474 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
475 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
476 {N_("/_Edit/Actio_ns"), NULL, NULL, 0, "<Branch>"},
478 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
479 {N_("/_View/_Folder tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
480 {N_("/_View/_Message view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
481 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
482 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
483 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
484 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
485 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
486 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
487 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
488 {N_("/_View/Status _bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
489 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
490 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
491 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
492 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
493 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
494 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
495 {N_("/_View/_Sort/Sort by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
496 {N_("/_View/_Sort/Sort by _color label"),
497 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
498 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
499 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
500 {N_("/_View/_Sort/Sort by a_ttachment"),
501 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
502 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
503 {N_("/_View/_Sort/_Attract by subject"),
504 NULL, attract_by_subject_cb, 0, NULL},
505 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, NULL},
506 {N_("/_View/U_nthread view"), "<shift><control>T", thread_cb, 1, NULL},
507 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
508 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
509 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
511 #define CODESET_SEPARATOR \
512 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
513 #define CODESET_ACTION(action) \
514 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
516 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
517 {N_("/_View/_Code set/_Auto detect"),
518 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
519 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
520 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
521 CODESET_ACTION(C_US_ASCII)},
524 {N_("/_View/_Code set/Unicode (_UTF-8)"),
525 CODESET_ACTION(C_UTF_8)},
528 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
529 CODESET_ACTION(C_ISO_8859_1)},
532 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
533 CODESET_ACTION(C_ISO_8859_2)},
535 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
536 CODESET_ACTION(C_ISO_8859_13)},
537 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
538 CODESET_ACTION(C_ISO_8859_4)},
540 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
541 CODESET_ACTION(C_ISO_8859_7)},
543 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
544 CODESET_ACTION(C_ISO_8859_9)},
546 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
547 CODESET_ACTION(C_ISO_8859_5)},
548 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
549 CODESET_ACTION(C_KOI8_R)},
550 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
551 CODESET_ACTION(C_CP1251)},
554 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
555 CODESET_ACTION(C_ISO_2022_JP)},
557 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
558 CODESET_ACTION(C_ISO_2022_JP_2)},
560 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
561 CODESET_ACTION(C_EUC_JP)},
562 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
563 CODESET_ACTION(C_SHIFT_JIS)},
566 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
567 CODESET_ACTION(C_GB2312)},
568 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
569 CODESET_ACTION(C_BIG5)},
570 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
571 CODESET_ACTION(C_EUC_TW)},
572 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
573 CODESET_ACTION(C_ISO_2022_CN)},
575 {N_("/_View/_Code set/Korean (EUC-_KR)"),
576 CODESET_ACTION(C_EUC_KR)},
577 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
578 CODESET_ACTION(C_ISO_2022_KR)},
580 {N_("/_View/_Code set/Thai (TIS-620)"),
581 CODESET_ACTION(C_TIS_620)},
582 {N_("/_View/_Code set/Thai (Windows-874)"),
583 CODESET_ACTION(C_WINDOWS_874)},
586 #undef CODESET_SEPARATOR
587 #undef CODESET_ACTION
589 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
590 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
591 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
592 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
593 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
594 {N_("/_View/_Go to/P_rev unread message"),
595 "<shift>P", prev_unread_cb, 0, NULL},
596 {N_("/_View/_Go to/N_ext unread message"),
597 "<shift>N", next_unread_cb, 0, NULL},
598 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
599 {N_("/_View/_Go to/Prev _marked message"),
600 NULL, prev_marked_cb, 0, NULL},
601 {N_("/_View/_Go to/Next m_arked message"),
602 NULL, next_marked_cb, 0, NULL},
603 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
604 {N_("/_View/_Go to/Prev _labeled message"),
605 NULL, prev_labeled_cb, 0, NULL},
606 {N_("/_View/_Go to/Next la_beled message"),
607 NULL, next_labeled_cb, 0, NULL},
608 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
609 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
610 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
611 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
612 {N_("/_View/_View source"), "<control>U", view_source_cb, 0, NULL},
613 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, NULL},
614 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
615 {N_("/_View/_Update"), "<control><alt>U", update_summary_cb, 0, NULL},
617 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
618 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
619 {N_("/_Message/Get from _all accounts"),
620 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
621 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
622 {N_("/_Message/Send queued messa_ges"),
623 NULL, send_queue_cb, 0, NULL},
624 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
625 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
626 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
627 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
628 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
629 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
630 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
631 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
632 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
633 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
634 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
635 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
636 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
637 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
638 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
639 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
640 {N_("/_Message/Delete du_plicated messages"),
641 NULL, delete_duplicated_cb, 0, NULL},
642 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
643 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
644 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
645 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
646 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
647 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
648 {N_("/_Message/_Mark/Mark as rea_d"),
649 NULL, mark_as_read_cb, 0, NULL},
650 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
652 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
653 {N_("/_Tool/_Address book"), "<shift><control>A", addressbook_open_cb, 0, NULL},
654 {N_("/_Tool/Add sender to address boo_k"),
655 NULL, add_address_cb, 0, NULL},
656 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
657 {N_("/_Tool/_Filter messages"), NULL, filter_cb, 0, NULL},
658 {N_("/_Tool/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
659 {N_("/_Tool/_Create filter rule/_Automatically"),
660 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
661 {N_("/_Tool/_Create filter rule/by _From"),
662 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
663 {N_("/_Tool/_Create filter rule/by _To"),
664 NULL, create_filter_cb, FILTER_BY_TO, NULL},
665 {N_("/_Tool/_Create filter rule/by _Subject"),
666 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
667 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
668 {N_("/_Tool/E_xecute"), "X", execute_summary_cb, 0, NULL},
669 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
670 {N_("/_Tool/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
672 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
673 {N_("/_Configuration/_Common preferences..."),
674 NULL, prefs_common_open_cb, 0, NULL},
675 {N_("/_Configuration/_Filter setting..."),
676 NULL, prefs_filter_open_cb, 0, NULL},
677 {N_("/_Configuration/_Scoring ..."),
678 NULL, prefs_scoring_open_cb, 0, NULL},
679 {N_("/_Configuration/_Filtering ..."),
680 NULL, prefs_filtering_open_cb, 0, NULL},
681 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
682 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
683 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
684 {N_("/_Configuration/_Preferences for current account..."),
685 NULL, prefs_account_open_cb, 0, NULL},
686 {N_("/_Configuration/Create _new account..."),
687 NULL, new_account_cb, 0, NULL},
688 {N_("/_Configuration/_Edit accounts..."),
689 NULL, account_edit_open, 0, NULL},
690 {N_("/_Configuration/C_hange current account"),
691 NULL, NULL, 0, "<Branch>"},
693 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
694 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
695 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
696 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
697 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
698 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
700 static GtkItemFactoryEntry reply_popup_entries[] =
702 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
703 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
705 static GtkItemFactoryEntry replyall_popup_entries[] =
707 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
708 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
710 static GtkItemFactoryEntry replysender_popup_entries[] =
712 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
713 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
715 static GtkItemFactoryEntry fwd_popup_entries[] =
717 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
718 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
722 MainWindow *main_window_create(SeparateType type)
728 GtkWidget *handlebox;
729 GtkWidget *vbox_body;
730 GtkWidget *hbox_stat;
731 GtkWidget *statusbar;
732 GtkWidget *progressbar;
733 GtkWidget *statuslabel;
734 GtkWidget *ac_button;
737 FolderView *folderview;
738 SummaryView *summaryview;
739 MessageView *messageview;
740 GdkColormap *colormap;
743 guint n_menu_entries;
744 GtkItemFactory *ifactory;
747 GtkWidget *compose_popup;
748 GtkWidget *reply_popup;
749 GtkWidget *replyall_popup;
750 GtkWidget *replysender_popup;
751 GtkWidget *fwd_popup;
754 debug_print(_("Creating main window...\n"));
755 mainwin = g_new0(MainWindow, 1);
758 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
759 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
760 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
761 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
762 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
763 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
764 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
765 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
766 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
767 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
768 GTK_SIGNAL_FUNC(key_pressed), mainwin);
770 gtk_widget_realize(window);
771 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
774 gtkut_widget_set_app_icon(window);
776 vbox = gtk_vbox_new(FALSE, 0);
777 gtk_widget_show(vbox);
778 gtk_container_add(GTK_CONTAINER(window), vbox);
781 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
782 menubar = menubar_create(window, mainwin_entries,
783 n_menu_entries, "<Main>", mainwin);
784 gtk_widget_show(menubar);
785 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
787 handlebox = gtk_handle_box_new();
788 gtk_widget_show(handlebox);
789 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
791 /* create the popup menus for the reply buttons specials */
792 n_menu_entries = sizeof(reply_popup_entries) /
793 sizeof(reply_popup_entries[0]);
794 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
795 "<ReplyPopup>", mainwin);
796 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
797 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
798 n_menu_entries = sizeof(replyall_popup_entries) /
799 sizeof(replyall_popup_entries[0]);
800 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
801 "<ReplyAllPopup>", mainwin);
802 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
803 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
804 n_menu_entries = sizeof(replysender_popup_entries) /
805 sizeof(replysender_popup_entries[0]);
806 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
807 "<ReplySenderPopup>", mainwin);
808 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
809 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
810 /* create the popup menu for the forward button */
811 n_menu_entries = sizeof(fwd_popup_entries) /
812 sizeof(fwd_popup_entries[0]);
813 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
814 "<ForwardPopup>", mainwin);
815 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
816 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
818 main_window_toolbar_create(mainwin, handlebox);
820 /* vbox that contains body */
821 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
822 gtk_widget_show(vbox_body);
823 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
824 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
826 hbox_stat = gtk_hbox_new(FALSE, 2);
827 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
829 statusbar = statusbar_create();
830 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
832 progressbar = gtk_progress_bar_new();
833 gtk_widget_set_usize(progressbar, 120, 1);
834 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
836 statuslabel = gtk_label_new("");
837 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
839 ac_button = gtk_button_new();
840 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
841 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
842 gtk_widget_set_usize(ac_button, -1, 1);
843 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
844 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
845 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
847 ac_label = gtk_label_new("");
848 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
850 gtk_widget_show_all(hbox_stat);
853 mainwin->folderview = folderview = folderview_create();
854 mainwin->summaryview = summaryview = summary_create();
855 mainwin->messageview = messageview = messageview_create();
856 mainwin->headerwin = header_window_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->headerwin = mainwin->headerwin;
866 summaryview->window = window;
868 messageview->mainwin = mainwin;
870 mainwin->window = window;
871 mainwin->vbox = vbox;
872 mainwin->menubar = menubar;
873 mainwin->handlebox = handlebox;
874 mainwin->vbox_body = vbox_body;
875 mainwin->hbox_stat = hbox_stat;
876 mainwin->statusbar = statusbar;
877 mainwin->progressbar = progressbar;
878 mainwin->statuslabel = statuslabel;
879 mainwin->ac_button = ac_button;
880 mainwin->ac_label = ac_label;
881 mainwin->reply_popup = reply_popup;
882 mainwin->replyall_popup = replyall_popup;
883 mainwin->replysender_popup = replysender_popup;
884 mainwin->fwd_popup = fwd_popup;
886 /* set context IDs for status bar */
887 mainwin->mainwin_cid = gtk_statusbar_get_context_id
888 (GTK_STATUSBAR(statusbar), "Main Window");
889 mainwin->folderview_cid = gtk_statusbar_get_context_id
890 (GTK_STATUSBAR(statusbar), "Folder View");
891 mainwin->summaryview_cid = gtk_statusbar_get_context_id
892 (GTK_STATUSBAR(statusbar), "Summary View");
894 /* allocate colors for summary view and folder view */
895 summaryview->color_marked.red = summaryview->color_marked.green = 0;
896 summaryview->color_marked.blue = (guint16)65535;
898 summaryview->color_dim.red = summaryview->color_dim.green =
899 summaryview->color_dim.blue = COLOR_DIM;
901 folderview->color_new.red = (guint16)55000;
902 folderview->color_new.green = folderview->color_new.blue = 15000;
904 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
905 &folderview->color_op);
907 summaryview->color_important.red = 0;
908 summaryview->color_marked.green = 0;
909 summaryview->color_important.blue = (guint16)65535;
911 color[0] = summaryview->color_marked;
912 color[1] = summaryview->color_dim;
913 color[2] = folderview->color_new;
914 color[3] = folderview->color_op;
916 colormap = gdk_window_get_colormap(window->window);
917 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
918 for (i = 0; i < 4; i++) {
919 if (success[i] == FALSE)
920 g_warning(_("MainWindow: color allocation %d failed\n"), i);
923 debug_print(_("done.\n"));
925 main_window_set_widgets(mainwin, type);
928 ifactory = gtk_item_factory_from_widget(menubar);
929 menuitem = gtk_item_factory_get_item
930 (ifactory, "/View/Code set/Auto detect");
931 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
933 switch (prefs_common.toolbar_style) {
935 menuitem = gtk_item_factory_get_item
936 (ifactory, "/View/Toolbar/None");
939 menuitem = gtk_item_factory_get_item
940 (ifactory, "/View/Toolbar/Icon");
943 menuitem = gtk_item_factory_get_item
944 (ifactory, "/View/Toolbar/Text");
947 menuitem = gtk_item_factory_get_item
948 (ifactory, "/View/Toolbar/Icon and text");
950 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
952 gtk_widget_hide(mainwin->hbox_stat);
953 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
954 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
955 prefs_common.show_statusbar);
956 #if 0 /* FIXED SEPARATE WINDOWS */
957 /* Message view and Folder tree are always shown at startup
958 * make that in the menu visible */
959 menuitem = gtk_item_factory_get_item(ifactory, "/View/Message view");
960 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
961 menuitem = gtk_item_factory_get_item(ifactory, "/View/Folder tree");
962 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
964 /* set the check of the SEPARATE_xxx menu items. we also need the main window
965 * as a property and pass the action type to the callback */
966 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
968 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
969 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
970 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
971 GUINT_TO_POINTER(SEPARATE_FOLDER));
973 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
975 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
976 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
977 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
978 GUINT_TO_POINTER(SEPARATE_MESSAGE));
980 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
981 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
984 menu_set_sensitive(ifactory, "/View/Thread view",
985 prefs_common.enable_thread ? FALSE : TRUE);
986 menu_set_sensitive(ifactory, "/View/Unthread view",
987 prefs_common.enable_thread ? TRUE : FALSE);
989 /* set account selection menu */
990 ac_menu = gtk_item_factory_get_widget
991 (ifactory, "/Configuration/Change current account");
992 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
993 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
994 mainwin->ac_menu = ac_menu;
996 main_window_set_toolbar_sensitive(mainwin);
998 /* Create actions menu */
999 update_mainwin_actions_menu(ifactory, mainwin);
1001 /* show main window */
1002 gtk_widget_set_uposition(mainwin->window,
1003 prefs_common.mainwin_x,
1004 prefs_common.mainwin_y);
1005 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1006 prefs_common.mainwin_height);
1007 gtk_widget_show(mainwin->window);
1009 /* initialize views */
1010 folderview_init(folderview);
1011 summary_init(summaryview);
1012 messageview_init(messageview);
1013 header_window_init(mainwin->headerwin);
1014 log_window_init(mainwin->logwin);
1016 mainwin->lock_count = 0;
1017 mainwin->cursor_count = 0;
1020 watch_cursor = gdk_cursor_new(GDK_WATCH);
1022 mainwin_list = g_list_append(mainwin_list, mainwin);
1027 void main_window_cursor_wait(MainWindow *mainwin)
1030 if (mainwin->cursor_count == 0)
1031 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1033 mainwin->cursor_count++;
1038 void main_window_cursor_normal(MainWindow *mainwin)
1040 if (mainwin->cursor_count)
1041 mainwin->cursor_count--;
1043 if (mainwin->cursor_count == 0)
1044 gdk_window_set_cursor(mainwin->window->window, NULL);
1049 /* lock / unlock the user-interface */
1050 void main_window_lock(MainWindow *mainwin)
1052 if (mainwin->lock_count == 0)
1053 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1055 mainwin->lock_count++;
1057 main_window_set_menu_sensitive(mainwin);
1058 main_window_set_toolbar_sensitive(mainwin);
1061 void main_window_unlock(MainWindow *mainwin)
1063 if (mainwin->lock_count)
1064 mainwin->lock_count--;
1066 main_window_set_menu_sensitive(mainwin);
1067 main_window_set_toolbar_sensitive(mainwin);
1069 if (mainwin->lock_count == 0)
1070 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1073 void main_window_reflect_prefs_all(void)
1076 MainWindow *mainwin;
1078 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1079 mainwin = (MainWindow *)cur->data;
1081 main_window_show_cur_account(mainwin);
1082 main_window_set_menu_sensitive(mainwin);
1083 main_window_set_toolbar_sensitive(mainwin);
1086 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1087 mainwin->toolbar = NULL;
1088 main_window_toolbar_create(mainwin, mainwin->handlebox);
1089 set_toolbar_style(mainwin);
1090 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1091 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1092 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1094 summary_redisplay_msg(mainwin->summaryview);
1095 headerview_set_visibility(mainwin->messageview->headerview,
1096 prefs_common.display_header_pane);
1100 void main_window_set_summary_column(void)
1103 MainWindow *mainwin;
1105 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1106 mainwin = (MainWindow *)cur->data;
1107 summary_set_column_order(mainwin->summaryview);
1111 void main_window_set_account_menu(GList *account_list)
1113 GList *cur, *cur_ac, *cur_item;
1114 GtkWidget *menuitem;
1115 MainWindow *mainwin;
1116 PrefsAccount *ac_prefs;
1118 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1119 mainwin = (MainWindow *)cur->data;
1121 /* destroy all previous menu item */
1122 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1123 while (cur_item != NULL) {
1124 GList *next = cur_item->next;
1125 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1129 for (cur_ac = account_list; cur_ac != NULL;
1130 cur_ac = cur_ac->next) {
1131 ac_prefs = (PrefsAccount *)cur_ac->data;
1133 menuitem = gtk_menu_item_new_with_label
1134 (ac_prefs->account_name
1135 ? ac_prefs->account_name : _("Untitled"));
1136 gtk_widget_show(menuitem);
1137 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1138 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1139 GTK_SIGNAL_FUNC(account_menu_cb),
1145 static void main_window_show_cur_account(MainWindow *mainwin)
1150 ac_name = g_strdup(cur_account
1151 ? (cur_account->account_name
1152 ? cur_account->account_name : _("Untitled"))
1156 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1158 buf = g_strdup(PROG_VERSION);
1159 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1162 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1163 gtk_widget_queue_resize(mainwin->ac_button);
1168 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1170 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1171 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1172 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1174 if (mainwin->type == type) return;
1176 /* remove widgets from those containers */
1177 gtk_widget_ref(folder_wid);
1178 gtk_widget_ref(summary_wid);
1179 gtk_widget_ref(message_wid);
1180 gtkut_container_remove
1181 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1182 gtkut_container_remove
1183 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1184 gtkut_container_remove
1185 (GTK_CONTAINER(message_wid->parent), message_wid);
1187 /* clean containers */
1188 switch (mainwin->type) {
1190 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1192 case SEPARATE_FOLDER:
1193 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1194 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1196 case SEPARATE_MESSAGE:
1197 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1198 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1201 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1202 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1206 gtk_widget_hide(mainwin->window);
1207 main_window_set_widgets(mainwin, type);
1208 gtk_widget_show(mainwin->window);
1210 gtk_widget_unref(folder_wid);
1211 gtk_widget_unref(summary_wid);
1212 gtk_widget_unref(message_wid);
1215 void main_window_get_size(MainWindow *mainwin)
1217 GtkAllocation *allocation;
1219 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1221 prefs_common.summaryview_width = allocation->width;
1223 if (mainwin->summaryview->msg_is_toggled_on)
1224 prefs_common.summaryview_height = allocation->height;
1226 prefs_common.mainview_width = allocation->width;
1228 allocation = &mainwin->window->allocation;
1230 prefs_common.mainview_height = allocation->height;
1231 prefs_common.mainwin_width = allocation->width;
1232 prefs_common.mainwin_height = allocation->height;
1234 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1236 prefs_common.folderview_width = allocation->width;
1237 prefs_common.folderview_height = allocation->height;
1240 void main_window_get_position(MainWindow *mainwin)
1244 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1246 prefs_common.mainview_x = x;
1247 prefs_common.mainview_y = y;
1248 prefs_common.mainwin_x = x;
1249 prefs_common.mainwin_y = y;
1251 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1254 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1260 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1261 folder = FOLDER(list->data);
1262 if (folder && folder->trash && folder->trash->total > 0)
1266 if (!has_trash) return;
1269 if (alertpanel(_("Empty trash"),
1270 _("Empty all messages in trash?"),
1271 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1273 manage_window_focus_in(mainwin->window, NULL, NULL);
1276 procmsg_empty_trash();
1278 for (list = folder_get_list(); list != NULL; list = list->next) {
1279 folder = list->data;
1280 if (folder && folder->trash && folder->trash->total != 0) {
1281 folder_item_scan(folder->trash);
1282 folderview_update_item(folder->trash, TRUE);
1286 if (mainwin->summaryview->folder_item &&
1287 mainwin->summaryview->folder_item->stype == F_TRASH)
1288 gtk_widget_grab_focus(mainwin->folderview->ctree);
1291 void main_window_add_mailbox(MainWindow *mainwin)
1296 path = input_dialog(_("Add mailbox"),
1297 _("Input the location of mailbox.\n"
1298 "If the existing mailbox is specified, it will be\n"
1299 "scanned automatically."),
1302 if (folder_find_from_path(path)) {
1303 alertpanel_error(_("The mailbox `%s' already exists."), path);
1307 if (!strcmp(path, "Mail"))
1308 folder = folder_new(F_MH, _("Mailbox"), path);
1310 folder = folder_new(F_MH, g_basename(path), path);
1313 if (folder->create_tree(folder) < 0) {
1314 alertpanel_error(_("Creation of the mailbox failed.\n"
1315 "Maybe some files already exist, or you don't have the permission to write there."));
1316 folder_destroy(folder);
1321 folder_set_ui_func(folder, scan_tree_func, mainwin);
1322 folder->scan_tree(folder);
1323 folder_set_ui_func(folder, NULL, NULL);
1325 folderview_set(mainwin->folderview);
1328 void main_window_add_mbox(MainWindow *mainwin)
1334 path = input_dialog(_("Add mbox mailbox"),
1335 _("Input the location of mailbox."),
1340 if (folder_find_from_path(path)) {
1341 alertpanel_error(_("The mailbox `%s' already exists."), path);
1347 if (!strcmp(path, "Mail"))
1348 folder = folder_new(F_MBOX, _("Mailbox"), path);
1352 folder = folder_new(F_MBOX, g_basename(path), path);
1355 if (folder->create_tree(folder) < 0) {
1356 alertpanel_error(_("Creation of the mailbox failed."));
1357 folder_destroy(folder);
1363 item = folder_item_new(folder->name, NULL);
1364 item->folder = folder;
1365 folder->node = g_node_new(item);
1367 folder->create_folder(folder, item, "inbox");
1368 folder->create_folder(folder, item, "outbox");
1369 folder->create_folder(folder, item, "queue");
1370 folder->create_folder(folder, item, "draft");
1371 folder->create_folder(folder, item, "trash");
1373 folderview_set(mainwin->folderview);
1378 M_UNLOCKED = 1 << 0,
1379 M_MSG_EXIST = 1 << 1,
1380 M_TARGET_EXIST = 1 << 2,
1381 M_SINGLE_TARGET_EXIST = 1 << 3,
1383 M_ALLOW_REEDIT = 1 << 5,
1384 M_HAVE_ACCOUNT = 1 << 6,
1385 M_THREADED = 1 << 7,
1386 M_UNTHREADED = 1 << 8,
1387 M_ALLOW_DELETE = 1 << 9,
1389 M_HAVE_NEWS_ACCOUNT = 1 << 11,
1390 M_HIDE_READ_MSG = 1 << 12
1393 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1395 SensitiveCond state = 0;
1396 SummarySelection selection;
1397 FolderItem *item = mainwin->summaryview->folder_item;
1398 GList *account_list = account_get_list();
1400 selection = summary_get_selection_type(mainwin->summaryview);
1402 if (mainwin->lock_count == 0)
1403 state |= M_UNLOCKED;
1404 if (selection != SUMMARY_NONE)
1405 state |= M_MSG_EXIST;
1409 state |= M_THREADED;
1411 state |= M_UNTHREADED;
1412 if (item->folder->type != F_NEWS)
1413 state |= M_ALLOW_DELETE;
1415 if (selection == SUMMARY_NONE && item->hide_read_msgs
1416 || selection != SUMMARY_NONE)
1417 state |= M_HIDE_READ_MSG;
1419 if (selection == SUMMARY_SELECTED_SINGLE ||
1420 selection == SUMMARY_SELECTED_MULTIPLE)
1421 state |= M_TARGET_EXIST;
1422 if (selection == SUMMARY_SELECTED_SINGLE)
1423 state |= M_SINGLE_TARGET_EXIST;
1424 if (mainwin->summaryview->folder_item &&
1425 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1427 if (selection == SUMMARY_SELECTED_SINGLE &&
1429 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1430 item->stype == F_QUEUE)))
1431 state |= M_ALLOW_REEDIT;
1433 state |= M_HAVE_ACCOUNT;
1435 for ( ; account_list != NULL; account_list = account_list->next) {
1436 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1437 state |= M_HAVE_NEWS_ACCOUNT;
1445 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1447 SensitiveCond state;
1456 entry[0].widget = mainwin->get_btn;
1457 entry[0].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1458 entry[1].widget = mainwin->getall_btn;
1459 entry[1].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1460 entry[2].widget = mainwin->compose_news_btn;
1461 entry[2].cond = M_HAVE_NEWS_ACCOUNT;
1462 entry[3].widget = mainwin->reply_btn;
1463 entry[3].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1464 entry[4].widget = mainwin->replyall_btn;
1465 entry[4].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1466 entry[5].widget = mainwin->replysender_btn;
1467 entry[5].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1468 entry[6].widget = mainwin->fwd_btn;
1469 entry[6].cond = M_HAVE_ACCOUNT|M_TARGET_EXIST;
1470 /* entry[6].widget = mainwin->prefs_btn;
1471 entry[6].cond = M_UNLOCKED;
1472 entry[7].widget = mainwin->account_btn;
1473 entry[7].cond = M_UNLOCKED; */
1474 entry[7].widget = mainwin->next_btn;
1475 entry[7].cond = M_MSG_EXIST;
1476 entry[8].widget = mainwin->delete_btn;
1477 entry[8].cond = M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED;
1478 entry[9].widget = mainwin->exec_btn;
1479 entry[9].cond = M_MSG_EXIST|M_EXEC|M_UNLOCKED;
1480 entry[10].widget = NULL;
1483 state = main_window_get_current_state(mainwin);
1485 for (i = 0; entry[i].widget != NULL; i++) {
1486 sensitive = ((entry[i].cond & state) == entry[i].cond);
1487 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1490 activate_compose_button(mainwin,
1491 prefs_common.toolbar_style,
1492 mainwin->compose_btn_type);
1495 void main_window_set_menu_sensitive(MainWindow *mainwin)
1497 GtkItemFactory *ifactory;
1498 SensitiveCond state;
1502 static const struct {
1506 {"/File/Add mailbox..." , M_UNLOCKED},
1507 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1508 {"/File/Rescan folder tree" , M_UNLOCKED},
1509 {"/File/Folder" , M_UNLOCKED},
1510 {"/File/Import mbox file..." , M_UNLOCKED},
1511 {"/File/Export to mbox file...", M_UNLOCKED},
1512 {"/File/Empty trash" , M_UNLOCKED},
1513 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1514 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1515 /* {"/File/Close", M_UNLOCKED}, */
1516 {"/File/Exit" , M_UNLOCKED},
1518 {"/Edit/Actions" , M_MSG_EXIST},
1519 {"/View/Sort" , M_MSG_EXIST},
1520 {"/View/Thread view" , M_UNTHREADED},
1521 {"/View/Unthread view" , M_THREADED},
1522 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1523 {"/View/Go to/Prev message" , M_MSG_EXIST},
1524 {"/View/Go to/Next message" , M_MSG_EXIST},
1525 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1526 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1527 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1528 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1529 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1530 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1531 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1532 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1533 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1535 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1536 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1537 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1538 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1539 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1540 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1541 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1542 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1543 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1544 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1545 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1546 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1547 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1548 {"/Message/Mark" , M_TARGET_EXIST},
1549 {"/Message/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1551 {"/Tool/Add sender to address book", M_SINGLE_TARGET_EXIST},
1552 {"/Tool/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1553 {"/Tool/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1554 {"/Tool/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1556 {"/Configuration", M_UNLOCKED},
1561 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1562 state = main_window_get_current_state(mainwin);
1564 for (i = 0; entry[i].entry != NULL; i++) {
1565 sensitive = ((entry[i].cond & state) == entry[i].cond);
1566 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1570 void main_window_popup(MainWindow *mainwin)
1576 gdk_window_get_origin(mainwin->window->window, &x, &y);
1577 sx = gdk_screen_width();
1578 sy = gdk_screen_height();
1579 x %= sx; if (x < 0) x = 0;
1580 y %= sy; if (y < 0) y = 0;
1581 gdk_window_move(mainwin->window->window, x, y);
1582 gdk_window_raise(mainwin->window->window);
1583 gdk_window_show(mainwin->window->window);
1585 debug_print("window position: x = %d, y = %d\n", x, y);
1587 switch (mainwin->type) {
1588 case SEPARATE_FOLDER:
1589 widget = mainwin->win.sep_folder.folderwin;
1590 gdk_window_get_origin(widget->window, &x, &y);
1591 x %= sx; if (x < 0) x = 0;
1592 y %= sy; if (y < 0) y = 0;
1593 gdk_window_move(widget->window, x, y);
1594 gdk_window_raise(widget->window);
1596 case SEPARATE_MESSAGE:
1597 widget = mainwin->win.sep_message.messagewin;
1598 gdk_window_get_origin(widget->window, &x, &y);
1599 x %= sx; if (x < 0) x = 0;
1600 y %= sy; if (y < 0) y = 0;
1601 gdk_window_move(widget->window, x, y);
1602 gdk_window_raise(widget->window);
1605 widget = mainwin->win.sep_both.folderwin;
1606 gdk_window_get_origin(widget->window, &x, &y);
1607 x %= sx; if (x < 0) x = 0;
1608 y %= sy; if (y < 0) y = 0;
1609 gdk_window_move(widget->window, x, y);
1610 gdk_window_raise(widget->window);
1611 widget = mainwin->win.sep_both.messagewin;
1612 gdk_window_get_origin(widget->window, &x, &y);
1613 x %= sx; if (x < 0) x = 0;
1614 y %= sy; if (y < 0) y = 0;
1615 gdk_window_move(widget->window, x, y);
1616 gdk_window_raise(widget->window);
1623 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1625 GtkWidget *folderwin = NULL;
1626 GtkWidget *messagewin = NULL;
1629 GtkWidget *vbox_body = mainwin->vbox_body;
1630 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1631 GtkWidget *menuitem;
1633 debug_print(_("Setting widgets..."));
1635 /* create separated window(s) if needed */
1636 if (type & SEPARATE_FOLDER) {
1637 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1638 gtk_window_set_title(GTK_WINDOW(folderwin),
1639 _("Sylpheed - Folder View"));
1640 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1641 "folder_view", "Sylpheed");
1642 gtk_window_set_policy(GTK_WINDOW(folderwin),
1644 gtk_widget_set_usize(folderwin, -1,
1645 prefs_common.mainview_height);
1646 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1648 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1649 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1652 if (type & SEPARATE_MESSAGE) {
1653 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1654 gtk_window_set_title(GTK_WINDOW(messagewin),
1655 _("Sylpheed - Message View"));
1656 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1657 "message_view", "Sylpheed");
1658 gtk_window_set_policy(GTK_WINDOW(messagewin),
1660 gtk_widget_set_usize
1661 (messagewin, prefs_common.mainview_width,
1662 prefs_common.mainview_height
1663 - prefs_common.summaryview_height
1664 + DEFAULT_HEADERVIEW_HEIGHT);
1665 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1667 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1668 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1674 hpaned = gtk_hpaned_new();
1675 gtk_widget_show(hpaned);
1676 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1677 gtk_paned_add1(GTK_PANED(hpaned),
1678 GTK_WIDGET_PTR(mainwin->folderview));
1680 vpaned = gtk_vpaned_new();
1681 if (mainwin->summaryview->msg_is_toggled_on) {
1682 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1683 gtk_paned_add1(GTK_PANED(vpaned),
1684 GTK_WIDGET_PTR(mainwin->summaryview));
1686 gtk_paned_add2(GTK_PANED(hpaned),
1687 GTK_WIDGET_PTR(mainwin->summaryview));
1688 gtk_widget_ref(vpaned);
1690 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1691 prefs_common.summaryview_width,
1692 prefs_common.summaryview_height);
1693 gtk_paned_add2(GTK_PANED(vpaned),
1694 GTK_WIDGET_PTR(mainwin->messageview));
1695 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1696 prefs_common.mainview_width, -1);
1697 gtk_widget_set_usize(mainwin->window,
1698 prefs_common.folderview_width +
1699 prefs_common.mainview_width,
1700 prefs_common.mainwin_height);
1701 gtk_widget_show_all(vpaned);
1703 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1704 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1705 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1706 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1707 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1708 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1710 mainwin->win.sep_none.hpaned = hpaned;
1711 mainwin->win.sep_none.vpaned = vpaned;
1713 case SEPARATE_FOLDER:
1714 vpaned = gtk_vpaned_new();
1715 if (mainwin->summaryview->msg_is_toggled_on) {
1716 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1718 gtk_paned_add1(GTK_PANED(vpaned),
1719 GTK_WIDGET_PTR(mainwin->summaryview));
1721 gtk_box_pack_start(GTK_BOX(vbox_body),
1722 GTK_WIDGET_PTR(mainwin->summaryview),
1724 gtk_widget_ref(vpaned);
1726 gtk_paned_add2(GTK_PANED(vpaned),
1727 GTK_WIDGET_PTR(mainwin->messageview));
1728 gtk_widget_show_all(vpaned);
1729 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1730 prefs_common.summaryview_width,
1731 prefs_common.summaryview_height);
1732 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1733 prefs_common.mainview_width, -1);
1734 gtk_widget_set_usize(mainwin->window,
1735 prefs_common.mainview_width,
1736 prefs_common.mainview_height);
1738 gtk_container_add(GTK_CONTAINER(folderwin),
1739 GTK_WIDGET_PTR(mainwin->folderview));
1741 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1742 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1744 mainwin->win.sep_folder.folderwin = folderwin;
1745 mainwin->win.sep_folder.vpaned = vpaned;
1747 gtk_widget_show_all(folderwin);
1749 case SEPARATE_MESSAGE:
1750 hpaned = gtk_hpaned_new();
1751 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1753 gtk_paned_add1(GTK_PANED(hpaned),
1754 GTK_WIDGET_PTR(mainwin->folderview));
1755 gtk_paned_add2(GTK_PANED(hpaned),
1756 GTK_WIDGET_PTR(mainwin->summaryview));
1757 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1758 prefs_common.summaryview_width,
1759 prefs_common.summaryview_height);
1760 gtk_widget_set_usize(mainwin->window,
1761 prefs_common.folderview_width +
1762 prefs_common.mainview_width,
1763 prefs_common.mainwin_height);
1764 gtk_widget_show_all(hpaned);
1765 gtk_container_add(GTK_CONTAINER(messagewin),
1766 GTK_WIDGET_PTR(mainwin->messageview));
1768 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1769 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1770 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1771 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1773 mainwin->win.sep_message.messagewin = messagewin;
1774 mainwin->win.sep_message.hpaned = hpaned;
1776 gtk_widget_show_all(messagewin);
1779 gtk_box_pack_start(GTK_BOX(vbox_body),
1780 GTK_WIDGET_PTR(mainwin->summaryview),
1782 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1783 prefs_common.summaryview_width,
1784 prefs_common.summaryview_height);
1785 gtk_widget_set_usize(mainwin->window,
1786 prefs_common.mainview_width,
1787 prefs_common.mainwin_height);
1788 gtk_container_add(GTK_CONTAINER(folderwin),
1789 GTK_WIDGET_PTR(mainwin->folderview));
1790 gtk_container_add(GTK_CONTAINER(messagewin),
1791 GTK_WIDGET_PTR(mainwin->messageview));
1793 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1794 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1796 mainwin->win.sep_both.folderwin = folderwin;
1797 mainwin->win.sep_both.messagewin = messagewin;
1799 gtk_widget_show_all(folderwin);
1800 gtk_widget_show_all(messagewin);
1804 mainwin->type = type;
1806 debug_print(_("done.\n"));
1809 static void main_window_toolbar_create(MainWindow *mainwin,
1810 GtkWidget *container)
1813 GtkWidget *icon_wid;
1815 GtkWidget *getall_btn;
1816 GtkWidget *compose_mail_btn;
1817 GtkWidget *compose_news_btn;
1818 GtkWidget *reply_btn;
1819 GtkWidget *replyall_btn;
1820 GtkWidget *replysender_btn;
1822 GtkWidget *send_btn;
1824 GtkWidget *prefs_btn;
1825 GtkWidget *account_btn;
1827 GtkWidget *next_btn;
1828 GtkWidget *delete_btn;
1829 GtkWidget *exec_btn;
1831 GtkTooltips *tooltips;
1833 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1835 gtk_container_add(GTK_CONTAINER(container), toolbar);
1836 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1837 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1838 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1839 GTK_TOOLBAR_SPACE_LINE);
1841 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1842 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1844 _("Get new mail from current account"),
1846 icon_wid, toolbar_inc_cb, mainwin);
1847 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1848 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1850 _("Get new mail from all accounts"),
1856 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1858 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1859 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1861 _("Send queued message(s)"),
1867 /* insert compose mail button widget */
1868 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1869 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1871 _("Compose an email message"),
1874 toolbar_compose_mail_cb,
1877 /* insert compose news button widget */
1878 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1879 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1881 _("Compose a news message"),
1884 toolbar_compose_news_cb,
1887 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1891 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1892 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1894 _("Reply to the message - Right button: more options"),
1900 /* replyall button */
1902 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1903 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1905 _("Reply to all - Right button: more options"),
1908 toolbar_reply_to_all_cb,
1911 /* reply to sender button */
1912 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1913 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1915 _("Reply to sender - Right button: more options"),
1918 toolbar_reply_to_sender_cb,
1921 /* forward button */
1922 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1923 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1925 _("Forward the message - Right button: more options"),
1931 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1933 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1934 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1936 _("Delete the message"),
1942 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1943 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1945 _("Execute marked process"),
1951 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
1952 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1954 _("Next unread message"),
1957 toolbar_next_unread_cb,
1961 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1963 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
1964 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1966 _("Common preference"),
1971 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
1972 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1974 _("Account setting"),
1979 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1980 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1984 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
1985 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
1988 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
1989 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
1992 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
1993 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
1996 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
1997 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2001 mainwin->toolbar = toolbar;
2002 mainwin->get_btn = get_btn;
2003 mainwin->getall_btn = getall_btn;
2004 mainwin->compose_mail_btn = compose_mail_btn;
2005 mainwin->compose_news_btn = compose_news_btn;
2006 mainwin->reply_btn = reply_btn;
2007 mainwin->replyall_btn = replyall_btn;
2008 mainwin->replysender_btn = replysender_btn;
2009 mainwin->fwd_btn = fwd_btn;
2010 mainwin->send_btn = send_btn;
2012 mainwin->prefs_btn = prefs_btn;
2013 mainwin->account_btn = account_btn;
2015 mainwin->next_btn = next_btn;
2016 mainwin->delete_btn = delete_btn;
2017 mainwin->exec_btn = exec_btn;
2019 gtk_widget_show_all(toolbar);
2022 /* callback functions */
2023 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2025 MainWindow *mainwindow = (MainWindow *) data;
2029 if (event->button == 3) {
2030 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2031 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2032 menu_button_position, widget,
2033 event->button, event->time);
2037 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2039 MainWindow *mainwin = (MainWindow *)data;
2041 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2042 manage_window_focus_in(mainwin->window, NULL, NULL);
2045 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2047 MainWindow *mainwindow = (MainWindow *) data;
2051 if (event->button == 3) {
2052 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2053 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2054 menu_button_position, widget,
2055 event->button, event->time);
2059 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2061 MainWindow *mainwin = (MainWindow *)data;
2063 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2064 manage_window_focus_in(mainwin->window, NULL, NULL);
2067 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2069 MainWindow *mainwindow = (MainWindow *) data;
2070 GtkWidget *replysender_menu, *replysender_item;
2074 if (event->button == 3) {
2075 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2076 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2077 menu_button_position, widget,
2078 event->button, event->time);
2082 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2084 MainWindow *mainwin = (MainWindow *)data;
2086 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2087 manage_window_focus_in(mainwin->window, NULL, NULL);
2090 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2092 MainWindow *mainwindow = (MainWindow *) data;
2096 if (event->button == 3) {
2097 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2098 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2099 menu_button_position, widget,
2100 event->button, event->time);
2104 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2106 MainWindow *mainwin = (MainWindow *)data;
2108 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2109 manage_window_focus_in(mainwin->window, NULL, NULL);
2112 static void toolbar_inc_cb (GtkWidget *widget,
2115 MainWindow *mainwin = (MainWindow *)data;
2117 inc_mail_cb(mainwin, 0, NULL);
2120 static void toolbar_inc_all_cb (GtkWidget *widget,
2123 MainWindow *mainwin = (MainWindow *)data;
2125 inc_all_account_mail_cb(mainwin, 0, NULL);
2128 static void toolbar_send_cb (GtkWidget *widget,
2131 MainWindow *mainwin = (MainWindow *)data;
2133 send_queue_cb(mainwin, 0, NULL);
2136 static void toolbar_compose_cb (GtkWidget *widget,
2139 MainWindow *mainwin = (MainWindow *)data;
2141 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2142 compose_cb(mainwin, 0, NULL);
2144 compose_news_cb(mainwin, 0, NULL);
2147 static void toolbar_compose_news_cb (GtkWidget *widget,
2150 MainWindow *mainwin = (MainWindow *)data;
2152 compose_news_cb(mainwin, 0, NULL);
2155 static void toolbar_compose_mail_cb (GtkWidget *widget,
2158 MainWindow *mainwin = (MainWindow *)data;
2160 compose_mail_cb(mainwin, 0, NULL);
2163 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2165 MainWindow *mainwin = (MainWindow *)data;
2168 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2169 : COMPOSE_REPLY_WITHOUT_QUOTE,
2173 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2175 MainWindow *mainwin = (MainWindow *)data;
2178 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2179 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2184 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2186 MainWindow *mainwin = (MainWindow *)data;
2189 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2190 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2194 static void toolbar_forward_cb (GtkWidget *widget,
2197 MainWindow *mainwin = (MainWindow *)data;
2199 if (prefs_common.forward_as_attachment)
2200 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2202 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2205 static void toolbar_delete_cb (GtkWidget *widget,
2208 MainWindow *mainwin = (MainWindow *)data;
2210 summary_delete(mainwin->summaryview);
2213 static void toolbar_exec_cb (GtkWidget *widget,
2216 MainWindow *mainwin = (MainWindow *)data;
2218 summary_execute(mainwin->summaryview);
2221 static void toolbar_next_unread_cb (GtkWidget *widget,
2224 MainWindow *mainwin = (MainWindow *)data;
2226 next_unread_cb(mainwin, 0, NULL);
2229 static void toolbar_prefs_cb (GtkWidget *widget,
2232 prefs_common_open();
2235 static void toolbar_account_cb (GtkWidget *widget,
2238 MainWindow *mainwin = (MainWindow *)data;
2240 prefs_account_open_cb(mainwin, 0, NULL);
2243 static void toolbar_account_button_pressed(GtkWidget *widget,
2244 GdkEventButton *event,
2247 MainWindow *mainwin = (MainWindow *)data;
2250 if (event->button != 3) return;
2252 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2253 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2256 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2257 menu_button_position, widget,
2258 event->button, event->time);
2261 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2264 MainWindow *mainwin = (MainWindow *)data;
2268 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2269 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2272 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2273 menu_button_position, widget,
2274 event->button, event->time);
2277 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2279 MainWindow *mainwin = (MainWindow *)data;
2282 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2283 if (!button) return;
2284 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2285 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2286 manage_window_focus_in(mainwin->window, NULL, NULL);
2289 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2292 MainWindow *mainwin = (MainWindow *)data;
2294 if (mainwin->lock_count == 0)
2295 app_exit_cb(data, 0, widget);
2300 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2303 main_window_add_mailbox(mainwin);
2306 static void add_mbox_cb(MainWindow *mainwin, guint action,
2309 main_window_add_mbox(mainwin);
2312 static void update_folderview_cb(MainWindow *mainwin, guint action,
2315 summary_show(mainwin->summaryview, NULL, FALSE);
2316 folderview_update_all();
2319 static void new_folder_cb(MainWindow *mainwin, guint action,
2322 folderview_new_folder(mainwin->folderview);
2325 static void rename_folder_cb(MainWindow *mainwin, guint action,
2328 folderview_rename_folder(mainwin->folderview);
2331 static void delete_folder_cb(MainWindow *mainwin, guint action,
2334 folderview_delete_folder(mainwin->folderview);
2337 static void import_mbox_cb(MainWindow *mainwin, guint action,
2340 import_mbox(mainwin->summaryview->folder_item);
2343 static void export_mbox_cb(MainWindow *mainwin, guint action,
2346 export_mbox(mainwin->summaryview->folder_item);
2349 static void empty_trash_cb(MainWindow *mainwin, guint action,
2352 main_window_empty_trash(mainwin, TRUE);
2355 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2357 summary_save_as(mainwin->summaryview);
2360 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2362 summary_print(mainwin->summaryview);
2365 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2367 if (prefs_common.confirm_on_exit) {
2368 if (alertpanel(_("Exit"), _("Exit this program?"),
2369 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2371 manage_window_focus_in(mainwin->window, NULL, NULL);
2374 app_will_exit(widget, mainwin);
2377 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2380 summary_search(mainwin->summaryview);
2382 message_search(mainwin->messageview);
2385 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2388 switch (mainwin->type) {
2390 case SEPARATE_MESSAGE:
2392 case SEPARATE_FOLDER:
2393 if (GTK_CHECK_MENU_ITEM(widget)->active)
2394 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2396 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2399 if (GTK_CHECK_MENU_ITEM(widget)->active)
2400 gtk_widget_show(mainwin->win.sep_both.folderwin);
2402 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2407 static void toggle_message_cb(MainWindow *mainwin, guint action,
2410 switch (mainwin->type) {
2412 case SEPARATE_FOLDER:
2414 case SEPARATE_MESSAGE:
2415 if (GTK_CHECK_MENU_ITEM(widget)->active)
2416 gtk_widget_show(mainwin->win.sep_message.messagewin);
2418 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2421 if (GTK_CHECK_MENU_ITEM(widget)->active)
2422 gtk_widget_show(mainwin->win.sep_both.messagewin);
2424 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2429 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2432 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2433 mainwin->compose_btn_type);
2434 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2435 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2436 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2437 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2439 mainwin->toolbar_style = (ToolbarStyle)action;
2440 prefs_common.toolbar_style = (ToolbarStyle)action;
2442 set_toolbar_style(mainwin);
2445 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2448 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2449 gtk_widget_show(mainwin->hbox_stat);
2450 prefs_common.show_statusbar = TRUE;
2452 gtk_widget_hide(mainwin->hbox_stat);
2453 prefs_common.show_statusbar = FALSE;
2457 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2459 summary_toggle_view_real(mainwin->summaryview);
2462 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2464 messageview_toggle_view_real(mainwin->messageview);
2467 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2470 MainWindow *mainwin;
2473 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2474 g_return_if_fail(mainwin != NULL);
2476 type = mainwin->type ^ action;
2477 main_window_separation_change(mainwin, type);
2479 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2480 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2483 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2486 addressbook_open(NULL);
2489 static void log_window_show_cb(MainWindow *mainwin, guint action,
2492 log_window_show(mainwin->logwin);
2495 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2500 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2503 inc_all_account_mail(mainwin);
2506 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2510 if (procmsg_send_queue() < 0)
2511 alertpanel_error(_("Some errors occurred while sending queued messages."));
2513 statusbar_pop_all();
2515 for (list = folder_get_list(); list != NULL; list = list->next) {
2518 folder = list->data;
2519 if (folder->queue) {
2520 folder_item_scan(folder->queue);
2521 folderview_update_item(folder->queue, TRUE);
2526 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2528 if (mainwin->summaryview->folder_item) {
2529 if (mainwin->summaryview->folder_item->folder->account != NULL
2530 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2531 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2533 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2539 static void compose_mail_cb(MainWindow *mainwin, guint action,
2546 if (mainwin->summaryview->folder_item) {
2547 ac = mainwin->summaryview->folder_item->folder->account;
2548 if (ac && ac->protocol != A_NNTP) {
2549 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2554 if(cur_account && (cur_account->protocol != A_NNTP)) {
2555 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2559 list = account_get_list();
2560 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2561 ac = (PrefsAccount *) cur->data;
2562 if (ac->protocol != A_NNTP) {
2563 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2569 static void compose_news_cb(MainWindow *mainwin, guint action,
2572 PrefsAccount * ac = NULL;
2576 if (mainwin->summaryview->folder_item) {
2577 ac = mainwin->summaryview->folder_item->folder->account;
2578 if (ac && ac->protocol == A_NNTP) {
2579 compose_new_with_recipient
2580 (ac, mainwin->summaryview->folder_item->path);
2585 list = account_get_list();
2586 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2587 ac = (PrefsAccount *) cur->data;
2588 if (ac->protocol == A_NNTP) {
2595 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2597 summary_reply(mainwin->summaryview, (ComposeMode)action);
2600 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2602 summary_move_to(mainwin->summaryview);
2605 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2607 summary_copy_to(mainwin->summaryview);
2610 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2612 summary_delete(mainwin->summaryview);
2615 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2617 summary_open_msg(mainwin->summaryview);
2620 static void view_source_cb(MainWindow *mainwin, guint action,
2623 summary_view_source(mainwin->summaryview);
2626 static void show_all_header_cb(MainWindow *mainwin, guint action,
2629 summary_display_msg_selected(mainwin->summaryview, TRUE);
2632 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2634 summary_reedit(mainwin->summaryview);
2637 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2639 summary_mark(mainwin->summaryview);
2642 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2644 summary_unmark(mainwin->summaryview);
2647 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2650 summary_mark_as_unread(mainwin->summaryview);
2653 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2656 summary_mark_as_read(mainwin->summaryview);
2659 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2662 summary_mark_all_read(mainwin->summaryview);
2665 static void add_address_cb(MainWindow *mainwin, guint action,
2668 summary_add_address(mainwin->summaryview);
2671 static void set_charset_cb(MainWindow *mainwin, guint action,
2676 str = conv_get_charset_str((CharSet)action);
2677 g_free(prefs_common.force_charset);
2678 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2680 summary_redisplay_msg(mainwin->summaryview);
2682 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2685 static void hide_read_messages (MainWindow *mainwin, guint action,
2688 if (!mainwin->summaryview->folder_item
2689 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2691 summary_toggle_show_read_messages(mainwin->summaryview);
2694 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2696 GtkItemFactory *ifactory;
2698 if (!mainwin->summaryview->folder_item) return;
2700 ifactory = gtk_item_factory_from_widget(widget);
2703 summary_thread_build(mainwin->summaryview);
2704 mainwin->summaryview->folder_item->threaded = TRUE;
2705 menu_set_sensitive(ifactory, "/View/Thread view", FALSE);
2706 menu_set_sensitive(ifactory, "/View/Unthread view", TRUE);
2708 summary_unthread(mainwin->summaryview);
2709 mainwin->summaryview->folder_item->threaded = FALSE;
2710 menu_set_sensitive(ifactory, "/View/Thread view", TRUE);
2711 menu_set_sensitive(ifactory, "/View/Unthread view", FALSE);
2715 static void set_display_item_cb(MainWindow *mainwin, guint action,
2718 prefs_summary_column_open();
2721 static void sort_summary_cb(MainWindow *mainwin, guint action,
2724 summary_sort(mainwin->summaryview, (SummarySortType)action);
2727 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2730 summary_attract_by_subject(mainwin->summaryview);
2733 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2736 summary_delete_duplicated(mainwin->summaryview);
2739 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2741 summary_filter(mainwin->summaryview);
2744 static void execute_summary_cb(MainWindow *mainwin, guint action,
2747 summary_execute(mainwin->summaryview);
2750 static void update_summary_cb(MainWindow *mainwin, guint action,
2754 FolderView *folderview = mainwin->folderview;
2756 if (!mainwin->summaryview->folder_item) return;
2757 if (!folderview->opened) return;
2759 folder_update_op_count();
2761 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2762 folderview->opened);
2765 summary_show(mainwin->summaryview, fitem, TRUE);
2768 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2770 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2773 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2775 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2778 static void prev_unread_cb(MainWindow *mainwin, guint action,
2781 summary_select_prev_unread(mainwin->summaryview);
2784 static void next_unread_cb(MainWindow *mainwin, guint action,
2787 summary_select_next_unread(mainwin->summaryview);
2790 static void prev_marked_cb(MainWindow *mainwin, guint action,
2793 summary_select_prev_marked(mainwin->summaryview);
2796 static void next_marked_cb(MainWindow *mainwin, guint action,
2799 summary_select_next_marked(mainwin->summaryview);
2802 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2805 summary_select_prev_labeled(mainwin->summaryview);
2808 static void next_labeled_cb(MainWindow *mainwin, guint action,
2811 summary_select_next_labeled(mainwin->summaryview);
2814 static void goto_folder_cb(MainWindow *mainwin, guint action,
2817 FolderItem *to_folder;
2819 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2822 folderview_select(mainwin->folderview, to_folder);
2825 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2827 messageview_copy_clipboard(mainwin->messageview);
2830 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2832 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2833 summary_select_all(mainwin->summaryview);
2834 else if (mainwin->summaryview->msg_is_toggled_on &&
2835 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2836 messageview_select_all(mainwin->messageview);
2839 static void create_filter_cb(MainWindow *mainwin, guint action,
2842 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2845 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2848 prefs_common_open();
2851 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2854 prefs_filter_open(NULL, NULL);
2857 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2860 prefs_scoring_open(NULL);
2863 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2866 prefs_filtering_open(NULL);
2869 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2872 prefs_template_open();
2875 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2878 prefs_actions_open(mainwin);
2881 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2885 new_account_cb(mainwin, 0, widget);
2887 gboolean prev_default = cur_account->is_default;
2889 prefs_account_open(cur_account);
2890 if (!prev_default && cur_account->is_default)
2891 account_set_as_default(cur_account);
2892 account_save_config_all();
2894 main_window_reflect_prefs_all();
2898 static void new_account_cb(MainWindow *mainwin, guint action,
2901 account_edit_open();
2902 if (!compose_get_compose_list()) account_add();
2905 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2907 cur_account = (PrefsAccount *)data;
2908 main_window_reflect_prefs_all();
2911 static void manual_open_cb(MainWindow *mainwin, guint action,
2914 manual_open((ManualLang)action);
2917 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2919 MainWindow *mainwin = (MainWindow *)data;
2923 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2924 LOCAL_FOLDER(folder)->rootpath,
2928 str = g_strdup_printf(_("Scanning folder %s ..."),
2929 LOCAL_FOLDER(folder)->rootpath);
2931 STATUSBAR_PUSH(mainwin, str);
2932 STATUSBAR_POP(mainwin);
2936 static void activate_compose_button (MainWindow *mainwin,
2938 ComposeButtonType type)
2940 SensitiveCond state = main_window_get_current_state(mainwin);
2942 if (style == TOOLBAR_NONE)
2945 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2946 : mainwin->compose_news_btn);
2947 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2948 : mainwin->compose_mail_btn);
2949 mainwin->compose_btn_type = type;
2952 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2954 if (mainwin->compose_btn_type != compose_btn_type)
2955 activate_compose_button(mainwin,
2956 prefs_common.toolbar_style,
2960 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
2962 MainWindow *mainwin = (MainWindow*) data;
2964 if (!mainwin) return;
2966 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
2969 #define BREAK_ON_MODIFIER_KEY() \
2970 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
2972 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
2974 MainWindow *mainwin = (MainWindow*) data;
2976 if (!mainwin || !event) return;
2978 switch (event->keyval) {
2979 case GDK_Q: /* Quit */
2980 BREAK_ON_MODIFIER_KEY();
2982 app_exit_cb(mainwin, 0, NULL);
2989 #undef BREAK_ON_MODIFIER_KEY
2991 static void set_toolbar_style(MainWindow *mainwin)
2993 switch (prefs_common.toolbar_style) {
2995 gtk_widget_hide(mainwin->handlebox);
2998 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3002 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3006 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3011 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3012 gtk_widget_show(mainwin->handlebox);
3013 gtk_widget_queue_resize(mainwin->handlebox);
3015 if (prefs_common.immediate_exec)
3016 gtk_widget_hide(mainwin->exec_btn);
3018 gtk_widget_show(mainwin->exec_btn);