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_filter_open_cb (MainWindow *mainwin,
461 static void prefs_template_open_cb (MainWindow *mainwin,
464 static void prefs_actions_open_cb (MainWindow *mainwin,
467 static void prefs_account_open_cb (MainWindow *mainwin,
470 static void prefs_scoring_open_cb (MainWindow *mainwin,
473 static void prefs_filtering_open_cb (MainWindow *mainwin,
477 static void new_account_cb (MainWindow *mainwin,
481 static void account_menu_cb (GtkMenuItem *menuitem,
484 static void online_switch_clicked(GtkButton *btn,
487 static void manual_open_cb (MainWindow *mainwin,
490 static void faq_open_cb (MainWindow *mainwin,
494 static void scan_tree_func (Folder *folder,
498 static void key_pressed (GtkWidget *widget,
502 static void set_toolbar_style(MainWindow *mainwin);
504 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
506 static void addr_harvest_cb ( MainWindow *mainwin,
510 static void addr_harvest_msg_cb ( MainWindow *mainwin,
514 #define SEPARATE_ACTION 500
516 static GtkItemFactoryEntry mainwin_entries[] =
518 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
519 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
520 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
521 {N_("/_File/_Check for new messages in all folders"),
522 NULL, update_folderview_cb, 0, NULL},
523 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
524 {N_("/_File/_Folder/Create _new folder..."),
525 NULL, new_folder_cb, 0, NULL},
526 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
527 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
528 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
529 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
530 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
531 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
532 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
533 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
534 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
535 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
536 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
537 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
539 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
540 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
541 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
542 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
543 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
544 {N_("/_Edit/_Find in current message..."),
545 "<control>F", search_cb, 0, NULL},
546 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
547 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
548 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
549 {N_("/_View/Show or hi_de/_Folder tree"),
550 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
551 {N_("/_View/Show or hi_de/_Message view"),
552 "V", toggle_message_cb, 0, "<ToggleItem>"},
553 {N_("/_View/Show or hi_de/_Toolbar"),
554 NULL, NULL, 0, "<Branch>"},
555 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
556 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
557 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
558 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
559 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
560 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
561 {N_("/_View/Show or hi_de/_Toolbar/_None"),
562 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
563 {N_("/_View/Show or hi_de/Status _bar"),
564 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
565 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
566 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
567 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
568 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
569 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
570 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
571 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
572 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
573 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
574 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
575 {N_("/_View/_Sort/by _color label"),
576 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
577 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
578 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
579 {N_("/_View/_Sort/by a_ttachment"),
580 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
581 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
582 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
583 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
584 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
585 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
586 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
587 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
588 {N_("/_View/_Sort/_Attract by subject"),
589 NULL, attract_by_subject_cb, 0, NULL},
590 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
591 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
592 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
593 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
594 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
596 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
597 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
598 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
599 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
600 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
601 {N_("/_View/_Go to/P_rev unread message"),
602 "<shift>P", prev_unread_cb, 0, NULL},
603 {N_("/_View/_Go to/N_ext unread message"),
604 "<shift>N", next_unread_cb, 0, NULL},
605 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
606 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
607 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
608 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
609 {N_("/_View/_Go to/Prev _marked message"),
610 NULL, prev_marked_cb, 0, NULL},
611 {N_("/_View/_Go to/Next m_arked message"),
612 NULL, next_marked_cb, 0, NULL},
613 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
614 {N_("/_View/_Go to/Prev _labeled message"),
615 NULL, prev_labeled_cb, 0, NULL},
616 {N_("/_View/_Go to/Next la_beled message"),
617 NULL, next_labeled_cb, 0, NULL},
618 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
619 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
620 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
622 #define CODESET_SEPARATOR \
623 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
624 #define CODESET_ACTION(action) \
625 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
627 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
628 {N_("/_View/_Code set/_Auto detect"),
629 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
630 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
631 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
632 CODESET_ACTION(C_US_ASCII)},
635 {N_("/_View/_Code set/Unicode (_UTF-8)"),
636 CODESET_ACTION(C_UTF_8)},
639 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
640 CODESET_ACTION(C_ISO_8859_1)},
641 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
642 CODESET_ACTION(C_ISO_8859_15)},
645 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
646 CODESET_ACTION(C_ISO_8859_2)},
648 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
649 CODESET_ACTION(C_ISO_8859_13)},
650 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
651 CODESET_ACTION(C_ISO_8859_4)},
653 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
654 CODESET_ACTION(C_ISO_8859_7)},
656 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
657 CODESET_ACTION(C_ISO_8859_9)},
659 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
660 CODESET_ACTION(C_ISO_8859_5)},
661 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
662 CODESET_ACTION(C_KOI8_R)},
663 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
664 CODESET_ACTION(C_WINDOWS_1251)},
667 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
668 CODESET_ACTION(C_ISO_2022_JP)},
670 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
671 CODESET_ACTION(C_ISO_2022_JP_2)},
673 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
674 CODESET_ACTION(C_EUC_JP)},
675 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
676 CODESET_ACTION(C_SHIFT_JIS)},
679 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
680 CODESET_ACTION(C_GB2312)},
681 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
682 CODESET_ACTION(C_BIG5)},
683 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
684 CODESET_ACTION(C_EUC_TW)},
685 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
686 CODESET_ACTION(C_ISO_2022_CN)},
688 {N_("/_View/_Code set/Korean (EUC-_KR)"),
689 CODESET_ACTION(C_EUC_KR)},
690 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
691 CODESET_ACTION(C_ISO_2022_KR)},
693 {N_("/_View/_Code set/Thai (TIS-620)"),
694 CODESET_ACTION(C_TIS_620)},
695 {N_("/_View/_Code set/Thai (Windows-874)"),
696 CODESET_ACTION(C_WINDOWS_874)},
699 #undef CODESET_SEPARATOR
700 #undef CODESET_ACTION
702 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
703 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
704 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
705 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
706 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
707 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
709 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
710 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
711 {N_("/_Message/Get from _all accounts"),
712 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
713 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
714 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
715 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
716 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
717 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
718 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
719 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
720 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
721 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
722 {N_("/_Message/Repl_y to/_sender"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
723 {N_("/_Message/Repl_y to/mailing _list"),
724 "<control>L", reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
725 {N_("/_Message/Follow-up and reply to"),NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
726 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
727 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
728 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
729 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
730 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
731 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
732 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
733 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
734 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
735 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
736 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
737 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
738 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
739 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
740 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
741 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
742 {N_("/_Message/_Mark/Mark as rea_d"),
743 NULL, mark_as_read_cb, 0, NULL},
744 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
746 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
747 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
748 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
749 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
750 {N_("/_Tools/Add sender to address boo_k"),
751 NULL, add_address_cb, 0, NULL},
752 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
753 {N_("/_Tools/_Harvest addresses/from _Folder..."),
754 NULL, addr_harvest_cb, 0, NULL},
755 {N_("/_Tools/_Harvest addresses/from _Messages..."),
756 NULL, addr_harvest_msg_cb, 0, NULL},
757 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
758 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
759 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
760 {N_("/_Tools/_Create filter rule/_Automatically"),
761 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
762 {N_("/_Tools/_Create filter rule/by _From"),
763 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
764 {N_("/_Tools/_Create filter rule/by _To"),
765 NULL, create_filter_cb, FILTER_BY_TO, NULL},
766 {N_("/_Tools/_Create filter rule/by _Subject"),
767 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
768 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
769 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
770 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
771 {N_("/_Tools/Delete du_plicated messages"),
772 NULL, delete_duplicated_cb, 0, NULL},
773 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
774 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
775 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
776 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
778 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
779 {N_("/_Configuration/_Common preferences..."),
780 NULL, prefs_common_open_cb, 0, NULL},
781 {N_("/_Configuration/C_ustom toolbar"),
782 NULL, NULL, 0, "<Branch>"},
783 {N_("/_Configuration/C_ustom toolbar/_Main toolbar..."),
784 NULL, prefs_toolbar_cb, TOOLBAR_MAIN, NULL},
785 {N_("/_Configuration/C_ustom toolbar/_Compose toolbar..."),
786 NULL, prefs_toolbar_cb, TOOLBAR_COMPOSE, NULL},
788 {N_("/_Configuration/_Filter setting..."),
789 NULL, prefs_filter_open_cb, 0, NULL},
791 {N_("/_Configuration/_Scoring..."),
792 NULL, prefs_scoring_open_cb, 0, NULL},
793 {N_("/_Configuration/_Filtering..."),
794 NULL, prefs_filtering_open_cb, 0, NULL},
795 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
796 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
797 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
798 {N_("/_Configuration/_Preferences for current account..."),
799 NULL, prefs_account_open_cb, 0, NULL},
800 {N_("/_Configuration/Create _new account..."),
801 NULL, new_account_cb, 0, NULL},
802 {N_("/_Configuration/_Edit accounts..."),
803 NULL, account_edit_open, 0, NULL},
804 {N_("/_Configuration/C_hange current account"),
805 NULL, NULL, 0, "<Branch>"},
807 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
808 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
809 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
810 {N_("/_Help/_Manual/_German"), NULL, manual_open_cb, MANUAL_LANG_DE, NULL},
811 {N_("/_Help/_Manual/_Spanish"), NULL, manual_open_cb, MANUAL_LANG_ES, NULL},
812 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
813 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
814 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
815 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
816 {N_("/_Help/_FAQ/_German"), NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
817 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
818 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
819 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
820 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
821 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
826 static GtkItemFactoryEntry reply_popup_entries[] =
828 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
829 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
831 static GtkItemFactoryEntry replyall_popup_entries[] =
833 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
834 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
836 static GtkItemFactoryEntry replylist_popup_entries[] =
838 {N_("/Reply to list with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE, NULL},
839 {N_("/_Reply to list without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE, NULL}
841 static GtkItemFactoryEntry replysender_popup_entries[] =
843 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
844 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
846 static GtkItemFactoryEntry fwd_popup_entries[] =
848 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
849 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
852 MainWindow *main_window_create(SeparateType type)
858 GtkWidget *handlebox;
859 GtkWidget *vbox_body;
860 GtkWidget *hbox_stat;
861 GtkWidget *statusbar;
862 GtkWidget *progressbar;
863 GtkWidget *statuslabel;
864 GtkWidget *ac_button;
866 GtkWidget *online_status;
867 GtkWidget *offline_status;
868 GtkWidget *online_switch;
869 GtkWidget *offline_switch;
871 FolderView *folderview;
872 SummaryView *summaryview;
873 MessageView *messageview;
874 GdkColormap *colormap;
877 GtkItemFactory *ifactory;
881 guint n_menu_entries;
883 static GdkGeometry geometry;
885 debug_print("Creating main window...\n");
886 mainwin = g_new0(MainWindow, 1);
889 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
890 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
891 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
892 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
894 if (!geometry.min_height) {
895 geometry.min_width = 320;
896 geometry.min_height = 200;
898 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
901 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
902 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
903 MANAGE_WINDOW_SIGNALS_CONNECT(window);
904 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
905 GTK_SIGNAL_FUNC(key_pressed), mainwin);
907 gtk_widget_realize(window);
908 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
911 gtkut_widget_set_app_icon(window);
913 vbox = gtk_vbox_new(FALSE, 0);
914 gtk_widget_show(vbox);
915 gtk_container_add(GTK_CONTAINER(window), vbox);
918 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
919 menubar = menubar_create(window, mainwin_entries,
920 n_menu_entries, "<Main>", mainwin);
921 gtk_widget_show(menubar);
922 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
923 ifactory = gtk_item_factory_from_widget(menubar);
925 handlebox = gtk_handle_box_new();
926 gtk_widget_show(handlebox);
927 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
929 /* link window to mainwin->window to avoid gdk warnings */
930 mainwin->window = window;
933 toolbar_create(mainwin, handlebox);
935 /* vbox that contains body */
936 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
937 gtk_widget_show(vbox_body);
938 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
939 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
941 hbox_stat = gtk_hbox_new(FALSE, 2);
942 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
944 statusbar = statusbar_create();
945 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
947 progressbar = gtk_progress_bar_new();
948 gtk_widget_set_usize(progressbar, 120, 1);
949 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
951 online_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
952 offline_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
953 online_switch = gtk_button_new ();
954 offline_switch = gtk_button_new ();
955 gtk_container_add (GTK_CONTAINER(online_switch), online_status);
956 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
957 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
958 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
959 gtk_container_add (GTK_CONTAINER(offline_switch), offline_status);
960 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
961 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
962 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
964 statuslabel = gtk_label_new("");
965 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
967 ac_button = gtk_button_new();
968 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
969 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
970 gtk_widget_set_usize(ac_button, -1, 1);
971 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
972 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
973 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
975 ac_label = gtk_label_new("");
976 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
978 gtk_widget_show_all(hbox_stat);
980 gtk_widget_hide(offline_switch);
982 mainwin->folderview = folderview = folderview_create();
983 mainwin->summaryview = summaryview = summary_create();
984 mainwin->messageview = messageview = messageview_create(mainwin);
985 mainwin->logwin = log_window_create();
987 folderview->mainwin = mainwin;
988 folderview->summaryview = summaryview;
990 summaryview->mainwin = mainwin;
991 summaryview->folderview = folderview;
992 summaryview->messageview = messageview;
993 summaryview->window = window;
995 messageview->mainwin = mainwin;
997 mainwin->vbox = vbox;
998 mainwin->menubar = menubar;
999 mainwin->menu_factory = ifactory;
1000 mainwin->handlebox = handlebox;
1001 mainwin->vbox_body = vbox_body;
1002 mainwin->hbox_stat = hbox_stat;
1003 mainwin->statusbar = statusbar;
1004 mainwin->progressbar = progressbar;
1005 mainwin->statuslabel = statuslabel;
1006 mainwin->ac_button = ac_button;
1007 mainwin->ac_label = ac_label;
1009 mainwin->online_switch = online_switch;
1010 mainwin->offline_switch = offline_switch;
1012 /* set context IDs for status bar */
1013 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1014 (GTK_STATUSBAR(statusbar), "Main Window");
1015 mainwin->folderview_cid = gtk_statusbar_get_context_id
1016 (GTK_STATUSBAR(statusbar), "Folder View");
1017 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1018 (GTK_STATUSBAR(statusbar), "Summary View");
1020 /* allocate colors for summary view and folder view */
1021 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1022 summaryview->color_marked.blue = (guint16)65535;
1024 summaryview->color_dim.red = summaryview->color_dim.green =
1025 summaryview->color_dim.blue = COLOR_DIM;
1027 folderview->color_new.red = (guint16)55000;
1028 folderview->color_new.green = folderview->color_new.blue = 15000;
1030 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1031 &folderview->color_op);
1033 summaryview->color_important.red = 0;
1034 summaryview->color_important.green = 0;
1035 summaryview->color_important.blue = (guint16)65535;
1037 color[0] = summaryview->color_marked;
1038 color[1] = summaryview->color_dim;
1039 color[2] = folderview->color_new;
1040 color[3] = folderview->color_op;
1042 colormap = gdk_window_get_colormap(window->window);
1043 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1044 for (i = 0; i < 4; i++) {
1045 if (success[i] == FALSE)
1046 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1049 debug_print("done.\n");
1051 messageview->visible = TRUE;
1053 main_window_set_widgets(mainwin, type);
1055 /* set menu items */
1056 menuitem = gtk_item_factory_get_item
1057 (ifactory, "/View/Code set/Auto detect");
1058 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1060 switch (prefs_common.toolbar_style) {
1062 menuitem = gtk_item_factory_get_item
1063 (ifactory, "/View/Show or hide/Toolbar/None");
1066 menuitem = gtk_item_factory_get_item
1067 (ifactory, "/View/Show or hide/Toolbar/Icon");
1070 menuitem = gtk_item_factory_get_item
1071 (ifactory, "/View/Show or hide/Toolbar/Text");
1074 menuitem = gtk_item_factory_get_item
1075 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1077 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1079 gtk_widget_hide(mainwin->hbox_stat);
1080 menuitem = gtk_item_factory_get_item
1081 (ifactory, "/View/Show or hide/Status bar");
1082 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1083 prefs_common.show_statusbar);
1085 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
1087 if (prefs_common.show_searchbar)
1088 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
1091 /* set account selection menu */
1092 ac_menu = gtk_item_factory_get_widget
1093 (ifactory, "/Configuration/Change current account");
1094 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1095 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1096 mainwin->ac_menu = ac_menu;
1098 toolbar_set_sensitive(mainwin);
1100 /* create actions menu */
1101 update_mainwin_actions_menu(ifactory, mainwin);
1103 /* show main window */
1104 gtk_widget_set_uposition(mainwin->window,
1105 prefs_common.mainwin_x,
1106 prefs_common.mainwin_y);
1107 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1108 prefs_common.mainwin_height);
1109 gtk_widget_show(mainwin->window);
1111 /* initialize views */
1112 folderview_init(folderview);
1113 summary_init(summaryview);
1114 messageview_init(messageview);
1115 log_window_init(mainwin->logwin);
1117 mainwin->lock_count = 0;
1118 mainwin->menu_lock_count = 0;
1119 mainwin->cursor_count = 0;
1122 watch_cursor = gdk_cursor_new(GDK_WATCH);
1124 mainwin_list = g_list_append(mainwin_list, mainwin);
1126 /* init work_offline */
1127 if (prefs_common.work_offline)
1128 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1133 void main_window_cursor_wait(MainWindow *mainwin)
1136 if (mainwin->cursor_count == 0)
1137 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1139 mainwin->cursor_count++;
1144 void main_window_cursor_normal(MainWindow *mainwin)
1146 if (mainwin->cursor_count)
1147 mainwin->cursor_count--;
1149 if (mainwin->cursor_count == 0)
1150 gdk_window_set_cursor(mainwin->window->window, NULL);
1155 /* lock / unlock the user-interface */
1156 void main_window_lock(MainWindow *mainwin)
1158 if (mainwin->lock_count == 0)
1159 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1161 mainwin->lock_count++;
1163 main_window_set_menu_sensitive(mainwin);
1164 toolbar_set_sensitive(mainwin);
1167 void main_window_unlock(MainWindow *mainwin)
1169 if (mainwin->lock_count)
1170 mainwin->lock_count--;
1172 main_window_set_menu_sensitive(mainwin);
1173 toolbar_set_sensitive(mainwin);
1175 if (mainwin->lock_count == 0)
1176 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1179 static void main_window_menu_callback_block(MainWindow *mainwin)
1181 mainwin->menu_lock_count++;
1184 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1186 if (mainwin->menu_lock_count)
1187 mainwin->menu_lock_count--;
1190 void main_window_reflect_prefs_all(void)
1192 main_window_reflect_prefs_all_real(FALSE);
1195 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1198 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);
1215 summary_redisplay_msg(mainwin->summaryview);
1216 headerview_set_visibility(mainwin->messageview->headerview,
1217 prefs_common.display_header_pane);
1221 void main_window_set_summary_column(void)
1224 MainWindow *mainwin;
1226 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1227 mainwin = (MainWindow *)cur->data;
1228 summary_set_column_order(mainwin->summaryview);
1232 void main_window_set_account_menu(GList *account_list)
1234 GList *cur, *cur_ac, *cur_item;
1235 GtkWidget *menuitem;
1236 MainWindow *mainwin;
1237 PrefsAccount *ac_prefs;
1239 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1240 mainwin = (MainWindow *)cur->data;
1242 /* destroy all previous menu item */
1243 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1244 while (cur_item != NULL) {
1245 GList *next = cur_item->next;
1246 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1250 for (cur_ac = account_list; cur_ac != NULL;
1251 cur_ac = cur_ac->next) {
1252 ac_prefs = (PrefsAccount *)cur_ac->data;
1254 menuitem = gtk_menu_item_new_with_label
1255 (ac_prefs->account_name
1256 ? ac_prefs->account_name : _("Untitled"));
1257 gtk_widget_show(menuitem);
1258 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1259 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1260 GTK_SIGNAL_FUNC(account_menu_cb),
1266 static void main_window_show_cur_account(MainWindow *mainwin)
1271 ac_name = g_strdup(cur_account
1272 ? (cur_account->account_name
1273 ? cur_account->account_name : _("Untitled"))
1277 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1279 buf = g_strdup(PROG_VERSION);
1280 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1283 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1284 gtk_widget_queue_resize(mainwin->ac_button);
1289 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1291 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1292 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1293 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1295 debug_print("Changing window separation type from %d to %d\n",
1296 mainwin->type, type);
1298 if (mainwin->type == type) return;
1300 /* remove widgets from those containers */
1301 gtk_widget_ref(folder_wid);
1302 gtk_widget_ref(summary_wid);
1303 gtk_widget_ref(message_wid);
1304 gtkut_container_remove
1305 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1306 gtkut_container_remove
1307 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1308 gtkut_container_remove
1309 (GTK_CONTAINER(message_wid->parent), message_wid);
1311 /* clean containers */
1312 switch (mainwin->type) {
1314 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1316 case SEPARATE_FOLDER:
1317 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1318 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1320 case SEPARATE_MESSAGE:
1321 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1322 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1325 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1326 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1330 gtk_widget_hide(mainwin->window);
1331 main_window_set_widgets(mainwin, type);
1332 gtk_widget_show(mainwin->window);
1334 gtk_widget_unref(folder_wid);
1335 gtk_widget_unref(summary_wid);
1336 gtk_widget_unref(message_wid);
1339 void main_window_toggle_message_view(MainWindow *mainwin)
1341 SummaryView *summaryview = mainwin->summaryview;
1342 union CompositeWin *cwin = &mainwin->win;
1343 GtkWidget *vpaned = NULL;
1344 GtkWidget *container = NULL;
1345 GtkWidget *msgwin = NULL;
1347 switch (mainwin->type) {
1349 vpaned = cwin->sep_none.vpaned;
1350 container = cwin->sep_none.hpaned;
1352 case SEPARATE_FOLDER:
1353 vpaned = cwin->sep_folder.vpaned;
1354 container = mainwin->vbox_body;
1356 case SEPARATE_MESSAGE:
1357 msgwin = mainwin->win.sep_message.messagewin;
1360 msgwin = mainwin->win.sep_both.messagewin;
1365 if (GTK_WIDGET_VISIBLE(msgwin)) {
1366 gtk_widget_hide(msgwin);
1367 mainwin->messageview->visible = FALSE;
1368 summaryview->displayed = NULL;
1370 gtk_widget_show(msgwin);
1371 mainwin->messageview->visible = TRUE;
1373 } else if (vpaned->parent != NULL) {
1374 mainwin->messageview->visible = FALSE;
1375 summaryview->displayed = NULL;
1376 gtk_widget_ref(vpaned);
1377 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1378 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1379 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1380 GTK_ARROW_UP, GTK_SHADOW_OUT);
1382 mainwin->messageview->visible = TRUE;
1383 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1384 gtk_container_add(GTK_CONTAINER(container), vpaned);
1385 gtk_widget_unref(vpaned);
1386 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1387 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1390 main_window_set_menu_sensitive(mainwin);
1392 gtk_widget_grab_focus(summaryview->ctree);
1395 void main_window_get_size(MainWindow *mainwin)
1397 GtkAllocation *allocation;
1399 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1401 prefs_common.summaryview_width = allocation->width;
1403 if ((mainwin->type == SEPARATE_NONE ||
1404 mainwin->type == SEPARATE_FOLDER) &&
1405 messageview_is_visible(mainwin->messageview))
1406 prefs_common.summaryview_height = allocation->height;
1408 prefs_common.mainview_width = allocation->width;
1410 allocation = &mainwin->window->allocation;
1412 prefs_common.mainview_height = allocation->height;
1413 prefs_common.mainwin_width = allocation->width;
1414 prefs_common.mainwin_height = allocation->height;
1416 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1418 prefs_common.folderview_width = allocation->width;
1419 prefs_common.folderview_height = allocation->height;
1422 void main_window_get_position(MainWindow *mainwin)
1426 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1428 prefs_common.mainview_x = x;
1429 prefs_common.mainview_y = y;
1430 prefs_common.mainwin_x = x;
1431 prefs_common.mainwin_y = y;
1433 debug_print("window position: x = %d, y = %d\n", x, y);
1436 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1442 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1443 folder = FOLDER(list->data);
1444 if (folder && folder->trash && folder->trash->total > 0)
1448 if (!has_trash) return;
1451 if (alertpanel(_("Empty trash"),
1452 _("Empty all messages in trash?"),
1453 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1455 manage_window_focus_in(mainwin->window, NULL, NULL);
1458 procmsg_empty_trash();
1460 for (list = folder_get_list(); list != NULL; list = list->next) {
1461 folder = list->data;
1462 if (folder && folder->trash) {
1463 folderview_update_item(folder->trash, TRUE);
1467 if (mainwin->summaryview->folder_item &&
1468 mainwin->summaryview->folder_item->stype == F_TRASH)
1469 gtk_widget_grab_focus(mainwin->folderview->ctree);
1472 void main_window_add_mailbox(MainWindow *mainwin)
1477 path = input_dialog(_("Add mailbox"),
1478 _("Input the location of mailbox.\n"
1479 "If the existing mailbox is specified, it will be\n"
1480 "scanned automatically."),
1483 if (folder_find_from_path(path)) {
1484 alertpanel_error(_("The mailbox `%s' already exists."), path);
1488 if (!strcmp(path, "Mail"))
1489 folder = folder_new(F_MH, _("Mailbox"), path);
1491 folder = folder_new(F_MH, g_basename(path), path);
1494 if (folder->create_tree(folder) < 0) {
1495 alertpanel_error(_("Creation of the mailbox failed.\n"
1496 "Maybe some files already exist, or you don't have the permission to write there."));
1497 folder_destroy(folder);
1502 folder_set_ui_func(folder, scan_tree_func, mainwin);
1503 folder_scan_tree(folder);
1504 folder_set_ui_func(folder, NULL, NULL);
1506 folderview_set(mainwin->folderview);
1509 void main_window_add_mbox(MainWindow *mainwin)
1515 path = input_dialog(_("Add mbox mailbox"),
1516 _("Input the location of mailbox."),
1521 if (folder_find_from_path(path)) {
1522 alertpanel_error(_("The mailbox `%s' already exists."), path);
1528 if (!strcmp(path, "Mail"))
1529 folder = folder_new(F_MBOX, _("Mailbox"), path);
1533 folder = folder_new(F_MBOX, g_basename(path), path);
1536 if (folder->create_tree(folder) < 0) {
1537 alertpanel_error(_("Creation of the mailbox failed."));
1538 folder_destroy(folder);
1544 item = folder_item_new(folder, folder->name, NULL);
1545 item->folder = folder;
1546 folder->node = g_node_new(item);
1548 folder->create_folder(folder, item, "inbox");
1549 folder->create_folder(folder, item, "outbox");
1550 folder->create_folder(folder, item, "queue");
1551 folder->create_folder(folder, item, "draft");
1552 folder->create_folder(folder, item, "trash");
1554 folderview_set(mainwin->folderview);
1557 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1559 SensitiveCond state = 0;
1560 SummarySelection selection;
1561 FolderItem *item = mainwin->summaryview->folder_item;
1562 GList *account_list = account_get_list();
1564 selection = summary_get_selection_type(mainwin->summaryview);
1566 if (mainwin->lock_count == 0)
1567 state |= M_UNLOCKED;
1568 if (selection != SUMMARY_NONE)
1569 state |= M_MSG_EXIST;
1570 if (item && item->path && item->parent && !item->no_select) {
1572 /* if (item->folder->type != F_NEWS) */
1573 state |= M_ALLOW_DELETE;
1575 if (prefs_common.immediate_exec == 0
1576 && mainwin->lock_count == 0)
1577 state |= M_DELAY_EXEC;
1579 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1580 || selection != SUMMARY_NONE)
1581 state |= M_HIDE_READ_MSG;
1583 if (mainwin->summaryview->threaded)
1584 state |= M_THREADED;
1586 state |= M_UNTHREADED;
1587 if (selection == SUMMARY_SELECTED_SINGLE ||
1588 selection == SUMMARY_SELECTED_MULTIPLE)
1589 state |= M_TARGET_EXIST;
1590 if (selection == SUMMARY_SELECTED_SINGLE)
1591 state |= M_SINGLE_TARGET_EXIST;
1592 if (mainwin->summaryview->folder_item &&
1593 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1596 state |= M_NOT_NEWS;
1597 if (selection == SUMMARY_SELECTED_SINGLE &&
1599 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1600 item->stype == F_QUEUE)))
1601 state |= M_ALLOW_REEDIT;
1603 state |= M_HAVE_ACCOUNT;
1605 for ( ; account_list != NULL; account_list = account_list->next) {
1606 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1607 state |= M_HAVE_NEWS_ACCOUNT;
1612 if (inc_is_active())
1613 state |= M_INC_ACTIVE;
1620 void main_window_set_menu_sensitive(MainWindow *mainwin)
1622 GtkItemFactory *ifactory = mainwin->menu_factory;
1623 SensitiveCond state;
1625 GtkWidget *menuitem;
1626 SummaryView *summaryview;
1630 static const struct {
1634 {"/File/Add mailbox..." , M_UNLOCKED},
1635 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1636 {"/File/Check for new messages in all folders", M_UNLOCKED},
1637 {"/File/Folder" , M_UNLOCKED},
1638 {"/File/Import mbox file..." , M_UNLOCKED},
1639 {"/File/Export to mbox file..." , M_UNLOCKED},
1640 {"/File/Empty trash" , M_UNLOCKED},
1641 {"/File/Work offline" , M_UNLOCKED},
1643 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1644 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1645 /* {"/File/Close" , M_UNLOCKED}, */
1646 {"/File/Exit" , M_UNLOCKED},
1648 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1650 {"/View/Sort" , M_EXEC},
1651 {"/View/Thread view" , M_EXEC},
1652 {"/View/Expand all threads" , M_MSG_EXIST},
1653 {"/View/Collapse all threads" , M_MSG_EXIST},
1654 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1655 {"/View/Go to/Prev message" , M_MSG_EXIST},
1656 {"/View/Go to/Next message" , M_MSG_EXIST},
1657 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1658 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1659 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1660 {"/View/Go to/Next new message" , M_MSG_EXIST},
1661 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1662 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1663 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1664 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1665 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1666 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1667 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1669 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1670 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1671 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1672 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1673 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1674 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1675 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1676 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1677 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1678 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1679 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1680 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1681 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1682 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1683 {"/Message/Mark" , M_TARGET_EXIST},
1685 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1686 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1687 {"/Tools/Harvest addresses" , M_UNLOCKED},
1688 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1689 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1690 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1691 {"/Tools/Execute" , M_DELAY_EXEC},
1692 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1694 {"/Configuration", M_UNLOCKED},
1699 state = main_window_get_current_state(mainwin);
1701 for (i = 0; entry[i].entry != NULL; i++) {
1702 sensitive = ((entry[i].cond & state) == entry[i].cond);
1703 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1706 main_window_menu_callback_block(mainwin);
1708 #define SET_CHECK_MENU_ACTIVE(path, active) \
1710 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1711 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1714 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1715 messageview_is_visible(mainwin->messageview));
1717 summaryview = mainwin->summaryview;
1718 menu_path = "/View/Sort/Don't sort";
1720 switch (summaryview->sort_key) {
1721 case SORT_BY_NUMBER:
1722 menu_path = "/View/Sort/by number"; break;
1724 menu_path = "/View/Sort/by size"; break;
1726 menu_path = "/View/Sort/by date"; break;
1728 menu_path = "/View/Sort/by from"; break;
1729 case SORT_BY_SUBJECT:
1730 menu_path = "/View/Sort/by subject"; break;
1732 menu_path = "/View/Sort/by color label"; break;
1734 menu_path = "/View/Sort/by mark"; break;
1735 case SORT_BY_UNREAD:
1736 menu_path = "/View/Sort/by unread"; break;
1738 menu_path = "/View/Sort/by attachment"; break;
1740 menu_path = "/View/Sort/by score"; break;
1741 case SORT_BY_LOCKED:
1742 menu_path = "/View/Sort/by locked"; break;
1745 menu_path = "/View/Sort/Don't sort"; break;
1747 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1749 if (summaryview->sort_type == SORT_ASCENDING) {
1750 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1752 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1755 if (summaryview->sort_key != SORT_BY_NONE) {
1756 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1757 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1759 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1760 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1763 SET_CHECK_MENU_ACTIVE("/View/Show all header",
1764 mainwin->messageview->textview->show_all_headers);
1765 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1767 #undef SET_CHECK_MENU_ACTIVE
1769 main_window_menu_callback_unblock(mainwin);
1772 void main_window_popup(MainWindow *mainwin)
1778 gdk_window_get_origin(mainwin->window->window, &x, &y);
1779 sx = gdk_screen_width();
1780 sy = gdk_screen_height();
1781 x %= sx; if (x < 0) x = 0;
1782 y %= sy; if (y < 0) y = 0;
1783 gdk_window_move(mainwin->window->window, x, y);
1784 gdk_window_raise(mainwin->window->window);
1785 gdk_window_show(mainwin->window->window);
1787 debug_print("window position: x = %d, y = %d\n", x, y);
1789 switch (mainwin->type) {
1790 case SEPARATE_FOLDER:
1791 widget = mainwin->win.sep_folder.folderwin;
1792 gdk_window_get_origin(widget->window, &x, &y);
1793 x %= sx; if (x < 0) x = 0;
1794 y %= sy; if (y < 0) y = 0;
1795 gdk_window_move(widget->window, x, y);
1796 gdk_window_raise(widget->window);
1798 case SEPARATE_MESSAGE:
1799 widget = mainwin->win.sep_message.messagewin;
1800 gdk_window_get_origin(widget->window, &x, &y);
1801 x %= sx; if (x < 0) x = 0;
1802 y %= sy; if (y < 0) y = 0;
1803 gdk_window_move(widget->window, x, y);
1804 gdk_window_raise(widget->window);
1807 widget = mainwin->win.sep_both.folderwin;
1808 gdk_window_get_origin(widget->window, &x, &y);
1809 x %= sx; if (x < 0) x = 0;
1810 y %= sy; if (y < 0) y = 0;
1811 gdk_window_move(widget->window, x, y);
1812 gdk_window_raise(widget->window);
1813 widget = mainwin->win.sep_both.messagewin;
1814 gdk_window_get_origin(widget->window, &x, &y);
1815 x %= sx; if (x < 0) x = 0;
1816 y %= sy; if (y < 0) y = 0;
1817 gdk_window_move(widget->window, x, y);
1818 gdk_window_raise(widget->window);
1825 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1827 GtkWidget *folderwin = NULL;
1828 GtkWidget *messagewin = NULL;
1831 GtkWidget *vbox_body = mainwin->vbox_body;
1832 GtkItemFactory *ifactory = mainwin->menu_factory;
1833 GtkWidget *menuitem;
1835 debug_print("Setting widgets...");
1837 /* create separated window(s) if needed */
1838 if (type & SEPARATE_FOLDER) {
1839 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1840 gtk_window_set_title(GTK_WINDOW(folderwin),
1841 _("Sylpheed - Folder View"));
1842 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1843 "folder_view", "Sylpheed");
1844 gtk_window_set_policy(GTK_WINDOW(folderwin),
1846 gtk_widget_set_usize(folderwin, -1,
1847 prefs_common.mainview_height);
1848 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1850 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1851 GTK_SIGNAL_FUNC(folder_window_close_cb),
1854 if (type & SEPARATE_MESSAGE) {
1855 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1856 gtk_window_set_title(GTK_WINDOW(messagewin),
1857 _("Sylpheed - Message View"));
1858 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1859 "message_view", "Sylpheed");
1860 gtk_window_set_policy(GTK_WINDOW(messagewin),
1862 gtk_widget_set_usize
1863 (messagewin, prefs_common.mainview_width,
1864 prefs_common.mainview_height
1865 - prefs_common.summaryview_height
1866 + DEFAULT_HEADERVIEW_HEIGHT);
1867 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1869 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1870 GTK_SIGNAL_FUNC(message_window_close_cb),
1876 hpaned = gtk_hpaned_new();
1877 gtk_widget_show(hpaned);
1878 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1879 gtk_paned_add1(GTK_PANED(hpaned),
1880 GTK_WIDGET_PTR(mainwin->folderview));
1882 vpaned = gtk_vpaned_new();
1883 if (messageview_is_visible(mainwin->messageview)) {
1884 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1885 gtk_paned_add1(GTK_PANED(vpaned),
1886 GTK_WIDGET_PTR(mainwin->summaryview));
1888 gtk_paned_add2(GTK_PANED(hpaned),
1889 GTK_WIDGET_PTR(mainwin->summaryview));
1890 gtk_widget_ref(vpaned);
1892 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1893 prefs_common.summaryview_width,
1894 prefs_common.summaryview_height);
1895 gtk_paned_add2(GTK_PANED(vpaned),
1896 GTK_WIDGET_PTR(mainwin->messageview));
1897 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1898 prefs_common.mainview_width, -1);
1899 gtk_widget_set_usize(mainwin->window,
1900 prefs_common.folderview_width +
1901 prefs_common.mainview_width,
1902 prefs_common.mainwin_height);
1903 gtk_widget_show_all(vpaned);
1905 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1906 * lose track of its visibility state */
1907 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1908 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1910 mainwin->win.sep_none.hpaned = hpaned;
1911 mainwin->win.sep_none.vpaned = vpaned;
1913 /* remove headerview if not in prefs */
1914 headerview_set_visibility(mainwin->messageview->headerview,
1915 prefs_common.display_header_pane);
1917 case SEPARATE_FOLDER:
1918 vpaned = gtk_vpaned_new();
1919 if (messageview_is_visible(mainwin->messageview)) {
1920 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1922 gtk_paned_add1(GTK_PANED(vpaned),
1923 GTK_WIDGET_PTR(mainwin->summaryview));
1925 gtk_box_pack_start(GTK_BOX(vbox_body),
1926 GTK_WIDGET_PTR(mainwin->summaryview),
1928 gtk_widget_ref(vpaned);
1930 gtk_paned_add2(GTK_PANED(vpaned),
1931 GTK_WIDGET_PTR(mainwin->messageview));
1932 gtk_widget_show_all(vpaned);
1933 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1934 prefs_common.summaryview_width,
1935 prefs_common.summaryview_height);
1936 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1937 prefs_common.mainview_width, -1);
1938 gtk_widget_set_usize(mainwin->window,
1939 prefs_common.mainview_width,
1940 prefs_common.mainview_height);
1942 gtk_container_add(GTK_CONTAINER(folderwin),
1943 GTK_WIDGET_PTR(mainwin->folderview));
1945 mainwin->win.sep_folder.folderwin = folderwin;
1946 mainwin->win.sep_folder.vpaned = vpaned;
1948 gtk_widget_show_all(folderwin);
1950 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1951 * lose track of its visibility state */
1952 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1953 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1955 /* remove headerview if not in prefs */
1956 headerview_set_visibility(mainwin->messageview->headerview,
1957 prefs_common.display_header_pane);
1960 case SEPARATE_MESSAGE:
1961 hpaned = gtk_hpaned_new();
1962 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1964 gtk_paned_add1(GTK_PANED(hpaned),
1965 GTK_WIDGET_PTR(mainwin->folderview));
1966 gtk_paned_add2(GTK_PANED(hpaned),
1967 GTK_WIDGET_PTR(mainwin->summaryview));
1968 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1969 prefs_common.summaryview_width,
1970 prefs_common.summaryview_height);
1971 gtk_widget_set_usize(mainwin->window,
1972 prefs_common.folderview_width +
1973 prefs_common.mainview_width,
1974 prefs_common.mainwin_height);
1975 gtk_widget_show_all(hpaned);
1976 gtk_container_add(GTK_CONTAINER(messagewin),
1977 GTK_WIDGET_PTR(mainwin->messageview));
1979 mainwin->win.sep_message.messagewin = messagewin;
1980 mainwin->win.sep_message.hpaned = hpaned;
1982 gtk_widget_show_all(messagewin);
1984 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1985 * lose track of its visibility state */
1986 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1987 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1990 gtk_box_pack_start(GTK_BOX(vbox_body),
1991 GTK_WIDGET_PTR(mainwin->summaryview),
1993 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1994 prefs_common.summaryview_width,
1995 prefs_common.summaryview_height);
1996 gtk_widget_set_usize(mainwin->window,
1997 prefs_common.mainview_width,
1998 prefs_common.mainwin_height);
1999 gtk_container_add(GTK_CONTAINER(folderwin),
2000 GTK_WIDGET_PTR(mainwin->folderview));
2001 gtk_container_add(GTK_CONTAINER(messagewin),
2002 GTK_WIDGET_PTR(mainwin->messageview));
2004 mainwin->win.sep_both.folderwin = folderwin;
2005 mainwin->win.sep_both.messagewin = messagewin;
2007 gtk_widget_show_all(folderwin);
2008 gtk_widget_show_all(messagewin);
2010 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2011 * lose track of its visibility state */
2012 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2013 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2017 /* rehide quick search if necessary */
2018 if (!prefs_common.show_searchbar)
2019 gtk_widget_hide(mainwin->summaryview->hbox_search);
2021 mainwin->type = type;
2023 mainwin->messageview->visible = TRUE;
2025 /* toggle menu state */
2026 menuitem = gtk_item_factory_get_item
2027 (ifactory, "/View/Show or hide/Folder tree");
2028 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2029 menuitem = gtk_item_factory_get_item
2030 (ifactory, "/View/Show or hide/Message view");
2031 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2033 menuitem = gtk_item_factory_get_item
2034 (ifactory, "/View/Separate folder tree");
2035 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2036 ((type & SEPARATE_FOLDER) != 0));
2037 menuitem = gtk_item_factory_get_item
2038 (ifactory, "/View/Separate message view");
2039 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2040 ((type & SEPARATE_MESSAGE) != 0));
2042 debug_print("done.\n");
2045 void main_window_destroy_all(void)
2047 while (mainwin_list != NULL) {
2048 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2050 /* free toolbar stuff */
2051 toolbar_clear_list(TOOLBAR_MAIN);
2052 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->t_action_list);
2053 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->t_item_list);
2055 g_free(mainwin->toolbar);
2058 mainwin_list = g_list_remove(mainwin_list, mainwin);
2060 g_list_free(mainwin_list);
2064 static void toolbar_account_button_pressed(GtkWidget *widget,
2065 GdkEventButton *event,
2068 MainWindow *mainwin = (MainWindow *)data;
2071 if (event->button != 3) return;
2073 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2074 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2077 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2078 menu_button_position, widget,
2079 event->button, event->time);
2083 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2086 MainWindow *mainwin = (MainWindow *)data;
2090 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2091 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2094 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2095 menu_button_position, widget,
2096 event->button, event->time);
2099 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2101 MainWindow *mainwin = (MainWindow *)data;
2104 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2105 if (!button) return;
2106 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2107 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2108 manage_window_focus_in(mainwin->window, NULL, NULL);
2111 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2114 MainWindow *mainwin = (MainWindow *)data;
2116 if (mainwin->lock_count == 0)
2117 app_exit_cb(data, 0, widget);
2122 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2125 MainWindow *mainwin = (MainWindow *)data;
2126 GtkWidget *menuitem;
2128 menuitem = gtk_item_factory_get_item
2129 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2130 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2135 static gint message_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/Message view");
2143 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2148 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2151 main_window_add_mailbox(mainwin);
2154 static void add_mbox_cb(MainWindow *mainwin, guint action,
2157 main_window_add_mbox(mainwin);
2160 static void update_folderview_cb(MainWindow *mainwin, guint action,
2163 summary_show(mainwin->summaryview, NULL);
2164 folderview_check_new_all();
2167 static void new_folder_cb(MainWindow *mainwin, guint action,
2170 folderview_new_folder(mainwin->folderview);
2173 static void rename_folder_cb(MainWindow *mainwin, guint action,
2176 folderview_rename_folder(mainwin->folderview);
2179 static void delete_folder_cb(MainWindow *mainwin, guint action,
2182 folderview_delete_folder(mainwin->folderview);
2185 static void import_mbox_cb(MainWindow *mainwin, guint action,
2188 import_mbox(mainwin->summaryview->folder_item);
2191 static void export_mbox_cb(MainWindow *mainwin, guint action,
2194 export_mbox(mainwin->summaryview->folder_item);
2197 static void empty_trash_cb(MainWindow *mainwin, guint action,
2200 main_window_empty_trash(mainwin, TRUE);
2203 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2205 summary_save_as(mainwin->summaryview);
2208 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2210 summary_print(mainwin->summaryview);
2213 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2215 if (prefs_common.confirm_on_exit) {
2216 if (alertpanel(_("Exit"), _("Exit this program?"),
2217 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2219 manage_window_focus_in(mainwin->window, NULL, NULL);
2222 app_will_exit(widget, mainwin);
2225 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2228 summary_search(mainwin->summaryview);
2230 message_search(mainwin->messageview);
2233 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2238 active = GTK_CHECK_MENU_ITEM(widget)->active;
2240 switch (mainwin->type) {
2242 case SEPARATE_MESSAGE:
2245 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2247 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2250 case SEPARATE_FOLDER:
2251 debug_print("separate folder\n");
2253 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2255 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2259 gtk_widget_show(mainwin->win.sep_both.folderwin);
2261 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2266 static void toggle_message_cb(MainWindow *mainwin, guint action,
2271 active = GTK_CHECK_MENU_ITEM(widget)->active;
2273 if (active != messageview_is_visible(mainwin->messageview))
2274 summary_toggle_view(mainwin->summaryview);
2277 /* Toolbar handling */
2278 static void toolbar_inc_cb(GtkWidget *widget,
2281 MainWindow *mainwin = (MainWindow *)data;
2283 inc_mail_cb(mainwin, 0, NULL);
2286 static void toolbar_inc_all_cb(GtkWidget *widget,
2289 MainWindow *mainwin = (MainWindow *)data;
2291 inc_all_account_mail_cb(mainwin, 0, NULL);
2294 static void toolbar_send_cb(GtkWidget *widget,
2297 MainWindow *mainwin = (MainWindow *)data;
2299 send_queue_cb(mainwin, 0, NULL);
2302 static void toolbar_compose_cb(GtkWidget *widget,
2305 MainWindow *mainwin = (MainWindow *)data;
2307 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
2308 compose_news_cb(mainwin, 0, NULL);
2310 compose_mail_cb(mainwin, 0, NULL);
2313 static void toolbar_reply_cb(GtkWidget *widget,
2316 MainWindow *mainwin = (MainWindow *)data;
2319 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2320 : COMPOSE_REPLY_WITHOUT_QUOTE,
2324 static void toolbar_reply_to_all_cb(GtkWidget *widget,
2327 MainWindow *mainwin = (MainWindow *)data;
2330 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2331 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2335 static void toolbar_reply_to_list_cb(GtkWidget *widget,
2338 MainWindow *mainwin = (MainWindow *)data;
2341 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
2342 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
2346 static void toolbar_reply_to_sender_cb(GtkWidget *widget,
2349 MainWindow *mainwin = (MainWindow *)data;
2352 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2353 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2357 static void toolbar_forward_cb(GtkWidget *widget,
2360 MainWindow *mainwin = (MainWindow *)data;
2362 if (prefs_common.forward_as_attachment)
2363 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2365 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2368 static void toolbar_delete_cb(GtkWidget *widget,
2371 MainWindow *mainwin = (MainWindow *)data;
2373 summary_delete(mainwin->summaryview);
2376 static void toolbar_exec_cb(GtkWidget *widget,
2379 MainWindow *mainwin = (MainWindow *)data;
2381 summary_execute(mainwin->summaryview);
2384 static void toolbar_next_unread_cb(GtkWidget *widget,
2387 MainWindow *mainwin = (MainWindow *)data;
2389 next_unread_cb(mainwin, 0, NULL);
2392 /* popup callback functions */
2393 static void toolbar_reply_popup_cb(GtkWidget *widget,
2394 GdkEventButton *event,
2397 MainWindow *mainwindow = (MainWindow *) data;
2401 if (event->button == 3) {
2402 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2403 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->reply_popup), NULL, NULL,
2404 menu_button_position, widget,
2405 event->button, event->time);
2409 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2411 MainWindow *mainwin = (MainWindow *)data;
2413 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->reply_btn), GTK_RELIEF_NONE);
2414 manage_window_focus_in(mainwin->window, NULL, NULL);
2417 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2419 MainWindow *mainwindow = (MainWindow *) data;
2423 if (event->button == 3) {
2424 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2425 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replyall_popup), NULL, NULL,
2426 menu_button_position, widget,
2427 event->button, event->time);
2431 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2433 MainWindow *mainwin = (MainWindow *)data;
2435 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replyall_btn), GTK_RELIEF_NONE);
2436 manage_window_focus_in(mainwin->window, NULL, NULL);
2439 static void toolbar_reply_to_list_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2441 MainWindow *mainwindow = (MainWindow *) data;
2445 if (event->button == 3) {
2446 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2447 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replylist_popup), NULL, NULL,
2448 menu_button_position, widget,
2449 event->button, event->time);
2453 static void toolbar_reply_to_list_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2455 MainWindow *mainwin = (MainWindow *)data;
2457 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replylist_btn), GTK_RELIEF_NONE);
2458 manage_window_focus_in(mainwin->window, NULL, NULL);
2461 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2463 MainWindow *mainwindow = (MainWindow *) data;
2467 if (event->button == 3) {
2468 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2469 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replysender_popup), NULL, NULL,
2470 menu_button_position, widget,
2471 event->button, event->time);
2475 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2477 MainWindow *mainwin = (MainWindow *)data;
2479 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replysender_btn), GTK_RELIEF_NONE);
2480 manage_window_focus_in(mainwin->window, NULL, NULL);
2483 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2485 MainWindow *mainwindow = (MainWindow *) data;
2489 if (event->button == 3) {
2490 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2491 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->fwd_popup), NULL, NULL,
2492 menu_button_position, widget,
2493 event->button, event->time);
2497 static void toolbar_forward_popup_closed_cb (GtkMenuShell *menu_shell,
2500 MainWindow *mainwin = (MainWindow *)data;
2502 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->fwd_btn), GTK_RELIEF_NONE);
2503 manage_window_focus_in(mainwin->window, NULL, NULL);
2506 static void activate_compose_button (MainToolbar *toolbar,
2508 ComposeButtonType type)
2510 if ((!toolbar->compose_mail_btn) || (!toolbar->compose_news_btn))
2513 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? toolbar->compose_mail_btn
2514 : toolbar->compose_news_btn);
2515 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? toolbar->compose_news_btn
2516 : toolbar->compose_mail_btn);
2517 toolbar->compose_btn_type = type;
2520 void toolbar_set_compose_button(MainToolbar *toolbar,
2521 ComposeButtonType compose_btn_type)
2523 if (toolbar->compose_btn_type != compose_btn_type)
2524 activate_compose_button(toolbar,
2525 prefs_common.toolbar_style,
2529 static void toolbar_buttons_cb(GtkWidget *widget,
2530 ToolbarItem *t_item)
2534 void (*func)(GtkWidget *widget, gpointer data);
2535 } toolbar_action[] = {
2536 { A_RECEIVE_ALL, toolbar_inc_all_cb },
2537 { A_RECEIVE_CUR, toolbar_inc_cb },
2538 { A_SEND_QUEUED, toolbar_send_cb },
2539 { A_COMPOSE_EMAIL, toolbar_compose_cb },
2540 { A_REPLY_MESSAGE, toolbar_reply_cb },
2541 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
2542 { A_REPLY_ALL, toolbar_reply_to_all_cb },
2543 { A_REPLY_ML, toolbar_reply_to_list_cb },
2544 { A_FORWARD, toolbar_forward_cb },
2545 { A_DELETE, toolbar_delete_cb },
2546 { A_EXECUTE, toolbar_exec_cb },
2547 { A_GOTO_NEXT, toolbar_next_unread_cb },
2548 { A_SYL_ACTIONS, toolbar_actions_execute_cb },
2550 { A_COMPOSE_NEWS, toolbar_compose_cb },
2551 { A_SEPARATOR, NULL }};
2553 gint num_items = sizeof(toolbar_action)/sizeof(toolbar_action[0]);
2556 for (i = A_RECEIVE_ALL; i < num_items; i++) {
2558 if (toolbar_action[i].index == t_item->index) {
2559 MainWindow *mainwin = (MainWindow*)t_item->parent;
2560 toolbar_action[i].func(widget, mainwin);
2566 static void toolbar_actions_execute_cb(GtkWidget *widget,
2569 MainWindow *mainwin = (MainWindow*)data;
2571 toolbar_action_execute(widget, mainwin->toolbar->t_action_list, data, TOOLBAR_MAIN);
2574 void toolbar_set_sensitive(MainWindow *mainwin)
2576 SensitiveCond state;
2578 MainToolbar *toolbar = mainwin->toolbar;
2580 GSList *entry_list = NULL;
2582 typedef struct _Entry Entry;
2589 #define SET_WIDGET_COND(w, c) \
2591 Entry *e = g_new0(Entry, 1); \
2594 entry_list = g_slist_append(entry_list, e); \
2597 SET_WIDGET_COND(toolbar->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2598 SET_WIDGET_COND(toolbar->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2599 SET_WIDGET_COND(toolbar->compose_news_btn, M_HAVE_ACCOUNT);
2600 SET_WIDGET_COND(toolbar->reply_btn,
2601 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2602 SET_WIDGET_COND(toolbar->replyall_btn,
2603 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2604 SET_WIDGET_COND(toolbar->replylist_btn,
2605 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2606 SET_WIDGET_COND(toolbar->replysender_btn,
2607 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2608 SET_WIDGET_COND(toolbar->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
2610 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST);
2611 SET_WIDGET_COND(toolbar->delete_btn,
2612 M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
2613 SET_WIDGET_COND(toolbar->exec_btn, M_DELAY_EXEC);
2615 for (cur = toolbar->t_action_list; cur != NULL; cur = cur->next) {
2616 ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
2618 SET_WIDGET_COND(act->widget, M_TARGET_EXIST|M_UNLOCKED);
2621 #undef SET_WIDGET_COND
2623 state = main_window_get_current_state(mainwin);
2625 for (cur = entry_list; cur != NULL; cur = cur->next) {
2626 Entry *e = (Entry*) cur->data;
2628 if (e->widget != NULL) {
2629 sensitive = ((e->cond & state) == e->cond);
2630 gtk_widget_set_sensitive(e->widget, sensitive);
2634 while (entry_list != NULL) {
2635 Entry *e = (Entry*) entry_list->data;
2639 entry_list = g_slist_remove(entry_list, e);
2642 g_slist_free(entry_list);
2644 activate_compose_button(toolbar,
2645 prefs_common.toolbar_style,
2646 toolbar->compose_btn_type);
2649 static void toolbar_update(MainWindow *mainwin)
2651 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox),
2652 GTK_WIDGET(mainwin->toolbar->toolbar));
2654 mainwin->toolbar->toolbar = NULL;
2655 mainwin->toolbar->get_btn = NULL;
2656 mainwin->toolbar->getall_btn = NULL;
2657 mainwin->toolbar->send_btn = NULL;
2658 mainwin->toolbar->compose_mail_btn = NULL;
2659 mainwin->toolbar->compose_news_btn = NULL;
2660 mainwin->toolbar->reply_btn = NULL;
2661 mainwin->toolbar->replyall_btn = NULL;
2662 mainwin->toolbar->replylist_btn = NULL;
2663 mainwin->toolbar->replysender_btn = NULL;
2664 mainwin->toolbar->fwd_btn = NULL;
2665 mainwin->toolbar->delete_btn = NULL;
2666 mainwin->toolbar->next_btn = NULL;
2667 mainwin->toolbar->exec_btn = NULL;
2669 toolbar_clear_list(TOOLBAR_MAIN);
2670 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->t_action_list);
2671 toolbar_create(mainwin, mainwin->handlebox);
2672 toolbar_set_sensitive(mainwin);
2676 static void toolbar_create(MainWindow *mainwin,
2677 GtkWidget *container)
2679 ToolbarItem *toolbar_item;
2682 GtkWidget *icon_wid = NULL;
2683 GtkWidget *icon_news = NULL;
2684 GtkWidget *item_news = NULL;
2686 GtkTooltips *toolbar_tips;
2687 ToolbarSylpheedActions *t_action_item;
2689 GSList *toolbar_list;
2691 guint n_menu_entries;
2692 GtkWidget *reply_popup;
2693 GtkWidget *replyall_popup;
2694 GtkWidget *replylist_popup;
2695 GtkWidget *replysender_popup;
2696 GtkWidget *fwd_popup;
2698 toolbar_tips = gtk_tooltips_new();
2700 if (mainwin->toolbar != NULL) {
2701 toolbar_clear_list(TOOLBAR_MAIN);
2702 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->t_action_list);
2703 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->t_item_list);
2704 g_free(mainwin->toolbar);
2707 toolbar_read_config_file(TOOLBAR_MAIN);
2708 toolbar_list = toolbar_get_list(TOOLBAR_MAIN);
2710 mainwin->toolbar = g_new0(MainToolbar, 1);
2712 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
2714 gtk_container_add(GTK_CONTAINER(container), toolbar);
2715 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
2716 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
2717 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
2718 GTK_TOOLBAR_SPACE_LINE);
2720 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2722 if (g_strcasecmp(((ToolbarItem*)cur->data)->file, SEPARATOR) == 0) {
2723 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2727 toolbar_item = g_new0(ToolbarItem, 1);
2728 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2729 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2730 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2732 toolbar_item->parent = (gpointer)mainwin;
2734 /* collect toolbar items in list to keep track */
2735 mainwin->toolbar->t_item_list = g_slist_append(mainwin->toolbar->t_item_list,
2738 icon_wid = stock_pixmap_widget(container, stock_pixmap_get_icon(toolbar_item->file));
2739 item = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2743 icon_wid, toolbar_buttons_cb,
2746 switch (toolbar_item->index) {
2748 mainwin->toolbar->getall_btn = item;
2749 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2750 mainwin->toolbar->getall_btn,
2751 _("Receive Mail on all Accounts"), NULL);
2754 mainwin->toolbar->get_btn = item;
2755 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2756 mainwin->toolbar->get_btn,
2757 _("Receive Mail on current Account"), NULL);
2760 mainwin->toolbar->send_btn = item;
2761 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2762 mainwin->toolbar->send_btn,
2763 _("Send Queued Message(s)"), NULL);
2765 case A_COMPOSE_EMAIL:
2766 icon_news = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2767 item_news = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2771 icon_news, toolbar_buttons_cb,
2773 mainwin->toolbar->compose_mail_btn = item;
2774 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2775 mainwin->toolbar->compose_mail_btn,
2776 _("Compose Email"), NULL);
2777 mainwin->toolbar->compose_news_btn = item_news;
2778 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2779 mainwin->toolbar->compose_news_btn,
2780 _("Compose News"), NULL);
2782 case A_REPLY_MESSAGE:
2783 mainwin->toolbar->reply_btn = item;
2784 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2785 mainwin->toolbar->reply_btn,
2786 _("Reply to Message"), NULL);
2787 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->reply_btn),
2788 "button_press_event",
2789 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2791 n_menu_entries = sizeof(reply_popup_entries) /
2792 sizeof(reply_popup_entries[0]);
2793 reply_popup = popupmenu_create(mainwin->window, reply_popup_entries, n_menu_entries,
2794 "<ReplyPopup>", mainwin);
2795 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
2796 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
2797 mainwin->toolbar->reply_popup = reply_popup;
2799 case A_REPLY_SENDER:
2800 mainwin->toolbar->replysender_btn = item;
2801 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2802 mainwin->toolbar->replysender_btn,
2803 _("Reply to Sender"), NULL);
2804 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replysender_btn),
2805 "button_press_event",
2806 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2808 n_menu_entries = sizeof(replysender_popup_entries) /
2809 sizeof(replysender_popup_entries[0]);
2810 replysender_popup = popupmenu_create(mainwin->window,
2811 replysender_popup_entries, n_menu_entries,
2812 "<ReplySenderPopup>", mainwin);
2813 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
2814 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
2815 mainwin->toolbar->replysender_popup = replysender_popup;
2818 mainwin->toolbar->replyall_btn = item;
2819 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2820 mainwin->toolbar->replyall_btn,
2821 _("Reply to All"), NULL);
2822 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replyall_btn),
2823 "button_press_event",
2824 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2826 n_menu_entries = sizeof(replyall_popup_entries) /
2827 sizeof(replyall_popup_entries[0]);
2828 replyall_popup = popupmenu_create(mainwin->window,
2829 replyall_popup_entries, n_menu_entries,
2830 "<ReplyAllPopup>", mainwin);
2831 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
2832 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
2833 mainwin->toolbar->replyall_popup = replyall_popup;
2836 mainwin->toolbar->replylist_btn = item;
2837 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2838 mainwin->toolbar->replylist_btn,
2839 _("Reply to Mailing-list"), NULL);
2840 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replylist_btn),
2841 "button_press_event",
2842 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_cb),
2844 n_menu_entries = sizeof(replylist_popup_entries) /
2845 sizeof(replylist_popup_entries[0]);
2846 replylist_popup = popupmenu_create(mainwin->window,
2847 replylist_popup_entries, n_menu_entries,
2848 "<ReplyMlPopup>", mainwin);
2849 gtk_signal_connect(GTK_OBJECT(replylist_popup), "selection_done",
2850 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_closed_cb), mainwin);
2851 mainwin->toolbar->replylist_popup = replylist_popup;
2854 mainwin->toolbar->fwd_btn = item;
2855 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2856 mainwin->toolbar->fwd_btn,
2857 _("Forward Message"), NULL);
2858 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->fwd_btn),
2859 "button_press_event",
2860 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2862 n_menu_entries = sizeof(fwd_popup_entries) /
2863 sizeof(fwd_popup_entries[0]);
2864 fwd_popup = popupmenu_create(mainwin->window,
2865 fwd_popup_entries, n_menu_entries,
2866 "<ForwardPopup>", mainwin);
2867 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
2868 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
2869 mainwin->toolbar->fwd_popup = fwd_popup;
2872 mainwin->toolbar->delete_btn = item;
2873 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2874 mainwin->toolbar->delete_btn,
2875 _("Delete Message"), NULL);
2878 mainwin->toolbar->exec_btn = item;
2879 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2880 mainwin->toolbar->exec_btn,
2881 _("Execute"), NULL);
2884 mainwin->toolbar->next_btn = item;
2885 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2886 mainwin->toolbar->next_btn,
2887 _("Goto Next Message"), NULL);
2890 t_action_item = g_new0(ToolbarSylpheedActions, 1);
2891 t_action_item->widget = item;
2892 t_action_item->name = g_strdup(toolbar_item->text);
2894 mainwin->toolbar->t_action_list =
2895 g_slist_append(mainwin->toolbar->t_action_list,
2898 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2900 t_action_item->name, NULL);
2902 gtk_widget_show(item);
2909 mainwin->toolbar->toolbar = toolbar;
2911 activate_compose_button(mainwin->toolbar,
2912 prefs_common.toolbar_style,
2913 mainwin->toolbar->compose_btn_type);
2915 gtk_widget_show_all(toolbar);
2918 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2921 switch ((ToolbarStyle)action) {
2923 gtk_widget_hide(mainwin->handlebox);
2925 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2929 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2933 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2938 if (action != TOOLBAR_NONE) {
2939 gtk_widget_show(mainwin->handlebox);
2940 gtk_widget_queue_resize(mainwin->handlebox);
2943 mainwin->toolbar_style = (ToolbarStyle)action;
2944 prefs_common.toolbar_style = (ToolbarStyle)action;
2947 /* END Toolbar Stuff */
2949 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2952 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2953 gtk_widget_show(mainwin->hbox_stat);
2954 prefs_common.show_statusbar = TRUE;
2956 gtk_widget_hide(mainwin->hbox_stat);
2957 prefs_common.show_statusbar = FALSE;
2961 static void separate_widget_cb(MainWindow *mainwin, guint action,
2966 if (GTK_CHECK_MENU_ITEM(widget)->active)
2967 type = mainwin->type | action;
2969 type = mainwin->type & ~action;
2971 main_window_separation_change(mainwin, type);
2973 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2974 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2977 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2979 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2980 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2982 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2986 static void online_switch_clicked (GtkButton *btn, gpointer data)
2988 MainWindow *mainwin;
2989 GtkItemFactory *ifactory;
2990 GtkCheckMenuItem *menuitem;
2992 mainwin = (MainWindow *) data;
2994 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2995 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2997 g_return_if_fail(mainwin != NULL);
2998 g_return_if_fail(menuitem != NULL);
3000 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3002 gtk_widget_hide (mainwin->online_switch);
3003 gtk_widget_show (mainwin->offline_switch);
3004 menuitem->active = TRUE;
3005 prefs_common.work_offline = TRUE;
3006 inc_autocheck_timer_remove();
3009 gtk_widget_hide (mainwin->offline_switch);
3010 gtk_widget_show (mainwin->online_switch);
3011 menuitem->active = FALSE;
3012 prefs_common.work_offline = FALSE;
3013 inc_autocheck_timer_set();
3017 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3020 addressbook_open(NULL);
3023 static void log_window_show_cb(MainWindow *mainwin, guint action,
3026 log_window_show(mainwin->logwin);
3029 static void sel_download_cb(MainWindow *mainwin, guint action,
3032 selective_download(mainwin);
3035 static void prefs_toolbar_cb(MainWindow *mainwin, guint action,
3038 prefs_toolbar(action);
3042 void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3044 inc_mail(mainwin, prefs_common.newmail_notify_manu);
3047 void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
3050 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
3053 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3058 void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3062 if (prefs_common.work_offline)
3063 if (alertpanel(_("Offline warning"),
3064 _("You're working offline. Override?"),
3065 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
3068 for (list = folder_get_list(); list != NULL; list = list->next) {
3069 Folder *folder = list->data;
3071 if (folder->queue) {
3072 if (procmsg_send_queue
3073 (folder->queue, prefs_common.savemsg) < 0)
3074 alertpanel_error(_("Some errors occurred while sending queued messages."));
3075 statusbar_pop_all();
3076 folder_item_scan(folder->queue);
3077 folderview_update_item(folder->queue, TRUE);
3082 void compose_mail_cb(MainWindow *mainwin, guint action,
3089 if (mainwin->summaryview->folder_item) {
3090 ac = mainwin->summaryview->folder_item->folder->account;
3091 if (ac && ac->protocol != A_NNTP) {
3092 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
3097 if(cur_account && (cur_account->protocol != A_NNTP)) {
3098 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
3102 list = account_get_list();
3103 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3104 ac = (PrefsAccount *) cur->data;
3105 if (ac->protocol != A_NNTP) {
3106 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
3112 void compose_news_cb(MainWindow *mainwin, guint action,
3115 PrefsAccount * ac = NULL;
3119 if (mainwin->summaryview->folder_item) {
3120 ac = mainwin->summaryview->folder_item->folder->account;
3121 if (ac && ac->protocol == A_NNTP) {
3123 mainwin->summaryview->folder_item->path,
3129 list = account_get_list();
3130 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3131 ac = (PrefsAccount *) cur->data;
3132 if (ac->protocol == A_NNTP) {
3133 compose_new(ac, NULL, NULL);
3139 void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3141 summary_reply(mainwin->summaryview, (ComposeMode)action);
3144 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3146 summary_move_to(mainwin->summaryview);
3149 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3151 summary_copy_to(mainwin->summaryview);
3154 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3156 summary_delete(mainwin->summaryview);
3159 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3161 summary_cancel(mainwin->summaryview);
3164 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3166 summary_open_msg(mainwin->summaryview);
3169 static void view_source_cb(MainWindow *mainwin, guint action,
3172 summary_view_source(mainwin->summaryview);
3175 static void show_all_header_cb(MainWindow *mainwin, guint action,
3178 if (mainwin->menu_lock_count) return;
3179 summary_display_msg_selected(mainwin->summaryview,
3180 GTK_CHECK_MENU_ITEM(widget)->active);
3183 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3185 summary_reedit(mainwin->summaryview);
3188 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3190 summary_mark(mainwin->summaryview);
3193 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3195 summary_unmark(mainwin->summaryview);
3198 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3201 summary_mark_as_unread(mainwin->summaryview);
3204 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3207 summary_mark_as_read(mainwin->summaryview);
3210 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3213 summary_mark_all_read(mainwin->summaryview);
3216 static void add_address_cb(MainWindow *mainwin, guint action,
3219 summary_add_address(mainwin->summaryview);
3222 static void set_charset_cb(MainWindow *mainwin, guint action,
3227 str = conv_get_charset_str((CharSet)action);
3228 g_free(prefs_common.force_charset);
3229 prefs_common.force_charset = str ? g_strdup(str) : NULL;
3231 summary_redisplay_msg(mainwin->summaryview);
3233 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3236 static void hide_read_messages (MainWindow *mainwin, guint action,
3239 if (!mainwin->summaryview->folder_item
3240 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
3242 summary_toggle_show_read_messages(mainwin->summaryview);
3245 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3247 if (mainwin->menu_lock_count) return;
3248 if (!mainwin->summaryview->folder_item) return;
3250 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3251 summary_thread_build(mainwin->summaryview);
3252 /* mainwin->summaryview->folder_item->threaded = TRUE; */
3254 summary_unthread(mainwin->summaryview);
3255 /* mainwin->summaryview->folder_item->threaded = FALSE; */
3259 static void expand_threads_cb(MainWindow *mainwin, guint action,
3262 summary_expand_threads(mainwin->summaryview);
3265 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3268 summary_collapse_threads(mainwin->summaryview);
3271 static void set_display_item_cb(MainWindow *mainwin, guint action,
3274 prefs_summary_column_open();
3277 static void sort_summary_cb(MainWindow *mainwin, guint action,
3280 FolderItem *item = mainwin->summaryview->folder_item;
3281 GtkWidget *menuitem;
3283 if (mainwin->menu_lock_count) return;
3285 menuitem = gtk_item_factory_get_item
3286 (mainwin->menu_factory, "/View/Sort/Ascending");
3287 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3288 GTK_CHECK_MENU_ITEM(menuitem)->active
3289 ? SORT_ASCENDING : SORT_DESCENDING);
3293 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3296 FolderItem *item = mainwin->summaryview->folder_item;
3298 if (mainwin->menu_lock_count) return;
3300 summary_sort(mainwin->summaryview,
3301 item->sort_key, (FolderSortType)action);
3304 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3307 summary_attract_by_subject(mainwin->summaryview);
3310 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3313 summary_delete_duplicated(mainwin->summaryview);
3316 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3318 summary_filter(mainwin->summaryview);
3321 static void execute_summary_cb(MainWindow *mainwin, guint action,
3324 summary_execute(mainwin->summaryview);
3327 static void update_summary_cb(MainWindow *mainwin, guint action,
3331 FolderView *folderview = mainwin->folderview;
3333 if (!mainwin->summaryview->folder_item) return;
3334 if (!folderview->opened) return;
3336 folder_update_op_count();
3338 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3339 folderview->opened);
3342 folder_item_scan(fitem);
3343 summary_show(mainwin->summaryview, fitem);
3346 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3348 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3351 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3353 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3356 static void prev_unread_cb(MainWindow *mainwin, guint action,
3359 summary_select_prev_unread(mainwin->summaryview);
3362 void next_unread_cb(MainWindow *mainwin, guint action,
3365 summary_select_next_unread(mainwin->summaryview);
3368 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3370 summary_select_prev_new(mainwin->summaryview);
3373 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3375 summary_select_next_new(mainwin->summaryview);
3378 static void prev_marked_cb(MainWindow *mainwin, guint action,
3381 summary_select_prev_marked(mainwin->summaryview);
3384 static void next_marked_cb(MainWindow *mainwin, guint action,
3387 summary_select_next_marked(mainwin->summaryview);
3390 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3393 summary_select_prev_labeled(mainwin->summaryview);
3396 static void next_labeled_cb(MainWindow *mainwin, guint action,
3399 summary_select_next_labeled(mainwin->summaryview);
3402 static void goto_folder_cb(MainWindow *mainwin, guint action,
3405 FolderItem *to_folder;
3407 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3410 folderview_select(mainwin->folderview, to_folder);
3413 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3415 messageview_copy_clipboard(mainwin->messageview);
3418 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3420 MessageView *msgview = mainwin->messageview;
3422 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3423 summary_select_all(mainwin->summaryview);
3424 else if (messageview_is_visible(msgview) &&
3425 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
3426 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3427 messageview_select_all(mainwin->messageview);
3430 static void select_thread_cb(MainWindow *mainwin, guint action,
3433 summary_select_thread(mainwin->summaryview);
3436 static void create_filter_cb(MainWindow *mainwin, guint action,
3439 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3442 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3445 prefs_common_open();
3448 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
3451 prefs_filter_open(NULL, NULL);
3454 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3457 prefs_scoring_open(NULL);
3460 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3463 prefs_filtering_open(NULL, NULL, NULL);
3466 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3469 prefs_template_open();
3472 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3475 prefs_actions_open(mainwin);
3478 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3482 new_account_cb(mainwin, 0, widget);
3484 gboolean prev_default = cur_account->is_default;
3486 prefs_account_open(cur_account);
3487 if (!prev_default && cur_account->is_default)
3488 account_set_as_default(cur_account);
3489 account_save_config_all();
3491 main_window_reflect_prefs_all();
3495 static void new_account_cb(MainWindow *mainwin, guint action,
3498 account_edit_open();
3499 if (!compose_get_compose_list()) account_add();
3502 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3504 cur_account = (PrefsAccount *)data;
3505 main_window_reflect_prefs_all();
3508 static void manual_open_cb(MainWindow *mainwin, guint action,
3511 manual_open((ManualLang)action);
3514 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3516 faq_open((ManualLang)action);
3519 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3521 MainWindow *mainwin = (MainWindow *)data;
3525 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3526 LOCAL_FOLDER(folder)->rootpath,
3530 str = g_strdup_printf(_("Scanning folder %s ..."),
3531 LOCAL_FOLDER(folder)->rootpath);
3533 STATUSBAR_PUSH(mainwin, str);
3534 STATUSBAR_POP(mainwin);
3538 #define BREAK_ON_MODIFIER_KEY() \
3539 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3541 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3543 MainWindow *mainwin = (MainWindow*) data;
3545 if (!mainwin || !event) return;
3547 switch (event->keyval) {
3548 case GDK_Q: /* Quit */
3549 BREAK_ON_MODIFIER_KEY();
3551 app_exit_cb(mainwin, 0, NULL);
3558 #undef BREAK_ON_MODIFIER_KEY
3560 static void set_toolbar_style(MainWindow *mainwin)
3562 switch (prefs_common.toolbar_style) {
3564 gtk_widget_hide(mainwin->handlebox);
3567 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
3571 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
3575 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
3580 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3581 gtk_widget_show(mainwin->handlebox);
3582 gtk_widget_queue_resize(mainwin->handlebox);
3587 * Harvest addresses for selected folder.
3589 static void addr_harvest_cb( MainWindow *mainwin,
3593 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3597 * Harvest addresses for selected messages in summary view.
3599 static void addr_harvest_msg_cb( MainWindow *mainwin,
3603 summary_harvest_address( mainwin->summaryview );