2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2002 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
55 #include "stock_pixmap.h"
62 #include "prefs_common.h"
63 #include "prefs_filter.h"
64 #include "prefs_actions.h"
65 #include "prefs_filtering.h"
66 #include "prefs_scoring.h"
67 #include "prefs_account.h"
68 #include "prefs_folder_item.h"
69 #include "prefs_summary_column.h"
70 #include "prefs_template.h"
72 #include "addressbook.h"
73 #include "logwindow.h"
74 #include "manage_window.h"
75 #include "alertpanel.h"
76 #include "statusbar.h"
77 #include "inputdialog.h"
84 #include "selective_download.h"
86 #define AC_LABEL_WIDTH 240
88 #define STATUSBAR_PUSH(mainwin, str) \
90 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
91 mainwin->mainwin_cid, str); \
92 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
95 #define STATUSBAR_POP(mainwin) \
97 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
98 mainwin->mainwin_cid); \
101 /* list of all instantiated MainWindow */
102 static GList *mainwin_list = NULL;
104 static GdkCursor *watch_cursor;
106 static void main_window_menu_callback_block (MainWindow *mainwin);
107 static void main_window_menu_callback_unblock (MainWindow *mainwin);
109 static void main_window_show_cur_account (MainWindow *mainwin);
111 static void main_window_set_widgets (MainWindow *mainwin,
113 static void main_window_toolbar_create (MainWindow *mainwin,
114 GtkWidget *container);
116 /* callback functions */
117 static void toolbar_inc_cb (GtkWidget *widget,
119 static void toolbar_inc_all_cb (GtkWidget *widget,
121 static void toolbar_send_cb (GtkWidget *widget,
124 static void toolbar_compose_cb (GtkWidget *widget,
126 static void toolbar_compose_news_cb (GtkWidget *widget,
128 static void toolbar_compose_mail_cb (GtkWidget *widget,
130 static void toolbar_reply_cb (GtkWidget *widget,
132 static void toolbar_reply_popup_cb (GtkWidget *widget,
133 GdkEventButton *event,
135 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell,
137 static void toolbar_reply_to_all_cb (GtkWidget *widget,
139 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget,
140 GdkEventButton *event,
142 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell,
144 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
146 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
147 GdkEventButton *event,
149 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell,
151 static void toolbar_forward_cb (GtkWidget *widget,
153 static void toolbar_forward_popup_cb (GtkWidget *widget,
154 GdkEventButton *event,
156 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell,
159 static void toolbar_delete_cb (GtkWidget *widget,
161 static void toolbar_exec_cb (GtkWidget *widget,
164 static void toolbar_next_unread_cb (GtkWidget *widget,
167 static void toolbar_prefs_cb (GtkWidget *widget,
169 static void toolbar_account_cb (GtkWidget *widget,
172 static void toolbar_account_button_pressed (GtkWidget *widget,
173 GdkEventButton *event,
175 static void ac_label_button_pressed (GtkWidget *widget,
176 GdkEventButton *event,
178 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
181 static gint main_window_close_cb (GtkWidget *widget,
185 static void add_mailbox_cb (MainWindow *mainwin,
188 static void add_mbox_cb (MainWindow *mainwin,
191 static void update_folderview_cb (MainWindow *mainwin,
194 static void new_folder_cb (MainWindow *mainwin,
197 static void rename_folder_cb (MainWindow *mainwin,
200 static void delete_folder_cb (MainWindow *mainwin,
203 static void import_mbox_cb (MainWindow *mainwin,
206 static void export_mbox_cb (MainWindow *mainwin,
209 static void empty_trash_cb (MainWindow *mainwin,
213 static void save_as_cb (MainWindow *mainwin,
216 static void print_cb (MainWindow *mainwin,
219 static void app_exit_cb (MainWindow *mainwin,
223 static void search_cb (MainWindow *mainwin,
227 static void toggle_folder_cb (MainWindow *mainwin,
230 static void toggle_message_cb (MainWindow *mainwin,
233 static void toggle_toolbar_cb (MainWindow *mainwin,
236 static void toggle_statusbar_cb (MainWindow *mainwin,
239 static void toggle_expand_summaryview_cb (MainWindow *mainwin,
242 static void toggle_expand_messageview_cb (MainWindow *mainwin,
245 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
249 static void addressbook_open_cb (MainWindow *mainwin,
252 static void log_window_show_cb (MainWindow *mainwin,
255 static void sel_download_cb (MainWindow *mainwin,
259 static void inc_mail_cb (MainWindow *mainwin,
262 static void inc_all_account_mail_cb (MainWindow *mainwin,
266 static void send_queue_cb (MainWindow *mainwin,
270 static void compose_cb (MainWindow *mainwin,
273 static void compose_mail_cb(MainWindow *mainwin, guint action,
275 static void compose_news_cb(MainWindow *mainwin, guint action,
277 static void reply_cb (MainWindow *mainwin,
281 static void open_msg_cb (MainWindow *mainwin,
285 static void view_source_cb (MainWindow *mainwin,
289 static void show_all_header_cb (MainWindow *mainwin,
293 static void reedit_cb (MainWindow *mainwin,
297 static void move_to_cb (MainWindow *mainwin,
300 static void copy_to_cb (MainWindow *mainwin,
303 static void delete_cb (MainWindow *mainwin,
307 static void mark_cb (MainWindow *mainwin,
310 static void unmark_cb (MainWindow *mainwin,
314 static void mark_as_unread_cb (MainWindow *mainwin,
317 static void mark_as_read_cb (MainWindow *mainwin,
320 static void mark_all_read_cb (MainWindow *mainwin,
323 static void add_address_cb (MainWindow *mainwin,
327 static void set_charset_cb (MainWindow *mainwin,
331 static void hide_read_messages (MainWindow *mainwin,
335 static void thread_cb (MainWindow *mainwin,
338 static void set_display_item_cb (MainWindow *mainwin,
341 static void sort_summary_cb (MainWindow *mainwin,
344 static void attract_by_subject_cb(MainWindow *mainwin,
348 static void delete_duplicated_cb (MainWindow *mainwin,
351 static void filter_cb (MainWindow *mainwin,
354 static void execute_summary_cb (MainWindow *mainwin,
357 static void update_summary_cb (MainWindow *mainwin,
361 static void prev_cb (MainWindow *mainwin,
364 static void next_cb (MainWindow *mainwin,
368 static void prev_unread_cb (MainWindow *mainwin,
371 static void next_unread_cb (MainWindow *mainwin,
374 static void prev_marked_cb (MainWindow *mainwin,
377 static void next_marked_cb (MainWindow *mainwin,
380 static void prev_labeled_cb (MainWindow *mainwin,
383 static void next_labeled_cb (MainWindow *mainwin,
387 static void goto_folder_cb (MainWindow *mainwin,
391 static void copy_cb (MainWindow *mainwin,
394 static void allsel_cb (MainWindow *mainwin,
397 static void selthread_cb (MainWindow *mainwin,
401 static void create_filter_cb (MainWindow *mainwin,
405 static void prefs_common_open_cb (MainWindow *mainwin,
408 static void prefs_filter_open_cb (MainWindow *mainwin,
411 static void prefs_scoring_open_cb (MainWindow *mainwin,
414 static void prefs_filtering_open_cb (MainWindow *mainwin,
417 static void prefs_account_open_cb(MainWindow *mainwin,
420 static void prefs_template_open_cb (MainWindow *mainwin,
423 static void prefs_actions_open_cb (MainWindow *mainwin,
426 static void new_account_cb (MainWindow *mainwin,
430 static void account_menu_cb (GtkMenuItem *menuitem,
433 static void manual_open_cb (MainWindow *mainwin,
437 static void scan_tree_func (Folder *folder,
441 static void activate_compose_button (MainWindow *mainwin,
443 ComposeButtonType type);
445 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
449 static void key_pressed (GtkWidget *widget,
453 static void set_toolbar_style(MainWindow *mainwin);
455 #define SEPARATE_ACTION 667
457 static GtkItemFactoryEntry mainwin_entries[] =
459 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
460 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
461 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
462 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
463 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
464 {N_("/_File/_Folder/Create _new folder..."),
465 NULL, new_folder_cb, 0, NULL},
466 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
467 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
468 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
469 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
470 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
471 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
472 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
473 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
474 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
475 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
477 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
478 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
479 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
480 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
481 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
482 {N_("/_Edit/_Find in current message..."),
483 "<control>F", search_cb, 0, NULL},
484 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
485 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
486 {N_("/_Edit/Actio_ns"), NULL, NULL, 0, "<Branch>"},
488 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
489 {N_("/_View/Separate _Folder Tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
490 {N_("/_View/Separate _Message View"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
491 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
492 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
493 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
494 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
495 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
496 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
497 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
498 {N_("/_View/Status _bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
499 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
500 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
501 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
502 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
503 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
504 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
505 {N_("/_View/_Sort/Sort by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
506 {N_("/_View/_Sort/Sort by _color label"),
507 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
508 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
509 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
510 {N_("/_View/_Sort/Sort by a_ttachment"),
511 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
512 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
513 {N_("/_View/_Sort/_Attract by subject"),
514 NULL, attract_by_subject_cb, 0, NULL},
515 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
516 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
517 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
518 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
520 #define CODESET_SEPARATOR \
521 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
522 #define CODESET_ACTION(action) \
523 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
525 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
526 {N_("/_View/_Code set/_Auto detect"),
527 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
528 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
529 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
530 CODESET_ACTION(C_US_ASCII)},
533 {N_("/_View/_Code set/Unicode (_UTF-8)"),
534 CODESET_ACTION(C_UTF_8)},
537 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
538 CODESET_ACTION(C_ISO_8859_1)},
539 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
540 CODESET_ACTION(C_ISO_8859_15)},
543 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
544 CODESET_ACTION(C_ISO_8859_2)},
546 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
547 CODESET_ACTION(C_ISO_8859_13)},
548 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
549 CODESET_ACTION(C_ISO_8859_4)},
551 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
552 CODESET_ACTION(C_ISO_8859_7)},
554 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
555 CODESET_ACTION(C_ISO_8859_9)},
557 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
558 CODESET_ACTION(C_ISO_8859_5)},
559 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
560 CODESET_ACTION(C_KOI8_R)},
561 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
562 CODESET_ACTION(C_CP1251)},
565 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
566 CODESET_ACTION(C_ISO_2022_JP)},
568 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
569 CODESET_ACTION(C_ISO_2022_JP_2)},
571 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
572 CODESET_ACTION(C_EUC_JP)},
573 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
574 CODESET_ACTION(C_SHIFT_JIS)},
577 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
578 CODESET_ACTION(C_GB2312)},
579 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
580 CODESET_ACTION(C_BIG5)},
581 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
582 CODESET_ACTION(C_EUC_TW)},
583 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
584 CODESET_ACTION(C_ISO_2022_CN)},
586 {N_("/_View/_Code set/Korean (EUC-_KR)"),
587 CODESET_ACTION(C_EUC_KR)},
588 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
589 CODESET_ACTION(C_ISO_2022_KR)},
591 {N_("/_View/_Code set/Thai (TIS-620)"),
592 CODESET_ACTION(C_TIS_620)},
593 {N_("/_View/_Code set/Thai (Windows-874)"),
594 CODESET_ACTION(C_WINDOWS_874)},
597 #undef CODESET_SEPARATOR
598 #undef CODESET_ACTION
600 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
601 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
602 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
603 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
604 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
605 {N_("/_View/_Go to/P_rev unread message"),
606 "<shift>P", prev_unread_cb, 0, NULL},
607 {N_("/_View/_Go to/N_ext unread message"),
608 "<shift>N", next_unread_cb, 0, NULL},
609 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
610 {N_("/_View/_Go to/Prev _marked message"),
611 NULL, prev_marked_cb, 0, NULL},
612 {N_("/_View/_Go to/Next m_arked message"),
613 NULL, next_marked_cb, 0, NULL},
614 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
615 {N_("/_View/_Go to/Prev _labeled message"),
616 NULL, prev_labeled_cb, 0, NULL},
617 {N_("/_View/_Go to/Next la_beled message"),
618 NULL, next_labeled_cb, 0, NULL},
619 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
621 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
622 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
623 {N_("/_View/_View source"), "<control>U", view_source_cb, 0, NULL},
624 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
625 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
626 {N_("/_View/_Update"), "<control><alt>U", update_summary_cb, 0, NULL},
628 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
629 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
630 {N_("/_Message/Get from _all accounts"),
631 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
632 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
633 {N_("/_Message/Send queued messa_ges"),
634 NULL, send_queue_cb, 0, NULL},
635 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
636 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
637 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
638 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
639 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
640 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
641 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
642 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
643 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
644 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
645 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
646 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
647 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
648 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
649 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
650 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
651 {N_("/_Message/Delete du_plicated messages"),
652 NULL, delete_duplicated_cb, 0, NULL},
653 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
654 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
655 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
656 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
657 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
658 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
659 {N_("/_Message/_Mark/Mark as rea_d"),
660 NULL, mark_as_read_cb, 0, NULL},
661 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
663 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
664 {N_("/_Tool/_Address book"), "<shift><control>A", addressbook_open_cb, 0, NULL},
665 {N_("/_Tool/Add sender to address boo_k"),
666 NULL, add_address_cb, 0, NULL},
667 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
668 {N_("/_Tool/_Filter messages"), NULL, filter_cb, 0, NULL},
669 {N_("/_Tool/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
670 {N_("/_Tool/_Create filter rule/_Automatically"),
671 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
672 {N_("/_Tool/_Create filter rule/by _From"),
673 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
674 {N_("/_Tool/_Create filter rule/by _To"),
675 NULL, create_filter_cb, FILTER_BY_TO, NULL},
676 {N_("/_Tool/_Create filter rule/by _Subject"),
677 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
678 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
679 {N_("/_Tool/E_xecute"), "X", execute_summary_cb, 0, NULL},
680 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
681 {N_("/_Tool/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
682 {N_("/_Tool/_Selective Download"), "<alt>S", sel_download_cb, 0, NULL},
684 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
685 {N_("/_Configuration/_Common preferences..."),
686 NULL, prefs_common_open_cb, 0, NULL},
687 {N_("/_Configuration/_Filter setting..."),
688 NULL, prefs_filter_open_cb, 0, NULL},
689 {N_("/_Configuration/_Scoring ..."),
690 NULL, prefs_scoring_open_cb, 0, NULL},
691 {N_("/_Configuration/_Filtering ..."),
692 NULL, prefs_filtering_open_cb, 0, NULL},
693 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
694 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
695 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
696 {N_("/_Configuration/_Preferences for current account..."),
697 NULL, prefs_account_open_cb, 0, NULL},
698 {N_("/_Configuration/Create _new account..."),
699 NULL, new_account_cb, 0, NULL},
700 {N_("/_Configuration/_Edit accounts..."),
701 NULL, account_edit_open, 0, NULL},
702 {N_("/_Configuration/C_hange current account"),
703 NULL, NULL, 0, "<Branch>"},
705 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
706 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
707 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
708 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
709 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
710 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
712 static GtkItemFactoryEntry reply_popup_entries[] =
714 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
715 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
717 static GtkItemFactoryEntry replyall_popup_entries[] =
719 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
720 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
722 static GtkItemFactoryEntry replysender_popup_entries[] =
724 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
725 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
727 static GtkItemFactoryEntry fwd_popup_entries[] =
729 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
730 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
734 MainWindow *main_window_create(SeparateType type)
740 GtkWidget *handlebox;
741 GtkWidget *vbox_body;
742 GtkWidget *hbox_stat;
743 GtkWidget *statusbar;
744 GtkWidget *progressbar;
745 GtkWidget *statuslabel;
746 GtkWidget *ac_button;
749 FolderView *folderview;
750 SummaryView *summaryview;
751 MessageView *messageview;
752 GdkColormap *colormap;
755 guint n_menu_entries;
756 GtkItemFactory *ifactory;
759 GtkWidget *compose_popup;
760 GtkWidget *reply_popup;
761 GtkWidget *replyall_popup;
762 GtkWidget *replysender_popup;
763 GtkWidget *fwd_popup;
766 debug_print(_("Creating main window...\n"));
767 mainwin = g_new0(MainWindow, 1);
770 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
771 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
772 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
773 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
774 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
775 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
776 MANAGE_WINDOW_SIGNALS_CONNECT(window);
777 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
778 GTK_SIGNAL_FUNC(key_pressed), mainwin);
780 gtk_widget_realize(window);
781 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
784 gtkut_widget_set_app_icon(window);
786 vbox = gtk_vbox_new(FALSE, 0);
787 gtk_widget_show(vbox);
788 gtk_container_add(GTK_CONTAINER(window), vbox);
791 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
792 menubar = menubar_create(window, mainwin_entries,
793 n_menu_entries, "<Main>", mainwin);
794 gtk_widget_show(menubar);
795 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
797 handlebox = gtk_handle_box_new();
798 gtk_widget_show(handlebox);
799 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
801 /* create the popup menus for the reply buttons specials */
802 n_menu_entries = sizeof(reply_popup_entries) /
803 sizeof(reply_popup_entries[0]);
804 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
805 "<ReplyPopup>", mainwin);
806 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
807 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
808 n_menu_entries = sizeof(replyall_popup_entries) /
809 sizeof(replyall_popup_entries[0]);
810 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
811 "<ReplyAllPopup>", mainwin);
812 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
813 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
814 n_menu_entries = sizeof(replysender_popup_entries) /
815 sizeof(replysender_popup_entries[0]);
816 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
817 "<ReplySenderPopup>", mainwin);
818 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
819 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
820 /* create the popup menu for the forward button */
821 n_menu_entries = sizeof(fwd_popup_entries) /
822 sizeof(fwd_popup_entries[0]);
823 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
824 "<ForwardPopup>", mainwin);
825 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
826 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
828 main_window_toolbar_create(mainwin, handlebox);
830 /* vbox that contains body */
831 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
832 gtk_widget_show(vbox_body);
833 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
834 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
836 hbox_stat = gtk_hbox_new(FALSE, 2);
837 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
839 statusbar = statusbar_create();
840 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
842 progressbar = gtk_progress_bar_new();
843 gtk_widget_set_usize(progressbar, 120, 1);
844 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
846 statuslabel = gtk_label_new("");
847 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
849 ac_button = gtk_button_new();
850 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
851 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
852 gtk_widget_set_usize(ac_button, -1, 1);
853 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
854 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
855 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
857 ac_label = gtk_label_new("");
858 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
860 gtk_widget_show_all(hbox_stat);
863 mainwin->folderview = folderview = folderview_create();
864 mainwin->summaryview = summaryview = summary_create();
865 mainwin->messageview = messageview = messageview_create();
866 mainwin->logwin = log_window_create();
868 folderview->mainwin = mainwin;
869 folderview->summaryview = summaryview;
871 summaryview->mainwin = mainwin;
872 summaryview->folderview = folderview;
873 summaryview->messageview = messageview;
874 summaryview->window = window;
876 messageview->mainwin = mainwin;
878 mainwin->window = window;
879 mainwin->vbox = vbox;
880 mainwin->menubar = menubar;
881 mainwin->handlebox = handlebox;
882 mainwin->vbox_body = vbox_body;
883 mainwin->hbox_stat = hbox_stat;
884 mainwin->statusbar = statusbar;
885 mainwin->progressbar = progressbar;
886 mainwin->statuslabel = statuslabel;
887 mainwin->ac_button = ac_button;
888 mainwin->ac_label = ac_label;
889 mainwin->reply_popup = reply_popup;
890 mainwin->replyall_popup = replyall_popup;
891 mainwin->replysender_popup = replysender_popup;
892 mainwin->fwd_popup = fwd_popup;
894 /* set context IDs for status bar */
895 mainwin->mainwin_cid = gtk_statusbar_get_context_id
896 (GTK_STATUSBAR(statusbar), "Main Window");
897 mainwin->folderview_cid = gtk_statusbar_get_context_id
898 (GTK_STATUSBAR(statusbar), "Folder View");
899 mainwin->summaryview_cid = gtk_statusbar_get_context_id
900 (GTK_STATUSBAR(statusbar), "Summary View");
902 /* allocate colors for summary view and folder view */
903 summaryview->color_marked.red = summaryview->color_marked.green = 0;
904 summaryview->color_marked.blue = (guint16)65535;
906 summaryview->color_dim.red = summaryview->color_dim.green =
907 summaryview->color_dim.blue = COLOR_DIM;
909 folderview->color_new.red = (guint16)55000;
910 folderview->color_new.green = folderview->color_new.blue = 15000;
912 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
913 &folderview->color_op);
915 summaryview->color_important.red = 0;
916 summaryview->color_marked.green = 0;
917 summaryview->color_important.blue = (guint16)65535;
919 color[0] = summaryview->color_marked;
920 color[1] = summaryview->color_dim;
921 color[2] = folderview->color_new;
922 color[3] = folderview->color_op;
924 colormap = gdk_window_get_colormap(window->window);
925 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
926 for (i = 0; i < 4; i++) {
927 if (success[i] == FALSE)
928 g_warning(_("MainWindow: color allocation %d failed\n"), i);
931 debug_print(_("done.\n"));
933 main_window_set_widgets(mainwin, type);
936 ifactory = gtk_item_factory_from_widget(menubar);
937 menuitem = gtk_item_factory_get_item
938 (ifactory, "/View/Code set/Auto detect");
939 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
941 switch (prefs_common.toolbar_style) {
943 menuitem = gtk_item_factory_get_item
944 (ifactory, "/View/Toolbar/None");
947 menuitem = gtk_item_factory_get_item
948 (ifactory, "/View/Toolbar/Icon");
951 menuitem = gtk_item_factory_get_item
952 (ifactory, "/View/Toolbar/Text");
955 menuitem = gtk_item_factory_get_item
956 (ifactory, "/View/Toolbar/Icon and text");
958 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
960 gtk_widget_hide(mainwin->hbox_stat);
961 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
962 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
963 prefs_common.show_statusbar);
964 #if 0 /* FIXED SEPARATE WINDOWS */
965 /* Message view and Folder tree are always shown at startup
966 * make that in the menu visible */
967 menuitem = gtk_item_factory_get_item(ifactory, "/View/Message view");
968 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
969 menuitem = gtk_item_factory_get_item(ifactory, "/View/Folder tree");
970 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
972 /* set the check of the SEPARATE_xxx menu items. we also need the main window
973 * as a property and pass the action type to the callback */
974 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
976 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
977 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
978 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
979 GUINT_TO_POINTER(SEPARATE_FOLDER));
981 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
983 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
984 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
985 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
986 GUINT_TO_POINTER(SEPARATE_MESSAGE));
988 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
989 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
992 /* set account selection menu */
993 ac_menu = gtk_item_factory_get_widget
994 (ifactory, "/Configuration/Change current account");
995 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
996 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
997 mainwin->ac_menu = ac_menu;
999 main_window_set_toolbar_sensitive(mainwin);
1001 /* Create actions menu */
1002 update_mainwin_actions_menu(ifactory, mainwin);
1004 /* show main window */
1005 gtk_widget_set_uposition(mainwin->window,
1006 prefs_common.mainwin_x,
1007 prefs_common.mainwin_y);
1008 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1009 prefs_common.mainwin_height);
1010 gtk_widget_show(mainwin->window);
1012 /* initialize views */
1013 folderview_init(folderview);
1014 summary_init(summaryview);
1015 messageview_init(messageview);
1016 log_window_init(mainwin->logwin);
1018 mainwin->lock_count = 0;
1019 mainwin->menu_lock_count = 0;
1020 mainwin->cursor_count = 0;
1023 watch_cursor = gdk_cursor_new(GDK_WATCH);
1025 mainwin_list = g_list_append(mainwin_list, mainwin);
1030 void main_window_cursor_wait(MainWindow *mainwin)
1033 if (mainwin->cursor_count == 0)
1034 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1036 mainwin->cursor_count++;
1041 void main_window_cursor_normal(MainWindow *mainwin)
1043 if (mainwin->cursor_count)
1044 mainwin->cursor_count--;
1046 if (mainwin->cursor_count == 0)
1047 gdk_window_set_cursor(mainwin->window->window, NULL);
1052 /* lock / unlock the user-interface */
1053 void main_window_lock(MainWindow *mainwin)
1055 if (mainwin->lock_count == 0)
1056 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1058 mainwin->lock_count++;
1060 main_window_set_menu_sensitive(mainwin);
1061 main_window_set_toolbar_sensitive(mainwin);
1064 void main_window_unlock(MainWindow *mainwin)
1066 if (mainwin->lock_count)
1067 mainwin->lock_count--;
1069 main_window_set_menu_sensitive(mainwin);
1070 main_window_set_toolbar_sensitive(mainwin);
1072 if (mainwin->lock_count == 0)
1073 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1076 static void main_window_menu_callback_block(MainWindow *mainwin)
1078 mainwin->menu_lock_count++;
1081 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1083 if (mainwin->menu_lock_count)
1084 mainwin->menu_lock_count--;
1087 void main_window_reflect_prefs_all(void)
1089 main_window_reflect_prefs_all_real(FALSE);
1092 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1095 MainWindow *mainwin;
1097 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1098 mainwin = (MainWindow *)cur->data;
1100 main_window_show_cur_account(mainwin);
1101 main_window_set_menu_sensitive(mainwin);
1102 main_window_set_toolbar_sensitive(mainwin);
1105 if (pixmap_theme_changed)
1107 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1108 mainwin->toolbar = NULL;
1109 main_window_toolbar_create(mainwin, mainwin->handlebox);
1110 set_toolbar_style(mainwin);
1111 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1112 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1113 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1116 summary_redisplay_msg(mainwin->summaryview);
1117 headerview_set_visibility(mainwin->messageview->headerview,
1118 prefs_common.display_header_pane);
1122 void main_window_set_summary_column(void)
1125 MainWindow *mainwin;
1127 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1128 mainwin = (MainWindow *)cur->data;
1129 summary_set_column_order(mainwin->summaryview);
1133 void main_window_set_account_menu(GList *account_list)
1135 GList *cur, *cur_ac, *cur_item;
1136 GtkWidget *menuitem;
1137 MainWindow *mainwin;
1138 PrefsAccount *ac_prefs;
1140 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1141 mainwin = (MainWindow *)cur->data;
1143 /* destroy all previous menu item */
1144 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1145 while (cur_item != NULL) {
1146 GList *next = cur_item->next;
1147 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1151 for (cur_ac = account_list; cur_ac != NULL;
1152 cur_ac = cur_ac->next) {
1153 ac_prefs = (PrefsAccount *)cur_ac->data;
1155 menuitem = gtk_menu_item_new_with_label
1156 (ac_prefs->account_name
1157 ? ac_prefs->account_name : _("Untitled"));
1158 gtk_widget_show(menuitem);
1159 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1160 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1161 GTK_SIGNAL_FUNC(account_menu_cb),
1167 static void main_window_show_cur_account(MainWindow *mainwin)
1172 ac_name = g_strdup(cur_account
1173 ? (cur_account->account_name
1174 ? cur_account->account_name : _("Untitled"))
1178 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1180 buf = g_strdup(PROG_VERSION);
1181 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1184 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1185 gtk_widget_queue_resize(mainwin->ac_button);
1190 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1192 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1193 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1194 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1196 if (mainwin->type == type) return;
1198 /* remove widgets from those containers */
1199 gtk_widget_ref(folder_wid);
1200 gtk_widget_ref(summary_wid);
1201 gtk_widget_ref(message_wid);
1202 gtkut_container_remove
1203 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1204 gtkut_container_remove
1205 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1206 gtkut_container_remove
1207 (GTK_CONTAINER(message_wid->parent), message_wid);
1209 /* clean containers */
1210 switch (mainwin->type) {
1212 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1214 case SEPARATE_FOLDER:
1215 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1216 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1218 case SEPARATE_MESSAGE:
1219 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1220 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1223 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1224 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1228 gtk_widget_hide(mainwin->window);
1229 main_window_set_widgets(mainwin, type);
1230 gtk_widget_show(mainwin->window);
1232 gtk_widget_unref(folder_wid);
1233 gtk_widget_unref(summary_wid);
1234 gtk_widget_unref(message_wid);
1237 void main_window_get_size(MainWindow *mainwin)
1239 GtkAllocation *allocation;
1241 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1243 prefs_common.summaryview_width = allocation->width;
1245 if (mainwin->summaryview->msg_is_toggled_on)
1246 prefs_common.summaryview_height = allocation->height;
1248 prefs_common.mainview_width = allocation->width;
1250 allocation = &mainwin->window->allocation;
1252 prefs_common.mainview_height = allocation->height;
1253 prefs_common.mainwin_width = allocation->width;
1254 prefs_common.mainwin_height = allocation->height;
1256 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1258 prefs_common.folderview_width = allocation->width;
1259 prefs_common.folderview_height = allocation->height;
1262 void main_window_get_position(MainWindow *mainwin)
1266 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1268 prefs_common.mainview_x = x;
1269 prefs_common.mainview_y = y;
1270 prefs_common.mainwin_x = x;
1271 prefs_common.mainwin_y = y;
1273 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1276 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1282 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1283 folder = FOLDER(list->data);
1284 if (folder && folder->trash && folder->trash->total > 0)
1288 if (!has_trash) return;
1291 if (alertpanel(_("Empty trash"),
1292 _("Empty all messages in trash?"),
1293 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1295 manage_window_focus_in(mainwin->window, NULL, NULL);
1298 procmsg_empty_trash();
1300 for (list = folder_get_list(); list != NULL; list = list->next) {
1301 folder = list->data;
1302 if (folder && folder->trash && folder->trash->total != 0) {
1303 folder_item_scan(folder->trash);
1304 folderview_update_item(folder->trash, TRUE);
1308 if (mainwin->summaryview->folder_item &&
1309 mainwin->summaryview->folder_item->stype == F_TRASH)
1310 gtk_widget_grab_focus(mainwin->folderview->ctree);
1313 void main_window_add_mailbox(MainWindow *mainwin)
1318 path = input_dialog(_("Add mailbox"),
1319 _("Input the location of mailbox.\n"
1320 "If the existing mailbox is specified, it will be\n"
1321 "scanned automatically."),
1324 if (folder_find_from_path(path)) {
1325 alertpanel_error(_("The mailbox `%s' already exists."), path);
1329 if (!strcmp(path, "Mail"))
1330 folder = folder_new(F_MH, _("Mailbox"), path);
1332 folder = folder_new(F_MH, g_basename(path), path);
1335 if (folder->create_tree(folder) < 0) {
1336 alertpanel_error(_("Creation of the mailbox failed.\n"
1337 "Maybe some files already exist, or you don't have the permission to write there."));
1338 folder_destroy(folder);
1343 folder_set_ui_func(folder, scan_tree_func, mainwin);
1344 folder->scan_tree(folder);
1345 folder_set_ui_func(folder, NULL, NULL);
1347 folderview_set(mainwin->folderview);
1350 void main_window_add_mbox(MainWindow *mainwin)
1356 path = input_dialog(_("Add mbox mailbox"),
1357 _("Input the location of mailbox."),
1362 if (folder_find_from_path(path)) {
1363 alertpanel_error(_("The mailbox `%s' already exists."), path);
1369 if (!strcmp(path, "Mail"))
1370 folder = folder_new(F_MBOX, _("Mailbox"), path);
1374 folder = folder_new(F_MBOX, g_basename(path), path);
1377 if (folder->create_tree(folder) < 0) {
1378 alertpanel_error(_("Creation of the mailbox failed."));
1379 folder_destroy(folder);
1385 item = folder_item_new(folder->name, NULL);
1386 item->folder = folder;
1387 folder->node = g_node_new(item);
1389 folder->create_folder(folder, item, "inbox");
1390 folder->create_folder(folder, item, "outbox");
1391 folder->create_folder(folder, item, "queue");
1392 folder->create_folder(folder, item, "draft");
1393 folder->create_folder(folder, item, "trash");
1395 folderview_set(mainwin->folderview);
1400 M_UNLOCKED = 1 << 0,
1401 M_MSG_EXIST = 1 << 1,
1402 M_TARGET_EXIST = 1 << 2,
1403 M_SINGLE_TARGET_EXIST = 1 << 3,
1405 M_ALLOW_REEDIT = 1 << 5,
1406 M_HAVE_ACCOUNT = 1 << 6,
1407 M_THREADED = 1 << 7,
1408 M_UNTHREADED = 1 << 8,
1409 M_ALLOW_DELETE = 1 << 9,
1411 M_HAVE_NEWS_ACCOUNT = 1 << 11,
1412 M_HIDE_READ_MSG = 1 << 12
1415 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1417 SensitiveCond state = 0;
1418 SummarySelection selection;
1419 FolderItem *item = mainwin->summaryview->folder_item;
1420 GList *account_list = account_get_list();
1422 selection = summary_get_selection_type(mainwin->summaryview);
1424 if (mainwin->lock_count == 0)
1425 state |= M_UNLOCKED;
1426 if (selection != SUMMARY_NONE)
1427 state |= M_MSG_EXIST;
1431 state |= M_THREADED;
1433 state |= M_UNTHREADED;
1434 if (item->folder->type != F_NEWS)
1435 state |= M_ALLOW_DELETE;
1437 if (selection == SUMMARY_NONE && item->hide_read_msgs
1438 || selection != SUMMARY_NONE)
1439 state |= M_HIDE_READ_MSG;
1441 if (selection == SUMMARY_SELECTED_SINGLE ||
1442 selection == SUMMARY_SELECTED_MULTIPLE)
1443 state |= M_TARGET_EXIST;
1444 if (selection == SUMMARY_SELECTED_SINGLE)
1445 state |= M_SINGLE_TARGET_EXIST;
1446 if (mainwin->summaryview->folder_item &&
1447 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1449 if (selection == SUMMARY_SELECTED_SINGLE &&
1451 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1452 item->stype == F_QUEUE)))
1453 state |= M_ALLOW_REEDIT;
1455 state |= M_HAVE_ACCOUNT;
1457 for ( ; account_list != NULL; account_list = account_list->next) {
1458 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1459 state |= M_HAVE_NEWS_ACCOUNT;
1467 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1469 SensitiveCond state;
1478 entry[0].widget = mainwin->get_btn;
1479 entry[0].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1480 entry[1].widget = mainwin->getall_btn;
1481 entry[1].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1482 entry[2].widget = mainwin->compose_news_btn;
1483 entry[2].cond = M_HAVE_NEWS_ACCOUNT;
1484 entry[3].widget = mainwin->reply_btn;
1485 entry[3].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1486 entry[4].widget = mainwin->replyall_btn;
1487 entry[4].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1488 entry[5].widget = mainwin->replysender_btn;
1489 entry[5].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1490 entry[6].widget = mainwin->fwd_btn;
1491 entry[6].cond = M_HAVE_ACCOUNT|M_TARGET_EXIST;
1492 /* entry[6].widget = mainwin->prefs_btn;
1493 entry[6].cond = M_UNLOCKED;
1494 entry[7].widget = mainwin->account_btn;
1495 entry[7].cond = M_UNLOCKED; */
1496 entry[7].widget = mainwin->next_btn;
1497 entry[7].cond = M_MSG_EXIST;
1498 entry[8].widget = mainwin->delete_btn;
1499 entry[8].cond = M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED;
1500 entry[9].widget = mainwin->exec_btn;
1501 entry[9].cond = M_MSG_EXIST|M_EXEC|M_UNLOCKED;
1502 entry[10].widget = NULL;
1505 state = main_window_get_current_state(mainwin);
1507 for (i = 0; entry[i].widget != NULL; i++) {
1508 sensitive = ((entry[i].cond & state) == entry[i].cond);
1509 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1512 activate_compose_button(mainwin,
1513 prefs_common.toolbar_style,
1514 mainwin->compose_btn_type);
1517 void main_window_set_menu_sensitive(MainWindow *mainwin)
1519 GtkItemFactory *ifactory;
1520 SensitiveCond state;
1522 GtkWidget *menuitem;
1525 static const struct {
1529 {"/File/Add mailbox..." , M_UNLOCKED},
1530 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1531 {"/File/Rescan folder tree" , M_UNLOCKED},
1532 {"/File/Folder" , M_UNLOCKED},
1533 {"/File/Import mbox file..." , M_UNLOCKED},
1534 {"/File/Export to mbox file...", M_UNLOCKED},
1535 {"/File/Empty trash" , M_UNLOCKED},
1536 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1537 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1538 /* {"/File/Close", M_UNLOCKED}, */
1539 {"/File/Exit" , M_UNLOCKED},
1541 {"/Edit/Actions" , M_MSG_EXIST},
1542 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1543 {"/View/Sort" , M_MSG_EXIST},
1544 {"/View/Thread view" , M_EXEC},
1545 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1546 {"/View/Go to/Prev message" , M_MSG_EXIST},
1547 {"/View/Go to/Next message" , M_MSG_EXIST},
1548 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1549 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1550 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1551 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1552 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1553 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1554 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1555 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1556 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1558 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1559 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1560 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1561 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1562 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1563 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1564 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1565 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1566 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1567 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1568 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1569 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1570 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1571 {"/Message/Mark" , M_TARGET_EXIST},
1572 {"/Message/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1574 {"/Tool/Add sender to address book", M_SINGLE_TARGET_EXIST},
1575 {"/Tool/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1576 {"/Tool/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1577 {"/Tool/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1579 {"/Configuration", M_UNLOCKED},
1584 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1585 state = main_window_get_current_state(mainwin);
1587 for (i = 0; entry[i].entry != NULL; i++) {
1588 sensitive = ((entry[i].cond & state) == entry[i].cond);
1589 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1592 main_window_menu_callback_block(mainwin);
1593 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all header");
1594 gtk_check_menu_item_set_active
1595 (GTK_CHECK_MENU_ITEM(menuitem),
1596 mainwin->messageview->textview->show_all_headers);
1597 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1598 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1599 (state & M_THREADED) != 0);
1600 main_window_menu_callback_unblock(mainwin);
1603 void main_window_popup(MainWindow *mainwin)
1609 gdk_window_get_origin(mainwin->window->window, &x, &y);
1610 sx = gdk_screen_width();
1611 sy = gdk_screen_height();
1612 x %= sx; if (x < 0) x = 0;
1613 y %= sy; if (y < 0) y = 0;
1614 gdk_window_move(mainwin->window->window, x, y);
1615 gdk_window_raise(mainwin->window->window);
1616 gdk_window_show(mainwin->window->window);
1618 debug_print("window position: x = %d, y = %d\n", x, y);
1620 switch (mainwin->type) {
1621 case SEPARATE_FOLDER:
1622 widget = mainwin->win.sep_folder.folderwin;
1623 gdk_window_get_origin(widget->window, &x, &y);
1624 x %= sx; if (x < 0) x = 0;
1625 y %= sy; if (y < 0) y = 0;
1626 gdk_window_move(widget->window, x, y);
1627 gdk_window_raise(widget->window);
1629 case SEPARATE_MESSAGE:
1630 widget = mainwin->win.sep_message.messagewin;
1631 gdk_window_get_origin(widget->window, &x, &y);
1632 x %= sx; if (x < 0) x = 0;
1633 y %= sy; if (y < 0) y = 0;
1634 gdk_window_move(widget->window, x, y);
1635 gdk_window_raise(widget->window);
1638 widget = mainwin->win.sep_both.folderwin;
1639 gdk_window_get_origin(widget->window, &x, &y);
1640 x %= sx; if (x < 0) x = 0;
1641 y %= sy; if (y < 0) y = 0;
1642 gdk_window_move(widget->window, x, y);
1643 gdk_window_raise(widget->window);
1644 widget = mainwin->win.sep_both.messagewin;
1645 gdk_window_get_origin(widget->window, &x, &y);
1646 x %= sx; if (x < 0) x = 0;
1647 y %= sy; if (y < 0) y = 0;
1648 gdk_window_move(widget->window, x, y);
1649 gdk_window_raise(widget->window);
1656 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1658 GtkWidget *folderwin = NULL;
1659 GtkWidget *messagewin = NULL;
1662 GtkWidget *vbox_body = mainwin->vbox_body;
1663 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1664 GtkWidget *menuitem;
1666 debug_print(_("Setting widgets..."));
1668 /* create separated window(s) if needed */
1669 if (type & SEPARATE_FOLDER) {
1670 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1671 gtk_window_set_title(GTK_WINDOW(folderwin),
1672 _("Sylpheed - Folder View"));
1673 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1674 "folder_view", "Sylpheed");
1675 gtk_window_set_policy(GTK_WINDOW(folderwin),
1677 gtk_widget_set_usize(folderwin, -1,
1678 prefs_common.mainview_height);
1679 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1681 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1682 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1685 if (type & SEPARATE_MESSAGE) {
1686 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1687 gtk_window_set_title(GTK_WINDOW(messagewin),
1688 _("Sylpheed - Message View"));
1689 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1690 "message_view", "Sylpheed");
1691 gtk_window_set_policy(GTK_WINDOW(messagewin),
1693 gtk_widget_set_usize
1694 (messagewin, prefs_common.mainview_width,
1695 prefs_common.mainview_height
1696 - prefs_common.summaryview_height
1697 + DEFAULT_HEADERVIEW_HEIGHT);
1698 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1700 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1701 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1707 hpaned = gtk_hpaned_new();
1708 gtk_widget_show(hpaned);
1709 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1710 gtk_paned_add1(GTK_PANED(hpaned),
1711 GTK_WIDGET_PTR(mainwin->folderview));
1713 vpaned = gtk_vpaned_new();
1714 if (mainwin->summaryview->msg_is_toggled_on) {
1715 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1716 gtk_paned_add1(GTK_PANED(vpaned),
1717 GTK_WIDGET_PTR(mainwin->summaryview));
1719 gtk_paned_add2(GTK_PANED(hpaned),
1720 GTK_WIDGET_PTR(mainwin->summaryview));
1721 gtk_widget_ref(vpaned);
1723 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1724 prefs_common.summaryview_width,
1725 prefs_common.summaryview_height);
1726 gtk_paned_add2(GTK_PANED(vpaned),
1727 GTK_WIDGET_PTR(mainwin->messageview));
1728 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1729 prefs_common.mainview_width, -1);
1730 gtk_widget_set_usize(mainwin->window,
1731 prefs_common.folderview_width +
1732 prefs_common.mainview_width,
1733 prefs_common.mainwin_height);
1734 gtk_widget_show_all(vpaned);
1736 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1737 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1738 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1739 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1740 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1741 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1743 mainwin->win.sep_none.hpaned = hpaned;
1744 mainwin->win.sep_none.vpaned = vpaned;
1746 case SEPARATE_FOLDER:
1747 vpaned = gtk_vpaned_new();
1748 if (mainwin->summaryview->msg_is_toggled_on) {
1749 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1751 gtk_paned_add1(GTK_PANED(vpaned),
1752 GTK_WIDGET_PTR(mainwin->summaryview));
1754 gtk_box_pack_start(GTK_BOX(vbox_body),
1755 GTK_WIDGET_PTR(mainwin->summaryview),
1757 gtk_widget_ref(vpaned);
1759 gtk_paned_add2(GTK_PANED(vpaned),
1760 GTK_WIDGET_PTR(mainwin->messageview));
1761 gtk_widget_show_all(vpaned);
1762 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1763 prefs_common.summaryview_width,
1764 prefs_common.summaryview_height);
1765 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1766 prefs_common.mainview_width, -1);
1767 gtk_widget_set_usize(mainwin->window,
1768 prefs_common.mainview_width,
1769 prefs_common.mainview_height);
1771 gtk_container_add(GTK_CONTAINER(folderwin),
1772 GTK_WIDGET_PTR(mainwin->folderview));
1774 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1775 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1777 mainwin->win.sep_folder.folderwin = folderwin;
1778 mainwin->win.sep_folder.vpaned = vpaned;
1780 gtk_widget_show_all(folderwin);
1782 case SEPARATE_MESSAGE:
1783 hpaned = gtk_hpaned_new();
1784 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1786 gtk_paned_add1(GTK_PANED(hpaned),
1787 GTK_WIDGET_PTR(mainwin->folderview));
1788 gtk_paned_add2(GTK_PANED(hpaned),
1789 GTK_WIDGET_PTR(mainwin->summaryview));
1790 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1791 prefs_common.summaryview_width,
1792 prefs_common.summaryview_height);
1793 gtk_widget_set_usize(mainwin->window,
1794 prefs_common.folderview_width +
1795 prefs_common.mainview_width,
1796 prefs_common.mainwin_height);
1797 gtk_widget_show_all(hpaned);
1798 gtk_container_add(GTK_CONTAINER(messagewin),
1799 GTK_WIDGET_PTR(mainwin->messageview));
1801 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1802 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1803 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1804 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1806 mainwin->win.sep_message.messagewin = messagewin;
1807 mainwin->win.sep_message.hpaned = hpaned;
1809 gtk_widget_show_all(messagewin);
1812 gtk_box_pack_start(GTK_BOX(vbox_body),
1813 GTK_WIDGET_PTR(mainwin->summaryview),
1815 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1816 prefs_common.summaryview_width,
1817 prefs_common.summaryview_height);
1818 gtk_widget_set_usize(mainwin->window,
1819 prefs_common.mainview_width,
1820 prefs_common.mainwin_height);
1821 gtk_container_add(GTK_CONTAINER(folderwin),
1822 GTK_WIDGET_PTR(mainwin->folderview));
1823 gtk_container_add(GTK_CONTAINER(messagewin),
1824 GTK_WIDGET_PTR(mainwin->messageview));
1826 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1827 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1829 mainwin->win.sep_both.folderwin = folderwin;
1830 mainwin->win.sep_both.messagewin = messagewin;
1832 gtk_widget_show_all(folderwin);
1833 gtk_widget_show_all(messagewin);
1837 mainwin->type = type;
1839 debug_print(_("done.\n"));
1842 static void main_window_toolbar_create(MainWindow *mainwin,
1843 GtkWidget *container)
1846 GtkWidget *icon_wid;
1848 GtkWidget *getall_btn;
1849 GtkWidget *compose_mail_btn;
1850 GtkWidget *compose_news_btn;
1851 GtkWidget *reply_btn;
1852 GtkWidget *replyall_btn;
1853 GtkWidget *replysender_btn;
1855 GtkWidget *send_btn;
1857 GtkWidget *prefs_btn;
1858 GtkWidget *account_btn;
1860 GtkWidget *next_btn;
1861 GtkWidget *delete_btn;
1862 GtkWidget *exec_btn;
1864 GtkTooltips *tooltips;
1866 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1868 gtk_container_add(GTK_CONTAINER(container), toolbar);
1869 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1870 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1871 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1872 GTK_TOOLBAR_SPACE_LINE);
1874 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1875 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1877 _("Get new mail from current account"),
1879 icon_wid, toolbar_inc_cb, mainwin);
1880 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1881 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1883 _("Get new mail from all accounts"),
1889 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1891 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1892 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1894 _("Send queued message(s)"),
1900 /* insert compose mail button widget */
1901 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1902 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1904 _("Compose an email message"),
1907 toolbar_compose_mail_cb,
1910 /* insert compose news button widget */
1911 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1912 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1914 _("Compose a news message"),
1917 toolbar_compose_news_cb,
1920 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1924 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1925 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1927 _("Reply to the message - Right button: more options"),
1933 /* replyall button */
1935 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1936 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1938 _("Reply to all - Right button: more options"),
1941 toolbar_reply_to_all_cb,
1944 /* reply to sender button */
1945 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1946 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1948 _("Reply to sender - Right button: more options"),
1951 toolbar_reply_to_sender_cb,
1954 /* forward button */
1955 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1956 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1958 _("Forward the message - Right button: more options"),
1964 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1966 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1967 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1969 _("Delete the message"),
1975 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1976 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1978 _("Execute marked process"),
1984 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
1985 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1987 _("Next unread message"),
1990 toolbar_next_unread_cb,
1994 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1996 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
1997 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1999 _("Common preference"),
2004 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2005 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2007 _("Account setting"),
2012 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2013 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2017 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2018 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2021 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2022 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2025 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2026 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2029 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2030 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2034 mainwin->toolbar = toolbar;
2035 mainwin->get_btn = get_btn;
2036 mainwin->getall_btn = getall_btn;
2037 mainwin->compose_mail_btn = compose_mail_btn;
2038 mainwin->compose_news_btn = compose_news_btn;
2039 mainwin->reply_btn = reply_btn;
2040 mainwin->replyall_btn = replyall_btn;
2041 mainwin->replysender_btn = replysender_btn;
2042 mainwin->fwd_btn = fwd_btn;
2043 mainwin->send_btn = send_btn;
2045 mainwin->prefs_btn = prefs_btn;
2046 mainwin->account_btn = account_btn;
2048 mainwin->next_btn = next_btn;
2049 mainwin->delete_btn = delete_btn;
2050 mainwin->exec_btn = exec_btn;
2052 gtk_widget_show_all(toolbar);
2055 /* callback functions */
2056 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2058 MainWindow *mainwindow = (MainWindow *) data;
2062 if (event->button == 3) {
2063 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2064 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2065 menu_button_position, widget,
2066 event->button, event->time);
2070 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2072 MainWindow *mainwin = (MainWindow *)data;
2074 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2075 manage_window_focus_in(mainwin->window, NULL, NULL);
2078 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2080 MainWindow *mainwindow = (MainWindow *) data;
2084 if (event->button == 3) {
2085 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2086 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2087 menu_button_position, widget,
2088 event->button, event->time);
2092 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2094 MainWindow *mainwin = (MainWindow *)data;
2096 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2097 manage_window_focus_in(mainwin->window, NULL, NULL);
2100 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2102 MainWindow *mainwindow = (MainWindow *) data;
2103 GtkWidget *replysender_menu, *replysender_item;
2107 if (event->button == 3) {
2108 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2109 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2110 menu_button_position, widget,
2111 event->button, event->time);
2115 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2117 MainWindow *mainwin = (MainWindow *)data;
2119 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2120 manage_window_focus_in(mainwin->window, NULL, NULL);
2123 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2125 MainWindow *mainwindow = (MainWindow *) data;
2129 if (event->button == 3) {
2130 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2131 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2132 menu_button_position, widget,
2133 event->button, event->time);
2137 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2139 MainWindow *mainwin = (MainWindow *)data;
2141 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2142 manage_window_focus_in(mainwin->window, NULL, NULL);
2145 static void toolbar_inc_cb (GtkWidget *widget,
2148 MainWindow *mainwin = (MainWindow *)data;
2150 inc_mail_cb(mainwin, 0, NULL);
2153 static void toolbar_inc_all_cb (GtkWidget *widget,
2156 MainWindow *mainwin = (MainWindow *)data;
2158 inc_all_account_mail_cb(mainwin, 0, NULL);
2161 static void toolbar_send_cb (GtkWidget *widget,
2164 MainWindow *mainwin = (MainWindow *)data;
2166 send_queue_cb(mainwin, 0, NULL);
2169 static void toolbar_compose_cb (GtkWidget *widget,
2172 MainWindow *mainwin = (MainWindow *)data;
2174 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2175 compose_cb(mainwin, 0, NULL);
2177 compose_news_cb(mainwin, 0, NULL);
2180 static void toolbar_compose_news_cb (GtkWidget *widget,
2183 MainWindow *mainwin = (MainWindow *)data;
2185 compose_news_cb(mainwin, 0, NULL);
2188 static void toolbar_compose_mail_cb (GtkWidget *widget,
2191 MainWindow *mainwin = (MainWindow *)data;
2193 compose_mail_cb(mainwin, 0, NULL);
2196 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2198 MainWindow *mainwin = (MainWindow *)data;
2201 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2202 : COMPOSE_REPLY_WITHOUT_QUOTE,
2206 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2208 MainWindow *mainwin = (MainWindow *)data;
2211 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2212 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2217 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2219 MainWindow *mainwin = (MainWindow *)data;
2222 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2223 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2227 static void toolbar_forward_cb (GtkWidget *widget,
2230 MainWindow *mainwin = (MainWindow *)data;
2232 if (prefs_common.forward_as_attachment)
2233 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2235 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2238 static void toolbar_delete_cb (GtkWidget *widget,
2241 MainWindow *mainwin = (MainWindow *)data;
2243 summary_delete(mainwin->summaryview);
2246 static void toolbar_exec_cb (GtkWidget *widget,
2249 MainWindow *mainwin = (MainWindow *)data;
2251 summary_execute(mainwin->summaryview);
2254 static void toolbar_next_unread_cb (GtkWidget *widget,
2257 MainWindow *mainwin = (MainWindow *)data;
2259 next_unread_cb(mainwin, 0, NULL);
2262 static void toolbar_prefs_cb (GtkWidget *widget,
2265 prefs_common_open();
2268 static void toolbar_account_cb (GtkWidget *widget,
2271 MainWindow *mainwin = (MainWindow *)data;
2273 prefs_account_open_cb(mainwin, 0, NULL);
2276 static void toolbar_account_button_pressed(GtkWidget *widget,
2277 GdkEventButton *event,
2280 MainWindow *mainwin = (MainWindow *)data;
2283 if (event->button != 3) return;
2285 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2286 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2289 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2290 menu_button_position, widget,
2291 event->button, event->time);
2294 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2297 MainWindow *mainwin = (MainWindow *)data;
2301 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2302 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2305 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2306 menu_button_position, widget,
2307 event->button, event->time);
2310 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2312 MainWindow *mainwin = (MainWindow *)data;
2315 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2316 if (!button) return;
2317 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2318 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2319 manage_window_focus_in(mainwin->window, NULL, NULL);
2322 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2325 MainWindow *mainwin = (MainWindow *)data;
2327 if (mainwin->lock_count == 0)
2328 app_exit_cb(data, 0, widget);
2333 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2336 main_window_add_mailbox(mainwin);
2339 static void add_mbox_cb(MainWindow *mainwin, guint action,
2342 main_window_add_mbox(mainwin);
2345 static void update_folderview_cb(MainWindow *mainwin, guint action,
2348 summary_show(mainwin->summaryview, NULL, FALSE);
2349 folderview_rescan_all();
2352 static void new_folder_cb(MainWindow *mainwin, guint action,
2355 folderview_new_folder(mainwin->folderview);
2358 static void rename_folder_cb(MainWindow *mainwin, guint action,
2361 folderview_rename_folder(mainwin->folderview);
2364 static void delete_folder_cb(MainWindow *mainwin, guint action,
2367 folderview_delete_folder(mainwin->folderview);
2370 static void import_mbox_cb(MainWindow *mainwin, guint action,
2373 import_mbox(mainwin->summaryview->folder_item);
2376 static void export_mbox_cb(MainWindow *mainwin, guint action,
2379 export_mbox(mainwin->summaryview->folder_item);
2382 static void empty_trash_cb(MainWindow *mainwin, guint action,
2385 main_window_empty_trash(mainwin, TRUE);
2388 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2390 summary_save_as(mainwin->summaryview);
2393 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2395 summary_print(mainwin->summaryview);
2398 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2400 if (prefs_common.confirm_on_exit) {
2401 if (alertpanel(_("Exit"), _("Exit this program?"),
2402 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2404 manage_window_focus_in(mainwin->window, NULL, NULL);
2407 app_will_exit(widget, mainwin);
2410 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2413 summary_search(mainwin->summaryview);
2415 message_search(mainwin->messageview);
2418 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2421 switch (mainwin->type) {
2423 case SEPARATE_MESSAGE:
2425 case SEPARATE_FOLDER:
2426 if (GTK_CHECK_MENU_ITEM(widget)->active)
2427 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2429 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2432 if (GTK_CHECK_MENU_ITEM(widget)->active)
2433 gtk_widget_show(mainwin->win.sep_both.folderwin);
2435 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2440 static void toggle_message_cb(MainWindow *mainwin, guint action,
2443 switch (mainwin->type) {
2445 case SEPARATE_FOLDER:
2447 case SEPARATE_MESSAGE:
2448 if (GTK_CHECK_MENU_ITEM(widget)->active)
2449 gtk_widget_show(mainwin->win.sep_message.messagewin);
2451 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2454 if (GTK_CHECK_MENU_ITEM(widget)->active)
2455 gtk_widget_show(mainwin->win.sep_both.messagewin);
2457 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2462 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2465 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2466 mainwin->compose_btn_type);
2467 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2468 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2469 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2470 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2472 mainwin->toolbar_style = (ToolbarStyle)action;
2473 prefs_common.toolbar_style = (ToolbarStyle)action;
2475 set_toolbar_style(mainwin);
2478 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2481 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2482 gtk_widget_show(mainwin->hbox_stat);
2483 prefs_common.show_statusbar = TRUE;
2485 gtk_widget_hide(mainwin->hbox_stat);
2486 prefs_common.show_statusbar = FALSE;
2490 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2492 summary_toggle_view_real(mainwin->summaryview);
2495 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2497 messageview_toggle_view_real(mainwin->messageview);
2500 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2503 MainWindow *mainwin;
2506 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2507 g_return_if_fail(mainwin != NULL);
2509 type = mainwin->type ^ action;
2510 main_window_separation_change(mainwin, type);
2512 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2513 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2516 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2519 addressbook_open(NULL);
2522 static void log_window_show_cb(MainWindow *mainwin, guint action,
2525 log_window_show(mainwin->logwin);
2528 static void sel_download_cb(MainWindow *mainwin, guint action,
2531 selective_download(mainwin);
2534 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2539 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2542 inc_all_account_mail(mainwin);
2545 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2549 if (procmsg_send_queue() < 0)
2550 alertpanel_error(_("Some errors occurred while sending queued messages."));
2552 statusbar_pop_all();
2554 for (list = folder_get_list(); list != NULL; list = list->next) {
2557 folder = list->data;
2558 if (folder->queue) {
2559 folder_item_scan(folder->queue);
2560 folderview_update_item(folder->queue, TRUE);
2565 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2567 if (mainwin->summaryview->folder_item) {
2568 if (mainwin->summaryview->folder_item->folder->account != NULL
2569 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2570 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2572 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2578 static void compose_mail_cb(MainWindow *mainwin, guint action,
2585 if (mainwin->summaryview->folder_item) {
2586 ac = mainwin->summaryview->folder_item->folder->account;
2587 if (ac && ac->protocol != A_NNTP) {
2588 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2593 if(cur_account && (cur_account->protocol != A_NNTP)) {
2594 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
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) {
2602 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2608 static void compose_news_cb(MainWindow *mainwin, guint action,
2611 PrefsAccount * ac = NULL;
2615 if (mainwin->summaryview->folder_item) {
2616 ac = mainwin->summaryview->folder_item->folder->account;
2617 if (ac && ac->protocol == A_NNTP) {
2618 compose_new_with_recipient
2619 (ac, mainwin->summaryview->folder_item->path);
2624 list = account_get_list();
2625 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2626 ac = (PrefsAccount *) cur->data;
2627 if (ac->protocol == A_NNTP) {
2634 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2636 summary_reply(mainwin->summaryview, (ComposeMode)action);
2639 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2641 summary_move_to(mainwin->summaryview);
2644 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2646 summary_copy_to(mainwin->summaryview);
2649 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2651 summary_delete(mainwin->summaryview);
2654 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2656 summary_open_msg(mainwin->summaryview);
2659 static void view_source_cb(MainWindow *mainwin, guint action,
2662 summary_view_source(mainwin->summaryview);
2665 static void show_all_header_cb(MainWindow *mainwin, guint action,
2668 if (mainwin->menu_lock_count) return;
2669 summary_display_msg_selected(mainwin->summaryview,
2670 GTK_CHECK_MENU_ITEM(widget)->active);
2673 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2675 summary_reedit(mainwin->summaryview);
2678 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2680 summary_mark(mainwin->summaryview);
2683 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2685 summary_unmark(mainwin->summaryview);
2688 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2691 summary_mark_as_unread(mainwin->summaryview);
2694 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2697 summary_mark_as_read(mainwin->summaryview);
2700 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2703 summary_mark_all_read(mainwin->summaryview);
2706 static void add_address_cb(MainWindow *mainwin, guint action,
2709 summary_add_address(mainwin->summaryview);
2712 static void set_charset_cb(MainWindow *mainwin, guint action,
2717 str = conv_get_charset_str((CharSet)action);
2718 g_free(prefs_common.force_charset);
2719 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2721 summary_redisplay_msg(mainwin->summaryview);
2723 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2726 static void hide_read_messages (MainWindow *mainwin, guint action,
2729 if (!mainwin->summaryview->folder_item
2730 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2732 summary_toggle_show_read_messages(mainwin->summaryview);
2735 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2737 GtkItemFactory *ifactory;
2739 if (mainwin->menu_lock_count) return;
2740 if (!mainwin->summaryview->folder_item) return;
2742 ifactory = gtk_item_factory_from_widget(widget);
2744 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2745 summary_thread_build(mainwin->summaryview);
2746 mainwin->summaryview->folder_item->threaded = TRUE;
2748 summary_unthread(mainwin->summaryview);
2749 mainwin->summaryview->folder_item->threaded = FALSE;
2753 static void set_display_item_cb(MainWindow *mainwin, guint action,
2756 prefs_summary_column_open();
2759 static void sort_summary_cb(MainWindow *mainwin, guint action,
2762 summary_sort(mainwin->summaryview, (SummarySortType)action);
2765 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2768 summary_attract_by_subject(mainwin->summaryview);
2771 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2774 summary_delete_duplicated(mainwin->summaryview);
2777 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2779 summary_filter(mainwin->summaryview);
2782 static void execute_summary_cb(MainWindow *mainwin, guint action,
2785 summary_execute(mainwin->summaryview);
2788 static void update_summary_cb(MainWindow *mainwin, guint action,
2792 FolderView *folderview = mainwin->folderview;
2794 if (!mainwin->summaryview->folder_item) return;
2795 if (!folderview->opened) return;
2797 folder_update_op_count();
2799 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2800 folderview->opened);
2803 summary_show(mainwin->summaryview, fitem, TRUE);
2806 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2808 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2811 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2813 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2816 static void prev_unread_cb(MainWindow *mainwin, guint action,
2819 summary_select_prev_unread(mainwin->summaryview);
2822 static void next_unread_cb(MainWindow *mainwin, guint action,
2825 summary_select_next_unread(mainwin->summaryview);
2828 static void prev_marked_cb(MainWindow *mainwin, guint action,
2831 summary_select_prev_marked(mainwin->summaryview);
2834 static void next_marked_cb(MainWindow *mainwin, guint action,
2837 summary_select_next_marked(mainwin->summaryview);
2840 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2843 summary_select_prev_labeled(mainwin->summaryview);
2846 static void next_labeled_cb(MainWindow *mainwin, guint action,
2849 summary_select_next_labeled(mainwin->summaryview);
2852 static void goto_folder_cb(MainWindow *mainwin, guint action,
2855 FolderItem *to_folder;
2857 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2860 folderview_select(mainwin->folderview, to_folder);
2863 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2865 messageview_copy_clipboard(mainwin->messageview);
2868 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2870 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2871 summary_select_all(mainwin->summaryview);
2872 else if (mainwin->summaryview->msg_is_toggled_on &&
2873 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2874 messageview_select_all(mainwin->messageview);
2877 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2879 if (mainwin->summaryview->msg_is_toggled_on)
2880 summary_select_thread(mainwin->summaryview);
2883 static void create_filter_cb(MainWindow *mainwin, guint action,
2886 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2889 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2892 prefs_common_open();
2895 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2898 prefs_filter_open(NULL, NULL);
2901 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2904 prefs_scoring_open(NULL);
2907 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2910 prefs_filtering_open(NULL);
2913 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2916 prefs_template_open();
2919 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2922 prefs_actions_open(mainwin);
2925 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2929 new_account_cb(mainwin, 0, widget);
2931 gboolean prev_default = cur_account->is_default;
2933 prefs_account_open(cur_account);
2934 if (!prev_default && cur_account->is_default)
2935 account_set_as_default(cur_account);
2936 account_save_config_all();
2938 main_window_reflect_prefs_all();
2942 static void new_account_cb(MainWindow *mainwin, guint action,
2945 account_edit_open();
2946 if (!compose_get_compose_list()) account_add();
2949 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2951 cur_account = (PrefsAccount *)data;
2952 main_window_reflect_prefs_all();
2955 static void manual_open_cb(MainWindow *mainwin, guint action,
2958 manual_open((ManualLang)action);
2961 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2963 MainWindow *mainwin = (MainWindow *)data;
2967 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2968 LOCAL_FOLDER(folder)->rootpath,
2972 str = g_strdup_printf(_("Scanning folder %s ..."),
2973 LOCAL_FOLDER(folder)->rootpath);
2975 STATUSBAR_PUSH(mainwin, str);
2976 STATUSBAR_POP(mainwin);
2980 static void activate_compose_button (MainWindow *mainwin,
2982 ComposeButtonType type)
2984 SensitiveCond state = main_window_get_current_state(mainwin);
2986 if (style == TOOLBAR_NONE)
2989 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2990 : mainwin->compose_news_btn);
2991 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2992 : mainwin->compose_mail_btn);
2993 mainwin->compose_btn_type = type;
2996 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2998 if (mainwin->compose_btn_type != compose_btn_type)
2999 activate_compose_button(mainwin,
3000 prefs_common.toolbar_style,
3004 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
3006 MainWindow *mainwin = (MainWindow*) data;
3008 if (!mainwin) return;
3010 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
3013 #define BREAK_ON_MODIFIER_KEY() \
3014 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3016 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3018 MainWindow *mainwin = (MainWindow*) data;
3020 if (!mainwin || !event) return;
3022 switch (event->keyval) {
3023 case GDK_Q: /* Quit */
3024 BREAK_ON_MODIFIER_KEY();
3026 app_exit_cb(mainwin, 0, NULL);
3033 #undef BREAK_ON_MODIFIER_KEY
3035 static void set_toolbar_style(MainWindow *mainwin)
3037 switch (prefs_common.toolbar_style) {
3039 gtk_widget_hide(mainwin->handlebox);
3042 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3046 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3050 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3055 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3056 gtk_widget_show(mainwin->handlebox);
3057 gtk_widget_queue_resize(mainwin->handlebox);
3059 if (prefs_common.immediate_exec)
3060 gtk_widget_hide(mainwin->exec_btn);
3062 gtk_widget_show(mainwin->exec_btn);