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_WINDOWS_1251)},
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/_German"), NULL, manual_open_cb, MANUAL_LANG_DE, NULL},
743 {N_("/_Help/_Manual/_Spanish"), NULL, manual_open_cb, MANUAL_LANG_ES, NULL},
744 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
745 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
746 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
747 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
748 {N_("/_Help/_FAQ/_German"), NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
749 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
750 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
751 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
752 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
753 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
755 static GtkItemFactoryEntry reply_popup_entries[] =
757 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
758 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
760 static GtkItemFactoryEntry replyall_popup_entries[] =
762 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
763 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
765 static GtkItemFactoryEntry replysender_popup_entries[] =
767 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
768 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
770 static GtkItemFactoryEntry fwd_popup_entries[] =
772 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
773 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
776 MainWindow *main_window_create(SeparateType type)
782 GtkWidget *handlebox;
783 GtkWidget *vbox_body;
784 GtkWidget *hbox_stat;
785 GtkWidget *statusbar;
786 GtkWidget *progressbar;
787 GtkWidget *statuslabel;
788 GtkWidget *ac_button;
790 GtkWidget *online_status;
791 GtkWidget *offline_status;
792 GtkWidget *online_switch;
793 GtkWidget *offline_switch;
795 FolderView *folderview;
796 SummaryView *summaryview;
797 MessageView *messageview;
798 GdkColormap *colormap;
801 guint n_menu_entries;
802 GtkItemFactory *ifactory;
805 GtkWidget *compose_popup;
806 GtkWidget *reply_popup;
807 GtkWidget *replyall_popup;
808 GtkWidget *replysender_popup;
809 GtkWidget *fwd_popup;
812 static GdkGeometry geometry;
814 debug_print(_("Creating main window...\n"));
815 mainwin = g_new0(MainWindow, 1);
818 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
819 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
820 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
821 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
823 if (!geometry.min_height) {
824 geometry.min_width = 320;
825 geometry.min_height = 200;
827 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
830 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
831 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
832 MANAGE_WINDOW_SIGNALS_CONNECT(window);
833 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
834 GTK_SIGNAL_FUNC(key_pressed), mainwin);
836 gtk_widget_realize(window);
837 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
840 gtkut_widget_set_app_icon(window);
842 vbox = gtk_vbox_new(FALSE, 0);
843 gtk_widget_show(vbox);
844 gtk_container_add(GTK_CONTAINER(window), vbox);
847 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
848 menubar = menubar_create(window, mainwin_entries,
849 n_menu_entries, "<Main>", mainwin);
850 gtk_widget_show(menubar);
851 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
853 handlebox = gtk_handle_box_new();
854 gtk_widget_show(handlebox);
855 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
857 /* create the popup menus for the reply buttons specials */
858 n_menu_entries = sizeof(reply_popup_entries) /
859 sizeof(reply_popup_entries[0]);
860 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
861 "<ReplyPopup>", mainwin);
862 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
863 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
864 n_menu_entries = sizeof(replyall_popup_entries) /
865 sizeof(replyall_popup_entries[0]);
866 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
867 "<ReplyAllPopup>", mainwin);
868 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
869 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
870 n_menu_entries = sizeof(replysender_popup_entries) /
871 sizeof(replysender_popup_entries[0]);
872 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
873 "<ReplySenderPopup>", mainwin);
874 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
875 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
876 /* create the popup menu for the forward button */
877 n_menu_entries = sizeof(fwd_popup_entries) /
878 sizeof(fwd_popup_entries[0]);
879 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
880 "<ForwardPopup>", mainwin);
881 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
882 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
884 main_window_toolbar_create(mainwin, handlebox);
886 /* vbox that contains body */
887 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
888 gtk_widget_show(vbox_body);
889 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
890 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
892 hbox_stat = gtk_hbox_new(FALSE, 2);
893 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
895 statusbar = statusbar_create();
896 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
898 progressbar = gtk_progress_bar_new();
899 gtk_widget_set_usize(progressbar, 120, 1);
900 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
902 online_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
903 offline_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
904 online_switch = gtk_button_new ();
905 offline_switch = gtk_button_new ();
906 gtk_container_add (GTK_CONTAINER(online_switch), online_status);
907 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
908 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
909 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
910 gtk_container_add (GTK_CONTAINER(offline_switch), offline_status);
911 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
912 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
913 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
915 statuslabel = gtk_label_new("");
916 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
918 ac_button = gtk_button_new();
919 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
920 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
921 gtk_widget_set_usize(ac_button, -1, 1);
922 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
923 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
924 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
926 ac_label = gtk_label_new("");
927 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
929 gtk_widget_show_all(hbox_stat);
931 gtk_widget_hide(offline_switch);
933 mainwin->folderview = folderview = folderview_create();
934 mainwin->summaryview = summaryview = summary_create();
935 mainwin->messageview = messageview = messageview_create();
936 mainwin->logwin = log_window_create();
938 folderview->mainwin = mainwin;
939 folderview->summaryview = summaryview;
941 summaryview->mainwin = mainwin;
942 summaryview->folderview = folderview;
943 summaryview->messageview = messageview;
944 summaryview->window = window;
946 messageview->mainwin = mainwin;
948 mainwin->window = window;
949 mainwin->vbox = vbox;
950 mainwin->menubar = menubar;
951 mainwin->handlebox = handlebox;
952 mainwin->vbox_body = vbox_body;
953 mainwin->hbox_stat = hbox_stat;
954 mainwin->statusbar = statusbar;
955 mainwin->progressbar = progressbar;
956 mainwin->statuslabel = statuslabel;
957 mainwin->ac_button = ac_button;
958 mainwin->ac_label = ac_label;
959 mainwin->reply_popup = reply_popup;
960 mainwin->replyall_popup = replyall_popup;
961 mainwin->replysender_popup = replysender_popup;
962 mainwin->fwd_popup = fwd_popup;
963 mainwin->online_switch = online_switch;
964 mainwin->offline_switch = offline_switch;
966 /* set context IDs for status bar */
967 mainwin->mainwin_cid = gtk_statusbar_get_context_id
968 (GTK_STATUSBAR(statusbar), "Main Window");
969 mainwin->folderview_cid = gtk_statusbar_get_context_id
970 (GTK_STATUSBAR(statusbar), "Folder View");
971 mainwin->summaryview_cid = gtk_statusbar_get_context_id
972 (GTK_STATUSBAR(statusbar), "Summary View");
974 /* allocate colors for summary view and folder view */
975 summaryview->color_marked.red = summaryview->color_marked.green = 0;
976 summaryview->color_marked.blue = (guint16)65535;
978 summaryview->color_dim.red = summaryview->color_dim.green =
979 summaryview->color_dim.blue = COLOR_DIM;
981 folderview->color_new.red = (guint16)55000;
982 folderview->color_new.green = folderview->color_new.blue = 15000;
984 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
985 &folderview->color_op);
987 summaryview->color_important.red = 0;
988 summaryview->color_important.green = 0;
989 summaryview->color_important.blue = (guint16)65535;
991 color[0] = summaryview->color_marked;
992 color[1] = summaryview->color_dim;
993 color[2] = folderview->color_new;
994 color[3] = folderview->color_op;
996 colormap = gdk_window_get_colormap(window->window);
997 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
998 for (i = 0; i < 4; i++) {
999 if (success[i] == FALSE)
1000 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1003 debug_print(_("done.\n"));
1005 main_window_set_widgets(mainwin, type);
1007 /* set menu items */
1008 ifactory = gtk_item_factory_from_widget(menubar);
1009 menuitem = gtk_item_factory_get_item
1010 (ifactory, "/View/Code set/Auto detect");
1011 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1013 switch (prefs_common.toolbar_style) {
1015 menuitem = gtk_item_factory_get_item
1016 (ifactory, "/View/Show or hide/Toolbar/None");
1019 menuitem = gtk_item_factory_get_item
1020 (ifactory, "/View/Show or hide/Toolbar/Icon");
1023 menuitem = gtk_item_factory_get_item
1024 (ifactory, "/View/Show or hide/Toolbar/Text");
1027 menuitem = gtk_item_factory_get_item
1028 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1030 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1032 gtk_widget_hide(mainwin->hbox_stat);
1033 menuitem = gtk_item_factory_get_item
1034 (ifactory, "/View/Show or hide/Status bar");
1035 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1036 prefs_common.show_statusbar);
1037 #if 0 /* FIXED SEPARATE WINDOWS */
1038 /* Message view and Folder tree are always shown at startup
1039 * make that in the menu visible */
1040 menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Message View");
1041 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1042 menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Folder Tree");
1043 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1045 /* set the check of the SEPARATE_xxx menu items. we also need the main window
1046 * as a property and pass the action type to the callback */
1047 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
1049 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
1050 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
1051 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
1052 GUINT_TO_POINTER(SEPARATE_FOLDER));
1054 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
1056 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
1057 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
1058 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
1059 GUINT_TO_POINTER(SEPARATE_MESSAGE));
1061 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
1062 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
1065 /* set account selection menu */
1066 ac_menu = gtk_item_factory_get_widget
1067 (ifactory, "/Configuration/Change current account");
1068 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1069 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1070 mainwin->ac_menu = ac_menu;
1072 main_window_set_toolbar_sensitive(mainwin);
1074 /* Create actions menu */
1075 update_mainwin_actions_menu(ifactory, mainwin);
1077 /* show main window */
1078 gtk_widget_set_uposition(mainwin->window,
1079 prefs_common.mainwin_x,
1080 prefs_common.mainwin_y);
1081 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1082 prefs_common.mainwin_height);
1083 gtk_widget_show(mainwin->window);
1085 /* initialize views */
1086 folderview_init(folderview);
1087 summary_init(summaryview);
1088 messageview_init(messageview);
1089 log_window_init(mainwin->logwin);
1091 mainwin->lock_count = 0;
1092 mainwin->menu_lock_count = 0;
1093 mainwin->cursor_count = 0;
1096 watch_cursor = gdk_cursor_new(GDK_WATCH);
1098 mainwin_list = g_list_append(mainwin_list, mainwin);
1100 /* init work_offline */
1101 if (prefs_common.work_offline)
1102 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1107 void main_window_cursor_wait(MainWindow *mainwin)
1110 if (mainwin->cursor_count == 0)
1111 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1113 mainwin->cursor_count++;
1118 void main_window_cursor_normal(MainWindow *mainwin)
1120 if (mainwin->cursor_count)
1121 mainwin->cursor_count--;
1123 if (mainwin->cursor_count == 0)
1124 gdk_window_set_cursor(mainwin->window->window, NULL);
1129 /* lock / unlock the user-interface */
1130 void main_window_lock(MainWindow *mainwin)
1132 if (mainwin->lock_count == 0)
1133 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1135 mainwin->lock_count++;
1137 main_window_set_menu_sensitive(mainwin);
1138 main_window_set_toolbar_sensitive(mainwin);
1141 void main_window_unlock(MainWindow *mainwin)
1143 if (mainwin->lock_count)
1144 mainwin->lock_count--;
1146 main_window_set_menu_sensitive(mainwin);
1147 main_window_set_toolbar_sensitive(mainwin);
1149 if (mainwin->lock_count == 0)
1150 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1153 static void main_window_menu_callback_block(MainWindow *mainwin)
1155 mainwin->menu_lock_count++;
1158 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1160 if (mainwin->menu_lock_count)
1161 mainwin->menu_lock_count--;
1164 void main_window_reflect_prefs_all(void)
1166 main_window_reflect_prefs_all_real(FALSE);
1169 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1172 MainWindow *mainwin;
1174 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1175 mainwin = (MainWindow *)cur->data;
1177 main_window_show_cur_account(mainwin);
1178 main_window_set_menu_sensitive(mainwin);
1179 main_window_set_toolbar_sensitive(mainwin);
1182 if (pixmap_theme_changed)
1184 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1185 mainwin->toolbar = NULL;
1186 main_window_toolbar_create(mainwin, mainwin->handlebox);
1187 set_toolbar_style(mainwin);
1188 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1189 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1190 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1193 summary_redisplay_msg(mainwin->summaryview);
1194 headerview_set_visibility(mainwin->messageview->headerview,
1195 prefs_common.display_header_pane);
1199 void main_window_set_summary_column(void)
1202 MainWindow *mainwin;
1204 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1205 mainwin = (MainWindow *)cur->data;
1206 summary_set_column_order(mainwin->summaryview);
1210 void main_window_set_account_menu(GList *account_list)
1212 GList *cur, *cur_ac, *cur_item;
1213 GtkWidget *menuitem;
1214 MainWindow *mainwin;
1215 PrefsAccount *ac_prefs;
1217 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1218 mainwin = (MainWindow *)cur->data;
1220 /* destroy all previous menu item */
1221 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1222 while (cur_item != NULL) {
1223 GList *next = cur_item->next;
1224 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1228 for (cur_ac = account_list; cur_ac != NULL;
1229 cur_ac = cur_ac->next) {
1230 ac_prefs = (PrefsAccount *)cur_ac->data;
1232 menuitem = gtk_menu_item_new_with_label
1233 (ac_prefs->account_name
1234 ? ac_prefs->account_name : _("Untitled"));
1235 gtk_widget_show(menuitem);
1236 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1237 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1238 GTK_SIGNAL_FUNC(account_menu_cb),
1244 static void main_window_show_cur_account(MainWindow *mainwin)
1249 ac_name = g_strdup(cur_account
1250 ? (cur_account->account_name
1251 ? cur_account->account_name : _("Untitled"))
1255 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1257 buf = g_strdup(PROG_VERSION);
1258 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1261 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1262 gtk_widget_queue_resize(mainwin->ac_button);
1267 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1269 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1270 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1271 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1273 if (mainwin->type == type) return;
1275 /* remove widgets from those containers */
1276 gtk_widget_ref(folder_wid);
1277 gtk_widget_ref(summary_wid);
1278 gtk_widget_ref(message_wid);
1279 gtkut_container_remove
1280 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1281 gtkut_container_remove
1282 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1283 gtkut_container_remove
1284 (GTK_CONTAINER(message_wid->parent), message_wid);
1286 /* clean containers */
1287 switch (mainwin->type) {
1289 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1291 case SEPARATE_FOLDER:
1292 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1293 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1295 case SEPARATE_MESSAGE:
1296 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1297 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1300 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1301 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1305 gtk_widget_hide(mainwin->window);
1306 main_window_set_widgets(mainwin, type);
1307 gtk_widget_show(mainwin->window);
1309 gtk_widget_unref(folder_wid);
1310 gtk_widget_unref(summary_wid);
1311 gtk_widget_unref(message_wid);
1314 void main_window_get_size(MainWindow *mainwin)
1316 GtkAllocation *allocation;
1318 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1320 prefs_common.summaryview_width = allocation->width;
1322 if (mainwin->summaryview->msg_is_toggled_on)
1323 prefs_common.summaryview_height = allocation->height;
1325 prefs_common.mainview_width = allocation->width;
1327 allocation = &mainwin->window->allocation;
1329 prefs_common.mainview_height = allocation->height;
1330 prefs_common.mainwin_width = allocation->width;
1331 prefs_common.mainwin_height = allocation->height;
1333 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1335 prefs_common.folderview_width = allocation->width;
1336 prefs_common.folderview_height = allocation->height;
1339 void main_window_get_position(MainWindow *mainwin)
1343 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1345 prefs_common.mainview_x = x;
1346 prefs_common.mainview_y = y;
1347 prefs_common.mainwin_x = x;
1348 prefs_common.mainwin_y = y;
1350 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1353 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1359 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1360 folder = FOLDER(list->data);
1361 if (folder && folder->trash && folder->trash->total > 0)
1365 if (!has_trash) return;
1368 if (alertpanel(_("Empty trash"),
1369 _("Empty all messages in trash?"),
1370 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1372 manage_window_focus_in(mainwin->window, NULL, NULL);
1375 procmsg_empty_trash();
1377 for (list = folder_get_list(); list != NULL; list = list->next) {
1378 folder = list->data;
1379 if (folder && folder->trash && folder->trash->total != 0) {
1380 folder_item_scan(folder->trash);
1381 folderview_update_item(folder->trash, TRUE);
1385 if (mainwin->summaryview->folder_item &&
1386 mainwin->summaryview->folder_item->stype == F_TRASH)
1387 gtk_widget_grab_focus(mainwin->folderview->ctree);
1390 void main_window_add_mailbox(MainWindow *mainwin)
1395 path = input_dialog(_("Add mailbox"),
1396 _("Input the location of mailbox.\n"
1397 "If the existing mailbox is specified, it will be\n"
1398 "scanned automatically."),
1401 if (folder_find_from_path(path)) {
1402 alertpanel_error(_("The mailbox `%s' already exists."), path);
1406 if (!strcmp(path, "Mail"))
1407 folder = folder_new(F_MH, _("Mailbox"), path);
1409 folder = folder_new(F_MH, g_basename(path), path);
1412 if (folder->create_tree(folder) < 0) {
1413 alertpanel_error(_("Creation of the mailbox failed.\n"
1414 "Maybe some files already exist, or you don't have the permission to write there."));
1415 folder_destroy(folder);
1420 folder_set_ui_func(folder, scan_tree_func, mainwin);
1421 folder->scan_tree(folder);
1422 folder_set_ui_func(folder, NULL, NULL);
1424 folderview_set(mainwin->folderview);
1427 void main_window_add_mbox(MainWindow *mainwin)
1433 path = input_dialog(_("Add mbox mailbox"),
1434 _("Input the location of mailbox."),
1439 if (folder_find_from_path(path)) {
1440 alertpanel_error(_("The mailbox `%s' already exists."), path);
1446 if (!strcmp(path, "Mail"))
1447 folder = folder_new(F_MBOX, _("Mailbox"), path);
1451 folder = folder_new(F_MBOX, g_basename(path), path);
1454 if (folder->create_tree(folder) < 0) {
1455 alertpanel_error(_("Creation of the mailbox failed."));
1456 folder_destroy(folder);
1462 item = folder_item_new(folder->name, NULL);
1463 item->folder = folder;
1464 folder->node = g_node_new(item);
1466 folder->create_folder(folder, item, "inbox");
1467 folder->create_folder(folder, item, "outbox");
1468 folder->create_folder(folder, item, "queue");
1469 folder->create_folder(folder, item, "draft");
1470 folder->create_folder(folder, item, "trash");
1472 folderview_set(mainwin->folderview);
1477 M_UNLOCKED = 1 << 0,
1478 M_MSG_EXIST = 1 << 1,
1479 M_TARGET_EXIST = 1 << 2,
1480 M_SINGLE_TARGET_EXIST = 1 << 3,
1482 M_ALLOW_REEDIT = 1 << 5,
1483 M_HAVE_ACCOUNT = 1 << 6,
1484 M_THREADED = 1 << 7,
1485 M_UNTHREADED = 1 << 8,
1486 M_ALLOW_DELETE = 1 << 9,
1487 M_INC_ACTIVE = 1 << 10,
1489 M_HAVE_NEWS_ACCOUNT = 1 << 12,
1490 M_HIDE_READ_MSG = 1 << 13
1493 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1495 SensitiveCond state = 0;
1496 SummarySelection selection;
1497 FolderItem *item = mainwin->summaryview->folder_item;
1498 GList *account_list = account_get_list();
1500 selection = summary_get_selection_type(mainwin->summaryview);
1502 if (mainwin->lock_count == 0)
1503 state |= M_UNLOCKED;
1504 if (selection != SUMMARY_NONE)
1505 state |= M_MSG_EXIST;
1509 state |= M_THREADED;
1511 state |= M_UNTHREADED;
1512 /* if (item->folder->type != F_NEWS) */
1513 state |= M_ALLOW_DELETE;
1515 if (selection == SUMMARY_NONE && item->hide_read_msgs
1516 || selection != SUMMARY_NONE)
1517 state |= M_HIDE_READ_MSG;
1519 if (selection == SUMMARY_SELECTED_SINGLE ||
1520 selection == SUMMARY_SELECTED_MULTIPLE)
1521 state |= M_TARGET_EXIST;
1522 if (selection == SUMMARY_SELECTED_SINGLE)
1523 state |= M_SINGLE_TARGET_EXIST;
1524 if (mainwin->summaryview->folder_item &&
1525 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1527 if (selection == SUMMARY_SELECTED_SINGLE &&
1529 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1530 item->stype == F_QUEUE)))
1531 state |= M_ALLOW_REEDIT;
1533 state |= M_HAVE_ACCOUNT;
1535 for ( ; account_list != NULL; account_list = account_list->next) {
1536 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1537 state |= M_HAVE_NEWS_ACCOUNT;
1542 if (inc_is_active())
1543 state |= M_INC_ACTIVE;
1548 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1550 SensitiveCond state;
1559 entry[0].widget = mainwin->get_btn;
1560 entry[0].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1561 entry[1].widget = mainwin->getall_btn;
1562 entry[1].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1563 entry[2].widget = mainwin->compose_news_btn;
1564 entry[2].cond = M_HAVE_NEWS_ACCOUNT;
1565 entry[3].widget = mainwin->reply_btn;
1566 entry[3].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1567 entry[4].widget = mainwin->replyall_btn;
1568 entry[4].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1569 entry[5].widget = mainwin->replysender_btn;
1570 entry[5].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1571 entry[6].widget = mainwin->fwd_btn;
1572 entry[6].cond = M_HAVE_ACCOUNT|M_TARGET_EXIST;
1573 /* entry[6].widget = mainwin->prefs_btn;
1574 entry[6].cond = M_UNLOCKED;
1575 entry[7].widget = mainwin->account_btn;
1576 entry[7].cond = M_UNLOCKED; */
1577 entry[7].widget = mainwin->next_btn;
1578 entry[7].cond = M_MSG_EXIST;
1579 entry[8].widget = mainwin->delete_btn;
1580 entry[8].cond = M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED;
1581 entry[9].widget = mainwin->exec_btn;
1582 entry[9].cond = M_MSG_EXIST|M_EXEC|M_UNLOCKED;
1583 entry[10].widget = NULL;
1586 state = main_window_get_current_state(mainwin);
1588 for (i = 0; entry[i].widget != NULL; i++) {
1589 sensitive = ((entry[i].cond & state) == entry[i].cond);
1590 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1593 activate_compose_button(mainwin,
1594 prefs_common.toolbar_style,
1595 mainwin->compose_btn_type);
1598 void main_window_set_menu_sensitive(MainWindow *mainwin)
1600 GtkItemFactory *ifactory;
1601 SensitiveCond state;
1603 GtkWidget *menuitem;
1606 static const struct {
1610 {"/File/Add mailbox..." , M_UNLOCKED},
1611 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1612 {"/File/Rescan folder tree" , M_UNLOCKED},
1613 {"/File/Folder" , M_UNLOCKED},
1614 {"/File/Import mbox file..." , M_UNLOCKED},
1615 {"/File/Export to mbox file...", M_UNLOCKED},
1616 {"/File/Empty trash" , M_UNLOCKED},
1617 {"/File/Work offline" , M_UNLOCKED},
1618 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1619 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1620 /* {"/File/Close", M_UNLOCKED}, */
1621 {"/File/Exit" , M_UNLOCKED},
1623 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1624 {"/View/Sort" , M_MSG_EXIST},
1625 {"/View/Thread view" , M_EXEC},
1626 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1627 {"/View/Go to/Prev message" , M_MSG_EXIST},
1628 {"/View/Go to/Next message" , M_MSG_EXIST},
1629 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1630 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1631 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1632 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1633 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1634 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1635 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1636 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1637 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1639 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1640 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1641 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1642 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1643 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1644 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1645 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1646 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1647 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1648 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1649 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1650 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1651 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1652 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1653 {"/Message/Mark" , M_TARGET_EXIST},
1655 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1656 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1657 {"/Tools/Harvest addresses" , M_UNLOCKED},
1658 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1659 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1660 {"/Tools/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1661 {"/Tools/Actions" , M_MSG_EXIST},
1662 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1664 {"/Configuration", M_UNLOCKED},
1669 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1670 state = main_window_get_current_state(mainwin);
1672 for (i = 0; entry[i].entry != NULL; i++) {
1673 sensitive = ((entry[i].cond & state) == entry[i].cond);
1674 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1677 main_window_menu_callback_block(mainwin);
1678 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all header");
1679 gtk_check_menu_item_set_active
1680 (GTK_CHECK_MENU_ITEM(menuitem),
1681 mainwin->messageview->textview->show_all_headers);
1682 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1683 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1684 (state & M_THREADED) != 0);
1685 main_window_menu_callback_unblock(mainwin);
1688 void main_window_popup(MainWindow *mainwin)
1694 gdk_window_get_origin(mainwin->window->window, &x, &y);
1695 sx = gdk_screen_width();
1696 sy = gdk_screen_height();
1697 x %= sx; if (x < 0) x = 0;
1698 y %= sy; if (y < 0) y = 0;
1699 gdk_window_move(mainwin->window->window, x, y);
1700 gdk_window_raise(mainwin->window->window);
1701 gdk_window_show(mainwin->window->window);
1703 debug_print("window position: x = %d, y = %d\n", x, y);
1705 switch (mainwin->type) {
1706 case SEPARATE_FOLDER:
1707 widget = mainwin->win.sep_folder.folderwin;
1708 gdk_window_get_origin(widget->window, &x, &y);
1709 x %= sx; if (x < 0) x = 0;
1710 y %= sy; if (y < 0) y = 0;
1711 gdk_window_move(widget->window, x, y);
1712 gdk_window_raise(widget->window);
1714 case SEPARATE_MESSAGE:
1715 widget = mainwin->win.sep_message.messagewin;
1716 gdk_window_get_origin(widget->window, &x, &y);
1717 x %= sx; if (x < 0) x = 0;
1718 y %= sy; if (y < 0) y = 0;
1719 gdk_window_move(widget->window, x, y);
1720 gdk_window_raise(widget->window);
1723 widget = mainwin->win.sep_both.folderwin;
1724 gdk_window_get_origin(widget->window, &x, &y);
1725 x %= sx; if (x < 0) x = 0;
1726 y %= sy; if (y < 0) y = 0;
1727 gdk_window_move(widget->window, x, y);
1728 gdk_window_raise(widget->window);
1729 widget = mainwin->win.sep_both.messagewin;
1730 gdk_window_get_origin(widget->window, &x, &y);
1731 x %= sx; if (x < 0) x = 0;
1732 y %= sy; if (y < 0) y = 0;
1733 gdk_window_move(widget->window, x, y);
1734 gdk_window_raise(widget->window);
1741 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1743 GtkWidget *folderwin = NULL;
1744 GtkWidget *messagewin = NULL;
1747 GtkWidget *vbox_body = mainwin->vbox_body;
1748 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1749 GtkWidget *menuitem;
1751 debug_print(_("Setting widgets..."));
1753 /* create separated window(s) if needed */
1754 if (type & SEPARATE_FOLDER) {
1755 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1756 gtk_window_set_title(GTK_WINDOW(folderwin),
1757 _("Sylpheed - Folder View"));
1758 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1759 "folder_view", "Sylpheed");
1760 gtk_window_set_policy(GTK_WINDOW(folderwin),
1762 gtk_widget_set_usize(folderwin, -1,
1763 prefs_common.mainview_height);
1764 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1766 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1767 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1770 if (type & SEPARATE_MESSAGE) {
1771 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1772 gtk_window_set_title(GTK_WINDOW(messagewin),
1773 _("Sylpheed - Message View"));
1774 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1775 "message_view", "Sylpheed");
1776 gtk_window_set_policy(GTK_WINDOW(messagewin),
1778 gtk_widget_set_usize
1779 (messagewin, prefs_common.mainview_width,
1780 prefs_common.mainview_height
1781 - prefs_common.summaryview_height
1782 + DEFAULT_HEADERVIEW_HEIGHT);
1783 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1785 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1786 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1792 hpaned = gtk_hpaned_new();
1793 gtk_widget_show(hpaned);
1794 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1795 gtk_paned_add1(GTK_PANED(hpaned),
1796 GTK_WIDGET_PTR(mainwin->folderview));
1798 vpaned = gtk_vpaned_new();
1799 if (mainwin->summaryview->msg_is_toggled_on) {
1800 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1801 gtk_paned_add1(GTK_PANED(vpaned),
1802 GTK_WIDGET_PTR(mainwin->summaryview));
1804 gtk_paned_add2(GTK_PANED(hpaned),
1805 GTK_WIDGET_PTR(mainwin->summaryview));
1806 gtk_widget_ref(vpaned);
1808 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1809 prefs_common.summaryview_width,
1810 prefs_common.summaryview_height);
1811 gtk_paned_add2(GTK_PANED(vpaned),
1812 GTK_WIDGET_PTR(mainwin->messageview));
1813 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1814 prefs_common.mainview_width, -1);
1815 gtk_widget_set_usize(mainwin->window,
1816 prefs_common.folderview_width +
1817 prefs_common.mainview_width,
1818 prefs_common.mainwin_height);
1819 gtk_widget_show_all(vpaned);
1821 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1822 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1823 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1824 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1825 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1826 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1828 mainwin->win.sep_none.hpaned = hpaned;
1829 mainwin->win.sep_none.vpaned = vpaned;
1831 case SEPARATE_FOLDER:
1832 vpaned = gtk_vpaned_new();
1833 if (mainwin->summaryview->msg_is_toggled_on) {
1834 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1836 gtk_paned_add1(GTK_PANED(vpaned),
1837 GTK_WIDGET_PTR(mainwin->summaryview));
1839 gtk_box_pack_start(GTK_BOX(vbox_body),
1840 GTK_WIDGET_PTR(mainwin->summaryview),
1842 gtk_widget_ref(vpaned);
1844 gtk_paned_add2(GTK_PANED(vpaned),
1845 GTK_WIDGET_PTR(mainwin->messageview));
1846 gtk_widget_show_all(vpaned);
1847 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1848 prefs_common.summaryview_width,
1849 prefs_common.summaryview_height);
1850 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1851 prefs_common.mainview_width, -1);
1852 gtk_widget_set_usize(mainwin->window,
1853 prefs_common.mainview_width,
1854 prefs_common.mainview_height);
1856 gtk_container_add(GTK_CONTAINER(folderwin),
1857 GTK_WIDGET_PTR(mainwin->folderview));
1859 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1860 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1862 mainwin->win.sep_folder.folderwin = folderwin;
1863 mainwin->win.sep_folder.vpaned = vpaned;
1865 gtk_widget_show_all(folderwin);
1867 case SEPARATE_MESSAGE:
1868 hpaned = gtk_hpaned_new();
1869 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1871 gtk_paned_add1(GTK_PANED(hpaned),
1872 GTK_WIDGET_PTR(mainwin->folderview));
1873 gtk_paned_add2(GTK_PANED(hpaned),
1874 GTK_WIDGET_PTR(mainwin->summaryview));
1875 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1876 prefs_common.summaryview_width,
1877 prefs_common.summaryview_height);
1878 gtk_widget_set_usize(mainwin->window,
1879 prefs_common.folderview_width +
1880 prefs_common.mainview_width,
1881 prefs_common.mainwin_height);
1882 gtk_widget_show_all(hpaned);
1883 gtk_container_add(GTK_CONTAINER(messagewin),
1884 GTK_WIDGET_PTR(mainwin->messageview));
1886 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1887 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1888 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1889 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1891 mainwin->win.sep_message.messagewin = messagewin;
1892 mainwin->win.sep_message.hpaned = hpaned;
1894 gtk_widget_show_all(messagewin);
1897 gtk_box_pack_start(GTK_BOX(vbox_body),
1898 GTK_WIDGET_PTR(mainwin->summaryview),
1900 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1901 prefs_common.summaryview_width,
1902 prefs_common.summaryview_height);
1903 gtk_widget_set_usize(mainwin->window,
1904 prefs_common.mainview_width,
1905 prefs_common.mainwin_height);
1906 gtk_container_add(GTK_CONTAINER(folderwin),
1907 GTK_WIDGET_PTR(mainwin->folderview));
1908 gtk_container_add(GTK_CONTAINER(messagewin),
1909 GTK_WIDGET_PTR(mainwin->messageview));
1911 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1912 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1914 mainwin->win.sep_both.folderwin = folderwin;
1915 mainwin->win.sep_both.messagewin = messagewin;
1917 gtk_widget_show_all(folderwin);
1918 gtk_widget_show_all(messagewin);
1922 mainwin->type = type;
1924 debug_print(_("done.\n"));
1927 static void main_window_toolbar_create(MainWindow *mainwin,
1928 GtkWidget *container)
1931 GtkWidget *icon_wid;
1933 GtkWidget *getall_btn;
1934 GtkWidget *compose_mail_btn;
1935 GtkWidget *compose_news_btn;
1936 GtkWidget *reply_btn;
1937 GtkWidget *replyall_btn;
1938 GtkWidget *replysender_btn;
1940 GtkWidget *send_btn;
1942 GtkWidget *prefs_btn;
1943 GtkWidget *account_btn;
1945 GtkWidget *next_btn;
1946 GtkWidget *delete_btn;
1947 GtkWidget *exec_btn;
1949 GtkTooltips *tooltips;
1951 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1953 gtk_container_add(GTK_CONTAINER(container), toolbar);
1954 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1955 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1956 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1957 GTK_TOOLBAR_SPACE_LINE);
1959 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1960 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1962 _("Get new mail from current account"),
1964 icon_wid, toolbar_inc_cb, mainwin);
1965 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1966 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1968 _("Get new mail from all accounts"),
1974 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1976 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1977 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1979 _("Send queued message(s)"),
1985 /* insert compose mail button widget */
1986 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1987 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1989 _("Compose an email message"),
1992 toolbar_compose_mail_cb,
1995 /* insert compose news button widget */
1996 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1997 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1999 _("Compose a news message"),
2002 toolbar_compose_news_cb,
2005 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2009 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
2010 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2012 _("Reply to the message - Right button: more options"),
2018 /* replyall button */
2020 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
2021 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2023 _("Reply to all - Right button: more options"),
2026 toolbar_reply_to_all_cb,
2029 /* reply to sender button */
2030 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
2031 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2033 _("Reply to sender - Right button: more options"),
2036 toolbar_reply_to_sender_cb,
2039 /* forward button */
2040 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
2041 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2043 _("Forward the message - Right button: more options"),
2049 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2051 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
2052 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2054 _("Delete the message"),
2060 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
2061 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2063 _("Execute marked process"),
2069 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
2070 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2072 _("Next unread message"),
2075 toolbar_next_unread_cb,
2079 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2081 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2082 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2084 _("Common preference"),
2089 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2090 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2092 _("Account setting"),
2097 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2098 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2102 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2103 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2106 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2107 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2110 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2111 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2114 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2115 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2119 mainwin->toolbar = toolbar;
2120 mainwin->get_btn = get_btn;
2121 mainwin->getall_btn = getall_btn;
2122 mainwin->compose_mail_btn = compose_mail_btn;
2123 mainwin->compose_news_btn = compose_news_btn;
2124 mainwin->reply_btn = reply_btn;
2125 mainwin->replyall_btn = replyall_btn;
2126 mainwin->replysender_btn = replysender_btn;
2127 mainwin->fwd_btn = fwd_btn;
2128 mainwin->send_btn = send_btn;
2130 mainwin->prefs_btn = prefs_btn;
2131 mainwin->account_btn = account_btn;
2133 mainwin->next_btn = next_btn;
2134 mainwin->delete_btn = delete_btn;
2135 mainwin->exec_btn = exec_btn;
2137 gtk_widget_show_all(toolbar);
2140 /* callback functions */
2141 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2143 MainWindow *mainwindow = (MainWindow *) data;
2147 if (event->button == 3) {
2148 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2149 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2150 menu_button_position, widget,
2151 event->button, event->time);
2155 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2157 MainWindow *mainwin = (MainWindow *)data;
2159 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2160 manage_window_focus_in(mainwin->window, NULL, NULL);
2163 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2165 MainWindow *mainwindow = (MainWindow *) data;
2169 if (event->button == 3) {
2170 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2171 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2172 menu_button_position, widget,
2173 event->button, event->time);
2177 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2179 MainWindow *mainwin = (MainWindow *)data;
2181 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2182 manage_window_focus_in(mainwin->window, NULL, NULL);
2185 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2187 MainWindow *mainwindow = (MainWindow *) data;
2188 GtkWidget *replysender_menu, *replysender_item;
2192 if (event->button == 3) {
2193 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2194 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2195 menu_button_position, widget,
2196 event->button, event->time);
2200 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2202 MainWindow *mainwin = (MainWindow *)data;
2204 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2205 manage_window_focus_in(mainwin->window, NULL, NULL);
2208 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2210 MainWindow *mainwindow = (MainWindow *) data;
2214 if (event->button == 3) {
2215 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2216 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2217 menu_button_position, widget,
2218 event->button, event->time);
2222 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2224 MainWindow *mainwin = (MainWindow *)data;
2226 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2227 manage_window_focus_in(mainwin->window, NULL, NULL);
2230 static void toolbar_inc_cb (GtkWidget *widget,
2233 MainWindow *mainwin = (MainWindow *)data;
2235 inc_mail_cb(mainwin, 0, NULL);
2238 static void toolbar_inc_all_cb (GtkWidget *widget,
2241 MainWindow *mainwin = (MainWindow *)data;
2243 inc_all_account_mail_cb(mainwin, 0, NULL);
2246 static void toolbar_send_cb (GtkWidget *widget,
2249 MainWindow *mainwin = (MainWindow *)data;
2251 send_queue_cb(mainwin, 0, NULL);
2254 static void toolbar_compose_cb (GtkWidget *widget,
2257 MainWindow *mainwin = (MainWindow *)data;
2259 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2260 compose_cb(mainwin, 0, NULL);
2262 compose_news_cb(mainwin, 0, NULL);
2265 static void toolbar_compose_news_cb (GtkWidget *widget,
2268 MainWindow *mainwin = (MainWindow *)data;
2270 compose_news_cb(mainwin, 0, NULL);
2273 static void toolbar_compose_mail_cb (GtkWidget *widget,
2276 MainWindow *mainwin = (MainWindow *)data;
2278 compose_mail_cb(mainwin, 0, NULL);
2281 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2283 MainWindow *mainwin = (MainWindow *)data;
2286 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2287 : COMPOSE_REPLY_WITHOUT_QUOTE,
2291 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2293 MainWindow *mainwin = (MainWindow *)data;
2296 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2297 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2302 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2304 MainWindow *mainwin = (MainWindow *)data;
2307 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2308 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2312 static void toolbar_forward_cb (GtkWidget *widget,
2315 MainWindow *mainwin = (MainWindow *)data;
2317 if (prefs_common.forward_as_attachment)
2318 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2320 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2323 static void toolbar_delete_cb (GtkWidget *widget,
2326 MainWindow *mainwin = (MainWindow *)data;
2328 summary_delete(mainwin->summaryview);
2331 static void toolbar_exec_cb (GtkWidget *widget,
2334 MainWindow *mainwin = (MainWindow *)data;
2336 summary_execute(mainwin->summaryview);
2339 static void toolbar_next_unread_cb (GtkWidget *widget,
2342 MainWindow *mainwin = (MainWindow *)data;
2344 next_unread_cb(mainwin, 0, NULL);
2347 static void toolbar_prefs_cb (GtkWidget *widget,
2350 prefs_common_open();
2353 static void toolbar_account_cb (GtkWidget *widget,
2356 MainWindow *mainwin = (MainWindow *)data;
2358 prefs_account_open_cb(mainwin, 0, NULL);
2361 static void toolbar_account_button_pressed(GtkWidget *widget,
2362 GdkEventButton *event,
2365 MainWindow *mainwin = (MainWindow *)data;
2368 if (event->button != 3) return;
2370 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2371 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2374 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2375 menu_button_position, widget,
2376 event->button, event->time);
2379 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2382 MainWindow *mainwin = (MainWindow *)data;
2386 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2387 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2390 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2391 menu_button_position, widget,
2392 event->button, event->time);
2395 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2397 MainWindow *mainwin = (MainWindow *)data;
2400 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2401 if (!button) return;
2402 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2403 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2404 manage_window_focus_in(mainwin->window, NULL, NULL);
2407 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2410 MainWindow *mainwin = (MainWindow *)data;
2412 if (mainwin->lock_count == 0)
2413 app_exit_cb(data, 0, widget);
2418 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2421 main_window_add_mailbox(mainwin);
2424 static void add_mbox_cb(MainWindow *mainwin, guint action,
2427 main_window_add_mbox(mainwin);
2430 static void update_folderview_cb(MainWindow *mainwin, guint action,
2433 summary_show(mainwin->summaryview, NULL, FALSE);
2434 folderview_rescan_all();
2437 static void new_folder_cb(MainWindow *mainwin, guint action,
2440 folderview_new_folder(mainwin->folderview);
2443 static void rename_folder_cb(MainWindow *mainwin, guint action,
2446 folderview_rename_folder(mainwin->folderview);
2449 static void delete_folder_cb(MainWindow *mainwin, guint action,
2452 folderview_delete_folder(mainwin->folderview);
2455 static void import_mbox_cb(MainWindow *mainwin, guint action,
2458 import_mbox(mainwin->summaryview->folder_item);
2461 static void export_mbox_cb(MainWindow *mainwin, guint action,
2464 export_mbox(mainwin->summaryview->folder_item);
2467 static void empty_trash_cb(MainWindow *mainwin, guint action,
2470 main_window_empty_trash(mainwin, TRUE);
2473 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2475 summary_save_as(mainwin->summaryview);
2478 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2480 summary_print(mainwin->summaryview);
2483 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2485 if (prefs_common.confirm_on_exit) {
2486 if (alertpanel(_("Exit"), _("Exit this program?"),
2487 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2489 manage_window_focus_in(mainwin->window, NULL, NULL);
2492 app_will_exit(widget, mainwin);
2495 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2498 summary_search(mainwin->summaryview);
2500 message_search(mainwin->messageview);
2503 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2506 switch (mainwin->type) {
2508 case SEPARATE_MESSAGE:
2510 case SEPARATE_FOLDER:
2511 if (GTK_CHECK_MENU_ITEM(widget)->active)
2512 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2514 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2517 if (GTK_CHECK_MENU_ITEM(widget)->active)
2518 gtk_widget_show(mainwin->win.sep_both.folderwin);
2520 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2525 static void toggle_message_cb(MainWindow *mainwin, guint action,
2528 switch (mainwin->type) {
2530 case SEPARATE_FOLDER:
2532 case SEPARATE_MESSAGE:
2533 if (GTK_CHECK_MENU_ITEM(widget)->active)
2534 gtk_widget_show(mainwin->win.sep_message.messagewin);
2536 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2539 if (GTK_CHECK_MENU_ITEM(widget)->active)
2540 gtk_widget_show(mainwin->win.sep_both.messagewin);
2542 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2547 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2550 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2551 mainwin->compose_btn_type);
2552 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2553 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2554 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2555 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2557 mainwin->toolbar_style = (ToolbarStyle)action;
2558 prefs_common.toolbar_style = (ToolbarStyle)action;
2560 set_toolbar_style(mainwin);
2563 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2566 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2567 gtk_widget_show(mainwin->hbox_stat);
2568 prefs_common.show_statusbar = TRUE;
2570 gtk_widget_hide(mainwin->hbox_stat);
2571 prefs_common.show_statusbar = FALSE;
2575 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2577 summary_toggle_view_real(mainwin->summaryview);
2580 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2582 messageview_toggle_view_real(mainwin->messageview);
2585 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2587 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2588 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2590 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2594 static void online_switch_clicked (GtkButton *btn, gpointer data)
2596 MainWindow *mainwin;
2597 GtkItemFactory *ifactory;
2598 GtkCheckMenuItem *menuitem;
2600 mainwin = (MainWindow *) data;
2602 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2603 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2605 g_return_if_fail(mainwin != NULL);
2606 g_return_if_fail(menuitem != NULL);
2608 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2610 gtk_widget_hide (mainwin->online_switch);
2611 gtk_widget_show (mainwin->offline_switch);
2612 menuitem->active = TRUE;
2613 prefs_common.work_offline = TRUE;
2614 inc_autocheck_timer_remove();
2617 gtk_widget_hide (mainwin->offline_switch);
2618 gtk_widget_show (mainwin->online_switch);
2619 menuitem->active = FALSE;
2620 prefs_common.work_offline = FALSE;
2621 inc_autocheck_timer_set();
2625 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2627 MainWindow *mainwin;
2630 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2631 g_return_if_fail(mainwin != NULL);
2633 type = mainwin->type ^ action;
2634 main_window_separation_change(mainwin, type);
2636 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2637 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2640 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2643 addressbook_open(NULL);
2646 static void log_window_show_cb(MainWindow *mainwin, guint action,
2649 log_window_show(mainwin->logwin);
2652 static void sel_download_cb(MainWindow *mainwin, guint action,
2655 selective_download(mainwin);
2658 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2660 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2663 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2666 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2669 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2674 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2678 if (prefs_common.work_offline)
2679 if (alertpanel(_("Offline warning"),
2680 _("You're working offline. Override?"),
2681 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
2684 for (list = folder_get_list(); list != NULL; list = list->next) {
2685 Folder *folder = list->data;
2687 if (folder->queue) {
2688 if (procmsg_send_queue
2689 (folder->queue, prefs_common.savemsg) < 0)
2690 alertpanel_error(_("Some errors occurred while sending queued messages."));
2691 statusbar_pop_all();
2692 folder_item_scan(folder->queue);
2693 folderview_update_item(folder->queue, TRUE);
2698 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2700 if (mainwin->summaryview->folder_item) {
2701 if (mainwin->summaryview->folder_item->folder->account != NULL
2702 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2703 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2705 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2711 static void compose_mail_cb(MainWindow *mainwin, guint action,
2718 if (mainwin->summaryview->folder_item) {
2719 ac = mainwin->summaryview->folder_item->folder->account;
2720 if (ac && ac->protocol != A_NNTP) {
2721 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2726 if(cur_account && (cur_account->protocol != A_NNTP)) {
2727 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2731 list = account_get_list();
2732 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2733 ac = (PrefsAccount *) cur->data;
2734 if (ac->protocol != A_NNTP) {
2735 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2741 static void compose_news_cb(MainWindow *mainwin, guint action,
2744 PrefsAccount * ac = NULL;
2748 if (mainwin->summaryview->folder_item) {
2749 ac = mainwin->summaryview->folder_item->folder->account;
2750 if (ac && ac->protocol == A_NNTP) {
2751 compose_new_with_recipient
2752 (ac, mainwin->summaryview->folder_item->path);
2757 list = account_get_list();
2758 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2759 ac = (PrefsAccount *) cur->data;
2760 if (ac->protocol == A_NNTP) {
2767 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2769 summary_reply(mainwin->summaryview, (ComposeMode)action);
2772 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2774 summary_move_to(mainwin->summaryview);
2777 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2779 summary_copy_to(mainwin->summaryview);
2782 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2784 summary_delete(mainwin->summaryview);
2787 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2789 summary_open_msg(mainwin->summaryview);
2792 static void view_source_cb(MainWindow *mainwin, guint action,
2795 summary_view_source(mainwin->summaryview);
2798 static void show_all_header_cb(MainWindow *mainwin, guint action,
2801 if (mainwin->menu_lock_count) return;
2802 summary_display_msg_selected(mainwin->summaryview,
2803 GTK_CHECK_MENU_ITEM(widget)->active);
2806 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2808 summary_reedit(mainwin->summaryview);
2811 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2813 summary_mark(mainwin->summaryview);
2816 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2818 summary_unmark(mainwin->summaryview);
2821 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2824 summary_mark_as_unread(mainwin->summaryview);
2827 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2830 summary_mark_as_read(mainwin->summaryview);
2833 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2836 summary_mark_all_read(mainwin->summaryview);
2839 static void add_address_cb(MainWindow *mainwin, guint action,
2842 summary_add_address(mainwin->summaryview);
2845 static void set_charset_cb(MainWindow *mainwin, guint action,
2850 str = conv_get_charset_str((CharSet)action);
2851 g_free(prefs_common.force_charset);
2852 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2854 summary_redisplay_msg(mainwin->summaryview);
2856 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2859 static void hide_read_messages (MainWindow *mainwin, guint action,
2862 if (!mainwin->summaryview->folder_item
2863 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2865 summary_toggle_show_read_messages(mainwin->summaryview);
2868 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2870 GtkItemFactory *ifactory;
2872 if (mainwin->menu_lock_count) return;
2873 if (!mainwin->summaryview->folder_item) return;
2875 ifactory = gtk_item_factory_from_widget(widget);
2877 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2878 summary_thread_build(mainwin->summaryview);
2879 mainwin->summaryview->folder_item->threaded = TRUE;
2881 summary_unthread(mainwin->summaryview);
2882 mainwin->summaryview->folder_item->threaded = FALSE;
2886 static void set_display_item_cb(MainWindow *mainwin, guint action,
2889 prefs_summary_column_open();
2892 static void sort_summary_cb(MainWindow *mainwin, guint action,
2895 summary_sort(mainwin->summaryview, (SummarySortType)action);
2898 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2901 summary_attract_by_subject(mainwin->summaryview);
2904 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2907 summary_delete_duplicated(mainwin->summaryview);
2910 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2912 summary_filter(mainwin->summaryview);
2915 static void execute_summary_cb(MainWindow *mainwin, guint action,
2918 summary_execute(mainwin->summaryview);
2921 static void update_summary_cb(MainWindow *mainwin, guint action,
2925 FolderView *folderview = mainwin->folderview;
2927 if (!mainwin->summaryview->folder_item) return;
2928 if (!folderview->opened) return;
2930 folder_update_op_count();
2932 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2933 folderview->opened);
2936 summary_show(mainwin->summaryview, fitem, TRUE);
2939 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2941 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2944 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2946 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2949 static void prev_unread_cb(MainWindow *mainwin, guint action,
2952 summary_select_prev_unread(mainwin->summaryview);
2955 static void next_unread_cb(MainWindow *mainwin, guint action,
2958 summary_select_next_unread(mainwin->summaryview);
2961 static void prev_marked_cb(MainWindow *mainwin, guint action,
2964 summary_select_prev_marked(mainwin->summaryview);
2967 static void next_marked_cb(MainWindow *mainwin, guint action,
2970 summary_select_next_marked(mainwin->summaryview);
2973 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2976 summary_select_prev_labeled(mainwin->summaryview);
2979 static void next_labeled_cb(MainWindow *mainwin, guint action,
2982 summary_select_next_labeled(mainwin->summaryview);
2985 static void goto_folder_cb(MainWindow *mainwin, guint action,
2988 FolderItem *to_folder;
2990 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2993 folderview_select(mainwin->folderview, to_folder);
2996 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2998 messageview_copy_clipboard(mainwin->messageview);
3001 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3003 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3004 summary_select_all(mainwin->summaryview);
3005 else if (mainwin->summaryview->msg_is_toggled_on &&
3006 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
3007 messageview_select_all(mainwin->messageview);
3010 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3012 if (mainwin->summaryview->msg_is_toggled_on)
3013 summary_select_thread(mainwin->summaryview);
3016 static void create_filter_cb(MainWindow *mainwin, guint action,
3019 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3022 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3025 prefs_common_open();
3028 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
3031 prefs_filter_open(NULL, NULL);
3034 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3037 prefs_scoring_open(NULL);
3040 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3043 prefs_filtering_open(NULL, NULL, NULL);
3046 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3049 prefs_template_open();
3052 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3055 prefs_actions_open(mainwin);
3058 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3062 new_account_cb(mainwin, 0, widget);
3064 gboolean prev_default = cur_account->is_default;
3066 prefs_account_open(cur_account);
3067 if (!prev_default && cur_account->is_default)
3068 account_set_as_default(cur_account);
3069 account_save_config_all();
3071 main_window_reflect_prefs_all();
3075 static void new_account_cb(MainWindow *mainwin, guint action,
3078 account_edit_open();
3079 if (!compose_get_compose_list()) account_add();
3082 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3084 cur_account = (PrefsAccount *)data;
3085 main_window_reflect_prefs_all();
3088 static void manual_open_cb(MainWindow *mainwin, guint action,
3091 manual_open((ManualLang)action);
3094 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3096 faq_open((ManualLang)action);
3099 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3101 MainWindow *mainwin = (MainWindow *)data;
3105 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3106 LOCAL_FOLDER(folder)->rootpath,
3110 str = g_strdup_printf(_("Scanning folder %s ..."),
3111 LOCAL_FOLDER(folder)->rootpath);
3113 STATUSBAR_PUSH(mainwin, str);
3114 STATUSBAR_POP(mainwin);
3118 static void activate_compose_button (MainWindow *mainwin,
3120 ComposeButtonType type)
3122 SensitiveCond state = main_window_get_current_state(mainwin);
3124 if (style == TOOLBAR_NONE)
3127 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
3128 : mainwin->compose_news_btn);
3129 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
3130 : mainwin->compose_mail_btn);
3131 mainwin->compose_btn_type = type;
3134 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
3136 if (mainwin->compose_btn_type != compose_btn_type)
3137 activate_compose_button(mainwin,
3138 prefs_common.toolbar_style,
3142 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
3144 MainWindow *mainwin = (MainWindow*) data;
3146 if (!mainwin) return;
3148 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
3151 #define BREAK_ON_MODIFIER_KEY() \
3152 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3154 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3156 MainWindow *mainwin = (MainWindow*) data;
3158 if (!mainwin || !event) return;
3160 switch (event->keyval) {
3161 case GDK_Q: /* Quit */
3162 BREAK_ON_MODIFIER_KEY();
3164 app_exit_cb(mainwin, 0, NULL);
3171 #undef BREAK_ON_MODIFIER_KEY
3173 static void set_toolbar_style(MainWindow *mainwin)
3175 switch (prefs_common.toolbar_style) {
3177 gtk_widget_hide(mainwin->handlebox);
3180 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3184 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3188 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3193 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3194 gtk_widget_show(mainwin->handlebox);
3195 gtk_widget_queue_resize(mainwin->handlebox);
3197 if (prefs_common.immediate_exec)
3198 gtk_widget_hide(mainwin->exec_btn);
3200 gtk_widget_show(mainwin->exec_btn);
3205 * Harvest addresses for selected folder.
3207 static void addr_harvest_cb( MainWindow *mainwin,
3211 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3215 * Harvest addresses for selected messages in summary view.
3217 static void addr_harvest_msg_cb( MainWindow *mainwin,
3221 summary_harvest_address( mainwin->summaryview );