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"
71 #include "prefs_toolbar.h"
73 #include "addressbook.h"
74 #include "logwindow.h"
75 #include "manage_window.h"
76 #include "alertpanel.h"
77 #include "statusbar.h"
78 #include "inputdialog.h"
85 #include "selective_download.h"
88 #define AC_LABEL_WIDTH 240
90 /* list of all instantiated MainWindow */
91 static GList *mainwin_list = NULL;
93 static GdkCursor *watch_cursor;
95 static void main_window_menu_callback_block (MainWindow *mainwin);
96 static void main_window_menu_callback_unblock (MainWindow *mainwin);
98 static void main_window_show_cur_account (MainWindow *mainwin);
100 static void main_window_set_widgets (MainWindow *mainwin,
104 static void toolbar_account_button_pressed (GtkWidget *widget,
105 GdkEventButton *event,
108 static void ac_label_button_pressed (GtkWidget *widget,
109 GdkEventButton *event,
111 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
114 static gint main_window_close_cb (GtkWidget *widget,
117 static gint folder_window_close_cb (GtkWidget *widget,
120 static gint message_window_close_cb (GtkWidget *widget,
124 static void add_mailbox_cb (MainWindow *mainwin,
127 static void add_mbox_cb (MainWindow *mainwin,
130 static void update_folderview_cb (MainWindow *mainwin,
133 static void new_folder_cb (MainWindow *mainwin,
136 static void rename_folder_cb (MainWindow *mainwin,
139 static void delete_folder_cb (MainWindow *mainwin,
142 static void import_mbox_cb (MainWindow *mainwin,
145 static void export_mbox_cb (MainWindow *mainwin,
148 static void empty_trash_cb (MainWindow *mainwin,
152 static void save_as_cb (MainWindow *mainwin,
155 static void print_cb (MainWindow *mainwin,
158 static void app_exit_cb (MainWindow *mainwin,
162 static void search_cb (MainWindow *mainwin,
166 static void toggle_folder_cb (MainWindow *mainwin,
169 static void toggle_message_cb (MainWindow *mainwin,
172 static void toggle_toolbar_cb (MainWindow *mainwin,
175 static void toggle_statusbar_cb (MainWindow *mainwin,
178 static void separate_widget_cb (MainWindow *mainwin,
182 static void addressbook_open_cb (MainWindow *mainwin,
185 static void log_window_show_cb (MainWindow *mainwin,
188 static void sel_download_cb (MainWindow *mainwin,
191 static void prefs_toolbar_cb (MainWindow *mainwin,
195 static void reply_cb (MainWindow *mainwin,
199 static void inc_mail_cb (MainWindow *mainwin,
203 static void inc_all_account_mail_cb (MainWindow *mainwin,
207 static void send_queue_cb (MainWindow *mainwin,
211 static void compose_mail_cb (MainWindow *mainwin,
215 static void compose_news_cb (MainWindow *mainwin,
219 static void next_unread_cb (MainWindow *mainwin,
223 static void toolbar_inc_cb (GtkWidget *widget,
226 static void toolbar_inc_all_cb (GtkWidget *widget,
229 static void toolbar_send_cb (GtkWidget *widget,
232 static void toolbar_compose_cb (GtkWidget *widget,
235 static void toolbar_reply_cb (GtkWidget *widget,
238 static void toolbar_reply_to_all_cb (GtkWidget *widget,
241 static void toolbar_reply_to_list_cb (GtkWidget *widget,
244 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
247 static void toolbar_forward_cb (GtkWidget *widget,
250 static void toolbar_delete_cb (GtkWidget *widget,
253 static void toolbar_exec_cb (GtkWidget *widget,
256 static void toolbar_next_unread_cb (GtkWidget *widget,
260 static void toolbar_reply_popup_cb (GtkWidget *widget,
261 GdkEventButton *event,
263 static void toolbar_reply_popup_closed_cb (GtkMenuShell *menu_shell,
266 static void toolbar_reply_to_all_popup_cb (GtkWidget *widget,
267 GdkEventButton *event,
270 static void toolbar_reply_to_all_popup_closed_cb
271 (GtkMenuShell *menu_shell,
274 static void toolbar_reply_to_list_popup_cb (GtkWidget *widget,
275 GdkEventButton *event,
278 static void toolbar_reply_to_list_popup_closed_cb
279 (GtkMenuShell *menu_shell,
282 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
283 GdkEventButton *event,
285 static void toolbar_reply_to_sender_popup_closed_cb
286 (GtkMenuShell *menu_shell,
289 static void toolbar_forward_popup_cb (GtkWidget *widget,
290 GdkEventButton *event,
293 static void toolbar_forward_popup_closed_cb
294 (GtkMenuShell *menu_shell,
297 static void activate_compose_button (MainToolbar *toolbar,
299 ComposeButtonType type);
300 static void toolbar_actions_execute_cb (GtkWidget *widget,
302 static void toolbar_buttons_cb (GtkWidget *widget,
303 ToolbarItem *toolbar_item);
304 static void toolbar_create (MainWindow *mainwin,
305 GtkWidget *container);
307 static void toolbar_update (MainWindow *mainwin);
309 static void inc_cancel_cb (MainWindow *mainwin,
313 static void open_msg_cb (MainWindow *mainwin,
317 static void view_source_cb (MainWindow *mainwin,
321 static void show_all_header_cb (MainWindow *mainwin,
325 static void reedit_cb (MainWindow *mainwin,
329 static void move_to_cb (MainWindow *mainwin,
332 static void copy_to_cb (MainWindow *mainwin,
335 static void delete_cb (MainWindow *mainwin,
339 static void cancel_cb (MainWindow *mainwin,
343 static void mark_cb (MainWindow *mainwin,
346 static void unmark_cb (MainWindow *mainwin,
350 static void mark_as_unread_cb (MainWindow *mainwin,
353 static void mark_as_read_cb (MainWindow *mainwin,
356 static void mark_all_read_cb (MainWindow *mainwin,
359 static void add_address_cb (MainWindow *mainwin,
363 static void set_charset_cb (MainWindow *mainwin,
367 static void hide_read_messages (MainWindow *mainwin,
371 static void thread_cb (MainWindow *mainwin,
374 static void expand_threads_cb (MainWindow *mainwin,
377 static void collapse_threads_cb (MainWindow *mainwin,
381 static void set_display_item_cb (MainWindow *mainwin,
384 static void sort_summary_cb (MainWindow *mainwin,
387 static void sort_summary_type_cb (MainWindow *mainwin,
390 static void attract_by_subject_cb(MainWindow *mainwin,
394 static void delete_duplicated_cb (MainWindow *mainwin,
397 static void filter_cb (MainWindow *mainwin,
400 static void execute_summary_cb (MainWindow *mainwin,
403 static void update_summary_cb (MainWindow *mainwin,
407 static void prev_cb (MainWindow *mainwin,
410 static void next_cb (MainWindow *mainwin,
414 static void prev_unread_cb (MainWindow *mainwin,
418 static void prev_new_cb (MainWindow *mainwin,
421 static void next_new_cb (MainWindow *mainwin,
424 static void prev_marked_cb (MainWindow *mainwin,
427 static void next_marked_cb (MainWindow *mainwin,
430 static void prev_labeled_cb (MainWindow *mainwin,
433 static void next_labeled_cb (MainWindow *mainwin,
437 static void goto_folder_cb (MainWindow *mainwin,
441 static void copy_cb (MainWindow *mainwin,
444 static void allsel_cb (MainWindow *mainwin,
447 static void select_thread_cb (MainWindow *mainwin,
451 static void create_filter_cb (MainWindow *mainwin,
455 static void prefs_common_open_cb (MainWindow *mainwin,
458 static void prefs_template_open_cb (MainWindow *mainwin,
461 static void prefs_actions_open_cb (MainWindow *mainwin,
464 static void prefs_account_open_cb (MainWindow *mainwin,
467 static void prefs_scoring_open_cb (MainWindow *mainwin,
470 static void prefs_filtering_open_cb (MainWindow *mainwin,
474 static void new_account_cb (MainWindow *mainwin,
478 static void account_menu_cb (GtkMenuItem *menuitem,
481 static void online_switch_clicked(GtkButton *btn,
484 static void manual_open_cb (MainWindow *mainwin,
487 static void faq_open_cb (MainWindow *mainwin,
491 static void scan_tree_func (Folder *folder,
495 static void key_pressed (GtkWidget *widget,
499 static void set_toolbar_style(MainWindow *mainwin);
501 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
503 static void addr_harvest_cb ( MainWindow *mainwin,
507 static void addr_harvest_msg_cb ( MainWindow *mainwin,
511 #define SEPARATE_ACTION 500
513 static GtkItemFactoryEntry mainwin_entries[] =
515 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
516 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
517 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
518 {N_("/_File/_Check for new messages in all folders"),
519 NULL, update_folderview_cb, 0, NULL},
520 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
521 {N_("/_File/_Folder/Create _new folder..."),
522 NULL, new_folder_cb, 0, NULL},
523 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
524 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
525 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
526 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
527 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
528 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
529 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
530 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
531 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
532 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
533 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
534 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
536 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
537 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
538 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
539 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
540 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
541 {N_("/_Edit/_Find in current message..."),
542 "<control>F", search_cb, 0, NULL},
543 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
544 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
545 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
546 {N_("/_View/Show or hi_de/_Folder tree"),
547 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
548 {N_("/_View/Show or hi_de/_Message view"),
549 "V", toggle_message_cb, 0, "<ToggleItem>"},
550 {N_("/_View/Show or hi_de/_Toolbar"),
551 NULL, NULL, 0, "<Branch>"},
552 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
553 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
554 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
555 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
556 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
557 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
558 {N_("/_View/Show or hi_de/_Toolbar/_None"),
559 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
560 {N_("/_View/Show or hi_de/Status _bar"),
561 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
562 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
563 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
564 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
565 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
566 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
567 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
568 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
569 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
570 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
571 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
572 {N_("/_View/_Sort/by _color label"),
573 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
574 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
575 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
576 {N_("/_View/_Sort/by a_ttachment"),
577 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
578 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
579 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
580 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
581 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
582 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
583 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
584 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
585 {N_("/_View/_Sort/_Attract by subject"),
586 NULL, attract_by_subject_cb, 0, NULL},
587 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
588 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
589 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
590 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
591 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
593 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
594 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
595 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
596 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
597 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
598 {N_("/_View/_Go to/P_rev unread message"),
599 "<shift>P", prev_unread_cb, 0, NULL},
600 {N_("/_View/_Go to/N_ext unread message"),
601 "<shift>N", next_unread_cb, 0, NULL},
602 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
603 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
604 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
605 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
606 {N_("/_View/_Go to/Prev _marked message"),
607 NULL, prev_marked_cb, 0, NULL},
608 {N_("/_View/_Go to/Next m_arked message"),
609 NULL, next_marked_cb, 0, NULL},
610 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
611 {N_("/_View/_Go to/Prev _labeled message"),
612 NULL, prev_labeled_cb, 0, NULL},
613 {N_("/_View/_Go to/Next la_beled message"),
614 NULL, next_labeled_cb, 0, NULL},
615 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
616 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
617 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
619 #define CODESET_SEPARATOR \
620 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
621 #define CODESET_ACTION(action) \
622 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
624 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
625 {N_("/_View/_Code set/_Auto detect"),
626 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
627 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
628 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
629 CODESET_ACTION(C_US_ASCII)},
632 {N_("/_View/_Code set/Unicode (_UTF-8)"),
633 CODESET_ACTION(C_UTF_8)},
636 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
637 CODESET_ACTION(C_ISO_8859_1)},
638 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
639 CODESET_ACTION(C_ISO_8859_15)},
642 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
643 CODESET_ACTION(C_ISO_8859_2)},
645 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
646 CODESET_ACTION(C_ISO_8859_13)},
647 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
648 CODESET_ACTION(C_ISO_8859_4)},
650 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
651 CODESET_ACTION(C_ISO_8859_7)},
653 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
654 CODESET_ACTION(C_ISO_8859_9)},
656 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
657 CODESET_ACTION(C_ISO_8859_5)},
658 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
659 CODESET_ACTION(C_KOI8_R)},
660 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
661 CODESET_ACTION(C_WINDOWS_1251)},
664 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
665 CODESET_ACTION(C_ISO_2022_JP)},
667 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
668 CODESET_ACTION(C_ISO_2022_JP_2)},
670 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
671 CODESET_ACTION(C_EUC_JP)},
672 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
673 CODESET_ACTION(C_SHIFT_JIS)},
676 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
677 CODESET_ACTION(C_GB2312)},
678 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
679 CODESET_ACTION(C_BIG5)},
680 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
681 CODESET_ACTION(C_EUC_TW)},
682 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
683 CODESET_ACTION(C_ISO_2022_CN)},
685 {N_("/_View/_Code set/Korean (EUC-_KR)"),
686 CODESET_ACTION(C_EUC_KR)},
687 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
688 CODESET_ACTION(C_ISO_2022_KR)},
690 {N_("/_View/_Code set/Thai (TIS-620)"),
691 CODESET_ACTION(C_TIS_620)},
692 {N_("/_View/_Code set/Thai (Windows-874)"),
693 CODESET_ACTION(C_WINDOWS_874)},
696 #undef CODESET_SEPARATOR
697 #undef CODESET_ACTION
699 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
700 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
701 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
702 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
703 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
704 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
706 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
707 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
708 {N_("/_Message/Get from _all accounts"),
709 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
710 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
711 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
712 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
713 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
714 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
715 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
716 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
717 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
718 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
719 {N_("/_Message/Repl_y to/_sender"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
720 {N_("/_Message/Repl_y to/mailing _list"),
721 "<control>L", reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
722 {N_("/_Message/Follow-up and reply to"),NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
723 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
724 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
725 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
726 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
727 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
728 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
729 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
730 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
731 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
732 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
733 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
734 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
735 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
736 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
737 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
738 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
739 {N_("/_Message/_Mark/Mark as rea_d"),
740 NULL, mark_as_read_cb, 0, NULL},
741 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
743 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
744 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
745 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
746 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
747 {N_("/_Tools/Add sender to address boo_k"),
748 NULL, add_address_cb, 0, NULL},
749 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
750 {N_("/_Tools/_Harvest addresses/from _Folder..."),
751 NULL, addr_harvest_cb, 0, NULL},
752 {N_("/_Tools/_Harvest addresses/from _Messages..."),
753 NULL, addr_harvest_msg_cb, 0, NULL},
754 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
755 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
756 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
757 {N_("/_Tools/_Create filter rule/_Automatically"),
758 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
759 {N_("/_Tools/_Create filter rule/by _From"),
760 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
761 {N_("/_Tools/_Create filter rule/by _To"),
762 NULL, create_filter_cb, FILTER_BY_TO, NULL},
763 {N_("/_Tools/_Create filter rule/by _Subject"),
764 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
765 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
766 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
767 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
768 {N_("/_Tools/Delete du_plicated messages"),
769 NULL, delete_duplicated_cb, 0, NULL},
770 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
771 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
772 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
773 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
775 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
776 {N_("/_Configuration/_Common preferences..."),
777 NULL, prefs_common_open_cb, 0, NULL},
778 {N_("/_Configuration/C_ustomize toolbar"),
779 NULL, NULL, 0, "<Branch>"},
780 {N_("/_Configuration/C_ustomize toolbar/_Main toolbar..."),
781 NULL, prefs_toolbar_cb, TOOLBAR_MAIN, NULL},
782 {N_("/_Configuration/C_ustomize toolbar/_Compose toolbar..."),
783 NULL, prefs_toolbar_cb, TOOLBAR_COMPOSE, NULL},
785 {N_("/_Configuration/_Filter setting..."),
786 NULL, prefs_filter_open_cb, 0, NULL},
788 {N_("/_Configuration/_Scoring..."),
789 NULL, prefs_scoring_open_cb, 0, NULL},
790 {N_("/_Configuration/_Filtering..."),
791 NULL, prefs_filtering_open_cb, 0, NULL},
792 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
793 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
794 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
795 {N_("/_Configuration/_Preferences for current account..."),
796 NULL, prefs_account_open_cb, 0, NULL},
797 {N_("/_Configuration/Create _new account..."),
798 NULL, new_account_cb, 0, NULL},
799 {N_("/_Configuration/_Edit accounts..."),
800 NULL, account_edit_open, 0, NULL},
801 {N_("/_Configuration/C_hange current account"),
802 NULL, NULL, 0, "<Branch>"},
804 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
805 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
806 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
807 {N_("/_Help/_Manual/_German"), NULL, manual_open_cb, MANUAL_LANG_DE, NULL},
808 {N_("/_Help/_Manual/_Spanish"), NULL, manual_open_cb, MANUAL_LANG_ES, NULL},
809 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
810 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
811 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
812 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
813 {N_("/_Help/_FAQ/_German"), NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
814 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
815 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
816 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
817 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
818 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
823 static GtkItemFactoryEntry reply_popup_entries[] =
825 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
826 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
828 static GtkItemFactoryEntry replyall_popup_entries[] =
830 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
831 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
833 static GtkItemFactoryEntry replylist_popup_entries[] =
835 {N_("/Reply to list with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE, NULL},
836 {N_("/_Reply to list without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE, NULL}
838 static GtkItemFactoryEntry replysender_popup_entries[] =
840 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
841 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
843 static GtkItemFactoryEntry fwd_popup_entries[] =
845 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
846 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
849 MainWindow *main_window_create(SeparateType type)
855 GtkWidget *handlebox;
856 GtkWidget *vbox_body;
857 GtkWidget *hbox_stat;
858 GtkWidget *statusbar;
859 GtkWidget *progressbar;
860 GtkWidget *statuslabel;
861 GtkWidget *ac_button;
863 GtkWidget *online_pixmap;
864 GtkWidget *offline_pixmap;
865 GtkWidget *online_switch;
866 GtkWidget *offline_switch;
868 FolderView *folderview;
869 SummaryView *summaryview;
870 MessageView *messageview;
871 GdkColormap *colormap;
874 GtkItemFactory *ifactory;
878 guint n_menu_entries;
880 static GdkGeometry geometry;
882 debug_print("Creating main window...\n");
883 mainwin = g_new0(MainWindow, 1);
886 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
887 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
888 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
889 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
891 if (!geometry.min_height) {
892 geometry.min_width = 320;
893 geometry.min_height = 200;
895 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
898 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
899 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
900 MANAGE_WINDOW_SIGNALS_CONNECT(window);
901 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
902 GTK_SIGNAL_FUNC(key_pressed), mainwin);
904 gtk_widget_realize(window);
905 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
908 gtkut_widget_set_app_icon(window);
910 vbox = gtk_vbox_new(FALSE, 0);
911 gtk_widget_show(vbox);
912 gtk_container_add(GTK_CONTAINER(window), vbox);
915 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
916 menubar = menubar_create(window, mainwin_entries,
917 n_menu_entries, "<Main>", mainwin);
918 gtk_widget_show(menubar);
919 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
920 ifactory = gtk_item_factory_from_widget(menubar);
922 handlebox = gtk_handle_box_new();
923 gtk_widget_show(handlebox);
924 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
926 /* link window to mainwin->window to avoid gdk warnings */
927 mainwin->window = window;
930 toolbar_create(mainwin, handlebox);
932 /* vbox that contains body */
933 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
934 gtk_widget_show(vbox_body);
935 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
936 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
938 hbox_stat = gtk_hbox_new(FALSE, 2);
939 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
941 statusbar = statusbar_create();
942 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
944 progressbar = gtk_progress_bar_new();
945 gtk_widget_set_usize(progressbar, 120, 1);
946 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
948 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
949 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
950 online_switch = gtk_button_new ();
951 offline_switch = gtk_button_new ();
952 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
953 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
954 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
955 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
956 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
957 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
958 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
959 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
961 statuslabel = gtk_label_new("");
962 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
964 ac_button = gtk_button_new();
965 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
966 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
967 gtk_widget_set_usize(ac_button, -1, 1);
968 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
969 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
970 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
972 ac_label = gtk_label_new("");
973 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
975 gtk_widget_show_all(hbox_stat);
977 gtk_widget_hide(offline_switch);
979 mainwin->folderview = folderview = folderview_create();
980 mainwin->summaryview = summaryview = summary_create();
981 mainwin->messageview = messageview = messageview_create(mainwin);
982 mainwin->logwin = log_window_create();
984 folderview->mainwin = mainwin;
985 folderview->summaryview = summaryview;
987 summaryview->mainwin = mainwin;
988 summaryview->folderview = folderview;
989 summaryview->messageview = messageview;
990 summaryview->window = window;
992 messageview->mainwin = mainwin;
994 mainwin->vbox = vbox;
995 mainwin->menubar = menubar;
996 mainwin->menu_factory = ifactory;
997 mainwin->handlebox = handlebox;
998 mainwin->vbox_body = vbox_body;
999 mainwin->hbox_stat = hbox_stat;
1000 mainwin->statusbar = statusbar;
1001 mainwin->progressbar = progressbar;
1002 mainwin->statuslabel = statuslabel;
1003 mainwin->ac_button = ac_button;
1004 mainwin->ac_label = ac_label;
1006 mainwin->online_switch = online_switch;
1007 mainwin->offline_switch = offline_switch;
1008 mainwin->online_pixmap = online_pixmap;
1009 mainwin->offline_pixmap = offline_pixmap;
1011 /* set context IDs for status bar */
1012 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1013 (GTK_STATUSBAR(statusbar), "Main Window");
1014 mainwin->folderview_cid = gtk_statusbar_get_context_id
1015 (GTK_STATUSBAR(statusbar), "Folder View");
1016 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1017 (GTK_STATUSBAR(statusbar), "Summary View");
1019 /* allocate colors for summary view and folder view */
1020 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1021 summaryview->color_marked.blue = (guint16)65535;
1023 summaryview->color_dim.red = summaryview->color_dim.green =
1024 summaryview->color_dim.blue = COLOR_DIM;
1026 folderview->color_new.red = (guint16)55000;
1027 folderview->color_new.green = folderview->color_new.blue = 15000;
1029 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1030 &folderview->color_op);
1032 summaryview->color_important.red = 0;
1033 summaryview->color_important.green = 0;
1034 summaryview->color_important.blue = (guint16)65535;
1036 color[0] = summaryview->color_marked;
1037 color[1] = summaryview->color_dim;
1038 color[2] = folderview->color_new;
1039 color[3] = folderview->color_op;
1041 colormap = gdk_window_get_colormap(window->window);
1042 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1043 for (i = 0; i < 4; i++) {
1044 if (success[i] == FALSE)
1045 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1048 debug_print("done.\n");
1050 messageview->visible = TRUE;
1052 main_window_set_widgets(mainwin, type);
1054 /* set menu items */
1055 menuitem = gtk_item_factory_get_item
1056 (ifactory, "/View/Code set/Auto detect");
1057 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1059 switch (prefs_common.toolbar_style) {
1061 menuitem = gtk_item_factory_get_item
1062 (ifactory, "/View/Show or hide/Toolbar/None");
1065 menuitem = gtk_item_factory_get_item
1066 (ifactory, "/View/Show or hide/Toolbar/Icon");
1069 menuitem = gtk_item_factory_get_item
1070 (ifactory, "/View/Show or hide/Toolbar/Text");
1073 menuitem = gtk_item_factory_get_item
1074 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1076 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1078 gtk_widget_hide(mainwin->hbox_stat);
1079 menuitem = gtk_item_factory_get_item
1080 (ifactory, "/View/Show or hide/Status bar");
1081 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1082 prefs_common.show_statusbar);
1084 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
1086 if (prefs_common.show_searchbar)
1087 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
1090 /* set account selection menu */
1091 ac_menu = gtk_item_factory_get_widget
1092 (ifactory, "/Configuration/Change current account");
1093 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1094 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1095 mainwin->ac_menu = ac_menu;
1097 toolbar_set_sensitive(mainwin);
1099 /* create actions menu */
1100 update_mainwin_actions_menu(ifactory, mainwin);
1102 /* show main window */
1103 gtk_widget_set_uposition(mainwin->window,
1104 prefs_common.mainwin_x,
1105 prefs_common.mainwin_y);
1106 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1107 prefs_common.mainwin_height);
1108 gtk_widget_show(mainwin->window);
1110 /* initialize views */
1111 folderview_init(folderview);
1112 summary_init(summaryview);
1113 messageview_init(messageview);
1114 log_window_init(mainwin->logwin);
1116 mainwin->lock_count = 0;
1117 mainwin->menu_lock_count = 0;
1118 mainwin->cursor_count = 0;
1121 watch_cursor = gdk_cursor_new(GDK_WATCH);
1123 mainwin_list = g_list_append(mainwin_list, mainwin);
1125 /* init work_offline */
1126 if (prefs_common.work_offline)
1127 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1132 void main_window_cursor_wait(MainWindow *mainwin)
1135 if (mainwin->cursor_count == 0)
1136 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1138 mainwin->cursor_count++;
1143 void main_window_cursor_normal(MainWindow *mainwin)
1145 if (mainwin->cursor_count)
1146 mainwin->cursor_count--;
1148 if (mainwin->cursor_count == 0)
1149 gdk_window_set_cursor(mainwin->window->window, NULL);
1154 /* lock / unlock the user-interface */
1155 void main_window_lock(MainWindow *mainwin)
1157 if (mainwin->lock_count == 0)
1158 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1160 mainwin->lock_count++;
1162 main_window_set_menu_sensitive(mainwin);
1163 toolbar_set_sensitive(mainwin);
1166 void main_window_unlock(MainWindow *mainwin)
1168 if (mainwin->lock_count)
1169 mainwin->lock_count--;
1171 main_window_set_menu_sensitive(mainwin);
1172 toolbar_set_sensitive(mainwin);
1174 if (mainwin->lock_count == 0)
1175 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1178 static void main_window_menu_callback_block(MainWindow *mainwin)
1180 mainwin->menu_lock_count++;
1183 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1185 if (mainwin->menu_lock_count)
1186 mainwin->menu_lock_count--;
1189 void main_window_reflect_prefs_all(void)
1191 main_window_reflect_prefs_all_real(FALSE);
1194 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1197 MainWindow *mainwin;
1200 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1201 mainwin = (MainWindow *)cur->data;
1203 main_window_show_cur_account(mainwin);
1204 main_window_set_menu_sensitive(mainwin);
1205 toolbar_set_sensitive(mainwin);
1208 if (pixmap_theme_changed) {
1209 toolbar_update(mainwin);
1210 set_toolbar_style(mainwin);
1211 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1212 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1214 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1215 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1216 mainwin->online_pixmap);
1217 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1218 gtk_widget_show(pixmap);
1219 mainwin->online_pixmap = pixmap;
1220 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1221 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1222 mainwin->offline_pixmap);
1223 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1224 gtk_widget_show(pixmap);
1225 mainwin->offline_pixmap = pixmap;
1228 summary_redisplay_msg(mainwin->summaryview);
1229 headerview_set_visibility(mainwin->messageview->headerview,
1230 prefs_common.display_header_pane);
1234 void main_window_set_summary_column(void)
1237 MainWindow *mainwin;
1239 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1240 mainwin = (MainWindow *)cur->data;
1241 summary_set_column_order(mainwin->summaryview);
1245 void main_window_set_account_menu(GList *account_list)
1247 GList *cur, *cur_ac, *cur_item;
1248 GtkWidget *menuitem;
1249 MainWindow *mainwin;
1250 PrefsAccount *ac_prefs;
1252 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1253 mainwin = (MainWindow *)cur->data;
1255 /* destroy all previous menu item */
1256 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1257 while (cur_item != NULL) {
1258 GList *next = cur_item->next;
1259 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1263 for (cur_ac = account_list; cur_ac != NULL;
1264 cur_ac = cur_ac->next) {
1265 ac_prefs = (PrefsAccount *)cur_ac->data;
1267 menuitem = gtk_menu_item_new_with_label
1268 (ac_prefs->account_name
1269 ? ac_prefs->account_name : _("Untitled"));
1270 gtk_widget_show(menuitem);
1271 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1272 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1273 GTK_SIGNAL_FUNC(account_menu_cb),
1279 static void main_window_show_cur_account(MainWindow *mainwin)
1284 ac_name = g_strdup(cur_account
1285 ? (cur_account->account_name
1286 ? cur_account->account_name : _("Untitled"))
1290 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1292 buf = g_strdup(PROG_VERSION);
1293 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1296 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1297 gtk_widget_queue_resize(mainwin->ac_button);
1302 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1304 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1305 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1306 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1308 debug_print("Changing window separation type from %d to %d\n",
1309 mainwin->type, type);
1311 if (mainwin->type == type) return;
1313 /* remove widgets from those containers */
1314 gtk_widget_ref(folder_wid);
1315 gtk_widget_ref(summary_wid);
1316 gtk_widget_ref(message_wid);
1317 gtkut_container_remove
1318 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1319 gtkut_container_remove
1320 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1321 gtkut_container_remove
1322 (GTK_CONTAINER(message_wid->parent), message_wid);
1324 /* clean containers */
1325 switch (mainwin->type) {
1327 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1329 case SEPARATE_FOLDER:
1330 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1331 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1333 case SEPARATE_MESSAGE:
1334 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1335 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1338 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1339 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1343 gtk_widget_hide(mainwin->window);
1344 main_window_set_widgets(mainwin, type);
1345 gtk_widget_show(mainwin->window);
1347 gtk_widget_unref(folder_wid);
1348 gtk_widget_unref(summary_wid);
1349 gtk_widget_unref(message_wid);
1352 void main_window_toggle_message_view(MainWindow *mainwin)
1354 SummaryView *summaryview = mainwin->summaryview;
1355 union CompositeWin *cwin = &mainwin->win;
1356 GtkWidget *vpaned = NULL;
1357 GtkWidget *container = NULL;
1358 GtkWidget *msgwin = NULL;
1360 switch (mainwin->type) {
1362 vpaned = cwin->sep_none.vpaned;
1363 container = cwin->sep_none.hpaned;
1365 case SEPARATE_FOLDER:
1366 vpaned = cwin->sep_folder.vpaned;
1367 container = mainwin->vbox_body;
1369 case SEPARATE_MESSAGE:
1370 msgwin = mainwin->win.sep_message.messagewin;
1373 msgwin = mainwin->win.sep_both.messagewin;
1378 if (GTK_WIDGET_VISIBLE(msgwin)) {
1379 gtk_widget_hide(msgwin);
1380 mainwin->messageview->visible = FALSE;
1381 summaryview->displayed = NULL;
1383 gtk_widget_show(msgwin);
1384 mainwin->messageview->visible = TRUE;
1386 } else if (vpaned->parent != NULL) {
1387 mainwin->messageview->visible = FALSE;
1388 summaryview->displayed = NULL;
1389 gtk_widget_ref(vpaned);
1390 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1391 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1392 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1393 GTK_ARROW_UP, GTK_SHADOW_OUT);
1395 mainwin->messageview->visible = TRUE;
1396 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1397 gtk_container_add(GTK_CONTAINER(container), vpaned);
1398 gtk_widget_unref(vpaned);
1399 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1400 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1403 main_window_set_menu_sensitive(mainwin);
1405 gtk_widget_grab_focus(summaryview->ctree);
1408 void main_window_get_size(MainWindow *mainwin)
1410 GtkAllocation *allocation;
1412 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1414 prefs_common.summaryview_width = allocation->width;
1416 if ((mainwin->type == SEPARATE_NONE ||
1417 mainwin->type == SEPARATE_FOLDER) &&
1418 messageview_is_visible(mainwin->messageview))
1419 prefs_common.summaryview_height = allocation->height;
1421 prefs_common.mainview_width = allocation->width;
1423 allocation = &mainwin->window->allocation;
1425 prefs_common.mainview_height = allocation->height;
1426 prefs_common.mainwin_width = allocation->width;
1427 prefs_common.mainwin_height = allocation->height;
1429 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1431 prefs_common.folderview_width = allocation->width;
1432 prefs_common.folderview_height = allocation->height;
1435 void main_window_get_position(MainWindow *mainwin)
1439 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1441 prefs_common.mainview_x = x;
1442 prefs_common.mainview_y = y;
1443 prefs_common.mainwin_x = x;
1444 prefs_common.mainwin_y = y;
1446 debug_print("window position: x = %d, y = %d\n", x, y);
1449 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1455 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1456 folder = FOLDER(list->data);
1457 if (folder && folder->trash && folder->trash->total > 0)
1461 if (!has_trash) return;
1464 if (alertpanel(_("Empty trash"),
1465 _("Empty all messages in trash?"),
1466 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1468 manage_window_focus_in(mainwin->window, NULL, NULL);
1471 procmsg_empty_trash();
1473 for (list = folder_get_list(); list != NULL; list = list->next) {
1474 folder = list->data;
1475 if (folder && folder->trash) {
1476 folderview_update_item(folder->trash, TRUE);
1480 if (mainwin->summaryview->folder_item &&
1481 mainwin->summaryview->folder_item->stype == F_TRASH)
1482 gtk_widget_grab_focus(mainwin->folderview->ctree);
1485 void main_window_add_mailbox(MainWindow *mainwin)
1490 path = input_dialog(_("Add mailbox"),
1491 _("Input the location of mailbox.\n"
1492 "If the existing mailbox is specified, it will be\n"
1493 "scanned automatically."),
1496 if (folder_find_from_path(path)) {
1497 alertpanel_error(_("The mailbox `%s' already exists."), path);
1501 if (!strcmp(path, "Mail"))
1502 folder = folder_new(F_MH, _("Mailbox"), path);
1504 folder = folder_new(F_MH, g_basename(path), path);
1507 if (folder->create_tree(folder) < 0) {
1508 alertpanel_error(_("Creation of the mailbox failed.\n"
1509 "Maybe some files already exist, or you don't have the permission to write there."));
1510 folder_destroy(folder);
1515 folder_set_ui_func(folder, scan_tree_func, mainwin);
1516 folder_scan_tree(folder);
1517 folder_set_ui_func(folder, NULL, NULL);
1519 folderview_set(mainwin->folderview);
1522 void main_window_add_mbox(MainWindow *mainwin)
1528 path = input_dialog(_("Add mbox mailbox"),
1529 _("Input the location of mailbox."),
1534 if (folder_find_from_path(path)) {
1535 alertpanel_error(_("The mailbox `%s' already exists."), path);
1541 if (!strcmp(path, "Mail"))
1542 folder = folder_new(F_MBOX, _("Mailbox"), path);
1546 folder = folder_new(F_MBOX, g_basename(path), path);
1549 if (folder->create_tree(folder) < 0) {
1550 alertpanel_error(_("Creation of the mailbox failed."));
1551 folder_destroy(folder);
1557 item = folder_item_new(folder, folder->name, NULL);
1558 item->folder = folder;
1559 folder->node = g_node_new(item);
1561 folder_create_folder(item, "inbox");
1562 folder_create_folder(item, "outbox");
1563 folder_create_folder(item, "queue");
1564 folder_create_folder(item, "draft");
1565 folder_create_folder(item, "trash");
1567 folderview_set(mainwin->folderview);
1570 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1572 SensitiveCond state = 0;
1573 SummarySelection selection;
1574 FolderItem *item = mainwin->summaryview->folder_item;
1575 GList *account_list = account_get_list();
1577 selection = summary_get_selection_type(mainwin->summaryview);
1579 if (mainwin->lock_count == 0)
1580 state |= M_UNLOCKED;
1581 if (selection != SUMMARY_NONE)
1582 state |= M_MSG_EXIST;
1583 if (item && item->path && item->parent && !item->no_select) {
1585 /* if (item->folder->type != F_NEWS) */
1586 state |= M_ALLOW_DELETE;
1588 if (prefs_common.immediate_exec == 0
1589 && mainwin->lock_count == 0)
1590 state |= M_DELAY_EXEC;
1592 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1593 || selection != SUMMARY_NONE)
1594 state |= M_HIDE_READ_MSG;
1596 if (mainwin->summaryview->threaded)
1597 state |= M_THREADED;
1599 state |= M_UNTHREADED;
1600 if (selection == SUMMARY_SELECTED_SINGLE ||
1601 selection == SUMMARY_SELECTED_MULTIPLE)
1602 state |= M_TARGET_EXIST;
1603 if (selection == SUMMARY_SELECTED_SINGLE)
1604 state |= M_SINGLE_TARGET_EXIST;
1605 if (mainwin->summaryview->folder_item &&
1606 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1609 state |= M_NOT_NEWS;
1610 if (selection == SUMMARY_SELECTED_SINGLE &&
1612 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1613 item->stype == F_QUEUE)))
1614 state |= M_ALLOW_REEDIT;
1616 state |= M_HAVE_ACCOUNT;
1618 for ( ; account_list != NULL; account_list = account_list->next) {
1619 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1620 state |= M_HAVE_NEWS_ACCOUNT;
1625 if (inc_is_active())
1626 state |= M_INC_ACTIVE;
1633 void main_window_set_menu_sensitive(MainWindow *mainwin)
1635 GtkItemFactory *ifactory = mainwin->menu_factory;
1636 SensitiveCond state;
1638 GtkWidget *menuitem;
1639 SummaryView *summaryview;
1643 static const struct {
1647 {"/File/Add mailbox..." , M_UNLOCKED},
1648 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1649 {"/File/Check for new messages in all folders", M_UNLOCKED},
1650 {"/File/Folder" , M_UNLOCKED},
1651 {"/File/Import mbox file..." , M_UNLOCKED},
1652 {"/File/Export to mbox file..." , M_UNLOCKED},
1653 {"/File/Empty trash" , M_UNLOCKED},
1654 {"/File/Work offline" , M_UNLOCKED},
1656 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1657 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1658 /* {"/File/Close" , M_UNLOCKED}, */
1659 {"/File/Exit" , M_UNLOCKED},
1661 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1663 {"/View/Sort" , M_EXEC},
1664 {"/View/Thread view" , M_EXEC},
1665 {"/View/Expand all threads" , M_MSG_EXIST},
1666 {"/View/Collapse all threads" , M_MSG_EXIST},
1667 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1668 {"/View/Go to/Prev message" , M_MSG_EXIST},
1669 {"/View/Go to/Next message" , M_MSG_EXIST},
1670 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1671 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1672 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1673 {"/View/Go to/Next new message" , M_MSG_EXIST},
1674 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1675 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1676 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1677 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1678 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1679 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1680 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1682 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1683 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1684 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1685 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1686 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1687 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1688 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1689 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1690 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1691 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1692 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1693 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1694 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1695 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1696 {"/Message/Mark" , M_TARGET_EXIST},
1698 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1699 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1700 {"/Tools/Harvest addresses" , M_UNLOCKED},
1701 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1702 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1703 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1704 {"/Tools/Execute" , M_DELAY_EXEC},
1705 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1707 {"/Configuration", M_UNLOCKED},
1712 state = main_window_get_current_state(mainwin);
1714 for (i = 0; entry[i].entry != NULL; i++) {
1715 sensitive = ((entry[i].cond & state) == entry[i].cond);
1716 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1719 main_window_menu_callback_block(mainwin);
1721 #define SET_CHECK_MENU_ACTIVE(path, active) \
1723 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1724 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1727 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1728 messageview_is_visible(mainwin->messageview));
1730 summaryview = mainwin->summaryview;
1731 menu_path = "/View/Sort/Don't sort";
1733 switch (summaryview->sort_key) {
1734 case SORT_BY_NUMBER:
1735 menu_path = "/View/Sort/by number"; break;
1737 menu_path = "/View/Sort/by size"; break;
1739 menu_path = "/View/Sort/by date"; break;
1741 menu_path = "/View/Sort/by from"; break;
1742 case SORT_BY_SUBJECT:
1743 menu_path = "/View/Sort/by subject"; break;
1745 menu_path = "/View/Sort/by color label"; break;
1747 menu_path = "/View/Sort/by mark"; break;
1748 case SORT_BY_UNREAD:
1749 menu_path = "/View/Sort/by unread"; break;
1751 menu_path = "/View/Sort/by attachment"; break;
1753 menu_path = "/View/Sort/by score"; break;
1754 case SORT_BY_LOCKED:
1755 menu_path = "/View/Sort/by locked"; break;
1758 menu_path = "/View/Sort/Don't sort"; break;
1760 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1762 if (summaryview->sort_type == SORT_ASCENDING) {
1763 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1765 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1768 if (summaryview->sort_key != SORT_BY_NONE) {
1769 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1770 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1772 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1773 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1776 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1777 mainwin->messageview->textview->show_all_headers);
1778 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1780 #undef SET_CHECK_MENU_ACTIVE
1782 main_window_menu_callback_unblock(mainwin);
1785 void main_window_popup(MainWindow *mainwin)
1791 gdk_window_get_origin(mainwin->window->window, &x, &y);
1792 sx = gdk_screen_width();
1793 sy = gdk_screen_height();
1794 x %= sx; if (x < 0) x = 0;
1795 y %= sy; if (y < 0) y = 0;
1796 gdk_window_move(mainwin->window->window, x, y);
1797 gdk_window_raise(mainwin->window->window);
1798 gdk_window_show(mainwin->window->window);
1800 debug_print("window position: x = %d, y = %d\n", x, y);
1802 switch (mainwin->type) {
1803 case SEPARATE_FOLDER:
1804 widget = mainwin->win.sep_folder.folderwin;
1805 gdk_window_get_origin(widget->window, &x, &y);
1806 x %= sx; if (x < 0) x = 0;
1807 y %= sy; if (y < 0) y = 0;
1808 gdk_window_move(widget->window, x, y);
1809 gdk_window_raise(widget->window);
1811 case SEPARATE_MESSAGE:
1812 widget = mainwin->win.sep_message.messagewin;
1813 gdk_window_get_origin(widget->window, &x, &y);
1814 x %= sx; if (x < 0) x = 0;
1815 y %= sy; if (y < 0) y = 0;
1816 gdk_window_move(widget->window, x, y);
1817 gdk_window_raise(widget->window);
1820 widget = mainwin->win.sep_both.folderwin;
1821 gdk_window_get_origin(widget->window, &x, &y);
1822 x %= sx; if (x < 0) x = 0;
1823 y %= sy; if (y < 0) y = 0;
1824 gdk_window_move(widget->window, x, y);
1825 gdk_window_raise(widget->window);
1826 widget = mainwin->win.sep_both.messagewin;
1827 gdk_window_get_origin(widget->window, &x, &y);
1828 x %= sx; if (x < 0) x = 0;
1829 y %= sy; if (y < 0) y = 0;
1830 gdk_window_move(widget->window, x, y);
1831 gdk_window_raise(widget->window);
1838 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1840 GtkWidget *folderwin = NULL;
1841 GtkWidget *messagewin = NULL;
1844 GtkWidget *vbox_body = mainwin->vbox_body;
1845 GtkItemFactory *ifactory = mainwin->menu_factory;
1846 GtkWidget *menuitem;
1848 debug_print("Setting widgets...");
1850 /* create separated window(s) if needed */
1851 if (type & SEPARATE_FOLDER) {
1852 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1853 gtk_window_set_title(GTK_WINDOW(folderwin),
1854 _("Sylpheed - Folder View"));
1855 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1856 "folder_view", "Sylpheed");
1857 gtk_window_set_policy(GTK_WINDOW(folderwin),
1859 gtk_widget_set_usize(folderwin, -1,
1860 prefs_common.mainview_height);
1861 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1863 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1864 GTK_SIGNAL_FUNC(folder_window_close_cb),
1867 if (type & SEPARATE_MESSAGE) {
1868 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1869 gtk_window_set_title(GTK_WINDOW(messagewin),
1870 _("Sylpheed - Message View"));
1871 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1872 "message_view", "Sylpheed");
1873 gtk_window_set_policy(GTK_WINDOW(messagewin),
1875 gtk_widget_set_usize
1876 (messagewin, prefs_common.mainview_width,
1877 prefs_common.mainview_height
1878 - prefs_common.summaryview_height
1879 + DEFAULT_HEADERVIEW_HEIGHT);
1880 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1882 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1883 GTK_SIGNAL_FUNC(message_window_close_cb),
1889 hpaned = gtk_hpaned_new();
1890 gtk_widget_show(hpaned);
1891 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1892 gtk_paned_add1(GTK_PANED(hpaned),
1893 GTK_WIDGET_PTR(mainwin->folderview));
1895 vpaned = gtk_vpaned_new();
1896 if (messageview_is_visible(mainwin->messageview)) {
1897 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1898 gtk_paned_add1(GTK_PANED(vpaned),
1899 GTK_WIDGET_PTR(mainwin->summaryview));
1901 gtk_paned_add2(GTK_PANED(hpaned),
1902 GTK_WIDGET_PTR(mainwin->summaryview));
1903 gtk_widget_ref(vpaned);
1905 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1906 prefs_common.summaryview_width,
1907 prefs_common.summaryview_height);
1908 gtk_paned_add2(GTK_PANED(vpaned),
1909 GTK_WIDGET_PTR(mainwin->messageview));
1910 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1911 prefs_common.mainview_width, -1);
1912 gtk_widget_set_usize(mainwin->window,
1913 prefs_common.folderview_width +
1914 prefs_common.mainview_width,
1915 prefs_common.mainwin_height);
1916 gtk_widget_show_all(vpaned);
1918 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1919 * lose track of its visibility state */
1920 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1921 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1923 mainwin->win.sep_none.hpaned = hpaned;
1924 mainwin->win.sep_none.vpaned = vpaned;
1926 /* remove headerview if not in prefs */
1927 headerview_set_visibility(mainwin->messageview->headerview,
1928 prefs_common.display_header_pane);
1930 case SEPARATE_FOLDER:
1931 vpaned = gtk_vpaned_new();
1932 if (messageview_is_visible(mainwin->messageview)) {
1933 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1935 gtk_paned_add1(GTK_PANED(vpaned),
1936 GTK_WIDGET_PTR(mainwin->summaryview));
1938 gtk_box_pack_start(GTK_BOX(vbox_body),
1939 GTK_WIDGET_PTR(mainwin->summaryview),
1941 gtk_widget_ref(vpaned);
1943 gtk_paned_add2(GTK_PANED(vpaned),
1944 GTK_WIDGET_PTR(mainwin->messageview));
1945 gtk_widget_show_all(vpaned);
1946 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1947 prefs_common.summaryview_width,
1948 prefs_common.summaryview_height);
1949 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1950 prefs_common.mainview_width, -1);
1951 gtk_widget_set_usize(mainwin->window,
1952 prefs_common.mainview_width,
1953 prefs_common.mainview_height);
1955 gtk_container_add(GTK_CONTAINER(folderwin),
1956 GTK_WIDGET_PTR(mainwin->folderview));
1958 mainwin->win.sep_folder.folderwin = folderwin;
1959 mainwin->win.sep_folder.vpaned = vpaned;
1961 gtk_widget_show_all(folderwin);
1963 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1964 * lose track of its visibility state */
1965 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1966 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1968 /* remove headerview if not in prefs */
1969 headerview_set_visibility(mainwin->messageview->headerview,
1970 prefs_common.display_header_pane);
1973 case SEPARATE_MESSAGE:
1974 hpaned = gtk_hpaned_new();
1975 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1977 gtk_paned_add1(GTK_PANED(hpaned),
1978 GTK_WIDGET_PTR(mainwin->folderview));
1979 gtk_paned_add2(GTK_PANED(hpaned),
1980 GTK_WIDGET_PTR(mainwin->summaryview));
1981 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1982 prefs_common.summaryview_width,
1983 prefs_common.summaryview_height);
1984 gtk_widget_set_usize(mainwin->window,
1985 prefs_common.folderview_width +
1986 prefs_common.mainview_width,
1987 prefs_common.mainwin_height);
1988 gtk_widget_show_all(hpaned);
1989 gtk_container_add(GTK_CONTAINER(messagewin),
1990 GTK_WIDGET_PTR(mainwin->messageview));
1992 mainwin->win.sep_message.messagewin = messagewin;
1993 mainwin->win.sep_message.hpaned = hpaned;
1995 gtk_widget_show_all(messagewin);
1997 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1998 * lose track of its visibility state */
1999 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2000 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2003 gtk_box_pack_start(GTK_BOX(vbox_body),
2004 GTK_WIDGET_PTR(mainwin->summaryview),
2006 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
2007 prefs_common.summaryview_width,
2008 prefs_common.summaryview_height);
2009 gtk_widget_set_usize(mainwin->window,
2010 prefs_common.mainview_width,
2011 prefs_common.mainwin_height);
2012 gtk_container_add(GTK_CONTAINER(folderwin),
2013 GTK_WIDGET_PTR(mainwin->folderview));
2014 gtk_container_add(GTK_CONTAINER(messagewin),
2015 GTK_WIDGET_PTR(mainwin->messageview));
2017 mainwin->win.sep_both.folderwin = folderwin;
2018 mainwin->win.sep_both.messagewin = messagewin;
2020 gtk_widget_show_all(folderwin);
2021 gtk_widget_show_all(messagewin);
2023 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2024 * lose track of its visibility state */
2025 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2026 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2030 /* rehide quick search if necessary */
2031 if (!prefs_common.show_searchbar)
2032 gtk_widget_hide(mainwin->summaryview->hbox_search);
2034 mainwin->type = type;
2036 mainwin->messageview->visible = TRUE;
2038 /* toggle menu state */
2039 menuitem = gtk_item_factory_get_item
2040 (ifactory, "/View/Show or hide/Folder tree");
2041 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2042 menuitem = gtk_item_factory_get_item
2043 (ifactory, "/View/Show or hide/Message view");
2044 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2046 menuitem = gtk_item_factory_get_item
2047 (ifactory, "/View/Separate folder tree");
2048 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2049 ((type & SEPARATE_FOLDER) != 0));
2050 menuitem = gtk_item_factory_get_item
2051 (ifactory, "/View/Separate message view");
2052 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2053 ((type & SEPARATE_MESSAGE) != 0));
2055 debug_print("done.\n");
2058 void main_window_destroy_all(void)
2060 while (mainwin_list != NULL) {
2061 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2063 /* free toolbar stuff */
2064 toolbar_clear_list(TOOLBAR_MAIN);
2065 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->t_action_list);
2066 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->t_item_list);
2068 g_free(mainwin->toolbar);
2071 mainwin_list = g_list_remove(mainwin_list, mainwin);
2073 g_list_free(mainwin_list);
2077 static void toolbar_account_button_pressed(GtkWidget *widget,
2078 GdkEventButton *event,
2081 MainWindow *mainwin = (MainWindow *)data;
2084 if (event->button != 3) return;
2086 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2087 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2090 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2091 menu_button_position, widget,
2092 event->button, event->time);
2096 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2099 MainWindow *mainwin = (MainWindow *)data;
2103 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2104 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2107 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2108 menu_button_position, widget,
2109 event->button, event->time);
2112 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2114 MainWindow *mainwin = (MainWindow *)data;
2117 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2118 if (!button) return;
2119 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2120 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2121 manage_window_focus_in(mainwin->window, NULL, NULL);
2124 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2127 MainWindow *mainwin = (MainWindow *)data;
2129 if (mainwin->lock_count == 0)
2130 app_exit_cb(data, 0, widget);
2135 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2138 MainWindow *mainwin = (MainWindow *)data;
2139 GtkWidget *menuitem;
2141 menuitem = gtk_item_factory_get_item
2142 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2143 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2148 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2151 MainWindow *mainwin = (MainWindow *)data;
2152 GtkWidget *menuitem;
2154 menuitem = gtk_item_factory_get_item
2155 (mainwin->menu_factory, "/View/Show or hide/Message view");
2156 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2161 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2164 main_window_add_mailbox(mainwin);
2167 static void add_mbox_cb(MainWindow *mainwin, guint action,
2170 main_window_add_mbox(mainwin);
2173 static void update_folderview_cb(MainWindow *mainwin, guint action,
2176 summary_show(mainwin->summaryview, NULL);
2177 folderview_check_new_all();
2180 static void new_folder_cb(MainWindow *mainwin, guint action,
2183 folderview_new_folder(mainwin->folderview);
2186 static void rename_folder_cb(MainWindow *mainwin, guint action,
2189 folderview_rename_folder(mainwin->folderview);
2192 static void delete_folder_cb(MainWindow *mainwin, guint action,
2195 folderview_delete_folder(mainwin->folderview);
2198 static void import_mbox_cb(MainWindow *mainwin, guint action,
2201 import_mbox(mainwin->summaryview->folder_item);
2204 static void export_mbox_cb(MainWindow *mainwin, guint action,
2207 export_mbox(mainwin->summaryview->folder_item);
2210 static void empty_trash_cb(MainWindow *mainwin, guint action,
2213 main_window_empty_trash(mainwin, TRUE);
2216 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2218 summary_save_as(mainwin->summaryview);
2221 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2223 summary_print(mainwin->summaryview);
2226 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2228 if (prefs_common.confirm_on_exit) {
2229 if (alertpanel(_("Exit"), _("Exit this program?"),
2230 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2232 manage_window_focus_in(mainwin->window, NULL, NULL);
2235 app_will_exit(widget, mainwin);
2238 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2241 summary_search(mainwin->summaryview);
2243 message_search(mainwin->messageview);
2246 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2251 active = GTK_CHECK_MENU_ITEM(widget)->active;
2253 switch (mainwin->type) {
2255 case SEPARATE_MESSAGE:
2258 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2260 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2263 case SEPARATE_FOLDER:
2264 debug_print("separate folder\n");
2266 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2268 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2272 gtk_widget_show(mainwin->win.sep_both.folderwin);
2274 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2279 static void toggle_message_cb(MainWindow *mainwin, guint action,
2284 active = GTK_CHECK_MENU_ITEM(widget)->active;
2286 if (active != messageview_is_visible(mainwin->messageview))
2287 summary_toggle_view(mainwin->summaryview);
2290 /* Toolbar handling */
2291 static void toolbar_inc_cb(GtkWidget *widget,
2294 MainWindow *mainwin = (MainWindow *)data;
2296 inc_mail_cb(mainwin, 0, NULL);
2299 static void toolbar_inc_all_cb(GtkWidget *widget,
2302 MainWindow *mainwin = (MainWindow *)data;
2304 inc_all_account_mail_cb(mainwin, 0, NULL);
2307 static void toolbar_send_cb(GtkWidget *widget,
2310 MainWindow *mainwin = (MainWindow *)data;
2312 send_queue_cb(mainwin, 0, NULL);
2315 static void toolbar_compose_cb(GtkWidget *widget,
2318 MainWindow *mainwin = (MainWindow *)data;
2320 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
2321 compose_news_cb(mainwin, 0, NULL);
2323 compose_mail_cb(mainwin, 0, NULL);
2326 static void toolbar_reply_cb(GtkWidget *widget,
2329 MainWindow *mainwin = (MainWindow *)data;
2331 if (prefs_common.default_reply_list)
2333 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
2334 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
2338 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2339 : COMPOSE_REPLY_WITHOUT_QUOTE,
2343 static void toolbar_reply_to_all_cb(GtkWidget *widget,
2346 MainWindow *mainwin = (MainWindow *)data;
2349 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2350 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2354 static void toolbar_reply_to_list_cb(GtkWidget *widget,
2357 MainWindow *mainwin = (MainWindow *)data;
2360 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
2361 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
2365 static void toolbar_reply_to_sender_cb(GtkWidget *widget,
2368 MainWindow *mainwin = (MainWindow *)data;
2371 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2372 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2376 static void toolbar_forward_cb(GtkWidget *widget,
2379 MainWindow *mainwin = (MainWindow *)data;
2381 if (prefs_common.forward_as_attachment)
2382 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2384 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2387 static void toolbar_delete_cb(GtkWidget *widget,
2390 MainWindow *mainwin = (MainWindow *)data;
2392 summary_delete(mainwin->summaryview);
2395 static void toolbar_exec_cb(GtkWidget *widget,
2398 MainWindow *mainwin = (MainWindow *)data;
2400 summary_execute(mainwin->summaryview);
2403 static void toolbar_next_unread_cb(GtkWidget *widget,
2406 MainWindow *mainwin = (MainWindow *)data;
2408 next_unread_cb(mainwin, 0, NULL);
2411 /* popup callback functions */
2412 static void toolbar_reply_popup_cb(GtkWidget *widget,
2413 GdkEventButton *event,
2416 MainWindow *mainwindow = (MainWindow *) data;
2420 if (event->button == 3) {
2421 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2422 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->reply_popup), NULL, NULL,
2423 menu_button_position, widget,
2424 event->button, event->time);
2428 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2430 MainWindow *mainwin = (MainWindow *)data;
2432 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->reply_btn), GTK_RELIEF_NONE);
2433 manage_window_focus_in(mainwin->window, NULL, NULL);
2436 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2438 MainWindow *mainwindow = (MainWindow *) data;
2442 if (event->button == 3) {
2443 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2444 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replyall_popup), NULL, NULL,
2445 menu_button_position, widget,
2446 event->button, event->time);
2450 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2452 MainWindow *mainwin = (MainWindow *)data;
2454 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replyall_btn), GTK_RELIEF_NONE);
2455 manage_window_focus_in(mainwin->window, NULL, NULL);
2458 static void toolbar_reply_to_list_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2460 MainWindow *mainwindow = (MainWindow *) data;
2464 if (event->button == 3) {
2465 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2466 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replylist_popup), NULL, NULL,
2467 menu_button_position, widget,
2468 event->button, event->time);
2472 static void toolbar_reply_to_list_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2474 MainWindow *mainwin = (MainWindow *)data;
2476 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replylist_btn), GTK_RELIEF_NONE);
2477 manage_window_focus_in(mainwin->window, NULL, NULL);
2480 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2482 MainWindow *mainwindow = (MainWindow *) data;
2486 if (event->button == 3) {
2487 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2488 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replysender_popup), NULL, NULL,
2489 menu_button_position, widget,
2490 event->button, event->time);
2494 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2496 MainWindow *mainwin = (MainWindow *)data;
2498 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replysender_btn), GTK_RELIEF_NONE);
2499 manage_window_focus_in(mainwin->window, NULL, NULL);
2502 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2504 MainWindow *mainwindow = (MainWindow *) data;
2508 if (event->button == 3) {
2509 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2510 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->fwd_popup), NULL, NULL,
2511 menu_button_position, widget,
2512 event->button, event->time);
2516 static void toolbar_forward_popup_closed_cb (GtkMenuShell *menu_shell,
2519 MainWindow *mainwin = (MainWindow *)data;
2521 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->fwd_btn), GTK_RELIEF_NONE);
2522 manage_window_focus_in(mainwin->window, NULL, NULL);
2525 static void activate_compose_button (MainToolbar *toolbar,
2527 ComposeButtonType type)
2529 if ((!toolbar->compose_mail_btn) || (!toolbar->compose_news_btn))
2532 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? toolbar->compose_mail_btn
2533 : toolbar->compose_news_btn);
2534 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? toolbar->compose_news_btn
2535 : toolbar->compose_mail_btn);
2536 toolbar->compose_btn_type = type;
2539 void toolbar_set_compose_button(MainToolbar *toolbar,
2540 ComposeButtonType compose_btn_type)
2542 if (toolbar->compose_btn_type != compose_btn_type)
2543 activate_compose_button(toolbar,
2544 prefs_common.toolbar_style,
2548 static void toolbar_buttons_cb(GtkWidget *widget,
2549 ToolbarItem *t_item)
2553 void (*func)(GtkWidget *widget, gpointer data);
2554 } toolbar_action[] = {
2555 { A_RECEIVE_ALL, toolbar_inc_all_cb },
2556 { A_RECEIVE_CUR, toolbar_inc_cb },
2557 { A_SEND_QUEUED, toolbar_send_cb },
2558 { A_COMPOSE_EMAIL, toolbar_compose_cb },
2559 { A_REPLY_MESSAGE, toolbar_reply_cb },
2560 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
2561 { A_REPLY_ALL, toolbar_reply_to_all_cb },
2562 { A_REPLY_ML, toolbar_reply_to_list_cb },
2563 { A_FORWARD, toolbar_forward_cb },
2564 { A_DELETE, toolbar_delete_cb },
2565 { A_EXECUTE, toolbar_exec_cb },
2566 { A_GOTO_NEXT, toolbar_next_unread_cb },
2567 { A_SYL_ACTIONS, toolbar_actions_execute_cb },
2569 { A_COMPOSE_NEWS, toolbar_compose_cb },
2570 { A_SEPARATOR, NULL }};
2572 gint num_items = sizeof(toolbar_action)/sizeof(toolbar_action[0]);
2575 for (i = A_RECEIVE_ALL; i < num_items; i++) {
2577 if (toolbar_action[i].index == t_item->index) {
2578 MainWindow *mainwin = (MainWindow*)t_item->parent;
2579 toolbar_action[i].func(widget, mainwin);
2585 static void toolbar_actions_execute_cb(GtkWidget *widget,
2588 MainWindow *mainwin = (MainWindow*)data;
2590 toolbar_action_execute(widget, mainwin->toolbar->t_action_list, data, TOOLBAR_MAIN);
2593 void toolbar_set_sensitive(MainWindow *mainwin)
2595 SensitiveCond state;
2597 MainToolbar *toolbar = mainwin->toolbar;
2599 GSList *entry_list = NULL;
2601 typedef struct _Entry Entry;
2608 #define SET_WIDGET_COND(w, c) \
2610 Entry *e = g_new0(Entry, 1); \
2613 entry_list = g_slist_append(entry_list, e); \
2616 SET_WIDGET_COND(toolbar->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2617 SET_WIDGET_COND(toolbar->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2618 SET_WIDGET_COND(toolbar->compose_news_btn, M_HAVE_ACCOUNT);
2619 SET_WIDGET_COND(toolbar->reply_btn,
2620 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2621 SET_WIDGET_COND(toolbar->replyall_btn,
2622 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2623 SET_WIDGET_COND(toolbar->replylist_btn,
2624 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2625 SET_WIDGET_COND(toolbar->replysender_btn,
2626 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2627 SET_WIDGET_COND(toolbar->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
2629 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST);
2630 SET_WIDGET_COND(toolbar->delete_btn,
2631 M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
2632 SET_WIDGET_COND(toolbar->exec_btn, M_DELAY_EXEC);
2634 for (cur = toolbar->t_action_list; cur != NULL; cur = cur->next) {
2635 ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
2637 SET_WIDGET_COND(act->widget, M_TARGET_EXIST|M_UNLOCKED);
2640 #undef SET_WIDGET_COND
2642 state = main_window_get_current_state(mainwin);
2644 for (cur = entry_list; cur != NULL; cur = cur->next) {
2645 Entry *e = (Entry*) cur->data;
2647 if (e->widget != NULL) {
2648 sensitive = ((e->cond & state) == e->cond);
2649 gtk_widget_set_sensitive(e->widget, sensitive);
2653 while (entry_list != NULL) {
2654 Entry *e = (Entry*) entry_list->data;
2658 entry_list = g_slist_remove(entry_list, e);
2661 g_slist_free(entry_list);
2663 activate_compose_button(toolbar,
2664 prefs_common.toolbar_style,
2665 toolbar->compose_btn_type);
2668 static void toolbar_update(MainWindow *mainwin)
2670 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox),
2671 GTK_WIDGET(mainwin->toolbar->toolbar));
2673 mainwin->toolbar->toolbar = NULL;
2674 mainwin->toolbar->get_btn = NULL;
2675 mainwin->toolbar->getall_btn = NULL;
2676 mainwin->toolbar->send_btn = NULL;
2677 mainwin->toolbar->compose_mail_btn = NULL;
2678 mainwin->toolbar->compose_news_btn = NULL;
2679 mainwin->toolbar->reply_btn = NULL;
2680 mainwin->toolbar->replyall_btn = NULL;
2681 mainwin->toolbar->replylist_btn = NULL;
2682 mainwin->toolbar->replysender_btn = NULL;
2683 mainwin->toolbar->fwd_btn = NULL;
2684 mainwin->toolbar->delete_btn = NULL;
2685 mainwin->toolbar->next_btn = NULL;
2686 mainwin->toolbar->exec_btn = NULL;
2688 toolbar_clear_list(TOOLBAR_MAIN);
2689 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->t_action_list);
2690 toolbar_create(mainwin, mainwin->handlebox);
2691 toolbar_set_sensitive(mainwin);
2695 static void toolbar_create(MainWindow *mainwin,
2696 GtkWidget *container)
2698 ToolbarItem *toolbar_item;
2701 GtkWidget *icon_wid = NULL;
2702 GtkWidget *icon_news = NULL;
2703 GtkWidget *item_news = NULL;
2705 GtkTooltips *toolbar_tips;
2706 ToolbarSylpheedActions *t_action_item;
2708 GSList *toolbar_list;
2710 guint n_menu_entries;
2711 GtkWidget *reply_popup;
2712 GtkWidget *replyall_popup;
2713 GtkWidget *replylist_popup;
2714 GtkWidget *replysender_popup;
2715 GtkWidget *fwd_popup;
2717 toolbar_tips = gtk_tooltips_new();
2719 if (mainwin->toolbar != NULL) {
2720 toolbar_clear_list(TOOLBAR_MAIN);
2721 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->t_action_list);
2722 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->t_item_list);
2723 g_free(mainwin->toolbar);
2726 toolbar_read_config_file(TOOLBAR_MAIN);
2727 toolbar_list = toolbar_get_list(TOOLBAR_MAIN);
2729 mainwin->toolbar = g_new0(MainToolbar, 1);
2731 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
2733 gtk_container_add(GTK_CONTAINER(container), toolbar);
2734 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
2735 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
2736 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
2737 GTK_TOOLBAR_SPACE_LINE);
2739 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2741 if (g_strcasecmp(((ToolbarItem*)cur->data)->file, SEPARATOR) == 0) {
2742 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2746 toolbar_item = g_new0(ToolbarItem, 1);
2747 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2748 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2749 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2751 toolbar_item->parent = (gpointer)mainwin;
2753 /* collect toolbar items in list to keep track */
2754 mainwin->toolbar->t_item_list = g_slist_append(mainwin->toolbar->t_item_list,
2757 icon_wid = stock_pixmap_widget(container, stock_pixmap_get_icon(toolbar_item->file));
2758 item = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2762 icon_wid, toolbar_buttons_cb,
2765 switch (toolbar_item->index) {
2767 mainwin->toolbar->getall_btn = item;
2768 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2769 mainwin->toolbar->getall_btn,
2770 _("Receive Mail on all Accounts"), NULL);
2773 mainwin->toolbar->get_btn = item;
2774 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2775 mainwin->toolbar->get_btn,
2776 _("Receive Mail on current Account"), NULL);
2779 mainwin->toolbar->send_btn = item;
2780 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2781 mainwin->toolbar->send_btn,
2782 _("Send Queued Message(s)"), NULL);
2784 case A_COMPOSE_EMAIL:
2785 icon_news = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2786 item_news = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2790 icon_news, toolbar_buttons_cb,
2792 mainwin->toolbar->compose_mail_btn = item;
2793 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2794 mainwin->toolbar->compose_mail_btn,
2795 _("Compose Email"), NULL);
2796 mainwin->toolbar->compose_news_btn = item_news;
2797 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2798 mainwin->toolbar->compose_news_btn,
2799 _("Compose News"), NULL);
2801 case A_REPLY_MESSAGE:
2802 mainwin->toolbar->reply_btn = item;
2803 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2804 mainwin->toolbar->reply_btn,
2805 _("Reply to Message"), NULL);
2806 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->reply_btn),
2807 "button_press_event",
2808 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2810 n_menu_entries = sizeof(reply_popup_entries) /
2811 sizeof(reply_popup_entries[0]);
2812 reply_popup = popupmenu_create(mainwin->window, reply_popup_entries, n_menu_entries,
2813 "<ReplyPopup>", mainwin);
2814 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
2815 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
2816 mainwin->toolbar->reply_popup = reply_popup;
2818 case A_REPLY_SENDER:
2819 mainwin->toolbar->replysender_btn = item;
2820 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2821 mainwin->toolbar->replysender_btn,
2822 _("Reply to Sender"), NULL);
2823 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replysender_btn),
2824 "button_press_event",
2825 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2827 n_menu_entries = sizeof(replysender_popup_entries) /
2828 sizeof(replysender_popup_entries[0]);
2829 replysender_popup = popupmenu_create(mainwin->window,
2830 replysender_popup_entries, n_menu_entries,
2831 "<ReplySenderPopup>", mainwin);
2832 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
2833 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
2834 mainwin->toolbar->replysender_popup = replysender_popup;
2837 mainwin->toolbar->replyall_btn = item;
2838 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2839 mainwin->toolbar->replyall_btn,
2840 _("Reply to All"), NULL);
2841 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replyall_btn),
2842 "button_press_event",
2843 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2845 n_menu_entries = sizeof(replyall_popup_entries) /
2846 sizeof(replyall_popup_entries[0]);
2847 replyall_popup = popupmenu_create(mainwin->window,
2848 replyall_popup_entries, n_menu_entries,
2849 "<ReplyAllPopup>", mainwin);
2850 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
2851 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
2852 mainwin->toolbar->replyall_popup = replyall_popup;
2855 mainwin->toolbar->replylist_btn = item;
2856 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2857 mainwin->toolbar->replylist_btn,
2858 _("Reply to Mailing-list"), NULL);
2859 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replylist_btn),
2860 "button_press_event",
2861 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_cb),
2863 n_menu_entries = sizeof(replylist_popup_entries) /
2864 sizeof(replylist_popup_entries[0]);
2865 replylist_popup = popupmenu_create(mainwin->window,
2866 replylist_popup_entries, n_menu_entries,
2867 "<ReplyMlPopup>", mainwin);
2868 gtk_signal_connect(GTK_OBJECT(replylist_popup), "selection_done",
2869 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_closed_cb), mainwin);
2870 mainwin->toolbar->replylist_popup = replylist_popup;
2873 mainwin->toolbar->fwd_btn = item;
2874 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2875 mainwin->toolbar->fwd_btn,
2876 _("Forward Message"), NULL);
2877 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->fwd_btn),
2878 "button_press_event",
2879 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2881 n_menu_entries = sizeof(fwd_popup_entries) /
2882 sizeof(fwd_popup_entries[0]);
2883 fwd_popup = popupmenu_create(mainwin->window,
2884 fwd_popup_entries, n_menu_entries,
2885 "<ForwardPopup>", mainwin);
2886 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
2887 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
2888 mainwin->toolbar->fwd_popup = fwd_popup;
2891 mainwin->toolbar->delete_btn = item;
2892 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2893 mainwin->toolbar->delete_btn,
2894 _("Delete Message"), NULL);
2897 mainwin->toolbar->exec_btn = item;
2898 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2899 mainwin->toolbar->exec_btn,
2900 _("Execute"), NULL);
2903 mainwin->toolbar->next_btn = item;
2904 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2905 mainwin->toolbar->next_btn,
2906 _("Goto Next Message"), NULL);
2909 t_action_item = g_new0(ToolbarSylpheedActions, 1);
2910 t_action_item->widget = item;
2911 t_action_item->name = g_strdup(toolbar_item->text);
2913 mainwin->toolbar->t_action_list =
2914 g_slist_append(mainwin->toolbar->t_action_list,
2917 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2919 t_action_item->name, NULL);
2921 gtk_widget_show(item);
2928 mainwin->toolbar->toolbar = toolbar;
2930 activate_compose_button(mainwin->toolbar,
2931 prefs_common.toolbar_style,
2932 mainwin->toolbar->compose_btn_type);
2934 gtk_widget_show_all(toolbar);
2937 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2940 switch ((ToolbarStyle)action) {
2942 gtk_widget_hide(mainwin->handlebox);
2944 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2948 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2952 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2957 if (action != TOOLBAR_NONE) {
2958 gtk_widget_show(mainwin->handlebox);
2959 gtk_widget_queue_resize(mainwin->handlebox);
2962 mainwin->toolbar_style = (ToolbarStyle)action;
2963 prefs_common.toolbar_style = (ToolbarStyle)action;
2966 /* END Toolbar Stuff */
2968 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2971 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2972 gtk_widget_show(mainwin->hbox_stat);
2973 prefs_common.show_statusbar = TRUE;
2975 gtk_widget_hide(mainwin->hbox_stat);
2976 prefs_common.show_statusbar = FALSE;
2980 static void separate_widget_cb(MainWindow *mainwin, guint action,
2985 if (GTK_CHECK_MENU_ITEM(widget)->active)
2986 type = mainwin->type | action;
2988 type = mainwin->type & ~action;
2990 main_window_separation_change(mainwin, type);
2992 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2993 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2996 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2998 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2999 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
3001 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3005 static void online_switch_clicked (GtkButton *btn, gpointer data)
3007 MainWindow *mainwin;
3008 GtkItemFactory *ifactory;
3009 GtkCheckMenuItem *menuitem;
3011 mainwin = (MainWindow *) data;
3013 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3014 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3016 g_return_if_fail(mainwin != NULL);
3017 g_return_if_fail(menuitem != NULL);
3019 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3021 gtk_widget_hide (mainwin->online_switch);
3022 gtk_widget_show (mainwin->offline_switch);
3023 menuitem->active = TRUE;
3024 prefs_common.work_offline = TRUE;
3025 inc_autocheck_timer_remove();
3028 gtk_widget_hide (mainwin->offline_switch);
3029 gtk_widget_show (mainwin->online_switch);
3030 menuitem->active = FALSE;
3031 prefs_common.work_offline = FALSE;
3032 inc_autocheck_timer_set();
3036 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3039 addressbook_open(NULL);
3042 static void log_window_show_cb(MainWindow *mainwin, guint action,
3045 log_window_show(mainwin->logwin);
3048 static void sel_download_cb(MainWindow *mainwin, guint action,
3051 selective_download(mainwin);
3054 static void prefs_toolbar_cb(MainWindow *mainwin, guint action,
3057 prefs_toolbar(action);
3061 void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3063 inc_mail(mainwin, prefs_common.newmail_notify_manu);
3066 void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
3069 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
3072 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3077 void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3081 if (prefs_common.work_offline)
3082 if (alertpanel(_("Offline warning"),
3083 _("You're working offline. Override?"),
3084 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
3087 for (list = folder_get_list(); list != NULL; list = list->next) {
3088 Folder *folder = list->data;
3090 if (folder->queue) {
3091 if (procmsg_send_queue
3092 (folder->queue, prefs_common.savemsg) < 0)
3093 alertpanel_error(_("Some errors occurred while sending queued messages."));
3094 statusbar_pop_all();
3095 folder_item_scan(folder->queue);
3096 folderview_update_item(folder->queue, TRUE);
3101 void compose_mail_cb(MainWindow *mainwin, guint action,
3108 if (mainwin->summaryview->folder_item) {
3109 ac = mainwin->summaryview->folder_item->folder->account;
3110 if (ac && ac->protocol != A_NNTP) {
3111 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
3116 if(cur_account && (cur_account->protocol != A_NNTP)) {
3117 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
3121 list = account_get_list();
3122 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3123 ac = (PrefsAccount *) cur->data;
3124 if (ac->protocol != A_NNTP) {
3125 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
3131 void compose_news_cb(MainWindow *mainwin, guint action,
3134 PrefsAccount * ac = NULL;
3138 if (mainwin->summaryview->folder_item) {
3139 ac = mainwin->summaryview->folder_item->folder->account;
3140 if (ac && ac->protocol == A_NNTP) {
3142 mainwin->summaryview->folder_item->path,
3148 list = account_get_list();
3149 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3150 ac = (PrefsAccount *) cur->data;
3151 if (ac->protocol == A_NNTP) {
3152 compose_new(ac, NULL, NULL);
3158 void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3160 summary_reply(mainwin->summaryview, (ComposeMode)action);
3163 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3165 summary_move_to(mainwin->summaryview);
3168 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3170 summary_copy_to(mainwin->summaryview);
3173 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3175 summary_delete(mainwin->summaryview);
3178 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3180 summary_cancel(mainwin->summaryview);
3183 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3185 summary_open_msg(mainwin->summaryview);
3188 static void view_source_cb(MainWindow *mainwin, guint action,
3191 summary_view_source(mainwin->summaryview);
3194 static void show_all_header_cb(MainWindow *mainwin, guint action,
3197 if (mainwin->menu_lock_count) return;
3198 summary_display_msg_selected(mainwin->summaryview,
3199 GTK_CHECK_MENU_ITEM(widget)->active);
3202 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3204 summary_reedit(mainwin->summaryview);