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 toggle_work_offline_cb (MainWindow *mainwin,
248 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
252 static void addressbook_open_cb (MainWindow *mainwin,
255 static void log_window_show_cb (MainWindow *mainwin,
258 static void sel_download_cb (MainWindow *mainwin,
262 static void inc_mail_cb (MainWindow *mainwin,
265 static void inc_all_account_mail_cb (MainWindow *mainwin,
268 static void inc_cancel_cb (MainWindow *mainwin,
272 static void send_queue_cb (MainWindow *mainwin,
276 static void compose_cb (MainWindow *mainwin,
279 static void compose_mail_cb(MainWindow *mainwin, guint action,
281 static void compose_news_cb(MainWindow *mainwin, guint action,
283 static void reply_cb (MainWindow *mainwin,
287 static void open_msg_cb (MainWindow *mainwin,
291 static void view_source_cb (MainWindow *mainwin,
295 static void show_all_header_cb (MainWindow *mainwin,
299 static void reedit_cb (MainWindow *mainwin,
303 static void move_to_cb (MainWindow *mainwin,
306 static void copy_to_cb (MainWindow *mainwin,
309 static void delete_cb (MainWindow *mainwin,
313 static void mark_cb (MainWindow *mainwin,
316 static void unmark_cb (MainWindow *mainwin,
320 static void mark_as_unread_cb (MainWindow *mainwin,
323 static void mark_as_read_cb (MainWindow *mainwin,
326 static void mark_all_read_cb (MainWindow *mainwin,
329 static void add_address_cb (MainWindow *mainwin,
333 static void set_charset_cb (MainWindow *mainwin,
337 static void hide_read_messages (MainWindow *mainwin,
341 static void thread_cb (MainWindow *mainwin,
344 static void set_display_item_cb (MainWindow *mainwin,
347 static void sort_summary_cb (MainWindow *mainwin,
350 static void attract_by_subject_cb(MainWindow *mainwin,
354 static void delete_duplicated_cb (MainWindow *mainwin,
357 static void filter_cb (MainWindow *mainwin,
360 static void execute_summary_cb (MainWindow *mainwin,
363 static void update_summary_cb (MainWindow *mainwin,
367 static void prev_cb (MainWindow *mainwin,
370 static void next_cb (MainWindow *mainwin,
374 static void prev_unread_cb (MainWindow *mainwin,
377 static void next_unread_cb (MainWindow *mainwin,
380 static void prev_marked_cb (MainWindow *mainwin,
383 static void next_marked_cb (MainWindow *mainwin,
386 static void prev_labeled_cb (MainWindow *mainwin,
389 static void next_labeled_cb (MainWindow *mainwin,
393 static void goto_folder_cb (MainWindow *mainwin,
397 static void copy_cb (MainWindow *mainwin,
400 static void allsel_cb (MainWindow *mainwin,
403 static void selthread_cb (MainWindow *mainwin,
406 static void create_filter_cb (MainWindow *mainwin,
410 static void prefs_common_open_cb (MainWindow *mainwin,
413 static void prefs_filter_open_cb (MainWindow *mainwin,
416 static void prefs_scoring_open_cb (MainWindow *mainwin,
419 static void prefs_filtering_open_cb (MainWindow *mainwin,
422 static void prefs_account_open_cb(MainWindow *mainwin,
425 static void prefs_template_open_cb (MainWindow *mainwin,
428 static void prefs_actions_open_cb (MainWindow *mainwin,
431 static void new_account_cb (MainWindow *mainwin,
435 static void account_menu_cb (GtkMenuItem *menuitem,
438 static void online_switch_clicked(GtkButton *btn,
441 static void manual_open_cb (MainWindow *mainwin,
444 static void faq_open_cb (MainWindow *mainwin,
448 static void scan_tree_func (Folder *folder,
452 static void activate_compose_button (MainWindow *mainwin,
454 ComposeButtonType type);
456 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
460 static void key_pressed (GtkWidget *widget,
464 static void set_toolbar_style(MainWindow *mainwin);
466 static void addr_harvest_cb ( MainWindow *mainwin,
470 static void addr_harvest_msg_cb ( MainWindow *mainwin,
474 #define SEPARATE_ACTION 667
476 static GtkItemFactoryEntry mainwin_entries[] =
478 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
479 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
480 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
481 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
482 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
483 {N_("/_File/_Folder/Create _new folder..."),
484 NULL, new_folder_cb, 0, NULL},
485 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
486 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
487 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
488 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
489 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
490 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
491 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
492 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
493 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
494 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
495 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
497 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
498 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
499 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
500 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
501 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
502 {N_("/_Edit/_Find in current message..."),
503 "<control>F", search_cb, 0, NULL},
504 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
505 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
506 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
507 {N_("/_View/Show or hi_de/_Toolbar"),
508 NULL, NULL, 0, "<Branch>"},
509 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
510 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
511 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
512 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
513 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
514 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
515 {N_("/_View/Show or hi_de/_Toolbar/_None"),
516 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
517 {N_("/_View/Show or hi_de/Status _bar"),
518 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
519 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
520 {N_("/_View/Separate _Folder Tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
521 {N_("/_View/Separate _Message View"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
522 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
523 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
524 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
525 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
526 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
527 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
528 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
529 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
530 {N_("/_View/_Sort/Sort by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
531 {N_("/_View/_Sort/Sort by _color label"),
532 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
533 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
534 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
535 {N_("/_View/_Sort/Sort by a_ttachment"),
536 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
537 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
538 {N_("/_View/_Sort/_Attract by subject"),
539 NULL, attract_by_subject_cb, 0, NULL},
540 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
541 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
542 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
544 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
545 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
546 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
547 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
548 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
549 {N_("/_View/_Go to/P_rev unread message"),
550 "<shift>P", prev_unread_cb, 0, NULL},
551 {N_("/_View/_Go to/N_ext unread message"),
552 "<shift>N", next_unread_cb, 0, NULL},
553 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
554 {N_("/_View/_Go to/Prev _marked message"),
555 NULL, prev_marked_cb, 0, NULL},
556 {N_("/_View/_Go to/Next m_arked message"),
557 NULL, next_marked_cb, 0, NULL},
558 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
559 {N_("/_View/_Go to/Prev _labeled message"),
560 NULL, prev_labeled_cb, 0, NULL},
561 {N_("/_View/_Go to/Next la_beled message"),
562 NULL, next_labeled_cb, 0, NULL},
563 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
564 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
565 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
567 #define CODESET_SEPARATOR \
568 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
569 #define CODESET_ACTION(action) \
570 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
572 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
573 {N_("/_View/_Code set/_Auto detect"),
574 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
575 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
576 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
577 CODESET_ACTION(C_US_ASCII)},
580 {N_("/_View/_Code set/Unicode (_UTF-8)"),
581 CODESET_ACTION(C_UTF_8)},
584 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
585 CODESET_ACTION(C_ISO_8859_1)},
586 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
587 CODESET_ACTION(C_ISO_8859_15)},
590 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
591 CODESET_ACTION(C_ISO_8859_2)},
593 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
594 CODESET_ACTION(C_ISO_8859_13)},
595 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
596 CODESET_ACTION(C_ISO_8859_4)},
598 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
599 CODESET_ACTION(C_ISO_8859_7)},
601 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
602 CODESET_ACTION(C_ISO_8859_9)},
604 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
605 CODESET_ACTION(C_ISO_8859_5)},
606 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
607 CODESET_ACTION(C_KOI8_R)},
608 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
609 CODESET_ACTION(C_CP1251)},
612 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
613 CODESET_ACTION(C_ISO_2022_JP)},
615 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
616 CODESET_ACTION(C_ISO_2022_JP_2)},
618 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
619 CODESET_ACTION(C_EUC_JP)},
620 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
621 CODESET_ACTION(C_SHIFT_JIS)},
624 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
625 CODESET_ACTION(C_GB2312)},
626 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
627 CODESET_ACTION(C_BIG5)},
628 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
629 CODESET_ACTION(C_EUC_TW)},
630 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
631 CODESET_ACTION(C_ISO_2022_CN)},
633 {N_("/_View/_Code set/Korean (EUC-_KR)"),
634 CODESET_ACTION(C_EUC_KR)},
635 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
636 CODESET_ACTION(C_ISO_2022_KR)},
638 {N_("/_View/_Code set/Thai (TIS-620)"),
639 CODESET_ACTION(C_TIS_620)},
640 {N_("/_View/_Code set/Thai (Windows-874)"),
641 CODESET_ACTION(C_WINDOWS_874)},
644 #undef CODESET_SEPARATOR
645 #undef CODESET_ACTION
647 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
648 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
649 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
650 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
651 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
652 {N_("/_View/_Update"), "<control><alt>U", update_summary_cb, 0, NULL},
654 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
655 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
656 {N_("/_Message/Get from _all accounts"),
657 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
658 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
659 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
660 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
661 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
662 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
663 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
664 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
665 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
666 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
667 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
668 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
669 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
670 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
671 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
672 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
673 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
674 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
675 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
676 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
677 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
678 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
679 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
680 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
681 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
682 {N_("/_Message/_Mark/Mark as rea_d"),
683 NULL, mark_as_read_cb, 0, NULL},
684 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
686 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
687 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
688 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
689 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
690 {N_("/_Tools/Add sender to address boo_k"),
691 NULL, add_address_cb, 0, NULL},
692 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
693 {N_("/_Tools/_Harvest addresses/from _Folder..."),
694 NULL, addr_harvest_cb, 0, NULL},
695 {N_("/_Tools/_Harvest addresses/from _Messages..."),
696 NULL, addr_harvest_msg_cb, 0, NULL},
697 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
698 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
699 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
700 {N_("/_Tools/_Create filter rule/_Automatically"),
701 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
702 {N_("/_Tools/_Create filter rule/by _From"),
703 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
704 {N_("/_Tools/_Create filter rule/by _To"),
705 NULL, create_filter_cb, FILTER_BY_TO, NULL},
706 {N_("/_Tools/_Create filter rule/by _Subject"),
707 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
708 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
709 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
710 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
711 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
712 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
713 {N_("/_Tools/Delete du_plicated messages"),
714 NULL, delete_duplicated_cb, 0, NULL},
715 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
716 {N_("/_Tools/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
718 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
719 {N_("/_Configuration/_Common preferences..."),
720 NULL, prefs_common_open_cb, 0, NULL},
721 {N_("/_Configuration/_Filter setting..."),
722 NULL, prefs_filter_open_cb, 0, NULL},
723 {N_("/_Configuration/_Scoring..."),
724 NULL, prefs_scoring_open_cb, 0, NULL},
725 {N_("/_Configuration/_Filtering..."),
726 NULL, prefs_filtering_open_cb, 0, NULL},
727 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
728 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
729 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
730 {N_("/_Configuration/_Preferences for current account..."),
731 NULL, prefs_account_open_cb, 0, NULL},
732 {N_("/_Configuration/Create _new account..."),
733 NULL, new_account_cb, 0, NULL},
734 {N_("/_Configuration/_Edit accounts..."),
735 NULL, account_edit_open, 0, NULL},
736 {N_("/_Configuration/C_hange current account"),
737 NULL, NULL, 0, "<Branch>"},
739 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
740 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
741 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
742 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
743 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
744 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
745 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
746 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
747 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
748 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
749 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
750 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
752 static GtkItemFactoryEntry reply_popup_entries[] =
754 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
755 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
757 static GtkItemFactoryEntry replyall_popup_entries[] =
759 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
760 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
762 static GtkItemFactoryEntry replysender_popup_entries[] =
764 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
765 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
767 static GtkItemFactoryEntry fwd_popup_entries[] =
769 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
770 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
773 MainWindow *main_window_create(SeparateType type)
779 GtkWidget *handlebox;
780 GtkWidget *vbox_body;
781 GtkWidget *hbox_stat;
782 GtkWidget *statusbar;
783 GtkWidget *progressbar;
784 GtkWidget *statuslabel;
785 GtkWidget *ac_button;
787 GtkWidget *online_status;
788 GtkWidget *offline_status;
789 GtkWidget *online_switch;
790 GtkWidget *offline_switch;
792 FolderView *folderview;
793 SummaryView *summaryview;
794 MessageView *messageview;
795 GdkColormap *colormap;
798 guint n_menu_entries;
799 GtkItemFactory *ifactory;
802 GtkWidget *compose_popup;
803 GtkWidget *reply_popup;
804 GtkWidget *replyall_popup;
805 GtkWidget *replysender_popup;
806 GtkWidget *fwd_popup;
809 static GdkGeometry geometry;
811 debug_print(_("Creating main window...\n"));
812 mainwin = g_new0(MainWindow, 1);
815 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
816 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
817 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
818 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
820 if (!geometry.min_height) {
821 geometry.min_width = 320;
822 geometry.min_height = 200;
824 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
827 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
828 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
829 MANAGE_WINDOW_SIGNALS_CONNECT(window);
830 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
831 GTK_SIGNAL_FUNC(key_pressed), mainwin);
833 gtk_widget_realize(window);
834 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
837 gtkut_widget_set_app_icon(window);
839 vbox = gtk_vbox_new(FALSE, 0);
840 gtk_widget_show(vbox);
841 gtk_container_add(GTK_CONTAINER(window), vbox);
844 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
845 menubar = menubar_create(window, mainwin_entries,
846 n_menu_entries, "<Main>", mainwin);
847 gtk_widget_show(menubar);
848 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
850 handlebox = gtk_handle_box_new();
851 gtk_widget_show(handlebox);
852 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
854 /* create the popup menus for the reply buttons specials */
855 n_menu_entries = sizeof(reply_popup_entries) /
856 sizeof(reply_popup_entries[0]);
857 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
858 "<ReplyPopup>", mainwin);
859 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
860 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
861 n_menu_entries = sizeof(replyall_popup_entries) /
862 sizeof(replyall_popup_entries[0]);
863 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
864 "<ReplyAllPopup>", mainwin);
865 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
866 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
867 n_menu_entries = sizeof(replysender_popup_entries) /
868 sizeof(replysender_popup_entries[0]);
869 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
870 "<ReplySenderPopup>", mainwin);
871 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
872 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
873 /* create the popup menu for the forward button */
874 n_menu_entries = sizeof(fwd_popup_entries) /
875 sizeof(fwd_popup_entries[0]);
876 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
877 "<ForwardPopup>", mainwin);
878 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
879 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
881 main_window_toolbar_create(mainwin, handlebox);
883 /* vbox that contains body */
884 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
885 gtk_widget_show(vbox_body);
886 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
887 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
889 hbox_stat = gtk_hbox_new(FALSE, 2);
890 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
892 statusbar = statusbar_create();
893 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
895 progressbar = gtk_progress_bar_new();
896 gtk_widget_set_usize(progressbar, 120, 1);
897 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
899 online_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
900 offline_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
901 online_switch = gtk_button_new ();
902 offline_switch = gtk_button_new ();
903 gtk_container_add (GTK_CONTAINER(online_switch), online_status);
904 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
905 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
906 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
907 gtk_container_add (GTK_CONTAINER(offline_switch), offline_status);
908 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
909 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
910 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
912 statuslabel = gtk_label_new("");
913 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
915 ac_button = gtk_button_new();
916 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
917 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
918 gtk_widget_set_usize(ac_button, -1, 1);
919 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
920 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
921 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
923 ac_label = gtk_label_new("");
924 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
926 gtk_widget_show_all(hbox_stat);
928 gtk_widget_hide(offline_switch);
930 mainwin->folderview = folderview = folderview_create();
931 mainwin->summaryview = summaryview = summary_create();
932 mainwin->messageview = messageview = messageview_create();
933 mainwin->logwin = log_window_create();
935 folderview->mainwin = mainwin;
936 folderview->summaryview = summaryview;
938 summaryview->mainwin = mainwin;
939 summaryview->folderview = folderview;
940 summaryview->messageview = messageview;
941 summaryview->window = window;
943 messageview->mainwin = mainwin;
945 mainwin->window = window;
946 mainwin->vbox = vbox;
947 mainwin->menubar = menubar;
948 mainwin->handlebox = handlebox;
949 mainwin->vbox_body = vbox_body;
950 mainwin->hbox_stat = hbox_stat;
951 mainwin->statusbar = statusbar;
952 mainwin->progressbar = progressbar;
953 mainwin->statuslabel = statuslabel;
954 mainwin->ac_button = ac_button;
955 mainwin->ac_label = ac_label;
956 mainwin->reply_popup = reply_popup;
957 mainwin->replyall_popup = replyall_popup;
958 mainwin->replysender_popup = replysender_popup;
959 mainwin->fwd_popup = fwd_popup;
960 mainwin->online_switch = online_switch;
961 mainwin->offline_switch = offline_switch;
963 /* set context IDs for status bar */
964 mainwin->mainwin_cid = gtk_statusbar_get_context_id
965 (GTK_STATUSBAR(statusbar), "Main Window");
966 mainwin->folderview_cid = gtk_statusbar_get_context_id
967 (GTK_STATUSBAR(statusbar), "Folder View");
968 mainwin->summaryview_cid = gtk_statusbar_get_context_id
969 (GTK_STATUSBAR(statusbar), "Summary View");
971 /* allocate colors for summary view and folder view */
972 summaryview->color_marked.red = summaryview->color_marked.green = 0;
973 summaryview->color_marked.blue = (guint16)65535;
975 summaryview->color_dim.red = summaryview->color_dim.green =
976 summaryview->color_dim.blue = COLOR_DIM;
978 folderview->color_new.red = (guint16)55000;
979 folderview->color_new.green = folderview->color_new.blue = 15000;
981 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
982 &folderview->color_op);
984 summaryview->color_important.red = 0;
985 summaryview->color_important.green = 0;
986 summaryview->color_important.blue = (guint16)65535;
988 color[0] = summaryview->color_marked;
989 color[1] = summaryview->color_dim;
990 color[2] = folderview->color_new;
991 color[3] = folderview->color_op;
993 colormap = gdk_window_get_colormap(window->window);
994 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
995 for (i = 0; i < 4; i++) {
996 if (success[i] == FALSE)
997 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1000 debug_print(_("done.\n"));
1002 main_window_set_widgets(mainwin, type);
1004 /* set menu items */
1005 ifactory = gtk_item_factory_from_widget(menubar);
1006 menuitem = gtk_item_factory_get_item
1007 (ifactory, "/View/Code set/Auto detect");
1008 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1010 switch (prefs_common.toolbar_style) {
1012 menuitem = gtk_item_factory_get_item
1013 (ifactory, "/View/Show or hide/Toolbar/None");
1016 menuitem = gtk_item_factory_get_item
1017 (ifactory, "/View/Show or hide/Toolbar/Icon");
1020 menuitem = gtk_item_factory_get_item
1021 (ifactory, "/View/Show or hide/Toolbar/Text");
1024 menuitem = gtk_item_factory_get_item
1025 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1027 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1029 gtk_widget_hide(mainwin->hbox_stat);
1030 menuitem = gtk_item_factory_get_item
1031 (ifactory, "/View/Show or hide/Status bar");
1032 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1033 prefs_common.show_statusbar);
1034 #if 0 /* FIXED SEPARATE WINDOWS */
1035 /* Message view and Folder tree are always shown at startup
1036 * make that in the menu visible */
1037 menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Message View");
1038 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1039 menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Folder Tree");
1040 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1042 /* set the check of the SEPARATE_xxx menu items. we also need the main window
1043 * as a property and pass the action type to the callback */
1044 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
1046 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
1047 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
1048 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
1049 GUINT_TO_POINTER(SEPARATE_FOLDER));
1051 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
1053 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
1054 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
1055 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
1056 GUINT_TO_POINTER(SEPARATE_MESSAGE));
1058 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
1059 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
1062 /* set account selection menu */
1063 ac_menu = gtk_item_factory_get_widget
1064 (ifactory, "/Configuration/Change current account");
1065 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1066 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1067 mainwin->ac_menu = ac_menu;
1069 main_window_set_toolbar_sensitive(mainwin);
1071 /* Create actions menu */
1072 update_mainwin_actions_menu(ifactory, mainwin);
1074 /* show main window */
1075 gtk_widget_set_uposition(mainwin->window,
1076 prefs_common.mainwin_x,
1077 prefs_common.mainwin_y);
1078 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1079 prefs_common.mainwin_height);
1080 gtk_widget_show(mainwin->window);
1082 /* initialize views */
1083 folderview_init(folderview);
1084 summary_init(summaryview);
1085 messageview_init(messageview);
1086 log_window_init(mainwin->logwin);
1088 mainwin->lock_count = 0;
1089 mainwin->menu_lock_count = 0;
1090 mainwin->cursor_count = 0;
1093 watch_cursor = gdk_cursor_new(GDK_WATCH);
1095 mainwin_list = g_list_append(mainwin_list, mainwin);
1097 /* init work_offline */
1098 if (prefs_common.work_offline)
1099 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1104 void main_window_cursor_wait(MainWindow *mainwin)
1107 if (mainwin->cursor_count == 0)
1108 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1110 mainwin->cursor_count++;
1115 void main_window_cursor_normal(MainWindow *mainwin)
1117 if (mainwin->cursor_count)
1118 mainwin->cursor_count--;
1120 if (mainwin->cursor_count == 0)
1121 gdk_window_set_cursor(mainwin->window->window, NULL);
1126 /* lock / unlock the user-interface */
1127 void main_window_lock(MainWindow *mainwin)
1129 if (mainwin->lock_count == 0)
1130 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1132 mainwin->lock_count++;
1134 main_window_set_menu_sensitive(mainwin);
1135 main_window_set_toolbar_sensitive(mainwin);
1138 void main_window_unlock(MainWindow *mainwin)
1140 if (mainwin->lock_count)
1141 mainwin->lock_count--;
1143 main_window_set_menu_sensitive(mainwin);
1144 main_window_set_toolbar_sensitive(mainwin);
1146 if (mainwin->lock_count == 0)
1147 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1150 static void main_window_menu_callback_block(MainWindow *mainwin)
1152 mainwin->menu_lock_count++;
1155 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1157 if (mainwin->menu_lock_count)
1158 mainwin->menu_lock_count--;
1161 void main_window_reflect_prefs_all(void)
1163 main_window_reflect_prefs_all_real(FALSE);
1166 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1169 MainWindow *mainwin;
1171 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1172 mainwin = (MainWindow *)cur->data;
1174 main_window_show_cur_account(mainwin);
1175 main_window_set_menu_sensitive(mainwin);
1176 main_window_set_toolbar_sensitive(mainwin);
1179 if (pixmap_theme_changed)
1181 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1182 mainwin->toolbar = NULL;
1183 main_window_toolbar_create(mainwin, mainwin->handlebox);
1184 set_toolbar_style(mainwin);
1185 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1186 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1187 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1190 summary_redisplay_msg(mainwin->summaryview);
1191 headerview_set_visibility(mainwin->messageview->headerview,
1192 prefs_common.display_header_pane);
1196 void main_window_set_summary_column(void)
1199 MainWindow *mainwin;
1201 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1202 mainwin = (MainWindow *)cur->data;
1203 summary_set_column_order(mainwin->summaryview);
1207 void main_window_set_account_menu(GList *account_list)
1209 GList *cur, *cur_ac, *cur_item;
1210 GtkWidget *menuitem;
1211 MainWindow *mainwin;
1212 PrefsAccount *ac_prefs;
1214 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1215 mainwin = (MainWindow *)cur->data;
1217 /* destroy all previous menu item */
1218 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1219 while (cur_item != NULL) {
1220 GList *next = cur_item->next;
1221 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1225 for (cur_ac = account_list; cur_ac != NULL;
1226 cur_ac = cur_ac->next) {
1227 ac_prefs = (PrefsAccount *)cur_ac->data;
1229 menuitem = gtk_menu_item_new_with_label
1230 (ac_prefs->account_name
1231 ? ac_prefs->account_name : _("Untitled"));
1232 gtk_widget_show(menuitem);
1233 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1234 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1235 GTK_SIGNAL_FUNC(account_menu_cb),
1241 static void main_window_show_cur_account(MainWindow *mainwin)
1246 ac_name = g_strdup(cur_account
1247 ? (cur_account->account_name
1248 ? cur_account->account_name : _("Untitled"))
1252 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1254 buf = g_strdup(PROG_VERSION);
1255 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1258 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1259 gtk_widget_queue_resize(mainwin->ac_button);
1264 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1266 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1267 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1268 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1270 if (mainwin->type == type) return;
1272 /* remove widgets from those containers */
1273 gtk_widget_ref(folder_wid);
1274 gtk_widget_ref(summary_wid);
1275 gtk_widget_ref(message_wid);
1276 gtkut_container_remove
1277 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1278 gtkut_container_remove
1279 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1280 gtkut_container_remove
1281 (GTK_CONTAINER(message_wid->parent), message_wid);
1283 /* clean containers */
1284 switch (mainwin->type) {
1286 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1288 case SEPARATE_FOLDER:
1289 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1290 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1292 case SEPARATE_MESSAGE:
1293 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1294 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1297 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1298 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1302 gtk_widget_hide(mainwin->window);
1303 main_window_set_widgets(mainwin, type);
1304 gtk_widget_show(mainwin->window);
1306 gtk_widget_unref(folder_wid);
1307 gtk_widget_unref(summary_wid);
1308 gtk_widget_unref(message_wid);
1311 void main_window_get_size(MainWindow *mainwin)
1313 GtkAllocation *allocation;
1315 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1317 prefs_common.summaryview_width = allocation->width;
1319 if (mainwin->summaryview->msg_is_toggled_on)
1320 prefs_common.summaryview_height = allocation->height;
1322 prefs_common.mainview_width = allocation->width;
1324 allocation = &mainwin->window->allocation;
1326 prefs_common.mainview_height = allocation->height;
1327 prefs_common.mainwin_width = allocation->width;
1328 prefs_common.mainwin_height = allocation->height;
1330 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1332 prefs_common.folderview_width = allocation->width;
1333 prefs_common.folderview_height = allocation->height;
1336 void main_window_get_position(MainWindow *mainwin)
1340 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1342 prefs_common.mainview_x = x;
1343 prefs_common.mainview_y = y;
1344 prefs_common.mainwin_x = x;
1345 prefs_common.mainwin_y = y;
1347 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1350 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1356 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1357 folder = FOLDER(list->data);
1358 if (folder && folder->trash && folder->trash->total > 0)
1362 if (!has_trash) return;
1365 if (alertpanel(_("Empty trash"),
1366 _("Empty all messages in trash?"),
1367 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1369 manage_window_focus_in(mainwin->window, NULL, NULL);
1372 procmsg_empty_trash();
1374 for (list = folder_get_list(); list != NULL; list = list->next) {
1375 folder = list->data;
1376 if (folder && folder->trash && folder->trash->total != 0) {
1377 folder_item_scan(folder->trash);
1378 folderview_update_item(folder->trash, TRUE);
1382 if (mainwin->summaryview->folder_item &&
1383 mainwin->summaryview->folder_item->stype == F_TRASH)
1384 gtk_widget_grab_focus(mainwin->folderview->ctree);
1387 void main_window_add_mailbox(MainWindow *mainwin)
1392 path = input_dialog(_("Add mailbox"),
1393 _("Input the location of mailbox.\n"
1394 "If the existing mailbox is specified, it will be\n"
1395 "scanned automatically."),
1398 if (folder_find_from_path(path)) {
1399 alertpanel_error(_("The mailbox `%s' already exists."), path);
1403 if (!strcmp(path, "Mail"))
1404 folder = folder_new(F_MH, _("Mailbox"), path);
1406 folder = folder_new(F_MH, g_basename(path), path);
1409 if (folder->create_tree(folder) < 0) {
1410 alertpanel_error(_("Creation of the mailbox failed.\n"
1411 "Maybe some files already exist, or you don't have the permission to write there."));
1412 folder_destroy(folder);
1417 folder_set_ui_func(folder, scan_tree_func, mainwin);
1418 folder->scan_tree(folder);
1419 folder_set_ui_func(folder, NULL, NULL);
1421 folderview_set(mainwin->folderview);
1424 void main_window_add_mbox(MainWindow *mainwin)
1430 path = input_dialog(_("Add mbox mailbox"),
1431 _("Input the location of mailbox."),
1436 if (folder_find_from_path(path)) {
1437 alertpanel_error(_("The mailbox `%s' already exists."), path);
1443 if (!strcmp(path, "Mail"))
1444 folder = folder_new(F_MBOX, _("Mailbox"), path);
1448 folder = folder_new(F_MBOX, g_basename(path), path);
1451 if (folder->create_tree(folder) < 0) {
1452 alertpanel_error(_("Creation of the mailbox failed."));
1453 folder_destroy(folder);
1459 item = folder_item_new(folder->name, NULL);
1460 item->folder = folder;
1461 folder->node = g_node_new(item);
1463 folder->create_folder(folder, item, "inbox");
1464 folder->create_folder(folder, item, "outbox");
1465 folder->create_folder(folder, item, "queue");
1466 folder->create_folder(folder, item, "draft");
1467 folder->create_folder(folder, item, "trash");
1469 folderview_set(mainwin->folderview);
1474 M_UNLOCKED = 1 << 0,
1475 M_MSG_EXIST = 1 << 1,
1476 M_TARGET_EXIST = 1 << 2,
1477 M_SINGLE_TARGET_EXIST = 1 << 3,
1479 M_ALLOW_REEDIT = 1 << 5,
1480 M_HAVE_ACCOUNT = 1 << 6,
1481 M_THREADED = 1 << 7,
1482 M_UNTHREADED = 1 << 8,
1483 M_ALLOW_DELETE = 1 << 9,
1484 M_INC_ACTIVE = 1 << 10,
1486 M_HAVE_NEWS_ACCOUNT = 1 << 12,
1487 M_HIDE_READ_MSG = 1 << 13
1490 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1492 SensitiveCond state = 0;
1493 SummarySelection selection;
1494 FolderItem *item = mainwin->summaryview->folder_item;
1495 GList *account_list = account_get_list();
1497 selection = summary_get_selection_type(mainwin->summaryview);
1499 if (mainwin->lock_count == 0)
1500 state |= M_UNLOCKED;
1501 if (selection != SUMMARY_NONE)
1502 state |= M_MSG_EXIST;
1506 state |= M_THREADED;
1508 state |= M_UNTHREADED;
1509 /* if (item->folder->type != F_NEWS) */
1510 state |= M_ALLOW_DELETE;
1512 if (selection == SUMMARY_NONE && item->hide_read_msgs
1513 || selection != SUMMARY_NONE)
1514 state |= M_HIDE_READ_MSG;
1516 if (selection == SUMMARY_SELECTED_SINGLE ||
1517 selection == SUMMARY_SELECTED_MULTIPLE)
1518 state |= M_TARGET_EXIST;
1519 if (selection == SUMMARY_SELECTED_SINGLE)
1520 state |= M_SINGLE_TARGET_EXIST;
1521 if (mainwin->summaryview->folder_item &&
1522 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1524 if (selection == SUMMARY_SELECTED_SINGLE &&
1526 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1527 item->stype == F_QUEUE)))
1528 state |= M_ALLOW_REEDIT;
1530 state |= M_HAVE_ACCOUNT;
1532 for ( ; account_list != NULL; account_list = account_list->next) {
1533 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1534 state |= M_HAVE_NEWS_ACCOUNT;
1539 if (inc_is_active())
1540 state |= M_INC_ACTIVE;
1545 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1547 SensitiveCond state;
1556 entry[0].widget = mainwin->get_btn;
1557 entry[0].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1558 entry[1].widget = mainwin->getall_btn;
1559 entry[1].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1560 entry[2].widget = mainwin->compose_news_btn;
1561 entry[2].cond = M_HAVE_NEWS_ACCOUNT;
1562 entry[3].widget = mainwin->reply_btn;
1563 entry[3].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1564 entry[4].widget = mainwin->replyall_btn;
1565 entry[4].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1566 entry[5].widget = mainwin->replysender_btn;
1567 entry[5].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1568 entry[6].widget = mainwin->fwd_btn;
1569 entry[6].cond = M_HAVE_ACCOUNT|M_TARGET_EXIST;
1570 /* entry[6].widget = mainwin->prefs_btn;
1571 entry[6].cond = M_UNLOCKED;
1572 entry[7].widget = mainwin->account_btn;
1573 entry[7].cond = M_UNLOCKED; */
1574 entry[7].widget = mainwin->next_btn;
1575 entry[7].cond = M_MSG_EXIST;
1576 entry[8].widget = mainwin->delete_btn;
1577 entry[8].cond = M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED;
1578 entry[9].widget = mainwin->exec_btn;
1579 entry[9].cond = M_MSG_EXIST|M_EXEC|M_UNLOCKED;
1580 entry[10].widget = NULL;
1583 state = main_window_get_current_state(mainwin);
1585 for (i = 0; entry[i].widget != NULL; i++) {
1586 sensitive = ((entry[i].cond & state) == entry[i].cond);
1587 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1590 activate_compose_button(mainwin,
1591 prefs_common.toolbar_style,
1592 mainwin->compose_btn_type);
1595 void main_window_set_menu_sensitive(MainWindow *mainwin)
1597 GtkItemFactory *ifactory;
1598 SensitiveCond state;
1600 GtkWidget *menuitem;
1603 static const struct {
1607 {"/File/Add mailbox..." , M_UNLOCKED},
1608 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1609 {"/File/Rescan folder tree" , M_UNLOCKED},
1610 {"/File/Folder" , M_UNLOCKED},
1611 {"/File/Import mbox file..." , M_UNLOCKED},
1612 {"/File/Export to mbox file...", M_UNLOCKED},
1613 {"/File/Empty trash" , M_UNLOCKED},
1614 {"/File/Work offline" , M_UNLOCKED},
1615 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1616 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1617 /* {"/File/Close", M_UNLOCKED}, */
1618 {"/File/Exit" , M_UNLOCKED},
1620 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1621 {"/View/Sort" , M_MSG_EXIST},
1622 {"/View/Thread view" , M_EXEC},
1623 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1624 {"/View/Go to/Prev message" , M_MSG_EXIST},
1625 {"/View/Go to/Next message" , M_MSG_EXIST},
1626 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1627 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1628 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1629 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1630 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1631 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1632 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1633 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1634 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1636 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1637 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1638 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1639 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1640 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1641 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1642 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1643 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1644 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1645 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1646 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1647 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1648 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1649 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1650 {"/Message/Mark" , M_TARGET_EXIST},
1652 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1653 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1654 {"/Tools/Harvest addresses" , M_UNLOCKED},
1655 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1656 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1657 {"/Tools/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1658 {"/Tools/Actions" , M_MSG_EXIST},
1659 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1661 {"/Configuration", M_UNLOCKED},
1666 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1667 state = main_window_get_current_state(mainwin);
1669 for (i = 0; entry[i].entry != NULL; i++) {
1670 sensitive = ((entry[i].cond & state) == entry[i].cond);
1671 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1674 main_window_menu_callback_block(mainwin);
1675 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all header");
1676 gtk_check_menu_item_set_active
1677 (GTK_CHECK_MENU_ITEM(menuitem),
1678 mainwin->messageview->textview->show_all_headers);
1679 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1680 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1681 (state & M_THREADED) != 0);
1682 main_window_menu_callback_unblock(mainwin);
1685 void main_window_popup(MainWindow *mainwin)
1691 gdk_window_get_origin(mainwin->window->window, &x, &y);
1692 sx = gdk_screen_width();
1693 sy = gdk_screen_height();
1694 x %= sx; if (x < 0) x = 0;
1695 y %= sy; if (y < 0) y = 0;
1696 gdk_window_move(mainwin->window->window, x, y);
1697 gdk_window_raise(mainwin->window->window);
1698 gdk_window_show(mainwin->window->window);
1700 debug_print("window position: x = %d, y = %d\n", x, y);
1702 switch (mainwin->type) {
1703 case SEPARATE_FOLDER:
1704 widget = mainwin->win.sep_folder.folderwin;
1705 gdk_window_get_origin(widget->window, &x, &y);
1706 x %= sx; if (x < 0) x = 0;
1707 y %= sy; if (y < 0) y = 0;
1708 gdk_window_move(widget->window, x, y);
1709 gdk_window_raise(widget->window);
1711 case SEPARATE_MESSAGE:
1712 widget = mainwin->win.sep_message.messagewin;
1713 gdk_window_get_origin(widget->window, &x, &y);
1714 x %= sx; if (x < 0) x = 0;
1715 y %= sy; if (y < 0) y = 0;
1716 gdk_window_move(widget->window, x, y);
1717 gdk_window_raise(widget->window);
1720 widget = mainwin->win.sep_both.folderwin;
1721 gdk_window_get_origin(widget->window, &x, &y);
1722 x %= sx; if (x < 0) x = 0;
1723 y %= sy; if (y < 0) y = 0;
1724 gdk_window_move(widget->window, x, y);
1725 gdk_window_raise(widget->window);
1726 widget = mainwin->win.sep_both.messagewin;
1727 gdk_window_get_origin(widget->window, &x, &y);
1728 x %= sx; if (x < 0) x = 0;
1729 y %= sy; if (y < 0) y = 0;
1730 gdk_window_move(widget->window, x, y);
1731 gdk_window_raise(widget->window);
1738 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1740 GtkWidget *folderwin = NULL;
1741 GtkWidget *messagewin = NULL;
1744 GtkWidget *vbox_body = mainwin->vbox_body;
1745 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1746 GtkWidget *menuitem;
1748 debug_print(_("Setting widgets..."));
1750 /* create separated window(s) if needed */
1751 if (type & SEPARATE_FOLDER) {
1752 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1753 gtk_window_set_title(GTK_WINDOW(folderwin),
1754 _("Sylpheed - Folder View"));
1755 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1756 "folder_view", "Sylpheed");
1757 gtk_window_set_policy(GTK_WINDOW(folderwin),
1759 gtk_widget_set_usize(folderwin, -1,
1760 prefs_common.mainview_height);
1761 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1763 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1764 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1767 if (type & SEPARATE_MESSAGE) {
1768 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1769 gtk_window_set_title(GTK_WINDOW(messagewin),
1770 _("Sylpheed - Message View"));
1771 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1772 "message_view", "Sylpheed");
1773 gtk_window_set_policy(GTK_WINDOW(messagewin),
1775 gtk_widget_set_usize
1776 (messagewin, prefs_common.mainview_width,
1777 prefs_common.mainview_height
1778 - prefs_common.summaryview_height
1779 + DEFAULT_HEADERVIEW_HEIGHT);
1780 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1782 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1783 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1789 hpaned = gtk_hpaned_new();
1790 gtk_widget_show(hpaned);
1791 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));
1795 vpaned = gtk_vpaned_new();
1796 if (mainwin->summaryview->msg_is_toggled_on) {
1797 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1798 gtk_paned_add1(GTK_PANED(vpaned),
1799 GTK_WIDGET_PTR(mainwin->summaryview));
1801 gtk_paned_add2(GTK_PANED(hpaned),
1802 GTK_WIDGET_PTR(mainwin->summaryview));
1803 gtk_widget_ref(vpaned);
1805 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1806 prefs_common.summaryview_width,
1807 prefs_common.summaryview_height);
1808 gtk_paned_add2(GTK_PANED(vpaned),
1809 GTK_WIDGET_PTR(mainwin->messageview));
1810 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1811 prefs_common.mainview_width, -1);
1812 gtk_widget_set_usize(mainwin->window,
1813 prefs_common.folderview_width +
1814 prefs_common.mainview_width,
1815 prefs_common.mainwin_height);
1816 gtk_widget_show_all(vpaned);
1818 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1819 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1820 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1821 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1822 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1823 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1825 mainwin->win.sep_none.hpaned = hpaned;
1826 mainwin->win.sep_none.vpaned = vpaned;
1828 case SEPARATE_FOLDER:
1829 vpaned = gtk_vpaned_new();
1830 if (mainwin->summaryview->msg_is_toggled_on) {
1831 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1833 gtk_paned_add1(GTK_PANED(vpaned),
1834 GTK_WIDGET_PTR(mainwin->summaryview));
1836 gtk_box_pack_start(GTK_BOX(vbox_body),
1837 GTK_WIDGET_PTR(mainwin->summaryview),
1839 gtk_widget_ref(vpaned);
1841 gtk_paned_add2(GTK_PANED(vpaned),
1842 GTK_WIDGET_PTR(mainwin->messageview));
1843 gtk_widget_show_all(vpaned);
1844 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1845 prefs_common.summaryview_width,
1846 prefs_common.summaryview_height);
1847 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1848 prefs_common.mainview_width, -1);
1849 gtk_widget_set_usize(mainwin->window,
1850 prefs_common.mainview_width,
1851 prefs_common.mainview_height);
1853 gtk_container_add(GTK_CONTAINER(folderwin),
1854 GTK_WIDGET_PTR(mainwin->folderview));
1856 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1857 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1859 mainwin->win.sep_folder.folderwin = folderwin;
1860 mainwin->win.sep_folder.vpaned = vpaned;
1862 gtk_widget_show_all(folderwin);
1864 case SEPARATE_MESSAGE:
1865 hpaned = gtk_hpaned_new();
1866 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1868 gtk_paned_add1(GTK_PANED(hpaned),
1869 GTK_WIDGET_PTR(mainwin->folderview));
1870 gtk_paned_add2(GTK_PANED(hpaned),
1871 GTK_WIDGET_PTR(mainwin->summaryview));
1872 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1873 prefs_common.summaryview_width,
1874 prefs_common.summaryview_height);
1875 gtk_widget_set_usize(mainwin->window,
1876 prefs_common.folderview_width +
1877 prefs_common.mainview_width,
1878 prefs_common.mainwin_height);
1879 gtk_widget_show_all(hpaned);
1880 gtk_container_add(GTK_CONTAINER(messagewin),
1881 GTK_WIDGET_PTR(mainwin->messageview));
1883 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1884 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1885 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1886 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1888 mainwin->win.sep_message.messagewin = messagewin;
1889 mainwin->win.sep_message.hpaned = hpaned;
1891 gtk_widget_show_all(messagewin);
1894 gtk_box_pack_start(GTK_BOX(vbox_body),
1895 GTK_WIDGET_PTR(mainwin->summaryview),
1897 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1898 prefs_common.summaryview_width,
1899 prefs_common.summaryview_height);
1900 gtk_widget_set_usize(mainwin->window,
1901 prefs_common.mainview_width,
1902 prefs_common.mainwin_height);
1903 gtk_container_add(GTK_CONTAINER(folderwin),
1904 GTK_WIDGET_PTR(mainwin->folderview));
1905 gtk_container_add(GTK_CONTAINER(messagewin),
1906 GTK_WIDGET_PTR(mainwin->messageview));
1908 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1909 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1911 mainwin->win.sep_both.folderwin = folderwin;
1912 mainwin->win.sep_both.messagewin = messagewin;
1914 gtk_widget_show_all(folderwin);
1915 gtk_widget_show_all(messagewin);
1919 mainwin->type = type;
1921 debug_print(_("done.\n"));
1924 static void main_window_toolbar_create(MainWindow *mainwin,
1925 GtkWidget *container)
1928 GtkWidget *icon_wid;
1930 GtkWidget *getall_btn;
1931 GtkWidget *compose_mail_btn;
1932 GtkWidget *compose_news_btn;
1933 GtkWidget *reply_btn;
1934 GtkWidget *replyall_btn;
1935 GtkWidget *replysender_btn;
1937 GtkWidget *send_btn;
1939 GtkWidget *prefs_btn;
1940 GtkWidget *account_btn;
1942 GtkWidget *next_btn;
1943 GtkWidget *delete_btn;
1944 GtkWidget *exec_btn;
1946 GtkTooltips *tooltips;
1948 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1950 gtk_container_add(GTK_CONTAINER(container), toolbar);
1951 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1952 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1953 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1954 GTK_TOOLBAR_SPACE_LINE);
1956 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1957 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1959 _("Get new mail from current account"),
1961 icon_wid, toolbar_inc_cb, mainwin);
1962 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1963 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1965 _("Get new mail from all accounts"),
1971 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1973 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1974 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1976 _("Send queued message(s)"),
1982 /* insert compose mail button widget */
1983 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1984 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1986 _("Compose an email message"),
1989 toolbar_compose_mail_cb,
1992 /* insert compose news button widget */
1993 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1994 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1996 _("Compose a news message"),
1999 toolbar_compose_news_cb,
2002 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2006 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
2007 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2009 _("Reply to the message - Right button: more options"),
2015 /* replyall button */
2017 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
2018 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2020 _("Reply to all - Right button: more options"),
2023 toolbar_reply_to_all_cb,
2026 /* reply to sender button */
2027 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
2028 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2030 _("Reply to sender - Right button: more options"),
2033 toolbar_reply_to_sender_cb,
2036 /* forward button */
2037 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
2038 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2040 _("Forward the message - Right button: more options"),
2046 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2048 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
2049 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2051 _("Delete the message"),
2057 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
2058 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2060 _("Execute marked process"),
2066 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
2067 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2069 _("Next unread message"),
2072 toolbar_next_unread_cb,
2076 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2078 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2079 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2081 _("Common preference"),
2086 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2087 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2089 _("Account setting"),
2094 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2095 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2099 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2100 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2103 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2104 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2107 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2108 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2111 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2112 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2116 mainwin->toolbar = toolbar;
2117 mainwin->get_btn = get_btn;
2118 mainwin->getall_btn = getall_btn;
2119 mainwin->compose_mail_btn = compose_mail_btn;
2120 mainwin->compose_news_btn = compose_news_btn;
2121 mainwin->reply_btn = reply_btn;
2122 mainwin->replyall_btn = replyall_btn;
2123 mainwin->replysender_btn = replysender_btn;
2124 mainwin->fwd_btn = fwd_btn;
2125 mainwin->send_btn = send_btn;
2127 mainwin->prefs_btn = prefs_btn;
2128 mainwin->account_btn = account_btn;
2130 mainwin->next_btn = next_btn;
2131 mainwin->delete_btn = delete_btn;
2132 mainwin->exec_btn = exec_btn;
2134 gtk_widget_show_all(toolbar);
2137 /* callback functions */
2138 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2140 MainWindow *mainwindow = (MainWindow *) data;
2144 if (event->button == 3) {
2145 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2146 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2147 menu_button_position, widget,
2148 event->button, event->time);
2152 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2154 MainWindow *mainwin = (MainWindow *)data;
2156 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2157 manage_window_focus_in(mainwin->window, NULL, NULL);
2160 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2162 MainWindow *mainwindow = (MainWindow *) data;
2166 if (event->button == 3) {
2167 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2168 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2169 menu_button_position, widget,
2170 event->button, event->time);
2174 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2176 MainWindow *mainwin = (MainWindow *)data;
2178 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2179 manage_window_focus_in(mainwin->window, NULL, NULL);
2182 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2184 MainWindow *mainwindow = (MainWindow *) data;
2185 GtkWidget *replysender_menu, *replysender_item;
2189 if (event->button == 3) {
2190 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2191 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2192 menu_button_position, widget,
2193 event->button, event->time);
2197 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2199 MainWindow *mainwin = (MainWindow *)data;
2201 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2202 manage_window_focus_in(mainwin->window, NULL, NULL);
2205 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2207 MainWindow *mainwindow = (MainWindow *) data;
2211 if (event->button == 3) {
2212 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2213 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2214 menu_button_position, widget,
2215 event->button, event->time);
2219 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2221 MainWindow *mainwin = (MainWindow *)data;
2223 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2224 manage_window_focus_in(mainwin->window, NULL, NULL);
2227 static void toolbar_inc_cb (GtkWidget *widget,
2230 MainWindow *mainwin = (MainWindow *)data;
2232 inc_mail_cb(mainwin, 0, NULL);
2235 static void toolbar_inc_all_cb (GtkWidget *widget,
2238 MainWindow *mainwin = (MainWindow *)data;
2240 inc_all_account_mail_cb(mainwin, 0, NULL);
2243 static void toolbar_send_cb (GtkWidget *widget,
2246 MainWindow *mainwin = (MainWindow *)data;
2248 send_queue_cb(mainwin, 0, NULL);
2251 static void toolbar_compose_cb (GtkWidget *widget,
2254 MainWindow *mainwin = (MainWindow *)data;
2256 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2257 compose_cb(mainwin, 0, NULL);
2259 compose_news_cb(mainwin, 0, NULL);
2262 static void toolbar_compose_news_cb (GtkWidget *widget,
2265 MainWindow *mainwin = (MainWindow *)data;
2267 compose_news_cb(mainwin, 0, NULL);
2270 static void toolbar_compose_mail_cb (GtkWidget *widget,
2273 MainWindow *mainwin = (MainWindow *)data;
2275 compose_mail_cb(mainwin, 0, NULL);
2278 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2280 MainWindow *mainwin = (MainWindow *)data;
2283 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2284 : COMPOSE_REPLY_WITHOUT_QUOTE,
2288 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2290 MainWindow *mainwin = (MainWindow *)data;
2293 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2294 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2299 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2301 MainWindow *mainwin = (MainWindow *)data;
2304 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2305 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2309 static void toolbar_forward_cb (GtkWidget *widget,
2312 MainWindow *mainwin = (MainWindow *)data;
2314 if (prefs_common.forward_as_attachment)
2315 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2317 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2320 static void toolbar_delete_cb (GtkWidget *widget,
2323 MainWindow *mainwin = (MainWindow *)data;
2325 summary_delete(mainwin->summaryview);
2328 static void toolbar_exec_cb (GtkWidget *widget,
2331 MainWindow *mainwin = (MainWindow *)data;
2333 summary_execute(mainwin->summaryview);
2336 static void toolbar_next_unread_cb (GtkWidget *widget,
2339 MainWindow *mainwin = (MainWindow *)data;
2341 next_unread_cb(mainwin, 0, NULL);
2344 static void toolbar_prefs_cb (GtkWidget *widget,
2347 prefs_common_open();
2350 static void toolbar_account_cb (GtkWidget *widget,
2353 MainWindow *mainwin = (MainWindow *)data;
2355 prefs_account_open_cb(mainwin, 0, NULL);
2358 static void toolbar_account_button_pressed(GtkWidget *widget,
2359 GdkEventButton *event,
2362 MainWindow *mainwin = (MainWindow *)data;
2365 if (event->button != 3) return;
2367 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2368 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2371 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2372 menu_button_position, widget,
2373 event->button, event->time);
2376 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2379 MainWindow *mainwin = (MainWindow *)data;
2383 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2384 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2387 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2388 menu_button_position, widget,
2389 event->button, event->time);
2392 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2394 MainWindow *mainwin = (MainWindow *)data;
2397 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2398 if (!button) return;
2399 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2400 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2401 manage_window_focus_in(mainwin->window, NULL, NULL);
2404 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2407 MainWindow *mainwin = (MainWindow *)data;
2409 if (mainwin->lock_count == 0)
2410 app_exit_cb(data, 0, widget);
2415 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2418 main_window_add_mailbox(mainwin);
2421 static void add_mbox_cb(MainWindow *mainwin, guint action,
2424 main_window_add_mbox(mainwin);
2427 static void update_folderview_cb(MainWindow *mainwin, guint action,
2430 summary_show(mainwin->summaryview, NULL, FALSE);
2431 folderview_rescan_all();
2434 static void new_folder_cb(MainWindow *mainwin, guint action,
2437 folderview_new_folder(mainwin->folderview);
2440 static void rename_folder_cb(MainWindow *mainwin, guint action,
2443 folderview_rename_folder(mainwin->folderview);
2446 static void delete_folder_cb(MainWindow *mainwin, guint action,
2449 folderview_delete_folder(mainwin->folderview);
2452 static void import_mbox_cb(MainWindow *mainwin, guint action,
2455 import_mbox(mainwin->summaryview->folder_item);
2458 static void export_mbox_cb(MainWindow *mainwin, guint action,
2461 export_mbox(mainwin->summaryview->folder_item);
2464 static void empty_trash_cb(MainWindow *mainwin, guint action,
2467 main_window_empty_trash(mainwin, TRUE);
2470 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2472 summary_save_as(mainwin->summaryview);
2475 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2477 summary_print(mainwin->summaryview);
2480 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2482 if (prefs_common.confirm_on_exit) {
2483 if (alertpanel(_("Exit"), _("Exit this program?"),
2484 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2486 manage_window_focus_in(mainwin->window, NULL, NULL);
2489 app_will_exit(widget, mainwin);
2492 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2495 summary_search(mainwin->summaryview);
2497 message_search(mainwin->messageview);
2500 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2503 switch (mainwin->type) {
2505 case SEPARATE_MESSAGE:
2507 case SEPARATE_FOLDER:
2508 if (GTK_CHECK_MENU_ITEM(widget)->active)
2509 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2511 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2514 if (GTK_CHECK_MENU_ITEM(widget)->active)
2515 gtk_widget_show(mainwin->win.sep_both.folderwin);
2517 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2522 static void toggle_message_cb(MainWindow *mainwin, guint action,
2525 switch (mainwin->type) {
2527 case SEPARATE_FOLDER:
2529 case SEPARATE_MESSAGE:
2530 if (GTK_CHECK_MENU_ITEM(widget)->active)
2531 gtk_widget_show(mainwin->win.sep_message.messagewin);
2533 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2536 if (GTK_CHECK_MENU_ITEM(widget)->active)
2537 gtk_widget_show(mainwin->win.sep_both.messagewin);
2539 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2544 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2547 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2548 mainwin->compose_btn_type);
2549 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2550 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2551 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2552 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2554 mainwin->toolbar_style = (ToolbarStyle)action;
2555 prefs_common.toolbar_style = (ToolbarStyle)action;
2557 set_toolbar_style(mainwin);
2560 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2563 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2564 gtk_widget_show(mainwin->hbox_stat);
2565 prefs_common.show_statusbar = TRUE;
2567 gtk_widget_hide(mainwin->hbox_stat);
2568 prefs_common.show_statusbar = FALSE;
2572 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2574 summary_toggle_view_real(mainwin->summaryview);
2577 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2579 messageview_toggle_view_real(mainwin->messageview);
2582 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2584 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2585 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2587 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2591 static void online_switch_clicked (GtkButton *btn, gpointer data)
2593 MainWindow *mainwin;
2594 GtkItemFactory *ifactory;
2595 GtkCheckMenuItem *menuitem;
2597 mainwin = (MainWindow *) data;
2599 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2600 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2602 g_return_if_fail(mainwin != NULL);
2603 g_return_if_fail(menuitem != NULL);
2605 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2607 gtk_widget_hide (mainwin->online_switch);
2608 gtk_widget_show (mainwin->offline_switch);
2609 menuitem->active = TRUE;
2610 prefs_common.work_offline = TRUE;
2611 inc_autocheck_timer_remove();
2614 gtk_widget_hide (mainwin->offline_switch);
2615 gtk_widget_show (mainwin->online_switch);
2616 menuitem->active = FALSE;
2617 prefs_common.work_offline = FALSE;
2618 inc_autocheck_timer_set();
2622 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2624 MainWindow *mainwin;
2627 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2628 g_return_if_fail(mainwin != NULL);
2630 type = mainwin->type ^ action;
2631 main_window_separation_change(mainwin, type);
2633 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2634 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2637 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2640 addressbook_open(NULL);
2643 static void log_window_show_cb(MainWindow *mainwin, guint action,
2646 log_window_show(mainwin->logwin);
2649 static void sel_download_cb(MainWindow *mainwin, guint action,
2652 selective_download(mainwin);
2655 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2657 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2660 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2663 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2666 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2671 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2675 if (prefs_common.work_offline)
2676 if (alertpanel(_("Offline warning"),
2677 _("You're working offline. Override?"),
2678 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
2681 for (list = folder_get_list(); list != NULL; list = list->next) {
2682 Folder *folder = list->data;
2684 if (folder->queue) {
2685 if (procmsg_send_queue
2686 (folder->queue, prefs_common.savemsg) < 0)
2687 alertpanel_error(_("Some errors occurred while sending queued messages."));
2688 statusbar_pop_all();
2689 folder_item_scan(folder->queue);
2690 folderview_update_item(folder->queue, TRUE);
2695 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2697 if (mainwin->summaryview->folder_item) {
2698 if (mainwin->summaryview->folder_item->folder->account != NULL
2699 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2700 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2702 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2708 static void compose_mail_cb(MainWindow *mainwin, guint action,
2715 if (mainwin->summaryview->folder_item) {
2716 ac = mainwin->summaryview->folder_item->folder->account;
2717 if (ac && ac->protocol != A_NNTP) {
2718 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2723 if(cur_account && (cur_account->protocol != A_NNTP)) {
2724 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2728 list = account_get_list();
2729 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2730 ac = (PrefsAccount *) cur->data;
2731 if (ac->protocol != A_NNTP) {
2732 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2738 static void compose_news_cb(MainWindow *mainwin, guint action,
2741 PrefsAccount * ac = NULL;
2745 if (mainwin->summaryview->folder_item) {
2746 ac = mainwin->summaryview->folder_item->folder->account;
2747 if (ac && ac->protocol == A_NNTP) {
2748 compose_new_with_recipient
2749 (ac, mainwin->summaryview->folder_item->path);
2754 list = account_get_list();
2755 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2756 ac = (PrefsAccount *) cur->data;
2757 if (ac->protocol == A_NNTP) {
2764 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2766 summary_reply(mainwin->summaryview, (ComposeMode)action);
2769 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2771 summary_move_to(mainwin->summaryview);
2774 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2776 summary_copy_to(mainwin->summaryview);
2779 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2781 summary_delete(mainwin->summaryview);
2784 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2786 summary_open_msg(mainwin->summaryview);
2789 static void view_source_cb(MainWindow *mainwin, guint action,
2792 summary_view_source(mainwin->summaryview);
2795 static void show_all_header_cb(MainWindow *mainwin, guint action,
2798 if (mainwin->menu_lock_count) return;
2799 summary_display_msg_selected(mainwin->summaryview,
2800 GTK_CHECK_MENU_ITEM(widget)->active);
2803 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2805 summary_reedit(mainwin->summaryview);
2808 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2810 summary_mark(mainwin->summaryview);
2813 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2815 summary_unmark(mainwin->summaryview);
2818 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2821 summary_mark_as_unread(mainwin->summaryview);
2824 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2827 summary_mark_as_read(mainwin->summaryview);
2830 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2833 summary_mark_all_read(mainwin->summaryview);
2836 static void add_address_cb(MainWindow *mainwin, guint action,
2839 summary_add_address(mainwin->summaryview);
2842 static void set_charset_cb(MainWindow *mainwin, guint action,
2847 str = conv_get_charset_str((CharSet)action);
2848 g_free(prefs_common.force_charset);
2849 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2851 summary_redisplay_msg(mainwin->summaryview);
2853 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2856 static void hide_read_messages (MainWindow *mainwin, guint action,
2859 if (!mainwin->summaryview->folder_item
2860 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2862 summary_toggle_show_read_messages(mainwin->summaryview);
2865 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2867 GtkItemFactory *ifactory;
2869 if (mainwin->menu_lock_count) return;
2870 if (!mainwin->summaryview->folder_item) return;
2872 ifactory = gtk_item_factory_from_widget(widget);
2874 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2875 summary_thread_build(mainwin->summaryview);
2876 mainwin->summaryview->folder_item->threaded = TRUE;
2878 summary_unthread(mainwin->summaryview);
2879 mainwin->summaryview->folder_item->threaded = FALSE;
2883 static void set_display_item_cb(MainWindow *mainwin, guint action,
2886 prefs_summary_column_open();
2889 static void sort_summary_cb(MainWindow *mainwin, guint action,
2892 summary_sort(mainwin->summaryview, (SummarySortType)action);
2895 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2898 summary_attract_by_subject(mainwin->summaryview);
2901 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2904 summary_delete_duplicated(mainwin->summaryview);
2907 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2909 summary_filter(mainwin->summaryview);
2912 static void execute_summary_cb(MainWindow *mainwin, guint action,
2915 summary_execute(mainwin->summaryview);
2918 static void update_summary_cb(MainWindow *mainwin, guint action,
2922 FolderView *folderview = mainwin->folderview;
2924 if (!mainwin->summaryview->folder_item) return;
2925 if (!folderview->opened) return;
2927 folder_update_op_count();
2929 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2930 folderview->opened);
2933 summary_show(mainwin->summaryview, fitem, TRUE);
2936 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2938 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2941 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2943 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2946 static void prev_unread_cb(MainWindow *mainwin, guint action,
2949 summary_select_prev_unread(mainwin->summaryview);
2952 static void next_unread_cb(MainWindow *mainwin, guint action,
2955 summary_select_next_unread(mainwin->summaryview);
2958 static void prev_marked_cb(MainWindow *mainwin, guint action,
2961 summary_select_prev_marked(mainwin->summaryview);
2964 static void next_marked_cb(MainWindow *mainwin, guint action,
2967 summary_select_next_marked(mainwin->summaryview);
2970 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2973 summary_select_prev_labeled(mainwin->summaryview);
2976 static void next_labeled_cb(MainWindow *mainwin, guint action,
2979 summary_select_next_labeled(mainwin->summaryview);
2982 static void goto_folder_cb(MainWindow *mainwin, guint action,
2985 FolderItem *to_folder;
2987 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2990 folderview_select(mainwin->folderview, to_folder);
2993 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2995 messageview_copy_clipboard(mainwin->messageview);
2998 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3000 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3001 summary_select_all(mainwin->summaryview);
3002 else if (mainwin->summaryview->msg_is_toggled_on &&
3003 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
3004 messageview_select_all(mainwin->messageview);
3007 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3009 if (mainwin->summaryview->msg_is_toggled_on)
3010 summary_select_thread(mainwin->summaryview);
3013 static void create_filter_cb(MainWindow *mainwin, guint action,
3016 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3019 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3022 prefs_common_open();
3025 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
3028 prefs_filter_open(NULL, NULL);
3031 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3034 prefs_scoring_open(NULL);
3037 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3040 prefs_filtering_open(NULL, NULL, NULL);
3043 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3046 prefs_template_open();
3049 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3052 prefs_actions_open(mainwin);
3055 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3059 new_account_cb(mainwin, 0, widget);
3061 gboolean prev_default = cur_account->is_default;
3063 prefs_account_open(cur_account);
3064 if (!prev_default && cur_account->is_default)
3065 account_set_as_default(cur_account);
3066 account_save_config_all();
3068 main_window_reflect_prefs_all();
3072 static void new_account_cb(MainWindow *mainwin, guint action,
3075 account_edit_open();
3076 if (!compose_get_compose_list()) account_add();
3079 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3081 cur_account = (PrefsAccount *)data;
3082 main_window_reflect_prefs_all();
3085 static void manual_open_cb(MainWindow *mainwin, guint action,
3088 manual_open((ManualLang)action);
3091 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3093 faq_open((ManualLang)action);
3096 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3098 MainWindow *mainwin = (MainWindow *)data;
3102 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3103 LOCAL_FOLDER(folder)->rootpath,
3107 str = g_strdup_printf(_("Scanning folder %s ..."),
3108 LOCAL_FOLDER(folder)->rootpath);
3110 STATUSBAR_PUSH(mainwin, str);
3111 STATUSBAR_POP(mainwin);
3115 static void activate_compose_button (MainWindow *mainwin,
3117 ComposeButtonType type)
3119 SensitiveCond state = main_window_get_current_state(mainwin);
3121 if (style == TOOLBAR_NONE)
3124 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
3125 : mainwin->compose_news_btn);
3126 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
3127 : mainwin->compose_mail_btn);
3128 mainwin->compose_btn_type = type;
3131 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
3133 if (mainwin->compose_btn_type != compose_btn_type)
3134 activate_compose_button(mainwin,
3135 prefs_common.toolbar_style,
3139 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
3141 MainWindow *mainwin = (MainWindow*) data;
3143 if (!mainwin) return;
3145 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
3148 #define BREAK_ON_MODIFIER_KEY() \
3149 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3151 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3153 MainWindow *mainwin = (MainWindow*) data;
3155 if (!mainwin || !event) return;
3157 switch (event->keyval) {
3158 case GDK_Q: /* Quit */
3159 BREAK_ON_MODIFIER_KEY();
3161 app_exit_cb(mainwin, 0, NULL);
3168 #undef BREAK_ON_MODIFIER_KEY
3170 static void set_toolbar_style(MainWindow *mainwin)
3172 switch (prefs_common.toolbar_style) {
3174 gtk_widget_hide(mainwin->handlebox);
3177 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3181 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3185 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3190 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3191 gtk_widget_show(mainwin->handlebox);
3192 gtk_widget_queue_resize(mainwin->handlebox);
3194 if (prefs_common.immediate_exec)
3195 gtk_widget_hide(mainwin->exec_btn);
3197 gtk_widget_show(mainwin->exec_btn);
3202 * Harvest addresses for selected folder.
3204 static void addr_harvest_cb( MainWindow *mainwin,
3208 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3212 * Harvest addresses for selected messages in summary view.
3214 static void addr_harvest_msg_cb( MainWindow *mainwin,
3218 summary_harvest_address( mainwin->summaryview );