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,
400 static void create_filter_cb (MainWindow *mainwin,
404 static void prefs_common_open_cb (MainWindow *mainwin,
407 static void prefs_filter_open_cb (MainWindow *mainwin,
410 static void prefs_scoring_open_cb (MainWindow *mainwin,
413 static void prefs_filtering_open_cb (MainWindow *mainwin,
416 static void prefs_account_open_cb(MainWindow *mainwin,
419 static void prefs_template_open_cb (MainWindow *mainwin,
422 static void prefs_actions_open_cb (MainWindow *mainwin,
425 static void new_account_cb (MainWindow *mainwin,
429 static void account_menu_cb (GtkMenuItem *menuitem,
432 static void manual_open_cb (MainWindow *mainwin,
436 static void faq_open_cb (MainWindow *mainwin,
440 static void scan_tree_func (Folder *folder,
444 static void activate_compose_button (MainWindow *mainwin,
446 ComposeButtonType type);
448 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
452 static void key_pressed (GtkWidget *widget,
456 static void set_toolbar_style(MainWindow *mainwin);
458 #define SEPARATE_ACTION 667
460 static GtkItemFactoryEntry mainwin_entries[] =
462 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
463 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
464 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
465 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
466 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
467 {N_("/_File/_Folder/Create _new folder..."),
468 NULL, new_folder_cb, 0, NULL},
469 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
470 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
471 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
472 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
473 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
474 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
475 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
476 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
477 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
478 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
480 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
481 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
482 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
483 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
484 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
485 {N_("/_Edit/_Find in current message..."),
486 "<control>F", search_cb, 0, NULL},
487 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
488 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
489 {N_("/_Edit/Actio_ns"), NULL, NULL, 0, "<Branch>"},
491 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
492 {N_("/_View/Separate _Folder Tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
493 {N_("/_View/Separate _Message View"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
494 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
495 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
496 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
497 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
498 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
499 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
500 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
501 {N_("/_View/Status _bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
502 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
503 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
504 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
505 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
506 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
507 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
508 {N_("/_View/_Sort/Sort by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
509 {N_("/_View/_Sort/Sort by _color label"),
510 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
511 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
512 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
513 {N_("/_View/_Sort/Sort by a_ttachment"),
514 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
515 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
516 {N_("/_View/_Sort/_Attract by subject"),
517 NULL, attract_by_subject_cb, 0, NULL},
518 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
519 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
520 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
521 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
523 #define CODESET_SEPARATOR \
524 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
525 #define CODESET_ACTION(action) \
526 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
528 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
529 {N_("/_View/_Code set/_Auto detect"),
530 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
531 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
532 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
533 CODESET_ACTION(C_US_ASCII)},
536 {N_("/_View/_Code set/Unicode (_UTF-8)"),
537 CODESET_ACTION(C_UTF_8)},
540 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
541 CODESET_ACTION(C_ISO_8859_1)},
542 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
543 CODESET_ACTION(C_ISO_8859_15)},
546 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
547 CODESET_ACTION(C_ISO_8859_2)},
549 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
550 CODESET_ACTION(C_ISO_8859_13)},
551 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
552 CODESET_ACTION(C_ISO_8859_4)},
554 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
555 CODESET_ACTION(C_ISO_8859_7)},
557 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
558 CODESET_ACTION(C_ISO_8859_9)},
560 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
561 CODESET_ACTION(C_ISO_8859_5)},
562 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
563 CODESET_ACTION(C_KOI8_R)},
564 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
565 CODESET_ACTION(C_CP1251)},
568 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
569 CODESET_ACTION(C_ISO_2022_JP)},
571 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
572 CODESET_ACTION(C_ISO_2022_JP_2)},
574 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
575 CODESET_ACTION(C_EUC_JP)},
576 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
577 CODESET_ACTION(C_SHIFT_JIS)},
580 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
581 CODESET_ACTION(C_GB2312)},
582 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
583 CODESET_ACTION(C_BIG5)},
584 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
585 CODESET_ACTION(C_EUC_TW)},
586 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
587 CODESET_ACTION(C_ISO_2022_CN)},
589 {N_("/_View/_Code set/Korean (EUC-_KR)"),
590 CODESET_ACTION(C_EUC_KR)},
591 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
592 CODESET_ACTION(C_ISO_2022_KR)},
594 {N_("/_View/_Code set/Thai (TIS-620)"),
595 CODESET_ACTION(C_TIS_620)},
596 {N_("/_View/_Code set/Thai (Windows-874)"),
597 CODESET_ACTION(C_WINDOWS_874)},
600 #undef CODESET_SEPARATOR
601 #undef CODESET_ACTION
603 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
604 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
605 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
606 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
607 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
608 {N_("/_View/_Go to/P_rev unread message"),
609 "<shift>P", prev_unread_cb, 0, NULL},
610 {N_("/_View/_Go to/N_ext unread message"),
611 "<shift>N", next_unread_cb, 0, NULL},
612 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
613 {N_("/_View/_Go to/Prev _marked message"),
614 NULL, prev_marked_cb, 0, NULL},
615 {N_("/_View/_Go to/Next m_arked message"),
616 NULL, next_marked_cb, 0, NULL},
617 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
618 {N_("/_View/_Go to/Prev _labeled message"),
619 NULL, prev_labeled_cb, 0, NULL},
620 {N_("/_View/_Go to/Next la_beled message"),
621 NULL, next_labeled_cb, 0, NULL},
622 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
623 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
624 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
625 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
626 {N_("/_View/_View source"), "<control>U", view_source_cb, 0, NULL},
627 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
628 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
629 {N_("/_View/_Update"), "<control><alt>U", update_summary_cb, 0, NULL},
631 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
632 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
633 {N_("/_Message/Get from _all accounts"),
634 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
635 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
636 {N_("/_Message/Send queued messa_ges"),
637 NULL, send_queue_cb, 0, NULL},
638 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
639 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
640 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
641 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
642 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
643 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
644 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
645 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
646 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
647 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
648 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
649 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
650 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
651 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
652 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
653 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
654 {N_("/_Message/Delete du_plicated messages"),
655 NULL, delete_duplicated_cb, 0, NULL},
656 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
657 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
658 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
659 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
660 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
661 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
662 {N_("/_Message/_Mark/Mark as rea_d"),
663 NULL, mark_as_read_cb, 0, NULL},
664 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
666 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
667 {N_("/_Tool/_Address book"), "<shift><control>A", addressbook_open_cb, 0, NULL},
668 {N_("/_Tool/Add sender to address boo_k"),
669 NULL, add_address_cb, 0, NULL},
670 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
671 {N_("/_Tool/_Filter messages"), NULL, filter_cb, 0, NULL},
672 {N_("/_Tool/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
673 {N_("/_Tool/_Create filter rule/_Automatically"),
674 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
675 {N_("/_Tool/_Create filter rule/by _From"),
676 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
677 {N_("/_Tool/_Create filter rule/by _To"),
678 NULL, create_filter_cb, FILTER_BY_TO, NULL},
679 {N_("/_Tool/_Create filter rule/by _Subject"),
680 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
681 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
682 {N_("/_Tool/E_xecute"), "X", execute_summary_cb, 0, NULL},
683 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
684 {N_("/_Tool/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
685 {N_("/_Tool/_Selective Download"), "<alt>S", sel_download_cb, 0, NULL},
687 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
688 {N_("/_Configuration/_Common preferences..."),
689 NULL, prefs_common_open_cb, 0, NULL},
690 {N_("/_Configuration/_Filter setting..."),
691 NULL, prefs_filter_open_cb, 0, NULL},
692 {N_("/_Configuration/_Scoring ..."),
693 NULL, prefs_scoring_open_cb, 0, NULL},
694 {N_("/_Configuration/_Filtering ..."),
695 NULL, prefs_filtering_open_cb, 0, NULL},
696 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
697 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
698 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
699 {N_("/_Configuration/_Preferences for current account..."),
700 NULL, prefs_account_open_cb, 0, NULL},
701 {N_("/_Configuration/Create _new account..."),
702 NULL, new_account_cb, 0, NULL},
703 {N_("/_Configuration/_Edit accounts..."),
704 NULL, account_edit_open, 0, NULL},
705 {N_("/_Configuration/C_hange current account"),
706 NULL, NULL, 0, "<Branch>"},
708 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
709 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
710 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
711 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
712 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, FAQ_LANG_EN, NULL},
713 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, FAQ_LANG_ES, NULL},
714 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, FAQ_LANG_FR, NULL},
715 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
716 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
718 static GtkItemFactoryEntry reply_popup_entries[] =
720 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
721 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
723 static GtkItemFactoryEntry replyall_popup_entries[] =
725 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
726 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
728 static GtkItemFactoryEntry replysender_popup_entries[] =
730 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
731 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
733 static GtkItemFactoryEntry fwd_popup_entries[] =
735 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
736 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
740 MainWindow *main_window_create(SeparateType type)
746 GtkWidget *handlebox;
747 GtkWidget *vbox_body;
748 GtkWidget *hbox_stat;
749 GtkWidget *statusbar;
750 GtkWidget *progressbar;
751 GtkWidget *statuslabel;
752 GtkWidget *ac_button;
755 FolderView *folderview;
756 SummaryView *summaryview;
757 MessageView *messageview;
758 GdkColormap *colormap;
761 guint n_menu_entries;
762 GtkItemFactory *ifactory;
765 GtkWidget *compose_popup;
766 GtkWidget *reply_popup;
767 GtkWidget *replyall_popup;
768 GtkWidget *replysender_popup;
769 GtkWidget *fwd_popup;
772 debug_print(_("Creating main window...\n"));
773 mainwin = g_new0(MainWindow, 1);
776 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
777 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
778 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
779 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
780 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
781 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
782 MANAGE_WINDOW_SIGNALS_CONNECT(window);
783 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
784 GTK_SIGNAL_FUNC(key_pressed), mainwin);
786 gtk_widget_realize(window);
787 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
790 gtkut_widget_set_app_icon(window);
792 vbox = gtk_vbox_new(FALSE, 0);
793 gtk_widget_show(vbox);
794 gtk_container_add(GTK_CONTAINER(window), vbox);
797 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
798 menubar = menubar_create(window, mainwin_entries,
799 n_menu_entries, "<Main>", mainwin);
800 gtk_widget_show(menubar);
801 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
803 handlebox = gtk_handle_box_new();
804 gtk_widget_show(handlebox);
805 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
807 /* create the popup menus for the reply buttons specials */
808 n_menu_entries = sizeof(reply_popup_entries) /
809 sizeof(reply_popup_entries[0]);
810 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
811 "<ReplyPopup>", mainwin);
812 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
813 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
814 n_menu_entries = sizeof(replyall_popup_entries) /
815 sizeof(replyall_popup_entries[0]);
816 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
817 "<ReplyAllPopup>", mainwin);
818 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
819 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
820 n_menu_entries = sizeof(replysender_popup_entries) /
821 sizeof(replysender_popup_entries[0]);
822 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
823 "<ReplySenderPopup>", mainwin);
824 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
825 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
826 /* create the popup menu for the forward button */
827 n_menu_entries = sizeof(fwd_popup_entries) /
828 sizeof(fwd_popup_entries[0]);
829 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
830 "<ForwardPopup>", mainwin);
831 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
832 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
834 main_window_toolbar_create(mainwin, handlebox);
836 /* vbox that contains body */
837 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
838 gtk_widget_show(vbox_body);
839 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
840 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
842 hbox_stat = gtk_hbox_new(FALSE, 2);
843 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
845 statusbar = statusbar_create();
846 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
848 progressbar = gtk_progress_bar_new();
849 gtk_widget_set_usize(progressbar, 120, 1);
850 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
852 statuslabel = gtk_label_new("");
853 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
855 ac_button = gtk_button_new();
856 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
857 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
858 gtk_widget_set_usize(ac_button, -1, 1);
859 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
860 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
861 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
863 ac_label = gtk_label_new("");
864 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
866 gtk_widget_show_all(hbox_stat);
869 mainwin->folderview = folderview = folderview_create();
870 mainwin->summaryview = summaryview = summary_create();
871 mainwin->messageview = messageview = messageview_create();
872 mainwin->logwin = log_window_create();
874 folderview->mainwin = mainwin;
875 folderview->summaryview = summaryview;
877 summaryview->mainwin = mainwin;
878 summaryview->folderview = folderview;
879 summaryview->messageview = messageview;
880 summaryview->window = window;
882 messageview->mainwin = mainwin;
884 mainwin->window = window;
885 mainwin->vbox = vbox;
886 mainwin->menubar = menubar;
887 mainwin->handlebox = handlebox;
888 mainwin->vbox_body = vbox_body;
889 mainwin->hbox_stat = hbox_stat;
890 mainwin->statusbar = statusbar;
891 mainwin->progressbar = progressbar;
892 mainwin->statuslabel = statuslabel;
893 mainwin->ac_button = ac_button;
894 mainwin->ac_label = ac_label;
895 mainwin->reply_popup = reply_popup;
896 mainwin->replyall_popup = replyall_popup;
897 mainwin->replysender_popup = replysender_popup;
898 mainwin->fwd_popup = fwd_popup;
900 /* set context IDs for status bar */
901 mainwin->mainwin_cid = gtk_statusbar_get_context_id
902 (GTK_STATUSBAR(statusbar), "Main Window");
903 mainwin->folderview_cid = gtk_statusbar_get_context_id
904 (GTK_STATUSBAR(statusbar), "Folder View");
905 mainwin->summaryview_cid = gtk_statusbar_get_context_id
906 (GTK_STATUSBAR(statusbar), "Summary View");
908 /* allocate colors for summary view and folder view */
909 summaryview->color_marked.red = summaryview->color_marked.green = 0;
910 summaryview->color_marked.blue = (guint16)65535;
912 summaryview->color_dim.red = summaryview->color_dim.green =
913 summaryview->color_dim.blue = COLOR_DIM;
915 folderview->color_new.red = (guint16)55000;
916 folderview->color_new.green = folderview->color_new.blue = 15000;
918 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
919 &folderview->color_op);
921 summaryview->color_important.red = 0;
922 summaryview->color_marked.green = 0;
923 summaryview->color_important.blue = (guint16)65535;
925 color[0] = summaryview->color_marked;
926 color[1] = summaryview->color_dim;
927 color[2] = folderview->color_new;
928 color[3] = folderview->color_op;
930 colormap = gdk_window_get_colormap(window->window);
931 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
932 for (i = 0; i < 4; i++) {
933 if (success[i] == FALSE)
934 g_warning(_("MainWindow: color allocation %d failed\n"), i);
937 debug_print(_("done.\n"));
939 main_window_set_widgets(mainwin, type);
942 ifactory = gtk_item_factory_from_widget(menubar);
943 menuitem = gtk_item_factory_get_item
944 (ifactory, "/View/Code set/Auto detect");
945 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
947 switch (prefs_common.toolbar_style) {
949 menuitem = gtk_item_factory_get_item
950 (ifactory, "/View/Toolbar/None");
953 menuitem = gtk_item_factory_get_item
954 (ifactory, "/View/Toolbar/Icon");
957 menuitem = gtk_item_factory_get_item
958 (ifactory, "/View/Toolbar/Text");
961 menuitem = gtk_item_factory_get_item
962 (ifactory, "/View/Toolbar/Icon and text");
964 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
966 gtk_widget_hide(mainwin->hbox_stat);
967 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
968 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
969 prefs_common.show_statusbar);
970 #if 0 /* FIXED SEPARATE WINDOWS */
971 /* Message view and Folder tree are always shown at startup
972 * make that in the menu visible */
973 menuitem = gtk_item_factory_get_item(ifactory, "/View/Message view");
974 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
975 menuitem = gtk_item_factory_get_item(ifactory, "/View/Folder tree");
976 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
978 /* set the check of the SEPARATE_xxx menu items. we also need the main window
979 * as a property and pass the action type to the callback */
980 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
982 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
983 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
984 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
985 GUINT_TO_POINTER(SEPARATE_FOLDER));
987 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
989 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
990 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
991 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
992 GUINT_TO_POINTER(SEPARATE_MESSAGE));
994 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
995 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
998 /* set account selection menu */
999 ac_menu = gtk_item_factory_get_widget
1000 (ifactory, "/Configuration/Change current account");
1001 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1002 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1003 mainwin->ac_menu = ac_menu;
1005 main_window_set_toolbar_sensitive(mainwin);
1007 /* Create actions menu */
1008 update_mainwin_actions_menu(ifactory, mainwin);
1010 /* show main window */
1011 gtk_widget_set_uposition(mainwin->window,
1012 prefs_common.mainwin_x,
1013 prefs_common.mainwin_y);
1014 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1015 prefs_common.mainwin_height);
1016 gtk_widget_show(mainwin->window);
1018 /* initialize views */
1019 folderview_init(folderview);
1020 summary_init(summaryview);
1021 messageview_init(messageview);
1022 log_window_init(mainwin->logwin);
1024 mainwin->lock_count = 0;
1025 mainwin->menu_lock_count = 0;
1026 mainwin->cursor_count = 0;
1029 watch_cursor = gdk_cursor_new(GDK_WATCH);
1031 mainwin_list = g_list_append(mainwin_list, mainwin);
1036 void main_window_cursor_wait(MainWindow *mainwin)
1039 if (mainwin->cursor_count == 0)
1040 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1042 mainwin->cursor_count++;
1047 void main_window_cursor_normal(MainWindow *mainwin)
1049 if (mainwin->cursor_count)
1050 mainwin->cursor_count--;
1052 if (mainwin->cursor_count == 0)
1053 gdk_window_set_cursor(mainwin->window->window, NULL);
1058 /* lock / unlock the user-interface */
1059 void main_window_lock(MainWindow *mainwin)
1061 if (mainwin->lock_count == 0)
1062 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1064 mainwin->lock_count++;
1066 main_window_set_menu_sensitive(mainwin);
1067 main_window_set_toolbar_sensitive(mainwin);
1070 void main_window_unlock(MainWindow *mainwin)
1072 if (mainwin->lock_count)
1073 mainwin->lock_count--;
1075 main_window_set_menu_sensitive(mainwin);
1076 main_window_set_toolbar_sensitive(mainwin);
1078 if (mainwin->lock_count == 0)
1079 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1082 static void main_window_menu_callback_block(MainWindow *mainwin)
1084 mainwin->menu_lock_count++;
1087 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1089 if (mainwin->menu_lock_count)
1090 mainwin->menu_lock_count--;
1093 void main_window_reflect_prefs_all(void)
1095 main_window_reflect_prefs_all_real(FALSE);
1098 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1101 MainWindow *mainwin;
1103 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1104 mainwin = (MainWindow *)cur->data;
1106 main_window_show_cur_account(mainwin);
1107 main_window_set_menu_sensitive(mainwin);
1108 main_window_set_toolbar_sensitive(mainwin);
1111 if (pixmap_theme_changed)
1113 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1114 mainwin->toolbar = NULL;
1115 main_window_toolbar_create(mainwin, mainwin->handlebox);
1116 set_toolbar_style(mainwin);
1117 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1118 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1119 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1122 summary_redisplay_msg(mainwin->summaryview);
1123 headerview_set_visibility(mainwin->messageview->headerview,
1124 prefs_common.display_header_pane);
1128 void main_window_set_summary_column(void)
1131 MainWindow *mainwin;
1133 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1134 mainwin = (MainWindow *)cur->data;
1135 summary_set_column_order(mainwin->summaryview);
1139 void main_window_set_account_menu(GList *account_list)
1141 GList *cur, *cur_ac, *cur_item;
1142 GtkWidget *menuitem;
1143 MainWindow *mainwin;
1144 PrefsAccount *ac_prefs;
1146 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1147 mainwin = (MainWindow *)cur->data;
1149 /* destroy all previous menu item */
1150 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1151 while (cur_item != NULL) {
1152 GList *next = cur_item->next;
1153 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1157 for (cur_ac = account_list; cur_ac != NULL;
1158 cur_ac = cur_ac->next) {
1159 ac_prefs = (PrefsAccount *)cur_ac->data;
1161 menuitem = gtk_menu_item_new_with_label
1162 (ac_prefs->account_name
1163 ? ac_prefs->account_name : _("Untitled"));
1164 gtk_widget_show(menuitem);
1165 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1166 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1167 GTK_SIGNAL_FUNC(account_menu_cb),
1173 static void main_window_show_cur_account(MainWindow *mainwin)
1178 ac_name = g_strdup(cur_account
1179 ? (cur_account->account_name
1180 ? cur_account->account_name : _("Untitled"))
1184 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1186 buf = g_strdup(PROG_VERSION);
1187 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1190 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1191 gtk_widget_queue_resize(mainwin->ac_button);
1196 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1198 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1199 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1200 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1202 if (mainwin->type == type) return;
1204 /* remove widgets from those containers */
1205 gtk_widget_ref(folder_wid);
1206 gtk_widget_ref(summary_wid);
1207 gtk_widget_ref(message_wid);
1208 gtkut_container_remove
1209 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1210 gtkut_container_remove
1211 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1212 gtkut_container_remove
1213 (GTK_CONTAINER(message_wid->parent), message_wid);
1215 /* clean containers */
1216 switch (mainwin->type) {
1218 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1220 case SEPARATE_FOLDER:
1221 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1222 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1224 case SEPARATE_MESSAGE:
1225 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1226 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1229 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1230 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1234 gtk_widget_hide(mainwin->window);
1235 main_window_set_widgets(mainwin, type);
1236 gtk_widget_show(mainwin->window);
1238 gtk_widget_unref(folder_wid);
1239 gtk_widget_unref(summary_wid);
1240 gtk_widget_unref(message_wid);
1243 void main_window_get_size(MainWindow *mainwin)
1245 GtkAllocation *allocation;
1247 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1249 prefs_common.summaryview_width = allocation->width;
1251 if (mainwin->summaryview->msg_is_toggled_on)
1252 prefs_common.summaryview_height = allocation->height;
1254 prefs_common.mainview_width = allocation->width;
1256 allocation = &mainwin->window->allocation;
1258 prefs_common.mainview_height = allocation->height;
1259 prefs_common.mainwin_width = allocation->width;
1260 prefs_common.mainwin_height = allocation->height;
1262 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1264 prefs_common.folderview_width = allocation->width;
1265 prefs_common.folderview_height = allocation->height;
1268 void main_window_get_position(MainWindow *mainwin)
1272 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1274 prefs_common.mainview_x = x;
1275 prefs_common.mainview_y = y;
1276 prefs_common.mainwin_x = x;
1277 prefs_common.mainwin_y = y;
1279 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1282 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1288 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1289 folder = FOLDER(list->data);
1290 if (folder && folder->trash && folder->trash->total > 0)
1294 if (!has_trash) return;
1297 if (alertpanel(_("Empty trash"),
1298 _("Empty all messages in trash?"),
1299 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1301 manage_window_focus_in(mainwin->window, NULL, NULL);
1304 procmsg_empty_trash();
1306 for (list = folder_get_list(); list != NULL; list = list->next) {
1307 folder = list->data;
1308 if (folder && folder->trash && folder->trash->total != 0) {
1309 folder_item_scan(folder->trash);
1310 folderview_update_item(folder->trash, TRUE);
1314 if (mainwin->summaryview->folder_item &&
1315 mainwin->summaryview->folder_item->stype == F_TRASH)
1316 gtk_widget_grab_focus(mainwin->folderview->ctree);
1319 void main_window_add_mailbox(MainWindow *mainwin)
1324 path = input_dialog(_("Add mailbox"),
1325 _("Input the location of mailbox.\n"
1326 "If the existing mailbox is specified, it will be\n"
1327 "scanned automatically."),
1330 if (folder_find_from_path(path)) {
1331 alertpanel_error(_("The mailbox `%s' already exists."), path);
1335 if (!strcmp(path, "Mail"))
1336 folder = folder_new(F_MH, _("Mailbox"), path);
1338 folder = folder_new(F_MH, g_basename(path), path);
1341 if (folder->create_tree(folder) < 0) {
1342 alertpanel_error(_("Creation of the mailbox failed.\n"
1343 "Maybe some files already exist, or you don't have the permission to write there."));
1344 folder_destroy(folder);
1349 folder_set_ui_func(folder, scan_tree_func, mainwin);
1350 folder->scan_tree(folder);
1351 folder_set_ui_func(folder, NULL, NULL);
1353 folderview_set(mainwin->folderview);
1356 void main_window_add_mbox(MainWindow *mainwin)
1362 path = input_dialog(_("Add mbox mailbox"),
1363 _("Input the location of mailbox."),
1368 if (folder_find_from_path(path)) {
1369 alertpanel_error(_("The mailbox `%s' already exists."), path);
1375 if (!strcmp(path, "Mail"))
1376 folder = folder_new(F_MBOX, _("Mailbox"), path);
1380 folder = folder_new(F_MBOX, g_basename(path), path);
1383 if (folder->create_tree(folder) < 0) {
1384 alertpanel_error(_("Creation of the mailbox failed."));
1385 folder_destroy(folder);
1391 item = folder_item_new(folder->name, NULL);
1392 item->folder = folder;
1393 folder->node = g_node_new(item);
1395 folder->create_folder(folder, item, "inbox");
1396 folder->create_folder(folder, item, "outbox");
1397 folder->create_folder(folder, item, "queue");
1398 folder->create_folder(folder, item, "draft");
1399 folder->create_folder(folder, item, "trash");
1401 folderview_set(mainwin->folderview);
1406 M_UNLOCKED = 1 << 0,
1407 M_MSG_EXIST = 1 << 1,
1408 M_TARGET_EXIST = 1 << 2,
1409 M_SINGLE_TARGET_EXIST = 1 << 3,
1411 M_ALLOW_REEDIT = 1 << 5,
1412 M_HAVE_ACCOUNT = 1 << 6,
1413 M_THREADED = 1 << 7,
1414 M_UNTHREADED = 1 << 8,
1415 M_ALLOW_DELETE = 1 << 9,
1417 M_HAVE_NEWS_ACCOUNT = 1 << 11,
1418 M_HIDE_READ_MSG = 1 << 12
1421 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1423 SensitiveCond state = 0;
1424 SummarySelection selection;
1425 FolderItem *item = mainwin->summaryview->folder_item;
1426 GList *account_list = account_get_list();
1428 selection = summary_get_selection_type(mainwin->summaryview);
1430 if (mainwin->lock_count == 0)
1431 state |= M_UNLOCKED;
1432 if (selection != SUMMARY_NONE)
1433 state |= M_MSG_EXIST;
1437 state |= M_THREADED;
1439 state |= M_UNTHREADED;
1440 /* if (item->folder->type != F_NEWS) */
1441 state |= M_ALLOW_DELETE;
1443 if (selection == SUMMARY_NONE && item->hide_read_msgs
1444 || selection != SUMMARY_NONE)
1445 state |= M_HIDE_READ_MSG;
1447 if (selection == SUMMARY_SELECTED_SINGLE ||
1448 selection == SUMMARY_SELECTED_MULTIPLE)
1449 state |= M_TARGET_EXIST;
1450 if (selection == SUMMARY_SELECTED_SINGLE)
1451 state |= M_SINGLE_TARGET_EXIST;
1452 if (mainwin->summaryview->folder_item &&
1453 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1455 if (selection == SUMMARY_SELECTED_SINGLE &&
1457 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1458 item->stype == F_QUEUE)))
1459 state |= M_ALLOW_REEDIT;
1461 state |= M_HAVE_ACCOUNT;
1463 for ( ; account_list != NULL; account_list = account_list->next) {
1464 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1465 state |= M_HAVE_NEWS_ACCOUNT;
1473 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1475 SensitiveCond state;
1484 entry[0].widget = mainwin->get_btn;
1485 entry[0].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1486 entry[1].widget = mainwin->getall_btn;
1487 entry[1].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1488 entry[2].widget = mainwin->compose_news_btn;
1489 entry[2].cond = M_HAVE_NEWS_ACCOUNT;
1490 entry[3].widget = mainwin->reply_btn;
1491 entry[3].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1492 entry[4].widget = mainwin->replyall_btn;
1493 entry[4].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1494 entry[5].widget = mainwin->replysender_btn;
1495 entry[5].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1496 entry[6].widget = mainwin->fwd_btn;
1497 entry[6].cond = M_HAVE_ACCOUNT|M_TARGET_EXIST;
1498 /* entry[6].widget = mainwin->prefs_btn;
1499 entry[6].cond = M_UNLOCKED;
1500 entry[7].widget = mainwin->account_btn;
1501 entry[7].cond = M_UNLOCKED; */
1502 entry[7].widget = mainwin->next_btn;
1503 entry[7].cond = M_MSG_EXIST;
1504 entry[8].widget = mainwin->delete_btn;
1505 entry[8].cond = M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED;
1506 entry[9].widget = mainwin->exec_btn;
1507 entry[9].cond = M_MSG_EXIST|M_EXEC|M_UNLOCKED;
1508 entry[10].widget = NULL;
1511 state = main_window_get_current_state(mainwin);
1513 for (i = 0; entry[i].widget != NULL; i++) {
1514 sensitive = ((entry[i].cond & state) == entry[i].cond);
1515 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1518 activate_compose_button(mainwin,
1519 prefs_common.toolbar_style,
1520 mainwin->compose_btn_type);
1523 void main_window_set_menu_sensitive(MainWindow *mainwin)
1525 GtkItemFactory *ifactory;
1526 SensitiveCond state;
1528 GtkWidget *menuitem;
1531 static const struct {
1535 {"/File/Add mailbox..." , M_UNLOCKED},
1536 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1537 {"/File/Rescan folder tree" , M_UNLOCKED},
1538 {"/File/Folder" , M_UNLOCKED},
1539 {"/File/Import mbox file..." , M_UNLOCKED},
1540 {"/File/Export to mbox file...", M_UNLOCKED},
1541 {"/File/Empty trash" , M_UNLOCKED},
1542 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1543 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1544 /* {"/File/Close", M_UNLOCKED}, */
1545 {"/File/Exit" , M_UNLOCKED},
1547 {"/Edit/Actions" , M_MSG_EXIST},
1548 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1549 {"/View/Sort" , M_MSG_EXIST},
1550 {"/View/Thread view" , M_EXEC},
1551 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1552 {"/View/Go to/Prev message" , M_MSG_EXIST},
1553 {"/View/Go to/Next message" , M_MSG_EXIST},
1554 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1555 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1556 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1557 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1558 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1559 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1560 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1561 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1562 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1564 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1565 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1566 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1567 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1568 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1569 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1570 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1571 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1572 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1573 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1574 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1575 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1576 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1577 {"/Message/Mark" , M_TARGET_EXIST},
1578 {"/Message/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1580 {"/Tool/Add sender to address book", M_SINGLE_TARGET_EXIST},
1581 {"/Tool/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1582 {"/Tool/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1583 {"/Tool/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1585 {"/Configuration", M_UNLOCKED},
1590 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1591 state = main_window_get_current_state(mainwin);
1593 for (i = 0; entry[i].entry != NULL; i++) {
1594 sensitive = ((entry[i].cond & state) == entry[i].cond);
1595 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1598 main_window_menu_callback_block(mainwin);
1599 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all header");
1600 gtk_check_menu_item_set_active
1601 (GTK_CHECK_MENU_ITEM(menuitem),
1602 mainwin->messageview->textview->show_all_headers);
1603 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1604 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1605 (state & M_THREADED) != 0);
1606 main_window_menu_callback_unblock(mainwin);
1609 void main_window_popup(MainWindow *mainwin)
1615 gdk_window_get_origin(mainwin->window->window, &x, &y);
1616 sx = gdk_screen_width();
1617 sy = gdk_screen_height();
1618 x %= sx; if (x < 0) x = 0;
1619 y %= sy; if (y < 0) y = 0;
1620 gdk_window_move(mainwin->window->window, x, y);
1621 gdk_window_raise(mainwin->window->window);
1622 gdk_window_show(mainwin->window->window);
1624 debug_print("window position: x = %d, y = %d\n", x, y);
1626 switch (mainwin->type) {
1627 case SEPARATE_FOLDER:
1628 widget = mainwin->win.sep_folder.folderwin;
1629 gdk_window_get_origin(widget->window, &x, &y);
1630 x %= sx; if (x < 0) x = 0;
1631 y %= sy; if (y < 0) y = 0;
1632 gdk_window_move(widget->window, x, y);
1633 gdk_window_raise(widget->window);
1635 case SEPARATE_MESSAGE:
1636 widget = mainwin->win.sep_message.messagewin;
1637 gdk_window_get_origin(widget->window, &x, &y);
1638 x %= sx; if (x < 0) x = 0;
1639 y %= sy; if (y < 0) y = 0;
1640 gdk_window_move(widget->window, x, y);
1641 gdk_window_raise(widget->window);
1644 widget = mainwin->win.sep_both.folderwin;
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);
1650 widget = mainwin->win.sep_both.messagewin;
1651 gdk_window_get_origin(widget->window, &x, &y);
1652 x %= sx; if (x < 0) x = 0;
1653 y %= sy; if (y < 0) y = 0;
1654 gdk_window_move(widget->window, x, y);
1655 gdk_window_raise(widget->window);
1662 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1664 GtkWidget *folderwin = NULL;
1665 GtkWidget *messagewin = NULL;
1668 GtkWidget *vbox_body = mainwin->vbox_body;
1669 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1670 GtkWidget *menuitem;
1672 debug_print(_("Setting widgets..."));
1674 /* create separated window(s) if needed */
1675 if (type & SEPARATE_FOLDER) {
1676 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1677 gtk_window_set_title(GTK_WINDOW(folderwin),
1678 _("Sylpheed - Folder View"));
1679 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1680 "folder_view", "Sylpheed");
1681 gtk_window_set_policy(GTK_WINDOW(folderwin),
1683 gtk_widget_set_usize(folderwin, -1,
1684 prefs_common.mainview_height);
1685 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1687 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1688 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1691 if (type & SEPARATE_MESSAGE) {
1692 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1693 gtk_window_set_title(GTK_WINDOW(messagewin),
1694 _("Sylpheed - Message View"));
1695 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1696 "message_view", "Sylpheed");
1697 gtk_window_set_policy(GTK_WINDOW(messagewin),
1699 gtk_widget_set_usize
1700 (messagewin, prefs_common.mainview_width,
1701 prefs_common.mainview_height
1702 - prefs_common.summaryview_height
1703 + DEFAULT_HEADERVIEW_HEIGHT);
1704 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1706 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1707 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1713 hpaned = gtk_hpaned_new();
1714 gtk_widget_show(hpaned);
1715 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1716 gtk_paned_add1(GTK_PANED(hpaned),
1717 GTK_WIDGET_PTR(mainwin->folderview));
1719 vpaned = gtk_vpaned_new();
1720 if (mainwin->summaryview->msg_is_toggled_on) {
1721 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1722 gtk_paned_add1(GTK_PANED(vpaned),
1723 GTK_WIDGET_PTR(mainwin->summaryview));
1725 gtk_paned_add2(GTK_PANED(hpaned),
1726 GTK_WIDGET_PTR(mainwin->summaryview));
1727 gtk_widget_ref(vpaned);
1729 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1730 prefs_common.summaryview_width,
1731 prefs_common.summaryview_height);
1732 gtk_paned_add2(GTK_PANED(vpaned),
1733 GTK_WIDGET_PTR(mainwin->messageview));
1734 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1735 prefs_common.mainview_width, -1);
1736 gtk_widget_set_usize(mainwin->window,
1737 prefs_common.folderview_width +
1738 prefs_common.mainview_width,
1739 prefs_common.mainwin_height);
1740 gtk_widget_show_all(vpaned);
1742 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1743 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1744 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1745 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1746 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1747 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1749 mainwin->win.sep_none.hpaned = hpaned;
1750 mainwin->win.sep_none.vpaned = vpaned;
1752 case SEPARATE_FOLDER:
1753 vpaned = gtk_vpaned_new();
1754 if (mainwin->summaryview->msg_is_toggled_on) {
1755 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1757 gtk_paned_add1(GTK_PANED(vpaned),
1758 GTK_WIDGET_PTR(mainwin->summaryview));
1760 gtk_box_pack_start(GTK_BOX(vbox_body),
1761 GTK_WIDGET_PTR(mainwin->summaryview),
1763 gtk_widget_ref(vpaned);
1765 gtk_paned_add2(GTK_PANED(vpaned),
1766 GTK_WIDGET_PTR(mainwin->messageview));
1767 gtk_widget_show_all(vpaned);
1768 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1769 prefs_common.summaryview_width,
1770 prefs_common.summaryview_height);
1771 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1772 prefs_common.mainview_width, -1);
1773 gtk_widget_set_usize(mainwin->window,
1774 prefs_common.mainview_width,
1775 prefs_common.mainview_height);
1777 gtk_container_add(GTK_CONTAINER(folderwin),
1778 GTK_WIDGET_PTR(mainwin->folderview));
1780 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1781 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1783 mainwin->win.sep_folder.folderwin = folderwin;
1784 mainwin->win.sep_folder.vpaned = vpaned;
1786 gtk_widget_show_all(folderwin);
1788 case SEPARATE_MESSAGE:
1789 hpaned = gtk_hpaned_new();
1790 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1792 gtk_paned_add1(GTK_PANED(hpaned),
1793 GTK_WIDGET_PTR(mainwin->folderview));
1794 gtk_paned_add2(GTK_PANED(hpaned),
1795 GTK_WIDGET_PTR(mainwin->summaryview));
1796 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1797 prefs_common.summaryview_width,
1798 prefs_common.summaryview_height);
1799 gtk_widget_set_usize(mainwin->window,
1800 prefs_common.folderview_width +
1801 prefs_common.mainview_width,
1802 prefs_common.mainwin_height);
1803 gtk_widget_show_all(hpaned);
1804 gtk_container_add(GTK_CONTAINER(messagewin),
1805 GTK_WIDGET_PTR(mainwin->messageview));
1807 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1808 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1809 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1810 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1812 mainwin->win.sep_message.messagewin = messagewin;
1813 mainwin->win.sep_message.hpaned = hpaned;
1815 gtk_widget_show_all(messagewin);
1818 gtk_box_pack_start(GTK_BOX(vbox_body),
1819 GTK_WIDGET_PTR(mainwin->summaryview),
1821 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1822 prefs_common.summaryview_width,
1823 prefs_common.summaryview_height);
1824 gtk_widget_set_usize(mainwin->window,
1825 prefs_common.mainview_width,
1826 prefs_common.mainwin_height);
1827 gtk_container_add(GTK_CONTAINER(folderwin),
1828 GTK_WIDGET_PTR(mainwin->folderview));
1829 gtk_container_add(GTK_CONTAINER(messagewin),
1830 GTK_WIDGET_PTR(mainwin->messageview));
1832 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1833 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1835 mainwin->win.sep_both.folderwin = folderwin;
1836 mainwin->win.sep_both.messagewin = messagewin;
1838 gtk_widget_show_all(folderwin);
1839 gtk_widget_show_all(messagewin);
1843 mainwin->type = type;
1845 debug_print(_("done.\n"));
1848 static void main_window_toolbar_create(MainWindow *mainwin,
1849 GtkWidget *container)
1852 GtkWidget *icon_wid;
1854 GtkWidget *getall_btn;
1855 GtkWidget *compose_mail_btn;
1856 GtkWidget *compose_news_btn;
1857 GtkWidget *reply_btn;
1858 GtkWidget *replyall_btn;
1859 GtkWidget *replysender_btn;
1861 GtkWidget *send_btn;
1863 GtkWidget *prefs_btn;
1864 GtkWidget *account_btn;
1866 GtkWidget *next_btn;
1867 GtkWidget *delete_btn;
1868 GtkWidget *exec_btn;
1870 GtkTooltips *tooltips;
1872 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1874 gtk_container_add(GTK_CONTAINER(container), toolbar);
1875 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1876 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1877 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1878 GTK_TOOLBAR_SPACE_LINE);
1880 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1881 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1883 _("Get new mail from current account"),
1885 icon_wid, toolbar_inc_cb, mainwin);
1886 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1887 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1889 _("Get new mail from all accounts"),
1895 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1897 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1898 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1900 _("Send queued message(s)"),
1906 /* insert compose mail button widget */
1907 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1908 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1910 _("Compose an email message"),
1913 toolbar_compose_mail_cb,
1916 /* insert compose news button widget */
1917 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1918 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1920 _("Compose a news message"),
1923 toolbar_compose_news_cb,
1926 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1930 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1931 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1933 _("Reply to the message - Right button: more options"),
1939 /* replyall button */
1941 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1942 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1944 _("Reply to all - Right button: more options"),
1947 toolbar_reply_to_all_cb,
1950 /* reply to sender button */
1951 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1952 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1954 _("Reply to sender - Right button: more options"),
1957 toolbar_reply_to_sender_cb,
1960 /* forward button */
1961 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1962 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1964 _("Forward the message - Right button: more options"),
1970 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1972 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1973 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1975 _("Delete the message"),
1981 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1982 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1984 _("Execute marked process"),
1990 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
1991 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1993 _("Next unread message"),
1996 toolbar_next_unread_cb,
2000 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2002 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2003 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2005 _("Common preference"),
2010 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2011 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2013 _("Account setting"),
2018 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2019 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2023 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2024 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2027 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2028 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2031 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2032 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2035 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2036 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2040 mainwin->toolbar = toolbar;
2041 mainwin->get_btn = get_btn;
2042 mainwin->getall_btn = getall_btn;
2043 mainwin->compose_mail_btn = compose_mail_btn;
2044 mainwin->compose_news_btn = compose_news_btn;
2045 mainwin->reply_btn = reply_btn;
2046 mainwin->replyall_btn = replyall_btn;
2047 mainwin->replysender_btn = replysender_btn;
2048 mainwin->fwd_btn = fwd_btn;
2049 mainwin->send_btn = send_btn;
2051 mainwin->prefs_btn = prefs_btn;
2052 mainwin->account_btn = account_btn;
2054 mainwin->next_btn = next_btn;
2055 mainwin->delete_btn = delete_btn;
2056 mainwin->exec_btn = exec_btn;
2058 gtk_widget_show_all(toolbar);
2061 /* callback functions */
2062 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2064 MainWindow *mainwindow = (MainWindow *) data;
2068 if (event->button == 3) {
2069 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2070 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2071 menu_button_position, widget,
2072 event->button, event->time);
2076 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2078 MainWindow *mainwin = (MainWindow *)data;
2080 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2081 manage_window_focus_in(mainwin->window, NULL, NULL);
2084 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2086 MainWindow *mainwindow = (MainWindow *) data;
2090 if (event->button == 3) {
2091 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2092 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2093 menu_button_position, widget,
2094 event->button, event->time);
2098 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2100 MainWindow *mainwin = (MainWindow *)data;
2102 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2103 manage_window_focus_in(mainwin->window, NULL, NULL);
2106 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2108 MainWindow *mainwindow = (MainWindow *) data;
2109 GtkWidget *replysender_menu, *replysender_item;
2113 if (event->button == 3) {
2114 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2115 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2116 menu_button_position, widget,
2117 event->button, event->time);
2121 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2123 MainWindow *mainwin = (MainWindow *)data;
2125 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2126 manage_window_focus_in(mainwin->window, NULL, NULL);
2129 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2131 MainWindow *mainwindow = (MainWindow *) data;
2135 if (event->button == 3) {
2136 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2137 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2138 menu_button_position, widget,
2139 event->button, event->time);
2143 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2145 MainWindow *mainwin = (MainWindow *)data;
2147 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2148 manage_window_focus_in(mainwin->window, NULL, NULL);
2151 static void toolbar_inc_cb (GtkWidget *widget,
2154 MainWindow *mainwin = (MainWindow *)data;
2156 inc_mail_cb(mainwin, 0, NULL);
2159 static void toolbar_inc_all_cb (GtkWidget *widget,
2162 MainWindow *mainwin = (MainWindow *)data;
2164 inc_all_account_mail_cb(mainwin, 0, NULL);
2167 static void toolbar_send_cb (GtkWidget *widget,
2170 MainWindow *mainwin = (MainWindow *)data;
2172 send_queue_cb(mainwin, 0, NULL);
2175 static void toolbar_compose_cb (GtkWidget *widget,
2178 MainWindow *mainwin = (MainWindow *)data;
2180 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2181 compose_cb(mainwin, 0, NULL);
2183 compose_news_cb(mainwin, 0, NULL);
2186 static void toolbar_compose_news_cb (GtkWidget *widget,
2189 MainWindow *mainwin = (MainWindow *)data;
2191 compose_news_cb(mainwin, 0, NULL);
2194 static void toolbar_compose_mail_cb (GtkWidget *widget,
2197 MainWindow *mainwin = (MainWindow *)data;
2199 compose_mail_cb(mainwin, 0, NULL);
2202 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2204 MainWindow *mainwin = (MainWindow *)data;
2207 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2208 : COMPOSE_REPLY_WITHOUT_QUOTE,
2212 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2214 MainWindow *mainwin = (MainWindow *)data;
2217 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2218 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2223 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2225 MainWindow *mainwin = (MainWindow *)data;
2228 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2229 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2233 static void toolbar_forward_cb (GtkWidget *widget,
2236 MainWindow *mainwin = (MainWindow *)data;
2238 if (prefs_common.forward_as_attachment)
2239 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2241 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2244 static void toolbar_delete_cb (GtkWidget *widget,
2247 MainWindow *mainwin = (MainWindow *)data;
2249 summary_delete(mainwin->summaryview);
2252 static void toolbar_exec_cb (GtkWidget *widget,
2255 MainWindow *mainwin = (MainWindow *)data;
2257 summary_execute(mainwin->summaryview);
2260 static void toolbar_next_unread_cb (GtkWidget *widget,
2263 MainWindow *mainwin = (MainWindow *)data;
2265 next_unread_cb(mainwin, 0, NULL);
2268 static void toolbar_prefs_cb (GtkWidget *widget,
2271 prefs_common_open();
2274 static void toolbar_account_cb (GtkWidget *widget,
2277 MainWindow *mainwin = (MainWindow *)data;
2279 prefs_account_open_cb(mainwin, 0, NULL);
2282 static void toolbar_account_button_pressed(GtkWidget *widget,
2283 GdkEventButton *event,
2286 MainWindow *mainwin = (MainWindow *)data;
2289 if (event->button != 3) return;
2291 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2292 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2295 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2296 menu_button_position, widget,
2297 event->button, event->time);
2300 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2303 MainWindow *mainwin = (MainWindow *)data;
2307 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2308 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2311 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2312 menu_button_position, widget,
2313 event->button, event->time);
2316 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2318 MainWindow *mainwin = (MainWindow *)data;
2321 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2322 if (!button) return;
2323 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2324 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2325 manage_window_focus_in(mainwin->window, NULL, NULL);
2328 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2331 MainWindow *mainwin = (MainWindow *)data;
2333 if (mainwin->lock_count == 0)
2334 app_exit_cb(data, 0, widget);
2339 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2342 main_window_add_mailbox(mainwin);
2345 static void add_mbox_cb(MainWindow *mainwin, guint action,
2348 main_window_add_mbox(mainwin);
2351 static void update_folderview_cb(MainWindow *mainwin, guint action,
2354 summary_show(mainwin->summaryview, NULL, FALSE);
2355 folderview_rescan_all();
2358 static void new_folder_cb(MainWindow *mainwin, guint action,
2361 folderview_new_folder(mainwin->folderview);
2364 static void rename_folder_cb(MainWindow *mainwin, guint action,
2367 folderview_rename_folder(mainwin->folderview);
2370 static void delete_folder_cb(MainWindow *mainwin, guint action,
2373 folderview_delete_folder(mainwin->folderview);
2376 static void import_mbox_cb(MainWindow *mainwin, guint action,
2379 import_mbox(mainwin->summaryview->folder_item);
2382 static void export_mbox_cb(MainWindow *mainwin, guint action,
2385 export_mbox(mainwin->summaryview->folder_item);
2388 static void empty_trash_cb(MainWindow *mainwin, guint action,
2391 main_window_empty_trash(mainwin, TRUE);
2394 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2396 summary_save_as(mainwin->summaryview);
2399 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2401 summary_print(mainwin->summaryview);
2404 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2406 if (prefs_common.confirm_on_exit) {
2407 if (alertpanel(_("Exit"), _("Exit this program?"),
2408 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2410 manage_window_focus_in(mainwin->window, NULL, NULL);
2413 app_will_exit(widget, mainwin);
2416 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2419 summary_search(mainwin->summaryview);
2421 message_search(mainwin->messageview);
2424 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2427 switch (mainwin->type) {
2429 case SEPARATE_MESSAGE:
2431 case SEPARATE_FOLDER:
2432 if (GTK_CHECK_MENU_ITEM(widget)->active)
2433 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2435 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2438 if (GTK_CHECK_MENU_ITEM(widget)->active)
2439 gtk_widget_show(mainwin->win.sep_both.folderwin);
2441 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2446 static void toggle_message_cb(MainWindow *mainwin, guint action,
2449 switch (mainwin->type) {
2451 case SEPARATE_FOLDER:
2453 case SEPARATE_MESSAGE:
2454 if (GTK_CHECK_MENU_ITEM(widget)->active)
2455 gtk_widget_show(mainwin->win.sep_message.messagewin);
2457 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2460 if (GTK_CHECK_MENU_ITEM(widget)->active)
2461 gtk_widget_show(mainwin->win.sep_both.messagewin);
2463 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2468 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2471 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2472 mainwin->compose_btn_type);
2473 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2474 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2475 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2476 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2478 mainwin->toolbar_style = (ToolbarStyle)action;
2479 prefs_common.toolbar_style = (ToolbarStyle)action;
2481 set_toolbar_style(mainwin);
2484 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2487 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2488 gtk_widget_show(mainwin->hbox_stat);
2489 prefs_common.show_statusbar = TRUE;
2491 gtk_widget_hide(mainwin->hbox_stat);
2492 prefs_common.show_statusbar = FALSE;
2496 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2498 summary_toggle_view_real(mainwin->summaryview);
2501 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2503 messageview_toggle_view_real(mainwin->messageview);
2506 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2509 MainWindow *mainwin;
2512 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2513 g_return_if_fail(mainwin != NULL);
2515 type = mainwin->type ^ action;
2516 main_window_separation_change(mainwin, type);
2518 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2519 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2522 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2525 addressbook_open(NULL);
2528 static void log_window_show_cb(MainWindow *mainwin, guint action,
2531 log_window_show(mainwin->logwin);
2534 static void sel_download_cb(MainWindow *mainwin, guint action,
2537 selective_download(mainwin);
2540 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2542 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2545 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2548 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2551 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2555 if (procmsg_send_queue() < 0)
2556 alertpanel_error(_("Some errors occurred while sending queued messages."));
2558 statusbar_pop_all();
2560 for (list = folder_get_list(); list != NULL; list = list->next) {
2563 folder = list->data;
2564 if (folder->queue) {
2565 folder_item_scan(folder->queue);
2566 folderview_update_item(folder->queue, TRUE);
2571 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2573 if (mainwin->summaryview->folder_item) {
2574 if (mainwin->summaryview->folder_item->folder->account != NULL
2575 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2576 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2578 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2584 static void compose_mail_cb(MainWindow *mainwin, guint action,
2591 if (mainwin->summaryview->folder_item) {
2592 ac = mainwin->summaryview->folder_item->folder->account;
2593 if (ac && ac->protocol != A_NNTP) {
2594 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2599 if(cur_account && (cur_account->protocol != A_NNTP)) {
2600 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2604 list = account_get_list();
2605 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2606 ac = (PrefsAccount *) cur->data;
2607 if (ac->protocol != A_NNTP) {
2608 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2614 static void compose_news_cb(MainWindow *mainwin, guint action,
2617 PrefsAccount * ac = NULL;
2621 if (mainwin->summaryview->folder_item) {
2622 ac = mainwin->summaryview->folder_item->folder->account;
2623 if (ac && ac->protocol == A_NNTP) {
2624 compose_new_with_recipient
2625 (ac, mainwin->summaryview->folder_item->path);
2630 list = account_get_list();
2631 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2632 ac = (PrefsAccount *) cur->data;
2633 if (ac->protocol == A_NNTP) {
2640 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2642 summary_reply(mainwin->summaryview, (ComposeMode)action);
2645 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2647 summary_move_to(mainwin->summaryview);
2650 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2652 summary_copy_to(mainwin->summaryview);
2655 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2657 summary_delete(mainwin->summaryview);
2660 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2662 summary_open_msg(mainwin->summaryview);
2665 static void view_source_cb(MainWindow *mainwin, guint action,
2668 summary_view_source(mainwin->summaryview);
2671 static void show_all_header_cb(MainWindow *mainwin, guint action,
2674 if (mainwin->menu_lock_count) return;
2675 summary_display_msg_selected(mainwin->summaryview,
2676 GTK_CHECK_MENU_ITEM(widget)->active);
2679 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2681 summary_reedit(mainwin->summaryview);
2684 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2686 summary_mark(mainwin->summaryview);
2689 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2691 summary_unmark(mainwin->summaryview);
2694 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2697 summary_mark_as_unread(mainwin->summaryview);
2700 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2703 summary_mark_as_read(mainwin->summaryview);
2706 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2709 summary_mark_all_read(mainwin->summaryview);
2712 static void add_address_cb(MainWindow *mainwin, guint action,
2715 summary_add_address(mainwin->summaryview);
2718 static void set_charset_cb(MainWindow *mainwin, guint action,
2723 str = conv_get_charset_str((CharSet)action);
2724 g_free(prefs_common.force_charset);
2725 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2727 summary_redisplay_msg(mainwin->summaryview);
2729 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2732 static void hide_read_messages (MainWindow *mainwin, guint action,
2735 if (!mainwin->summaryview->folder_item
2736 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2738 summary_toggle_show_read_messages(mainwin->summaryview);
2741 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2743 GtkItemFactory *ifactory;
2745 if (mainwin->menu_lock_count) return;
2746 if (!mainwin->summaryview->folder_item) return;
2748 ifactory = gtk_item_factory_from_widget(widget);
2750 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2751 summary_thread_build(mainwin->summaryview);
2752 mainwin->summaryview->folder_item->threaded = TRUE;
2754 summary_unthread(mainwin->summaryview);
2755 mainwin->summaryview->folder_item->threaded = FALSE;
2759 static void set_display_item_cb(MainWindow *mainwin, guint action,
2762 prefs_summary_column_open();
2765 static void sort_summary_cb(MainWindow *mainwin, guint action,
2768 summary_sort(mainwin->summaryview, (SummarySortType)action);
2771 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2774 summary_attract_by_subject(mainwin->summaryview);
2777 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2780 summary_delete_duplicated(mainwin->summaryview);
2783 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2785 summary_filter(mainwin->summaryview);
2788 static void execute_summary_cb(MainWindow *mainwin, guint action,
2791 summary_execute(mainwin->summaryview);
2794 static void update_summary_cb(MainWindow *mainwin, guint action,
2798 FolderView *folderview = mainwin->folderview;
2800 if (!mainwin->summaryview->folder_item) return;
2801 if (!folderview->opened) return;
2803 folder_update_op_count();
2805 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2806 folderview->opened);
2809 summary_show(mainwin->summaryview, fitem, TRUE);
2812 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2814 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2817 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2819 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2822 static void prev_unread_cb(MainWindow *mainwin, guint action,
2825 summary_select_prev_unread(mainwin->summaryview);
2828 static void next_unread_cb(MainWindow *mainwin, guint action,
2831 summary_select_next_unread(mainwin->summaryview);
2834 static void prev_marked_cb(MainWindow *mainwin, guint action,
2837 summary_select_prev_marked(mainwin->summaryview);
2840 static void next_marked_cb(MainWindow *mainwin, guint action,
2843 summary_select_next_marked(mainwin->summaryview);
2846 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2849 summary_select_prev_labeled(mainwin->summaryview);
2852 static void next_labeled_cb(MainWindow *mainwin, guint action,
2855 summary_select_next_labeled(mainwin->summaryview);
2858 static void goto_folder_cb(MainWindow *mainwin, guint action,
2861 FolderItem *to_folder;
2863 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2866 folderview_select(mainwin->folderview, to_folder);
2869 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2871 messageview_copy_clipboard(mainwin->messageview);
2874 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2876 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2877 summary_select_all(mainwin->summaryview);
2878 else if (mainwin->summaryview->msg_is_toggled_on &&
2879 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2880 messageview_select_all(mainwin->messageview);
2883 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2885 if (mainwin->summaryview->msg_is_toggled_on)
2886 summary_select_thread(mainwin->summaryview);
2889 static void create_filter_cb(MainWindow *mainwin, guint action,
2892 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2895 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2898 prefs_common_open();
2901 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2904 prefs_filter_open(NULL, NULL);
2907 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2910 prefs_scoring_open(NULL);
2913 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2916 prefs_filtering_open(NULL);
2919 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2922 prefs_template_open();
2925 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2928 prefs_actions_open(mainwin);
2931 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2935 new_account_cb(mainwin, 0, widget);
2937 gboolean prev_default = cur_account->is_default;
2939 prefs_account_open(cur_account);
2940 if (!prev_default && cur_account->is_default)
2941 account_set_as_default(cur_account);
2942 account_save_config_all();
2944 main_window_reflect_prefs_all();
2948 static void new_account_cb(MainWindow *mainwin, guint action,
2951 account_edit_open();
2952 if (!compose_get_compose_list()) account_add();
2955 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2957 cur_account = (PrefsAccount *)data;
2958 main_window_reflect_prefs_all();
2961 static void manual_open_cb(MainWindow *mainwin, guint action,
2964 manual_open((ManualLang)action);
2967 static void faq_open_cb(MainWindow *mainwin, guint action,
2970 faq_open((FaqLang)action);
2973 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2975 MainWindow *mainwin = (MainWindow *)data;
2979 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2980 LOCAL_FOLDER(folder)->rootpath,
2984 str = g_strdup_printf(_("Scanning folder %s ..."),
2985 LOCAL_FOLDER(folder)->rootpath);
2987 STATUSBAR_PUSH(mainwin, str);
2988 STATUSBAR_POP(mainwin);
2992 static void activate_compose_button (MainWindow *mainwin,
2994 ComposeButtonType type)
2996 SensitiveCond state = main_window_get_current_state(mainwin);
2998 if (style == TOOLBAR_NONE)
3001 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
3002 : mainwin->compose_news_btn);
3003 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
3004 : mainwin->compose_mail_btn);
3005 mainwin->compose_btn_type = type;
3008 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
3010 if (mainwin->compose_btn_type != compose_btn_type)
3011 activate_compose_button(mainwin,
3012 prefs_common.toolbar_style,
3016 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
3018 MainWindow *mainwin = (MainWindow*) data;
3020 if (!mainwin) return;
3022 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
3025 #define BREAK_ON_MODIFIER_KEY() \
3026 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3028 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3030 MainWindow *mainwin = (MainWindow*) data;
3032 if (!mainwin || !event) return;
3034 switch (event->keyval) {
3035 case GDK_Q: /* Quit */
3036 BREAK_ON_MODIFIER_KEY();
3038 app_exit_cb(mainwin, 0, NULL);
3045 #undef BREAK_ON_MODIFIER_KEY
3047 static void set_toolbar_style(MainWindow *mainwin)
3049 switch (prefs_common.toolbar_style) {
3051 gtk_widget_hide(mainwin->handlebox);
3054 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3058 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3062 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3067 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3068 gtk_widget_show(mainwin->handlebox);
3069 gtk_widget_queue_resize(mainwin->handlebox);
3071 if (prefs_common.immediate_exec)
3072 gtk_widget_hide(mainwin->exec_btn);
3074 gtk_widget_show(mainwin->exec_btn);