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,
398 static void create_filter_cb (MainWindow *mainwin,
402 static void prefs_common_open_cb (MainWindow *mainwin,
405 static void prefs_filter_open_cb (MainWindow *mainwin,
408 static void prefs_scoring_open_cb (MainWindow *mainwin,
411 static void prefs_filtering_open_cb (MainWindow *mainwin,
414 static void prefs_account_open_cb(MainWindow *mainwin,
417 static void prefs_template_open_cb (MainWindow *mainwin,
420 static void prefs_actions_open_cb (MainWindow *mainwin,
423 static void new_account_cb (MainWindow *mainwin,
427 static void account_menu_cb (GtkMenuItem *menuitem,
430 static void manual_open_cb (MainWindow *mainwin,
434 static void scan_tree_func (Folder *folder,
438 static void activate_compose_button (MainWindow *mainwin,
440 ComposeButtonType type);
442 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
446 static void key_pressed (GtkWidget *widget,
450 static void set_toolbar_style(MainWindow *mainwin);
452 #define SEPARATE_ACTION 667
454 static GtkItemFactoryEntry mainwin_entries[] =
456 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
457 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
458 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
459 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
460 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
461 {N_("/_File/_Folder/Create _new folder..."),
462 NULL, new_folder_cb, 0, NULL},
463 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
464 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
465 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
466 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
467 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
468 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
469 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
470 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
471 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
472 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
474 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
475 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
476 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
477 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
478 {N_("/_Edit/_Find in current message..."),
479 "<control>F", search_cb, 0, NULL},
480 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
481 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
482 {N_("/_Edit/Actio_ns"), NULL, NULL, 0, "<Branch>"},
484 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
485 {N_("/_View/Separate _Folder Tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
486 {N_("/_View/Separate _Message View"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
487 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
488 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
489 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
490 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
491 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
492 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
493 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
494 {N_("/_View/Status _bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
495 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
496 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
497 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
498 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
499 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
500 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
501 {N_("/_View/_Sort/Sort by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
502 {N_("/_View/_Sort/Sort by _color label"),
503 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
504 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
505 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
506 {N_("/_View/_Sort/Sort by a_ttachment"),
507 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
508 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
509 {N_("/_View/_Sort/_Attract by subject"),
510 NULL, attract_by_subject_cb, 0, NULL},
511 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
512 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
513 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
514 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
516 #define CODESET_SEPARATOR \
517 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
518 #define CODESET_ACTION(action) \
519 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
521 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
522 {N_("/_View/_Code set/_Auto detect"),
523 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
524 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
525 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
526 CODESET_ACTION(C_US_ASCII)},
529 {N_("/_View/_Code set/Unicode (_UTF-8)"),
530 CODESET_ACTION(C_UTF_8)},
533 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
534 CODESET_ACTION(C_ISO_8859_1)},
537 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
538 CODESET_ACTION(C_ISO_8859_2)},
540 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
541 CODESET_ACTION(C_ISO_8859_13)},
542 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
543 CODESET_ACTION(C_ISO_8859_4)},
545 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
546 CODESET_ACTION(C_ISO_8859_7)},
548 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
549 CODESET_ACTION(C_ISO_8859_9)},
551 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
552 CODESET_ACTION(C_ISO_8859_5)},
553 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
554 CODESET_ACTION(C_KOI8_R)},
555 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
556 CODESET_ACTION(C_CP1251)},
559 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
560 CODESET_ACTION(C_ISO_2022_JP)},
562 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
563 CODESET_ACTION(C_ISO_2022_JP_2)},
565 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
566 CODESET_ACTION(C_EUC_JP)},
567 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
568 CODESET_ACTION(C_SHIFT_JIS)},
571 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
572 CODESET_ACTION(C_GB2312)},
573 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
574 CODESET_ACTION(C_BIG5)},
575 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
576 CODESET_ACTION(C_EUC_TW)},
577 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
578 CODESET_ACTION(C_ISO_2022_CN)},
580 {N_("/_View/_Code set/Korean (EUC-_KR)"),
581 CODESET_ACTION(C_EUC_KR)},
582 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
583 CODESET_ACTION(C_ISO_2022_KR)},
585 {N_("/_View/_Code set/Thai (TIS-620)"),
586 CODESET_ACTION(C_TIS_620)},
587 {N_("/_View/_Code set/Thai (Windows-874)"),
588 CODESET_ACTION(C_WINDOWS_874)},
591 #undef CODESET_SEPARATOR
592 #undef CODESET_ACTION
594 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
595 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
596 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
597 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
598 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
599 {N_("/_View/_Go to/P_rev unread message"),
600 "<shift>P", prev_unread_cb, 0, NULL},
601 {N_("/_View/_Go to/N_ext unread message"),
602 "<shift>N", next_unread_cb, 0, NULL},
603 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
604 {N_("/_View/_Go to/Prev _marked message"),
605 NULL, prev_marked_cb, 0, NULL},
606 {N_("/_View/_Go to/Next m_arked message"),
607 NULL, next_marked_cb, 0, NULL},
608 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
609 {N_("/_View/_Go to/Prev _labeled message"),
610 NULL, prev_labeled_cb, 0, NULL},
611 {N_("/_View/_Go to/Next la_beled message"),
612 NULL, next_labeled_cb, 0, NULL},
613 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
614 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
615 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
616 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
617 {N_("/_View/_View source"), "<control>U", view_source_cb, 0, NULL},
618 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
619 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_View/_Update"), "<control><alt>U", update_summary_cb, 0, NULL},
622 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
623 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
624 {N_("/_Message/Get from _all accounts"),
625 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
626 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
627 {N_("/_Message/Send queued messa_ges"),
628 NULL, send_queue_cb, 0, NULL},
629 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
630 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
631 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
632 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
633 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
634 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
635 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
636 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
637 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
638 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
639 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
640 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
641 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
642 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
643 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
644 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
645 {N_("/_Message/Delete du_plicated messages"),
646 NULL, delete_duplicated_cb, 0, NULL},
647 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
648 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
649 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
650 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
651 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
652 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
653 {N_("/_Message/_Mark/Mark as rea_d"),
654 NULL, mark_as_read_cb, 0, NULL},
655 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
657 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
658 {N_("/_Tool/_Address book"), "<shift><control>A", addressbook_open_cb, 0, NULL},
659 {N_("/_Tool/Add sender to address boo_k"),
660 NULL, add_address_cb, 0, NULL},
661 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
662 {N_("/_Tool/_Filter messages"), NULL, filter_cb, 0, NULL},
663 {N_("/_Tool/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
664 {N_("/_Tool/_Create filter rule/_Automatically"),
665 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
666 {N_("/_Tool/_Create filter rule/by _From"),
667 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
668 {N_("/_Tool/_Create filter rule/by _To"),
669 NULL, create_filter_cb, FILTER_BY_TO, NULL},
670 {N_("/_Tool/_Create filter rule/by _Subject"),
671 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
672 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
673 {N_("/_Tool/E_xecute"), "X", execute_summary_cb, 0, NULL},
674 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
675 {N_("/_Tool/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
676 {N_("/_Tool/_Selective Download"), "<alt>S", sel_download_cb, 0, NULL},
678 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
679 {N_("/_Configuration/_Common preferences..."),
680 NULL, prefs_common_open_cb, 0, NULL},
681 {N_("/_Configuration/_Filter setting..."),
682 NULL, prefs_filter_open_cb, 0, NULL},
683 {N_("/_Configuration/_Scoring ..."),
684 NULL, prefs_scoring_open_cb, 0, NULL},
685 {N_("/_Configuration/_Filtering ..."),
686 NULL, prefs_filtering_open_cb, 0, NULL},
687 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
688 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
689 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
690 {N_("/_Configuration/_Preferences for current account..."),
691 NULL, prefs_account_open_cb, 0, NULL},
692 {N_("/_Configuration/Create _new account..."),
693 NULL, new_account_cb, 0, NULL},
694 {N_("/_Configuration/_Edit accounts..."),
695 NULL, account_edit_open, 0, NULL},
696 {N_("/_Configuration/C_hange current account"),
697 NULL, NULL, 0, "<Branch>"},
699 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
700 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
701 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
702 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
703 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
704 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
706 static GtkItemFactoryEntry reply_popup_entries[] =
708 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
709 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
711 static GtkItemFactoryEntry replyall_popup_entries[] =
713 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
714 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
716 static GtkItemFactoryEntry replysender_popup_entries[] =
718 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
719 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
721 static GtkItemFactoryEntry fwd_popup_entries[] =
723 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
724 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
728 MainWindow *main_window_create(SeparateType type)
734 GtkWidget *handlebox;
735 GtkWidget *vbox_body;
736 GtkWidget *hbox_stat;
737 GtkWidget *statusbar;
738 GtkWidget *progressbar;
739 GtkWidget *statuslabel;
740 GtkWidget *ac_button;
743 FolderView *folderview;
744 SummaryView *summaryview;
745 MessageView *messageview;
746 GdkColormap *colormap;
749 guint n_menu_entries;
750 GtkItemFactory *ifactory;
753 GtkWidget *compose_popup;
754 GtkWidget *reply_popup;
755 GtkWidget *replyall_popup;
756 GtkWidget *replysender_popup;
757 GtkWidget *fwd_popup;
760 debug_print(_("Creating main window...\n"));
761 mainwin = g_new0(MainWindow, 1);
764 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
765 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
766 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
767 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
768 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
769 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
770 MANAGE_WINDOW_SIGNALS_CONNECT(window);
771 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
772 GTK_SIGNAL_FUNC(key_pressed), mainwin);
774 gtk_widget_realize(window);
775 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
778 gtkut_widget_set_app_icon(window);
780 vbox = gtk_vbox_new(FALSE, 0);
781 gtk_widget_show(vbox);
782 gtk_container_add(GTK_CONTAINER(window), vbox);
785 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
786 menubar = menubar_create(window, mainwin_entries,
787 n_menu_entries, "<Main>", mainwin);
788 gtk_widget_show(menubar);
789 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
791 handlebox = gtk_handle_box_new();
792 gtk_widget_show(handlebox);
793 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
795 /* create the popup menus for the reply buttons specials */
796 n_menu_entries = sizeof(reply_popup_entries) /
797 sizeof(reply_popup_entries[0]);
798 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
799 "<ReplyPopup>", mainwin);
800 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
801 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
802 n_menu_entries = sizeof(replyall_popup_entries) /
803 sizeof(replyall_popup_entries[0]);
804 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
805 "<ReplyAllPopup>", mainwin);
806 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
807 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
808 n_menu_entries = sizeof(replysender_popup_entries) /
809 sizeof(replysender_popup_entries[0]);
810 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
811 "<ReplySenderPopup>", mainwin);
812 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
813 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
814 /* create the popup menu for the forward button */
815 n_menu_entries = sizeof(fwd_popup_entries) /
816 sizeof(fwd_popup_entries[0]);
817 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
818 "<ForwardPopup>", mainwin);
819 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
820 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
822 main_window_toolbar_create(mainwin, handlebox);
824 /* vbox that contains body */
825 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
826 gtk_widget_show(vbox_body);
827 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
828 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
830 hbox_stat = gtk_hbox_new(FALSE, 2);
831 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
833 statusbar = statusbar_create();
834 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
836 progressbar = gtk_progress_bar_new();
837 gtk_widget_set_usize(progressbar, 120, 1);
838 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
840 statuslabel = gtk_label_new("");
841 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
843 ac_button = gtk_button_new();
844 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
845 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
846 gtk_widget_set_usize(ac_button, -1, 1);
847 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
848 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
849 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
851 ac_label = gtk_label_new("");
852 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
854 gtk_widget_show_all(hbox_stat);
857 mainwin->folderview = folderview = folderview_create();
858 mainwin->summaryview = summaryview = summary_create();
859 mainwin->messageview = messageview = messageview_create();
860 mainwin->logwin = log_window_create();
862 folderview->mainwin = mainwin;
863 folderview->summaryview = summaryview;
865 summaryview->mainwin = mainwin;
866 summaryview->folderview = folderview;
867 summaryview->messageview = messageview;
868 summaryview->window = window;
870 messageview->mainwin = mainwin;
872 mainwin->window = window;
873 mainwin->vbox = vbox;
874 mainwin->menubar = menubar;
875 mainwin->handlebox = handlebox;
876 mainwin->vbox_body = vbox_body;
877 mainwin->hbox_stat = hbox_stat;
878 mainwin->statusbar = statusbar;
879 mainwin->progressbar = progressbar;
880 mainwin->statuslabel = statuslabel;
881 mainwin->ac_button = ac_button;
882 mainwin->ac_label = ac_label;
883 mainwin->reply_popup = reply_popup;
884 mainwin->replyall_popup = replyall_popup;
885 mainwin->replysender_popup = replysender_popup;
886 mainwin->fwd_popup = fwd_popup;
888 /* set context IDs for status bar */
889 mainwin->mainwin_cid = gtk_statusbar_get_context_id
890 (GTK_STATUSBAR(statusbar), "Main Window");
891 mainwin->folderview_cid = gtk_statusbar_get_context_id
892 (GTK_STATUSBAR(statusbar), "Folder View");
893 mainwin->summaryview_cid = gtk_statusbar_get_context_id
894 (GTK_STATUSBAR(statusbar), "Summary View");
896 /* allocate colors for summary view and folder view */
897 summaryview->color_marked.red = summaryview->color_marked.green = 0;
898 summaryview->color_marked.blue = (guint16)65535;
900 summaryview->color_dim.red = summaryview->color_dim.green =
901 summaryview->color_dim.blue = COLOR_DIM;
903 folderview->color_new.red = (guint16)55000;
904 folderview->color_new.green = folderview->color_new.blue = 15000;
906 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
907 &folderview->color_op);
909 summaryview->color_important.red = 0;
910 summaryview->color_marked.green = 0;
911 summaryview->color_important.blue = (guint16)65535;
913 color[0] = summaryview->color_marked;
914 color[1] = summaryview->color_dim;
915 color[2] = folderview->color_new;
916 color[3] = folderview->color_op;
918 colormap = gdk_window_get_colormap(window->window);
919 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
920 for (i = 0; i < 4; i++) {
921 if (success[i] == FALSE)
922 g_warning(_("MainWindow: color allocation %d failed\n"), i);
925 debug_print(_("done.\n"));
927 main_window_set_widgets(mainwin, type);
930 ifactory = gtk_item_factory_from_widget(menubar);
931 menuitem = gtk_item_factory_get_item
932 (ifactory, "/View/Code set/Auto detect");
933 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
935 switch (prefs_common.toolbar_style) {
937 menuitem = gtk_item_factory_get_item
938 (ifactory, "/View/Toolbar/None");
941 menuitem = gtk_item_factory_get_item
942 (ifactory, "/View/Toolbar/Icon");
945 menuitem = gtk_item_factory_get_item
946 (ifactory, "/View/Toolbar/Text");
949 menuitem = gtk_item_factory_get_item
950 (ifactory, "/View/Toolbar/Icon and text");
952 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
954 gtk_widget_hide(mainwin->hbox_stat);
955 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
956 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
957 prefs_common.show_statusbar);
958 #if 0 /* FIXED SEPARATE WINDOWS */
959 /* Message view and Folder tree are always shown at startup
960 * make that in the menu visible */
961 menuitem = gtk_item_factory_get_item(ifactory, "/View/Message view");
962 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
963 menuitem = gtk_item_factory_get_item(ifactory, "/View/Folder tree");
964 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
966 /* set the check of the SEPARATE_xxx menu items. we also need the main window
967 * as a property and pass the action type to the callback */
968 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
970 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
971 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
972 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
973 GUINT_TO_POINTER(SEPARATE_FOLDER));
975 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
977 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
978 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
979 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
980 GUINT_TO_POINTER(SEPARATE_MESSAGE));
982 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
983 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
986 /* set account selection menu */
987 ac_menu = gtk_item_factory_get_widget
988 (ifactory, "/Configuration/Change current account");
989 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
990 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
991 mainwin->ac_menu = ac_menu;
993 main_window_set_toolbar_sensitive(mainwin);
995 /* Create actions menu */
996 update_mainwin_actions_menu(ifactory, mainwin);
998 /* show main window */
999 gtk_widget_set_uposition(mainwin->window,
1000 prefs_common.mainwin_x,
1001 prefs_common.mainwin_y);
1002 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1003 prefs_common.mainwin_height);
1004 gtk_widget_show(mainwin->window);
1006 /* initialize views */
1007 folderview_init(folderview);
1008 summary_init(summaryview);
1009 messageview_init(messageview);
1010 log_window_init(mainwin->logwin);
1012 mainwin->lock_count = 0;
1013 mainwin->menu_lock_count = 0;
1014 mainwin->cursor_count = 0;
1017 watch_cursor = gdk_cursor_new(GDK_WATCH);
1019 mainwin_list = g_list_append(mainwin_list, mainwin);
1024 void main_window_cursor_wait(MainWindow *mainwin)
1027 if (mainwin->cursor_count == 0)
1028 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1030 mainwin->cursor_count++;
1035 void main_window_cursor_normal(MainWindow *mainwin)
1037 if (mainwin->cursor_count)
1038 mainwin->cursor_count--;
1040 if (mainwin->cursor_count == 0)
1041 gdk_window_set_cursor(mainwin->window->window, NULL);
1046 /* lock / unlock the user-interface */
1047 void main_window_lock(MainWindow *mainwin)
1049 if (mainwin->lock_count == 0)
1050 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1052 mainwin->lock_count++;
1054 main_window_set_menu_sensitive(mainwin);
1055 main_window_set_toolbar_sensitive(mainwin);
1058 void main_window_unlock(MainWindow *mainwin)
1060 if (mainwin->lock_count)
1061 mainwin->lock_count--;
1063 main_window_set_menu_sensitive(mainwin);
1064 main_window_set_toolbar_sensitive(mainwin);
1066 if (mainwin->lock_count == 0)
1067 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1070 static void main_window_menu_callback_block(MainWindow *mainwin)
1072 mainwin->menu_lock_count++;
1075 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1077 if (mainwin->menu_lock_count)
1078 mainwin->menu_lock_count--;
1081 void main_window_reflect_prefs_all(void)
1083 main_window_reflect_prefs_all_real(FALSE);
1086 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1089 MainWindow *mainwin;
1091 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1092 mainwin = (MainWindow *)cur->data;
1094 main_window_show_cur_account(mainwin);
1095 main_window_set_menu_sensitive(mainwin);
1096 main_window_set_toolbar_sensitive(mainwin);
1099 if (pixmap_theme_changed)
1101 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1102 mainwin->toolbar = NULL;
1103 main_window_toolbar_create(mainwin, mainwin->handlebox);
1104 set_toolbar_style(mainwin);
1105 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1106 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1107 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1110 summary_redisplay_msg(mainwin->summaryview);
1111 headerview_set_visibility(mainwin->messageview->headerview,
1112 prefs_common.display_header_pane);
1116 void main_window_set_summary_column(void)
1119 MainWindow *mainwin;
1121 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1122 mainwin = (MainWindow *)cur->data;
1123 summary_set_column_order(mainwin->summaryview);
1127 void main_window_set_account_menu(GList *account_list)
1129 GList *cur, *cur_ac, *cur_item;
1130 GtkWidget *menuitem;
1131 MainWindow *mainwin;
1132 PrefsAccount *ac_prefs;
1134 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1135 mainwin = (MainWindow *)cur->data;
1137 /* destroy all previous menu item */
1138 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1139 while (cur_item != NULL) {
1140 GList *next = cur_item->next;
1141 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1145 for (cur_ac = account_list; cur_ac != NULL;
1146 cur_ac = cur_ac->next) {
1147 ac_prefs = (PrefsAccount *)cur_ac->data;
1149 menuitem = gtk_menu_item_new_with_label
1150 (ac_prefs->account_name
1151 ? ac_prefs->account_name : _("Untitled"));
1152 gtk_widget_show(menuitem);
1153 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1154 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1155 GTK_SIGNAL_FUNC(account_menu_cb),
1161 static void main_window_show_cur_account(MainWindow *mainwin)
1166 ac_name = g_strdup(cur_account
1167 ? (cur_account->account_name
1168 ? cur_account->account_name : _("Untitled"))
1172 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1174 buf = g_strdup(PROG_VERSION);
1175 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1178 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1179 gtk_widget_queue_resize(mainwin->ac_button);
1184 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1186 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1187 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1188 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1190 if (mainwin->type == type) return;
1192 /* remove widgets from those containers */
1193 gtk_widget_ref(folder_wid);
1194 gtk_widget_ref(summary_wid);
1195 gtk_widget_ref(message_wid);
1196 gtkut_container_remove
1197 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1198 gtkut_container_remove
1199 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1200 gtkut_container_remove
1201 (GTK_CONTAINER(message_wid->parent), message_wid);
1203 /* clean containers */
1204 switch (mainwin->type) {
1206 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1208 case SEPARATE_FOLDER:
1209 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1210 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1212 case SEPARATE_MESSAGE:
1213 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1214 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1217 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1218 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1222 gtk_widget_hide(mainwin->window);
1223 main_window_set_widgets(mainwin, type);
1224 gtk_widget_show(mainwin->window);
1226 gtk_widget_unref(folder_wid);
1227 gtk_widget_unref(summary_wid);
1228 gtk_widget_unref(message_wid);
1231 void main_window_get_size(MainWindow *mainwin)
1233 GtkAllocation *allocation;
1235 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1237 prefs_common.summaryview_width = allocation->width;
1239 if (mainwin->summaryview->msg_is_toggled_on)
1240 prefs_common.summaryview_height = allocation->height;
1242 prefs_common.mainview_width = allocation->width;
1244 allocation = &mainwin->window->allocation;
1246 prefs_common.mainview_height = allocation->height;
1247 prefs_common.mainwin_width = allocation->width;
1248 prefs_common.mainwin_height = allocation->height;
1250 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1252 prefs_common.folderview_width = allocation->width;
1253 prefs_common.folderview_height = allocation->height;
1256 void main_window_get_position(MainWindow *mainwin)
1260 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1262 prefs_common.mainview_x = x;
1263 prefs_common.mainview_y = y;
1264 prefs_common.mainwin_x = x;
1265 prefs_common.mainwin_y = y;
1267 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1270 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1276 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1277 folder = FOLDER(list->data);
1278 if (folder && folder->trash && folder->trash->total > 0)
1282 if (!has_trash) return;
1285 if (alertpanel(_("Empty trash"),
1286 _("Empty all messages in trash?"),
1287 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1289 manage_window_focus_in(mainwin->window, NULL, NULL);
1292 procmsg_empty_trash();
1294 for (list = folder_get_list(); list != NULL; list = list->next) {
1295 folder = list->data;
1296 if (folder && folder->trash && folder->trash->total != 0) {
1297 folder_item_scan(folder->trash);
1298 folderview_update_item(folder->trash, TRUE);
1302 if (mainwin->summaryview->folder_item &&
1303 mainwin->summaryview->folder_item->stype == F_TRASH)
1304 gtk_widget_grab_focus(mainwin->folderview->ctree);
1307 void main_window_add_mailbox(MainWindow *mainwin)
1312 path = input_dialog(_("Add mailbox"),
1313 _("Input the location of mailbox.\n"
1314 "If the existing mailbox is specified, it will be\n"
1315 "scanned automatically."),
1318 if (folder_find_from_path(path)) {
1319 alertpanel_error(_("The mailbox `%s' already exists."), path);
1323 if (!strcmp(path, "Mail"))
1324 folder = folder_new(F_MH, _("Mailbox"), path);
1326 folder = folder_new(F_MH, g_basename(path), path);
1329 if (folder->create_tree(folder) < 0) {
1330 alertpanel_error(_("Creation of the mailbox failed.\n"
1331 "Maybe some files already exist, or you don't have the permission to write there."));
1332 folder_destroy(folder);
1337 folder_set_ui_func(folder, scan_tree_func, mainwin);
1338 folder->scan_tree(folder);
1339 folder_set_ui_func(folder, NULL, NULL);
1341 folderview_set(mainwin->folderview);
1344 void main_window_add_mbox(MainWindow *mainwin)
1350 path = input_dialog(_("Add mbox mailbox"),
1351 _("Input the location of mailbox."),
1356 if (folder_find_from_path(path)) {
1357 alertpanel_error(_("The mailbox `%s' already exists."), path);
1363 if (!strcmp(path, "Mail"))
1364 folder = folder_new(F_MBOX, _("Mailbox"), path);
1368 folder = folder_new(F_MBOX, g_basename(path), path);
1371 if (folder->create_tree(folder) < 0) {
1372 alertpanel_error(_("Creation of the mailbox failed."));
1373 folder_destroy(folder);
1379 item = folder_item_new(folder->name, NULL);
1380 item->folder = folder;
1381 folder->node = g_node_new(item);
1383 folder->create_folder(folder, item, "inbox");
1384 folder->create_folder(folder, item, "outbox");
1385 folder->create_folder(folder, item, "queue");
1386 folder->create_folder(folder, item, "draft");
1387 folder->create_folder(folder, item, "trash");
1389 folderview_set(mainwin->folderview);
1394 M_UNLOCKED = 1 << 0,
1395 M_MSG_EXIST = 1 << 1,
1396 M_TARGET_EXIST = 1 << 2,
1397 M_SINGLE_TARGET_EXIST = 1 << 3,
1399 M_ALLOW_REEDIT = 1 << 5,
1400 M_HAVE_ACCOUNT = 1 << 6,
1401 M_THREADED = 1 << 7,
1402 M_UNTHREADED = 1 << 8,
1403 M_ALLOW_DELETE = 1 << 9,
1405 M_HAVE_NEWS_ACCOUNT = 1 << 11,
1406 M_HIDE_READ_MSG = 1 << 12
1409 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1411 SensitiveCond state = 0;
1412 SummarySelection selection;
1413 FolderItem *item = mainwin->summaryview->folder_item;
1414 GList *account_list = account_get_list();
1416 selection = summary_get_selection_type(mainwin->summaryview);
1418 if (mainwin->lock_count == 0)
1419 state |= M_UNLOCKED;
1420 if (selection != SUMMARY_NONE)
1421 state |= M_MSG_EXIST;
1425 state |= M_THREADED;
1427 state |= M_UNTHREADED;
1428 if (item->folder->type != F_NEWS)
1429 state |= M_ALLOW_DELETE;
1431 if (selection == SUMMARY_NONE && item->hide_read_msgs
1432 || selection != SUMMARY_NONE)
1433 state |= M_HIDE_READ_MSG;
1435 if (selection == SUMMARY_SELECTED_SINGLE ||
1436 selection == SUMMARY_SELECTED_MULTIPLE)
1437 state |= M_TARGET_EXIST;
1438 if (selection == SUMMARY_SELECTED_SINGLE)
1439 state |= M_SINGLE_TARGET_EXIST;
1440 if (mainwin->summaryview->folder_item &&
1441 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1443 if (selection == SUMMARY_SELECTED_SINGLE &&
1445 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1446 item->stype == F_QUEUE)))
1447 state |= M_ALLOW_REEDIT;
1449 state |= M_HAVE_ACCOUNT;
1451 for ( ; account_list != NULL; account_list = account_list->next) {
1452 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1453 state |= M_HAVE_NEWS_ACCOUNT;
1461 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1463 SensitiveCond state;
1472 entry[0].widget = mainwin->get_btn;
1473 entry[0].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1474 entry[1].widget = mainwin->getall_btn;
1475 entry[1].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1476 entry[2].widget = mainwin->compose_news_btn;
1477 entry[2].cond = M_HAVE_NEWS_ACCOUNT;
1478 entry[3].widget = mainwin->reply_btn;
1479 entry[3].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1480 entry[4].widget = mainwin->replyall_btn;
1481 entry[4].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1482 entry[5].widget = mainwin->replysender_btn;
1483 entry[5].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1484 entry[6].widget = mainwin->fwd_btn;
1485 entry[6].cond = M_HAVE_ACCOUNT|M_TARGET_EXIST;
1486 /* entry[6].widget = mainwin->prefs_btn;
1487 entry[6].cond = M_UNLOCKED;
1488 entry[7].widget = mainwin->account_btn;
1489 entry[7].cond = M_UNLOCKED; */
1490 entry[7].widget = mainwin->next_btn;
1491 entry[7].cond = M_MSG_EXIST;
1492 entry[8].widget = mainwin->delete_btn;
1493 entry[8].cond = M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED;
1494 entry[9].widget = mainwin->exec_btn;
1495 entry[9].cond = M_MSG_EXIST|M_EXEC|M_UNLOCKED;
1496 entry[10].widget = NULL;
1499 state = main_window_get_current_state(mainwin);
1501 for (i = 0; entry[i].widget != NULL; i++) {
1502 sensitive = ((entry[i].cond & state) == entry[i].cond);
1503 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1506 activate_compose_button(mainwin,
1507 prefs_common.toolbar_style,
1508 mainwin->compose_btn_type);
1511 void main_window_set_menu_sensitive(MainWindow *mainwin)
1513 GtkItemFactory *ifactory;
1514 SensitiveCond state;
1516 GtkWidget *menuitem;
1519 static const struct {
1523 {"/File/Add mailbox..." , M_UNLOCKED},
1524 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1525 {"/File/Rescan folder tree" , M_UNLOCKED},
1526 {"/File/Folder" , M_UNLOCKED},
1527 {"/File/Import mbox file..." , M_UNLOCKED},
1528 {"/File/Export to mbox file...", M_UNLOCKED},
1529 {"/File/Empty trash" , M_UNLOCKED},
1530 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1531 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1532 /* {"/File/Close", M_UNLOCKED}, */
1533 {"/File/Exit" , M_UNLOCKED},
1535 {"/Edit/Actions" , M_MSG_EXIST},
1536 {"/View/Sort" , M_MSG_EXIST},
1537 {"/View/Thread view" , M_EXEC},
1538 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1539 {"/View/Go to/Prev message" , M_MSG_EXIST},
1540 {"/View/Go to/Next message" , M_MSG_EXIST},
1541 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1542 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1543 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1544 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1545 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1546 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1547 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1548 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1549 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1551 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1552 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1553 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1554 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1555 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1556 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1557 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1558 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1559 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1560 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1561 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1562 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1563 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1564 {"/Message/Mark" , M_TARGET_EXIST},
1565 {"/Message/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1567 {"/Tool/Add sender to address book", M_SINGLE_TARGET_EXIST},
1568 {"/Tool/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1569 {"/Tool/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1570 {"/Tool/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1572 {"/Configuration", M_UNLOCKED},
1577 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1578 state = main_window_get_current_state(mainwin);
1580 for (i = 0; entry[i].entry != NULL; i++) {
1581 sensitive = ((entry[i].cond & state) == entry[i].cond);
1582 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1585 main_window_menu_callback_block(mainwin);
1586 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all header");
1587 gtk_check_menu_item_set_active
1588 (GTK_CHECK_MENU_ITEM(menuitem),
1589 mainwin->messageview->textview->show_all_headers);
1590 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1591 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1592 (state & M_THREADED) != 0);
1593 main_window_menu_callback_unblock(mainwin);
1596 void main_window_popup(MainWindow *mainwin)
1602 gdk_window_get_origin(mainwin->window->window, &x, &y);
1603 sx = gdk_screen_width();
1604 sy = gdk_screen_height();
1605 x %= sx; if (x < 0) x = 0;
1606 y %= sy; if (y < 0) y = 0;
1607 gdk_window_move(mainwin->window->window, x, y);
1608 gdk_window_raise(mainwin->window->window);
1609 gdk_window_show(mainwin->window->window);
1611 debug_print("window position: x = %d, y = %d\n", x, y);
1613 switch (mainwin->type) {
1614 case SEPARATE_FOLDER:
1615 widget = mainwin->win.sep_folder.folderwin;
1616 gdk_window_get_origin(widget->window, &x, &y);
1617 x %= sx; if (x < 0) x = 0;
1618 y %= sy; if (y < 0) y = 0;
1619 gdk_window_move(widget->window, x, y);
1620 gdk_window_raise(widget->window);
1622 case SEPARATE_MESSAGE:
1623 widget = mainwin->win.sep_message.messagewin;
1624 gdk_window_get_origin(widget->window, &x, &y);
1625 x %= sx; if (x < 0) x = 0;
1626 y %= sy; if (y < 0) y = 0;
1627 gdk_window_move(widget->window, x, y);
1628 gdk_window_raise(widget->window);
1631 widget = mainwin->win.sep_both.folderwin;
1632 gdk_window_get_origin(widget->window, &x, &y);
1633 x %= sx; if (x < 0) x = 0;
1634 y %= sy; if (y < 0) y = 0;
1635 gdk_window_move(widget->window, x, y);
1636 gdk_window_raise(widget->window);
1637 widget = mainwin->win.sep_both.messagewin;
1638 gdk_window_get_origin(widget->window, &x, &y);
1639 x %= sx; if (x < 0) x = 0;
1640 y %= sy; if (y < 0) y = 0;
1641 gdk_window_move(widget->window, x, y);
1642 gdk_window_raise(widget->window);
1649 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1651 GtkWidget *folderwin = NULL;
1652 GtkWidget *messagewin = NULL;
1655 GtkWidget *vbox_body = mainwin->vbox_body;
1656 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1657 GtkWidget *menuitem;
1659 debug_print(_("Setting widgets..."));
1661 /* create separated window(s) if needed */
1662 if (type & SEPARATE_FOLDER) {
1663 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1664 gtk_window_set_title(GTK_WINDOW(folderwin),
1665 _("Sylpheed - Folder View"));
1666 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1667 "folder_view", "Sylpheed");
1668 gtk_window_set_policy(GTK_WINDOW(folderwin),
1670 gtk_widget_set_usize(folderwin, -1,
1671 prefs_common.mainview_height);
1672 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1674 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1675 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1678 if (type & SEPARATE_MESSAGE) {
1679 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1680 gtk_window_set_title(GTK_WINDOW(messagewin),
1681 _("Sylpheed - Message View"));
1682 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1683 "message_view", "Sylpheed");
1684 gtk_window_set_policy(GTK_WINDOW(messagewin),
1686 gtk_widget_set_usize
1687 (messagewin, prefs_common.mainview_width,
1688 prefs_common.mainview_height
1689 - prefs_common.summaryview_height
1690 + DEFAULT_HEADERVIEW_HEIGHT);
1691 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1693 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1694 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1700 hpaned = gtk_hpaned_new();
1701 gtk_widget_show(hpaned);
1702 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1703 gtk_paned_add1(GTK_PANED(hpaned),
1704 GTK_WIDGET_PTR(mainwin->folderview));
1706 vpaned = gtk_vpaned_new();
1707 if (mainwin->summaryview->msg_is_toggled_on) {
1708 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1709 gtk_paned_add1(GTK_PANED(vpaned),
1710 GTK_WIDGET_PTR(mainwin->summaryview));
1712 gtk_paned_add2(GTK_PANED(hpaned),
1713 GTK_WIDGET_PTR(mainwin->summaryview));
1714 gtk_widget_ref(vpaned);
1716 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1717 prefs_common.summaryview_width,
1718 prefs_common.summaryview_height);
1719 gtk_paned_add2(GTK_PANED(vpaned),
1720 GTK_WIDGET_PTR(mainwin->messageview));
1721 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1722 prefs_common.mainview_width, -1);
1723 gtk_widget_set_usize(mainwin->window,
1724 prefs_common.folderview_width +
1725 prefs_common.mainview_width,
1726 prefs_common.mainwin_height);
1727 gtk_widget_show_all(vpaned);
1729 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1730 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1731 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1732 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1733 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1734 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1736 mainwin->win.sep_none.hpaned = hpaned;
1737 mainwin->win.sep_none.vpaned = vpaned;
1739 case SEPARATE_FOLDER:
1740 vpaned = gtk_vpaned_new();
1741 if (mainwin->summaryview->msg_is_toggled_on) {
1742 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1744 gtk_paned_add1(GTK_PANED(vpaned),
1745 GTK_WIDGET_PTR(mainwin->summaryview));
1747 gtk_box_pack_start(GTK_BOX(vbox_body),
1748 GTK_WIDGET_PTR(mainwin->summaryview),
1750 gtk_widget_ref(vpaned);
1752 gtk_paned_add2(GTK_PANED(vpaned),
1753 GTK_WIDGET_PTR(mainwin->messageview));
1754 gtk_widget_show_all(vpaned);
1755 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1756 prefs_common.summaryview_width,
1757 prefs_common.summaryview_height);
1758 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1759 prefs_common.mainview_width, -1);
1760 gtk_widget_set_usize(mainwin->window,
1761 prefs_common.mainview_width,
1762 prefs_common.mainview_height);
1764 gtk_container_add(GTK_CONTAINER(folderwin),
1765 GTK_WIDGET_PTR(mainwin->folderview));
1767 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1768 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1770 mainwin->win.sep_folder.folderwin = folderwin;
1771 mainwin->win.sep_folder.vpaned = vpaned;
1773 gtk_widget_show_all(folderwin);
1775 case SEPARATE_MESSAGE:
1776 hpaned = gtk_hpaned_new();
1777 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1779 gtk_paned_add1(GTK_PANED(hpaned),
1780 GTK_WIDGET_PTR(mainwin->folderview));
1781 gtk_paned_add2(GTK_PANED(hpaned),
1782 GTK_WIDGET_PTR(mainwin->summaryview));
1783 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1784 prefs_common.summaryview_width,
1785 prefs_common.summaryview_height);
1786 gtk_widget_set_usize(mainwin->window,
1787 prefs_common.folderview_width +
1788 prefs_common.mainview_width,
1789 prefs_common.mainwin_height);
1790 gtk_widget_show_all(hpaned);
1791 gtk_container_add(GTK_CONTAINER(messagewin),
1792 GTK_WIDGET_PTR(mainwin->messageview));
1794 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1795 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1796 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1797 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1799 mainwin->win.sep_message.messagewin = messagewin;
1800 mainwin->win.sep_message.hpaned = hpaned;
1802 gtk_widget_show_all(messagewin);
1805 gtk_box_pack_start(GTK_BOX(vbox_body),
1806 GTK_WIDGET_PTR(mainwin->summaryview),
1808 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1809 prefs_common.summaryview_width,
1810 prefs_common.summaryview_height);
1811 gtk_widget_set_usize(mainwin->window,
1812 prefs_common.mainview_width,
1813 prefs_common.mainwin_height);
1814 gtk_container_add(GTK_CONTAINER(folderwin),
1815 GTK_WIDGET_PTR(mainwin->folderview));
1816 gtk_container_add(GTK_CONTAINER(messagewin),
1817 GTK_WIDGET_PTR(mainwin->messageview));
1819 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1820 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1822 mainwin->win.sep_both.folderwin = folderwin;
1823 mainwin->win.sep_both.messagewin = messagewin;
1825 gtk_widget_show_all(folderwin);
1826 gtk_widget_show_all(messagewin);
1830 mainwin->type = type;
1832 debug_print(_("done.\n"));
1835 static void main_window_toolbar_create(MainWindow *mainwin,
1836 GtkWidget *container)
1839 GtkWidget *icon_wid;
1841 GtkWidget *getall_btn;
1842 GtkWidget *compose_mail_btn;
1843 GtkWidget *compose_news_btn;
1844 GtkWidget *reply_btn;
1845 GtkWidget *replyall_btn;
1846 GtkWidget *replysender_btn;
1848 GtkWidget *send_btn;
1850 GtkWidget *prefs_btn;
1851 GtkWidget *account_btn;
1853 GtkWidget *next_btn;
1854 GtkWidget *delete_btn;
1855 GtkWidget *exec_btn;
1857 GtkTooltips *tooltips;
1859 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1861 gtk_container_add(GTK_CONTAINER(container), toolbar);
1862 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1863 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1864 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1865 GTK_TOOLBAR_SPACE_LINE);
1867 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1868 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1870 _("Get new mail from current account"),
1872 icon_wid, toolbar_inc_cb, mainwin);
1873 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1874 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1876 _("Get new mail from all accounts"),
1882 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1884 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1885 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1887 _("Send queued message(s)"),
1893 /* insert compose mail button widget */
1894 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1895 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1897 _("Compose an email message"),
1900 toolbar_compose_mail_cb,
1903 /* insert compose news button widget */
1904 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1905 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1907 _("Compose a news message"),
1910 toolbar_compose_news_cb,
1913 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1917 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1918 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1920 _("Reply to the message - Right button: more options"),
1926 /* replyall button */
1928 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1929 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1931 _("Reply to all - Right button: more options"),
1934 toolbar_reply_to_all_cb,
1937 /* reply to sender button */
1938 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1939 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1941 _("Reply to sender - Right button: more options"),
1944 toolbar_reply_to_sender_cb,
1947 /* forward button */
1948 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1949 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1951 _("Forward the message - Right button: more options"),
1957 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1959 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1960 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1962 _("Delete the message"),
1968 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1969 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1971 _("Execute marked process"),
1977 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
1978 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1980 _("Next unread message"),
1983 toolbar_next_unread_cb,
1987 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1989 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
1990 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1992 _("Common preference"),
1997 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
1998 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2000 _("Account setting"),
2005 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2006 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2010 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2011 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2014 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2015 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2018 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2019 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2022 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2023 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2027 mainwin->toolbar = toolbar;
2028 mainwin->get_btn = get_btn;
2029 mainwin->getall_btn = getall_btn;
2030 mainwin->compose_mail_btn = compose_mail_btn;
2031 mainwin->compose_news_btn = compose_news_btn;
2032 mainwin->reply_btn = reply_btn;
2033 mainwin->replyall_btn = replyall_btn;
2034 mainwin->replysender_btn = replysender_btn;
2035 mainwin->fwd_btn = fwd_btn;
2036 mainwin->send_btn = send_btn;
2038 mainwin->prefs_btn = prefs_btn;
2039 mainwin->account_btn = account_btn;
2041 mainwin->next_btn = next_btn;
2042 mainwin->delete_btn = delete_btn;
2043 mainwin->exec_btn = exec_btn;
2045 gtk_widget_show_all(toolbar);
2048 /* callback functions */
2049 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2051 MainWindow *mainwindow = (MainWindow *) data;
2055 if (event->button == 3) {
2056 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2057 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2058 menu_button_position, widget,
2059 event->button, event->time);
2063 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2065 MainWindow *mainwin = (MainWindow *)data;
2067 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2068 manage_window_focus_in(mainwin->window, NULL, NULL);
2071 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2073 MainWindow *mainwindow = (MainWindow *) data;
2077 if (event->button == 3) {
2078 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2079 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2080 menu_button_position, widget,
2081 event->button, event->time);
2085 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2087 MainWindow *mainwin = (MainWindow *)data;
2089 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2090 manage_window_focus_in(mainwin->window, NULL, NULL);
2093 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2095 MainWindow *mainwindow = (MainWindow *) data;
2096 GtkWidget *replysender_menu, *replysender_item;
2100 if (event->button == 3) {
2101 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2102 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2103 menu_button_position, widget,
2104 event->button, event->time);
2108 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2110 MainWindow *mainwin = (MainWindow *)data;
2112 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2113 manage_window_focus_in(mainwin->window, NULL, NULL);
2116 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2118 MainWindow *mainwindow = (MainWindow *) data;
2122 if (event->button == 3) {
2123 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2124 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2125 menu_button_position, widget,
2126 event->button, event->time);
2130 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2132 MainWindow *mainwin = (MainWindow *)data;
2134 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2135 manage_window_focus_in(mainwin->window, NULL, NULL);
2138 static void toolbar_inc_cb (GtkWidget *widget,
2141 MainWindow *mainwin = (MainWindow *)data;
2143 inc_mail_cb(mainwin, 0, NULL);
2146 static void toolbar_inc_all_cb (GtkWidget *widget,
2149 MainWindow *mainwin = (MainWindow *)data;
2151 inc_all_account_mail_cb(mainwin, 0, NULL);
2154 static void toolbar_send_cb (GtkWidget *widget,
2157 MainWindow *mainwin = (MainWindow *)data;
2159 send_queue_cb(mainwin, 0, NULL);
2162 static void toolbar_compose_cb (GtkWidget *widget,
2165 MainWindow *mainwin = (MainWindow *)data;
2167 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2168 compose_cb(mainwin, 0, NULL);
2170 compose_news_cb(mainwin, 0, NULL);
2173 static void toolbar_compose_news_cb (GtkWidget *widget,
2176 MainWindow *mainwin = (MainWindow *)data;
2178 compose_news_cb(mainwin, 0, NULL);
2181 static void toolbar_compose_mail_cb (GtkWidget *widget,
2184 MainWindow *mainwin = (MainWindow *)data;
2186 compose_mail_cb(mainwin, 0, NULL);
2189 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2191 MainWindow *mainwin = (MainWindow *)data;
2194 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2195 : COMPOSE_REPLY_WITHOUT_QUOTE,
2199 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2201 MainWindow *mainwin = (MainWindow *)data;
2204 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2205 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2210 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2212 MainWindow *mainwin = (MainWindow *)data;
2215 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2216 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2220 static void toolbar_forward_cb (GtkWidget *widget,
2223 MainWindow *mainwin = (MainWindow *)data;
2225 if (prefs_common.forward_as_attachment)
2226 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2228 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2231 static void toolbar_delete_cb (GtkWidget *widget,
2234 MainWindow *mainwin = (MainWindow *)data;
2236 summary_delete(mainwin->summaryview);
2239 static void toolbar_exec_cb (GtkWidget *widget,
2242 MainWindow *mainwin = (MainWindow *)data;
2244 summary_execute(mainwin->summaryview);
2247 static void toolbar_next_unread_cb (GtkWidget *widget,
2250 MainWindow *mainwin = (MainWindow *)data;
2252 next_unread_cb(mainwin, 0, NULL);
2255 static void toolbar_prefs_cb (GtkWidget *widget,
2258 prefs_common_open();
2261 static void toolbar_account_cb (GtkWidget *widget,
2264 MainWindow *mainwin = (MainWindow *)data;
2266 prefs_account_open_cb(mainwin, 0, NULL);
2269 static void toolbar_account_button_pressed(GtkWidget *widget,
2270 GdkEventButton *event,
2273 MainWindow *mainwin = (MainWindow *)data;
2276 if (event->button != 3) return;
2278 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2279 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2282 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2283 menu_button_position, widget,
2284 event->button, event->time);
2287 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2290 MainWindow *mainwin = (MainWindow *)data;
2294 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2295 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2298 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2299 menu_button_position, widget,
2300 event->button, event->time);
2303 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2305 MainWindow *mainwin = (MainWindow *)data;
2308 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2309 if (!button) return;
2310 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2311 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2312 manage_window_focus_in(mainwin->window, NULL, NULL);
2315 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2318 MainWindow *mainwin = (MainWindow *)data;
2320 if (mainwin->lock_count == 0)
2321 app_exit_cb(data, 0, widget);
2326 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2329 main_window_add_mailbox(mainwin);
2332 static void add_mbox_cb(MainWindow *mainwin, guint action,
2335 main_window_add_mbox(mainwin);
2338 static void update_folderview_cb(MainWindow *mainwin, guint action,
2341 summary_show(mainwin->summaryview, NULL, FALSE);
2342 folderview_rescan_all();
2345 static void new_folder_cb(MainWindow *mainwin, guint action,
2348 folderview_new_folder(mainwin->folderview);
2351 static void rename_folder_cb(MainWindow *mainwin, guint action,
2354 folderview_rename_folder(mainwin->folderview);
2357 static void delete_folder_cb(MainWindow *mainwin, guint action,
2360 folderview_delete_folder(mainwin->folderview);
2363 static void import_mbox_cb(MainWindow *mainwin, guint action,
2366 import_mbox(mainwin->summaryview->folder_item);
2369 static void export_mbox_cb(MainWindow *mainwin, guint action,
2372 export_mbox(mainwin->summaryview->folder_item);
2375 static void empty_trash_cb(MainWindow *mainwin, guint action,
2378 main_window_empty_trash(mainwin, TRUE);
2381 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2383 summary_save_as(mainwin->summaryview);
2386 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2388 summary_print(mainwin->summaryview);
2391 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2393 if (prefs_common.confirm_on_exit) {
2394 if (alertpanel(_("Exit"), _("Exit this program?"),
2395 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2397 manage_window_focus_in(mainwin->window, NULL, NULL);
2400 app_will_exit(widget, mainwin);
2403 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2406 summary_search(mainwin->summaryview);
2408 message_search(mainwin->messageview);
2411 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2414 switch (mainwin->type) {
2416 case SEPARATE_MESSAGE:
2418 case SEPARATE_FOLDER:
2419 if (GTK_CHECK_MENU_ITEM(widget)->active)
2420 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2422 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2425 if (GTK_CHECK_MENU_ITEM(widget)->active)
2426 gtk_widget_show(mainwin->win.sep_both.folderwin);
2428 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2433 static void toggle_message_cb(MainWindow *mainwin, guint action,
2436 switch (mainwin->type) {
2438 case SEPARATE_FOLDER:
2440 case SEPARATE_MESSAGE:
2441 if (GTK_CHECK_MENU_ITEM(widget)->active)
2442 gtk_widget_show(mainwin->win.sep_message.messagewin);
2444 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2447 if (GTK_CHECK_MENU_ITEM(widget)->active)
2448 gtk_widget_show(mainwin->win.sep_both.messagewin);
2450 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2455 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2458 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2459 mainwin->compose_btn_type);
2460 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2461 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2462 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2463 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2465 mainwin->toolbar_style = (ToolbarStyle)action;
2466 prefs_common.toolbar_style = (ToolbarStyle)action;
2468 set_toolbar_style(mainwin);
2471 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2474 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2475 gtk_widget_show(mainwin->hbox_stat);
2476 prefs_common.show_statusbar = TRUE;
2478 gtk_widget_hide(mainwin->hbox_stat);
2479 prefs_common.show_statusbar = FALSE;
2483 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2485 summary_toggle_view_real(mainwin->summaryview);
2488 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2490 messageview_toggle_view_real(mainwin->messageview);
2493 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2496 MainWindow *mainwin;
2499 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2500 g_return_if_fail(mainwin != NULL);
2502 type = mainwin->type ^ action;
2503 main_window_separation_change(mainwin, type);
2505 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2506 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2509 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2512 addressbook_open(NULL);
2515 static void log_window_show_cb(MainWindow *mainwin, guint action,
2518 log_window_show(mainwin->logwin);
2521 static void sel_download_cb(MainWindow *mainwin, guint action,
2524 selective_download(mainwin);
2527 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2532 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2535 inc_all_account_mail(mainwin);
2538 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2542 if (procmsg_send_queue() < 0)
2543 alertpanel_error(_("Some errors occurred while sending queued messages."));
2545 statusbar_pop_all();
2547 for (list = folder_get_list(); list != NULL; list = list->next) {
2550 folder = list->data;
2551 if (folder->queue) {
2552 folder_item_scan(folder->queue);
2553 folderview_update_item(folder->queue, TRUE);
2558 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2560 if (mainwin->summaryview->folder_item) {
2561 if (mainwin->summaryview->folder_item->folder->account != NULL
2562 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2563 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2565 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2571 static void compose_mail_cb(MainWindow *mainwin, guint action,
2578 if (mainwin->summaryview->folder_item) {
2579 ac = mainwin->summaryview->folder_item->folder->account;
2580 if (ac && ac->protocol != A_NNTP) {
2581 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2586 if(cur_account && (cur_account->protocol != A_NNTP)) {
2587 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2591 list = account_get_list();
2592 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2593 ac = (PrefsAccount *) cur->data;
2594 if (ac->protocol != A_NNTP) {
2595 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2601 static void compose_news_cb(MainWindow *mainwin, guint action,
2604 PrefsAccount * ac = NULL;
2608 if (mainwin->summaryview->folder_item) {
2609 ac = mainwin->summaryview->folder_item->folder->account;
2610 if (ac && ac->protocol == A_NNTP) {
2611 compose_new_with_recipient
2612 (ac, mainwin->summaryview->folder_item->path);
2617 list = account_get_list();
2618 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2619 ac = (PrefsAccount *) cur->data;
2620 if (ac->protocol == A_NNTP) {
2627 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2629 summary_reply(mainwin->summaryview, (ComposeMode)action);
2632 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2634 summary_move_to(mainwin->summaryview);
2637 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2639 summary_copy_to(mainwin->summaryview);
2642 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2644 summary_delete(mainwin->summaryview);
2647 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2649 summary_open_msg(mainwin->summaryview);
2652 static void view_source_cb(MainWindow *mainwin, guint action,
2655 summary_view_source(mainwin->summaryview);
2658 static void show_all_header_cb(MainWindow *mainwin, guint action,
2661 if (mainwin->menu_lock_count) return;
2662 summary_display_msg_selected(mainwin->summaryview,
2663 GTK_CHECK_MENU_ITEM(widget)->active);
2666 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2668 summary_reedit(mainwin->summaryview);
2671 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2673 summary_mark(mainwin->summaryview);
2676 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2678 summary_unmark(mainwin->summaryview);
2681 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2684 summary_mark_as_unread(mainwin->summaryview);
2687 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2690 summary_mark_as_read(mainwin->summaryview);
2693 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2696 summary_mark_all_read(mainwin->summaryview);
2699 static void add_address_cb(MainWindow *mainwin, guint action,
2702 summary_add_address(mainwin->summaryview);
2705 static void set_charset_cb(MainWindow *mainwin, guint action,
2710 str = conv_get_charset_str((CharSet)action);
2711 g_free(prefs_common.force_charset);
2712 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2714 summary_redisplay_msg(mainwin->summaryview);
2716 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2719 static void hide_read_messages (MainWindow *mainwin, guint action,
2722 if (!mainwin->summaryview->folder_item
2723 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2725 summary_toggle_show_read_messages(mainwin->summaryview);
2728 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2730 GtkItemFactory *ifactory;
2732 if (mainwin->menu_lock_count) return;
2733 if (!mainwin->summaryview->folder_item) return;
2735 ifactory = gtk_item_factory_from_widget(widget);
2737 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2738 summary_thread_build(mainwin->summaryview);
2739 mainwin->summaryview->folder_item->threaded = TRUE;
2741 summary_unthread(mainwin->summaryview);
2742 mainwin->summaryview->folder_item->threaded = FALSE;
2746 static void set_display_item_cb(MainWindow *mainwin, guint action,
2749 prefs_summary_column_open();
2752 static void sort_summary_cb(MainWindow *mainwin, guint action,
2755 summary_sort(mainwin->summaryview, (SummarySortType)action);
2758 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2761 summary_attract_by_subject(mainwin->summaryview);
2764 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2767 summary_delete_duplicated(mainwin->summaryview);
2770 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2772 summary_filter(mainwin->summaryview);
2775 static void execute_summary_cb(MainWindow *mainwin, guint action,
2778 summary_execute(mainwin->summaryview);
2781 static void update_summary_cb(MainWindow *mainwin, guint action,
2785 FolderView *folderview = mainwin->folderview;
2787 if (!mainwin->summaryview->folder_item) return;
2788 if (!folderview->opened) return;
2790 folder_update_op_count();
2792 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2793 folderview->opened);
2796 summary_show(mainwin->summaryview, fitem, TRUE);
2799 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2801 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2804 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2806 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2809 static void prev_unread_cb(MainWindow *mainwin, guint action,
2812 summary_select_prev_unread(mainwin->summaryview);
2815 static void next_unread_cb(MainWindow *mainwin, guint action,
2818 summary_select_next_unread(mainwin->summaryview);
2821 static void prev_marked_cb(MainWindow *mainwin, guint action,
2824 summary_select_prev_marked(mainwin->summaryview);
2827 static void next_marked_cb(MainWindow *mainwin, guint action,
2830 summary_select_next_marked(mainwin->summaryview);
2833 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2836 summary_select_prev_labeled(mainwin->summaryview);
2839 static void next_labeled_cb(MainWindow *mainwin, guint action,
2842 summary_select_next_labeled(mainwin->summaryview);
2845 static void goto_folder_cb(MainWindow *mainwin, guint action,
2848 FolderItem *to_folder;
2850 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2853 folderview_select(mainwin->folderview, to_folder);
2856 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2858 messageview_copy_clipboard(mainwin->messageview);
2861 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2863 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2864 summary_select_all(mainwin->summaryview);
2865 else if (mainwin->summaryview->msg_is_toggled_on &&
2866 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2867 messageview_select_all(mainwin->messageview);
2870 static void create_filter_cb(MainWindow *mainwin, guint action,
2873 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2876 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2879 prefs_common_open();
2882 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2885 prefs_filter_open(NULL, NULL);
2888 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2891 prefs_scoring_open(NULL);
2894 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2897 prefs_filtering_open(NULL);
2900 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2903 prefs_template_open();
2906 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2909 prefs_actions_open(mainwin);
2912 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2916 new_account_cb(mainwin, 0, widget);
2918 gboolean prev_default = cur_account->is_default;
2920 prefs_account_open(cur_account);
2921 if (!prev_default && cur_account->is_default)
2922 account_set_as_default(cur_account);
2923 account_save_config_all();
2925 main_window_reflect_prefs_all();
2929 static void new_account_cb(MainWindow *mainwin, guint action,
2932 account_edit_open();
2933 if (!compose_get_compose_list()) account_add();
2936 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2938 cur_account = (PrefsAccount *)data;
2939 main_window_reflect_prefs_all();
2942 static void manual_open_cb(MainWindow *mainwin, guint action,
2945 manual_open((ManualLang)action);
2948 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2950 MainWindow *mainwin = (MainWindow *)data;
2954 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2955 LOCAL_FOLDER(folder)->rootpath,
2959 str = g_strdup_printf(_("Scanning folder %s ..."),
2960 LOCAL_FOLDER(folder)->rootpath);
2962 STATUSBAR_PUSH(mainwin, str);
2963 STATUSBAR_POP(mainwin);
2967 static void activate_compose_button (MainWindow *mainwin,
2969 ComposeButtonType type)
2971 SensitiveCond state = main_window_get_current_state(mainwin);
2973 if (style == TOOLBAR_NONE)
2976 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2977 : mainwin->compose_news_btn);
2978 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2979 : mainwin->compose_mail_btn);
2980 mainwin->compose_btn_type = type;
2983 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2985 if (mainwin->compose_btn_type != compose_btn_type)
2986 activate_compose_button(mainwin,
2987 prefs_common.toolbar_style,
2991 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
2993 MainWindow *mainwin = (MainWindow*) data;
2995 if (!mainwin) return;
2997 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
3000 #define BREAK_ON_MODIFIER_KEY() \
3001 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3003 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3005 MainWindow *mainwin = (MainWindow*) data;
3007 if (!mainwin || !event) return;
3009 switch (event->keyval) {
3010 case GDK_Q: /* Quit */
3011 BREAK_ON_MODIFIER_KEY();
3013 app_exit_cb(mainwin, 0, NULL);
3020 #undef BREAK_ON_MODIFIER_KEY
3022 static void set_toolbar_style(MainWindow *mainwin)
3024 switch (prefs_common.toolbar_style) {
3026 gtk_widget_hide(mainwin->handlebox);
3029 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3033 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3037 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3042 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3043 gtk_widget_show(mainwin->handlebox);
3044 gtk_widget_queue_resize(mainwin->handlebox);
3046 if (prefs_common.immediate_exec)
3047 gtk_widget_hide(mainwin->exec_btn);
3049 gtk_widget_show(mainwin->exec_btn);