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_actions.h"
64 #include "prefs_filtering.h"
65 #include "prefs_scoring.h"
66 #include "prefs_account.h"
67 #include "prefs_folder_item.h"
68 #include "prefs_summary_column.h"
69 #include "prefs_template.h"
70 #include "prefs_toolbar.h"
72 #include "addressbook.h"
73 #include "logwindow.h"
74 #include "manage_window.h"
75 #include "alertpanel.h"
76 #include "statusbar.h"
77 #include "inputdialog.h"
84 #include "selective_download.h"
85 #include "ssl_manager.h"
86 #include "sslcertwindow.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_exec_cb (GtkWidget *widget,
253 static void toolbar_next_unread_cb (GtkWidget *widget,
257 static void toolbar_reply_popup_cb (GtkWidget *widget,
258 GdkEventButton *event,
260 static void toolbar_reply_popup_closed_cb (GtkMenuShell *menu_shell,
263 static void toolbar_reply_to_all_popup_cb (GtkWidget *widget,
264 GdkEventButton *event,
267 static void toolbar_reply_to_all_popup_closed_cb
268 (GtkMenuShell *menu_shell,
271 static void toolbar_reply_to_list_popup_cb (GtkWidget *widget,
272 GdkEventButton *event,
275 static void toolbar_reply_to_list_popup_closed_cb
276 (GtkMenuShell *menu_shell,
279 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
280 GdkEventButton *event,
282 static void toolbar_reply_to_sender_popup_closed_cb
283 (GtkMenuShell *menu_shell,
286 static void toolbar_forward_popup_cb (GtkWidget *widget,
287 GdkEventButton *event,
290 static void toolbar_forward_popup_closed_cb
291 (GtkMenuShell *menu_shell,
294 static void activate_compose_button (Toolbar *toolbar,
296 ComposeButtonType type);
297 static void toolbar_buttons_cb (GtkWidget *widget,
299 static void toolbar_create (MainWindow *mainwin,
300 GtkWidget *container);
302 static void toolbar_update (MainWindow *mainwin);
304 static void inc_cancel_cb (MainWindow *mainwin,
308 static void open_msg_cb (MainWindow *mainwin,
312 static void view_source_cb (MainWindow *mainwin,
316 static void show_all_header_cb (MainWindow *mainwin,
320 static void reedit_cb (MainWindow *mainwin,
324 static void move_to_cb (MainWindow *mainwin,
327 static void copy_to_cb (MainWindow *mainwin,
330 static void delete_cb (MainWindow *mainwin,
334 static void cancel_cb (MainWindow *mainwin,
338 static void mark_cb (MainWindow *mainwin,
341 static void unmark_cb (MainWindow *mainwin,
345 static void mark_as_unread_cb (MainWindow *mainwin,
348 static void mark_as_read_cb (MainWindow *mainwin,
351 static void mark_all_read_cb (MainWindow *mainwin,
354 static void add_address_cb (MainWindow *mainwin,
358 static void set_charset_cb (MainWindow *mainwin,
362 static void hide_read_messages (MainWindow *mainwin,
366 static void thread_cb (MainWindow *mainwin,
369 static void expand_threads_cb (MainWindow *mainwin,
372 static void collapse_threads_cb (MainWindow *mainwin,
376 static void set_display_item_cb (MainWindow *mainwin,
379 static void sort_summary_cb (MainWindow *mainwin,
382 static void sort_summary_type_cb (MainWindow *mainwin,
385 static void attract_by_subject_cb(MainWindow *mainwin,
389 static void delete_duplicated_cb (MainWindow *mainwin,
392 static void filter_cb (MainWindow *mainwin,
395 static void execute_summary_cb (MainWindow *mainwin,
398 static void update_summary_cb (MainWindow *mainwin,
402 static void prev_cb (MainWindow *mainwin,
405 static void next_cb (MainWindow *mainwin,
409 static void prev_unread_cb (MainWindow *mainwin,
413 static void prev_new_cb (MainWindow *mainwin,
416 static void next_new_cb (MainWindow *mainwin,
419 static void prev_marked_cb (MainWindow *mainwin,
422 static void next_marked_cb (MainWindow *mainwin,
425 static void prev_labeled_cb (MainWindow *mainwin,
428 static void next_labeled_cb (MainWindow *mainwin,
432 static void goto_folder_cb (MainWindow *mainwin,
436 static void copy_cb (MainWindow *mainwin,
439 static void allsel_cb (MainWindow *mainwin,
442 static void select_thread_cb (MainWindow *mainwin,
446 static void create_filter_cb (MainWindow *mainwin,
450 static void prefs_common_open_cb (MainWindow *mainwin,
453 static void prefs_template_open_cb (MainWindow *mainwin,
456 static void prefs_actions_open_cb (MainWindow *mainwin,
459 static void prefs_account_open_cb (MainWindow *mainwin,
462 static void prefs_scoring_open_cb (MainWindow *mainwin,
465 static void prefs_filtering_open_cb (MainWindow *mainwin,
469 static void ssl_manager_open_cb (MainWindow *mainwin,
473 static void new_account_cb (MainWindow *mainwin,
477 static void account_menu_cb (GtkMenuItem *menuitem,
480 static void online_switch_clicked(GtkButton *btn,
483 static void manual_open_cb (MainWindow *mainwin,
487 static void scan_tree_func (Folder *folder,
491 static void key_pressed (GtkWidget *widget,
495 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
497 static void addr_harvest_cb ( MainWindow *mainwin,
501 static void addr_harvest_msg_cb ( MainWindow *mainwin,
505 #define SEPARATE_ACTION 500
507 static GtkItemFactoryEntry mainwin_entries[] =
509 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
510 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
511 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
512 {N_("/_File/_Check for new messages in all folders"),
513 NULL, update_folderview_cb, 0, NULL},
514 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
515 {N_("/_File/_Folder/Create _new folder..."),
516 NULL, new_folder_cb, 0, NULL},
517 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
518 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
519 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
520 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
521 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
522 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
523 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
524 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
525 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
526 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
527 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
528 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
530 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
531 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
532 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
533 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
534 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
535 {N_("/_Edit/_Find in current message..."),
536 "<control>F", search_cb, 0, NULL},
537 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
538 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
539 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
540 {N_("/_View/Show or hi_de/_Folder tree"),
541 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
542 {N_("/_View/Show or hi_de/_Message view"),
543 "V", toggle_message_cb, 0, "<ToggleItem>"},
544 {N_("/_View/Show or hi_de/_Toolbar"),
545 NULL, NULL, 0, "<Branch>"},
546 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
547 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
548 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
549 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
550 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
551 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
552 {N_("/_View/Show or hi_de/_Toolbar/_None"),
553 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
554 {N_("/_View/Show or hi_de/Status _bar"),
555 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
556 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
557 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
558 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
559 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
560 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
561 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
562 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
563 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
564 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
565 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
566 {N_("/_View/_Sort/by _color label"),
567 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
568 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
569 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
570 {N_("/_View/_Sort/by a_ttachment"),
571 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
572 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
573 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
574 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
575 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
576 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
577 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
578 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
579 {N_("/_View/_Sort/_Attract by subject"),
580 NULL, attract_by_subject_cb, 0, NULL},
581 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
582 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
583 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
584 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
585 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
587 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
588 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
589 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
590 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
591 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
592 {N_("/_View/_Go to/P_rev unread message"),
593 "<shift>P", prev_unread_cb, 0, NULL},
594 {N_("/_View/_Go to/N_ext unread message"),
595 "<shift>N", next_unread_cb, 0, NULL},
596 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
597 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
598 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
599 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
600 {N_("/_View/_Go to/Prev _marked message"),
601 NULL, prev_marked_cb, 0, NULL},
602 {N_("/_View/_Go to/Next m_arked message"),
603 NULL, next_marked_cb, 0, NULL},
604 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
605 {N_("/_View/_Go to/Prev _labeled message"),
606 NULL, prev_labeled_cb, 0, NULL},
607 {N_("/_View/_Go to/Next la_beled message"),
608 NULL, next_labeled_cb, 0, NULL},
609 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
610 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
611 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
613 #define CODESET_SEPARATOR \
614 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
615 #define CODESET_ACTION(action) \
616 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
618 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
619 {N_("/_View/_Code set/_Auto detect"),
620 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
621 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
622 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
623 CODESET_ACTION(C_US_ASCII)},
626 {N_("/_View/_Code set/Unicode (_UTF-8)"),
627 CODESET_ACTION(C_UTF_8)},
630 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
631 CODESET_ACTION(C_ISO_8859_1)},
632 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
633 CODESET_ACTION(C_ISO_8859_15)},
636 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
637 CODESET_ACTION(C_ISO_8859_2)},
639 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
640 CODESET_ACTION(C_ISO_8859_13)},
641 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
642 CODESET_ACTION(C_ISO_8859_4)},
644 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
645 CODESET_ACTION(C_ISO_8859_7)},
647 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
648 CODESET_ACTION(C_ISO_8859_9)},
650 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
651 CODESET_ACTION(C_ISO_8859_5)},
652 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
653 CODESET_ACTION(C_KOI8_R)},
654 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
655 CODESET_ACTION(C_WINDOWS_1251)},
658 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
659 CODESET_ACTION(C_ISO_2022_JP)},
661 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
662 CODESET_ACTION(C_ISO_2022_JP_2)},
664 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
665 CODESET_ACTION(C_EUC_JP)},
666 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
667 CODESET_ACTION(C_SHIFT_JIS)},
670 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
671 CODESET_ACTION(C_GB2312)},
672 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
673 CODESET_ACTION(C_BIG5)},
674 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
675 CODESET_ACTION(C_EUC_TW)},
676 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
677 CODESET_ACTION(C_ISO_2022_CN)},
679 {N_("/_View/_Code set/Korean (EUC-_KR)"),
680 CODESET_ACTION(C_EUC_KR)},
681 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
682 CODESET_ACTION(C_ISO_2022_KR)},
684 {N_("/_View/_Code set/Thai (TIS-620)"),
685 CODESET_ACTION(C_TIS_620)},
686 {N_("/_View/_Code set/Thai (Windows-874)"),
687 CODESET_ACTION(C_WINDOWS_874)},
690 #undef CODESET_SEPARATOR
691 #undef CODESET_ACTION
693 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
694 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
695 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
696 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
697 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
698 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
700 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
701 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
702 {N_("/_Message/Get from _all accounts"),
703 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
704 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
705 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
706 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
707 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
708 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
709 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
710 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
711 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
712 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
713 {N_("/_Message/Repl_y to/_sender"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
714 {N_("/_Message/Repl_y to/mailing _list"),
715 "<control>L", reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
716 {N_("/_Message/Follow-up and reply to"),NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
717 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
718 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
719 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
720 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
721 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
722 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
723 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
724 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
725 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
726 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
727 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
728 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
729 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
730 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
731 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
732 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
733 {N_("/_Message/_Mark/Mark as rea_d"),
734 NULL, mark_as_read_cb, 0, NULL},
735 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
737 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
738 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
739 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
740 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
741 {N_("/_Tools/Add sender to address boo_k"),
742 NULL, add_address_cb, 0, NULL},
743 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
744 {N_("/_Tools/_Harvest addresses/from _Folder..."),
745 NULL, addr_harvest_cb, 0, NULL},
746 {N_("/_Tools/_Harvest addresses/from _Messages..."),
747 NULL, addr_harvest_msg_cb, 0, NULL},
748 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
749 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
750 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
751 {N_("/_Tools/_Create filter rule/_Automatically"),
752 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
753 {N_("/_Tools/_Create filter rule/by _From"),
754 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
755 {N_("/_Tools/_Create filter rule/by _To"),
756 NULL, create_filter_cb, FILTER_BY_TO, NULL},
757 {N_("/_Tools/_Create filter rule/by _Subject"),
758 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
759 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
760 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
761 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
762 {N_("/_Tools/Delete du_plicated messages"),
763 NULL, delete_duplicated_cb, 0, NULL},
764 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
765 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
767 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
768 {N_("/_Tools/SSL certi_ficates..."),
769 NULL, ssl_manager_open_cb, 0, NULL},
771 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
772 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
774 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
775 {N_("/_Configuration/_Common preferences..."),
776 NULL, prefs_common_open_cb, 0, NULL},
777 {N_("/_Configuration/C_ustomize toolbars"),
778 NULL, NULL, 0, "<Branch>"},
779 {N_("/_Configuration/C_ustomize toolbars/_Main window..."),
780 NULL, prefs_toolbar_cb, TOOLBAR_MAIN, NULL},
781 {N_("/_Configuration/C_ustomize toolbars/_Compose window..."),
782 NULL, prefs_toolbar_cb, TOOLBAR_COMPOSE, NULL},
783 {N_("/_Configuration/C_ustomize toolbars/M_essage view..."),
784 NULL, prefs_toolbar_cb, TOOLBAR_MSGVIEW, NULL},
785 {N_("/_Configuration/_Scoring..."),
786 NULL, prefs_scoring_open_cb, 0, NULL},
787 {N_("/_Configuration/_Filtering..."),
788 NULL, prefs_filtering_open_cb, 0, NULL},
789 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
790 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
791 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
792 {N_("/_Configuration/_Preferences for current account..."),
793 NULL, prefs_account_open_cb, 0, NULL},
794 {N_("/_Configuration/Create _new account..."),
795 NULL, new_account_cb, 0, NULL},
796 {N_("/_Configuration/_Edit accounts..."),
797 NULL, account_edit_open, 0, NULL},
798 {N_("/_Configuration/C_hange current account"),
799 NULL, NULL, 0, "<Branch>"},
801 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
802 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
803 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
804 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
805 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
806 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
807 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
808 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
809 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
814 static GtkItemFactoryEntry reply_popup_entries[] =
816 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
817 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
819 static GtkItemFactoryEntry replyall_popup_entries[] =
821 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
822 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
824 static GtkItemFactoryEntry replylist_popup_entries[] =
826 {N_("/Reply to list with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE, NULL},
827 {N_("/_Reply to list without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE, NULL}
829 static GtkItemFactoryEntry replysender_popup_entries[] =
831 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
832 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
834 static GtkItemFactoryEntry fwd_popup_entries[] =
836 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
837 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
840 MainWindow *main_window_create(SeparateType type)
846 GtkWidget *handlebox;
847 GtkWidget *vbox_body;
848 GtkWidget *hbox_stat;
849 GtkWidget *statusbar;
850 GtkWidget *progressbar;
851 GtkWidget *statuslabel;
852 GtkWidget *ac_button;
854 GtkWidget *online_pixmap;
855 GtkWidget *offline_pixmap;
856 GtkWidget *online_switch;
857 GtkWidget *offline_switch;
859 FolderView *folderview;
860 SummaryView *summaryview;
861 MessageView *messageview;
862 GdkColormap *colormap;
865 GtkItemFactory *ifactory;
869 guint n_menu_entries;
871 static GdkGeometry geometry;
873 debug_print("Creating main window...\n");
874 mainwin = g_new0(MainWindow, 1);
877 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
878 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
879 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
880 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
882 if (!geometry.min_height) {
883 geometry.min_width = 320;
884 geometry.min_height = 200;
886 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
889 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
890 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
891 MANAGE_WINDOW_SIGNALS_CONNECT(window);
892 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
893 GTK_SIGNAL_FUNC(key_pressed), mainwin);
895 gtk_widget_realize(window);
896 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
899 gtkut_widget_set_app_icon(window);
901 vbox = gtk_vbox_new(FALSE, 0);
902 gtk_widget_show(vbox);
903 gtk_container_add(GTK_CONTAINER(window), vbox);
906 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
907 menubar = menubar_create(window, mainwin_entries,
908 n_menu_entries, "<Main>", mainwin);
909 gtk_widget_show(menubar);
910 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
911 ifactory = gtk_item_factory_from_widget(menubar);
913 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
914 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
916 handlebox = gtk_handle_box_new();
917 gtk_widget_show(handlebox);
918 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
920 /* link window to mainwin->window to avoid gdk warnings */
921 mainwin->window = window;
924 toolbar_create(mainwin, handlebox);
926 /* vbox that contains body */
927 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
928 gtk_widget_show(vbox_body);
929 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
930 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
932 hbox_stat = gtk_hbox_new(FALSE, 2);
933 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
935 statusbar = statusbar_create();
936 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
938 progressbar = gtk_progress_bar_new();
939 gtk_widget_set_usize(progressbar, 120, 1);
940 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
942 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
943 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
944 online_switch = gtk_button_new ();
945 offline_switch = gtk_button_new ();
946 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
947 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
948 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
949 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
950 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
951 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
952 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
953 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
955 statuslabel = gtk_label_new("");
956 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
958 ac_button = gtk_button_new();
959 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
960 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
961 gtk_widget_set_usize(ac_button, -1, 1);
962 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
963 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
964 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
966 ac_label = gtk_label_new("");
967 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
969 gtk_widget_show_all(hbox_stat);
971 gtk_widget_hide(offline_switch);
973 mainwin->folderview = folderview = folderview_create();
974 mainwin->summaryview = summaryview = summary_create();
975 mainwin->messageview = messageview = messageview_create(mainwin);
976 mainwin->logwin = log_window_create();
978 folderview->mainwin = mainwin;
979 folderview->summaryview = summaryview;
981 summaryview->mainwin = mainwin;
982 summaryview->folderview = folderview;
983 summaryview->messageview = messageview;
984 summaryview->window = window;
986 mainwin->vbox = vbox;
987 mainwin->menubar = menubar;
988 mainwin->menu_factory = ifactory;
989 mainwin->handlebox = handlebox;
990 mainwin->vbox_body = vbox_body;
991 mainwin->hbox_stat = hbox_stat;
992 mainwin->statusbar = statusbar;
993 mainwin->progressbar = progressbar;
994 mainwin->statuslabel = statuslabel;
995 mainwin->ac_button = ac_button;
996 mainwin->ac_label = ac_label;
998 mainwin->online_switch = online_switch;
999 mainwin->offline_switch = offline_switch;
1000 mainwin->online_pixmap = online_pixmap;
1001 mainwin->offline_pixmap = offline_pixmap;
1003 /* set context IDs for status bar */
1004 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1005 (GTK_STATUSBAR(statusbar), "Main Window");
1006 mainwin->folderview_cid = gtk_statusbar_get_context_id
1007 (GTK_STATUSBAR(statusbar), "Folder View");
1008 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1009 (GTK_STATUSBAR(statusbar), "Summary View");
1011 /* allocate colors for summary view and folder view */
1012 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1013 summaryview->color_marked.blue = (guint16)65535;
1015 summaryview->color_dim.red = summaryview->color_dim.green =
1016 summaryview->color_dim.blue = COLOR_DIM;
1018 folderview->color_new.red = (guint16)55000;
1019 folderview->color_new.green = folderview->color_new.blue = 15000;
1021 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1022 &folderview->color_op);
1024 summaryview->color_important.red = 0;
1025 summaryview->color_important.green = 0;
1026 summaryview->color_important.blue = (guint16)65535;
1028 color[0] = summaryview->color_marked;
1029 color[1] = summaryview->color_dim;
1030 color[2] = folderview->color_new;
1031 color[3] = folderview->color_op;
1033 colormap = gdk_window_get_colormap(window->window);
1034 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1035 for (i = 0; i < 4; i++) {
1036 if (success[i] == FALSE)
1037 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1040 debug_print("done.\n");
1042 messageview->visible = TRUE;
1044 main_window_set_widgets(mainwin, type);
1046 /* set menu items */
1047 menuitem = gtk_item_factory_get_item
1048 (ifactory, "/View/Code set/Auto detect");
1049 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1051 switch (prefs_common.toolbar_style) {
1053 menuitem = gtk_item_factory_get_item
1054 (ifactory, "/View/Show or hide/Toolbar/None");
1057 menuitem = gtk_item_factory_get_item
1058 (ifactory, "/View/Show or hide/Toolbar/Icon");
1061 menuitem = gtk_item_factory_get_item
1062 (ifactory, "/View/Show or hide/Toolbar/Text");
1065 menuitem = gtk_item_factory_get_item
1066 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1068 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1070 gtk_widget_hide(mainwin->hbox_stat);
1071 menuitem = gtk_item_factory_get_item
1072 (ifactory, "/View/Show or hide/Status bar");
1073 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1074 prefs_common.show_statusbar);
1076 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
1078 if (prefs_common.show_searchbar)
1079 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
1082 /* set account selection menu */
1083 ac_menu = gtk_item_factory_get_widget
1084 (ifactory, "/Configuration/Change current account");
1085 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1086 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1087 mainwin->ac_menu = ac_menu;
1089 toolbar_set_sensitive(mainwin);
1091 /* create actions menu */
1092 update_mainwin_actions_menu(ifactory, mainwin);
1094 /* show main window */
1095 gtk_widget_set_uposition(mainwin->window,
1096 prefs_common.mainwin_x,
1097 prefs_common.mainwin_y);
1098 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1099 prefs_common.mainwin_height);
1100 gtk_widget_show(mainwin->window);
1102 /* initialize views */
1103 folderview_init(folderview);
1104 summary_init(summaryview);
1105 messageview_init(messageview);
1106 log_window_init(mainwin->logwin);
1108 sslcertwindow_register_hook();
1110 mainwin->lock_count = 0;
1111 mainwin->menu_lock_count = 0;
1112 mainwin->cursor_count = 0;
1115 watch_cursor = gdk_cursor_new(GDK_WATCH);
1117 mainwin_list = g_list_append(mainwin_list, mainwin);
1119 /* init work_offline */
1120 if (prefs_common.work_offline)
1121 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1126 void main_window_cursor_wait(MainWindow *mainwin)
1129 if (mainwin->cursor_count == 0)
1130 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1132 mainwin->cursor_count++;
1137 void main_window_cursor_normal(MainWindow *mainwin)
1139 if (mainwin->cursor_count)
1140 mainwin->cursor_count--;
1142 if (mainwin->cursor_count == 0)
1143 gdk_window_set_cursor(mainwin->window->window, NULL);
1148 /* lock / unlock the user-interface */
1149 void main_window_lock(MainWindow *mainwin)
1151 if (mainwin->lock_count == 0)
1152 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1154 mainwin->lock_count++;
1156 main_window_set_menu_sensitive(mainwin);
1157 toolbar_set_sensitive(mainwin);
1160 void main_window_unlock(MainWindow *mainwin)
1162 if (mainwin->lock_count)
1163 mainwin->lock_count--;
1165 main_window_set_menu_sensitive(mainwin);
1166 toolbar_set_sensitive(mainwin);
1168 if (mainwin->lock_count == 0)
1169 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1172 static void main_window_menu_callback_block(MainWindow *mainwin)
1174 mainwin->menu_lock_count++;
1177 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1179 if (mainwin->menu_lock_count)
1180 mainwin->menu_lock_count--;
1183 void main_window_reflect_prefs_all(void)
1185 main_window_reflect_prefs_all_real(FALSE);
1188 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1191 MainWindow *mainwin;
1194 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1195 mainwin = (MainWindow *)cur->data;
1197 main_window_show_cur_account(mainwin);
1198 main_window_set_menu_sensitive(mainwin);
1199 toolbar_set_sensitive(mainwin);
1202 if (pixmap_theme_changed) {
1203 toolbar_update(mainwin);
1204 common_toolbar_set_style(mainwin, TOOLBAR_MAIN);
1205 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1206 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1208 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1209 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1210 mainwin->online_pixmap);
1211 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1212 gtk_widget_show(pixmap);
1213 mainwin->online_pixmap = pixmap;
1214 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1215 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1216 mainwin->offline_pixmap);
1217 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1218 gtk_widget_show(pixmap);
1219 mainwin->offline_pixmap = pixmap;
1222 summary_redisplay_msg(mainwin->summaryview);
1223 headerview_set_visibility(mainwin->messageview->headerview,
1224 prefs_common.display_header_pane);
1228 void main_window_set_summary_column(void)
1231 MainWindow *mainwin;
1233 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1234 mainwin = (MainWindow *)cur->data;
1235 summary_set_column_order(mainwin->summaryview);
1239 void main_window_set_account_menu(GList *account_list)
1241 GList *cur, *cur_ac, *cur_item;
1242 GtkWidget *menuitem;
1243 MainWindow *mainwin;
1244 PrefsAccount *ac_prefs;
1246 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1247 mainwin = (MainWindow *)cur->data;
1249 /* destroy all previous menu item */
1250 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1251 while (cur_item != NULL) {
1252 GList *next = cur_item->next;
1253 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1257 for (cur_ac = account_list; cur_ac != NULL;
1258 cur_ac = cur_ac->next) {
1259 ac_prefs = (PrefsAccount *)cur_ac->data;
1261 menuitem = gtk_menu_item_new_with_label
1262 (ac_prefs->account_name
1263 ? ac_prefs->account_name : _("Untitled"));
1264 gtk_widget_show(menuitem);
1265 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1266 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1267 GTK_SIGNAL_FUNC(account_menu_cb),
1273 static void main_window_show_cur_account(MainWindow *mainwin)
1278 ac_name = g_strdup(cur_account
1279 ? (cur_account->account_name
1280 ? cur_account->account_name : _("Untitled"))
1284 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1286 buf = g_strdup(PROG_VERSION);
1287 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1290 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1291 gtk_widget_queue_resize(mainwin->ac_button);
1296 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1298 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1299 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1300 //GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1301 GtkWidget *message_wid = mainwin->messageview->vbox;
1303 debug_print("Changing window separation type from %d to %d\n",
1304 mainwin->type, type);
1306 if (mainwin->type == type) return;
1308 /* remove widgets from those containers */
1309 gtk_widget_ref(folder_wid);
1310 gtk_widget_ref(summary_wid);
1311 gtk_widget_ref(message_wid);
1312 gtkut_container_remove
1313 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1314 gtkut_container_remove
1315 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1316 gtkut_container_remove
1317 (GTK_CONTAINER(message_wid->parent), message_wid);
1319 /* clean containers */
1320 switch (mainwin->type) {
1322 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1324 case SEPARATE_FOLDER:
1325 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1326 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1328 case SEPARATE_MESSAGE:
1329 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1330 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1333 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1334 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1338 gtk_widget_hide(mainwin->window);
1339 main_window_set_widgets(mainwin, type);
1340 gtk_widget_show(mainwin->window);
1342 gtk_widget_unref(folder_wid);
1343 gtk_widget_unref(summary_wid);
1344 gtk_widget_unref(message_wid);
1347 void main_window_toggle_message_view(MainWindow *mainwin)
1349 SummaryView *summaryview = mainwin->summaryview;
1350 union CompositeWin *cwin = &mainwin->win;
1351 GtkWidget *vpaned = NULL;
1352 GtkWidget *container = NULL;
1353 GtkWidget *msgwin = NULL;
1355 switch (mainwin->type) {
1357 vpaned = cwin->sep_none.vpaned;
1358 container = cwin->sep_none.hpaned;
1360 case SEPARATE_FOLDER:
1361 vpaned = cwin->sep_folder.vpaned;
1362 container = mainwin->vbox_body;
1364 case SEPARATE_MESSAGE:
1365 msgwin = mainwin->win.sep_message.messagewin;
1368 msgwin = mainwin->win.sep_both.messagewin;
1373 if (GTK_WIDGET_VISIBLE(msgwin)) {
1374 gtk_widget_hide(msgwin);
1375 mainwin->messageview->visible = FALSE;
1376 summaryview->displayed = NULL;
1378 gtk_widget_show(msgwin);
1379 mainwin->messageview->visible = TRUE;
1381 } else if (vpaned->parent != NULL) {
1382 mainwin->messageview->visible = FALSE;
1383 summaryview->displayed = NULL;
1384 gtk_widget_ref(vpaned);
1385 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1386 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1387 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1388 GTK_ARROW_UP, GTK_SHADOW_OUT);
1390 mainwin->messageview->visible = TRUE;
1391 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1392 gtk_container_add(GTK_CONTAINER(container), vpaned);
1393 gtk_widget_unref(vpaned);
1394 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1395 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1398 main_window_set_menu_sensitive(mainwin);
1400 gtk_widget_grab_focus(summaryview->ctree);
1403 void main_window_get_size(MainWindow *mainwin)
1405 GtkAllocation *allocation;
1407 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1409 prefs_common.summaryview_width = allocation->width;
1411 if ((mainwin->type == SEPARATE_NONE ||
1412 mainwin->type == SEPARATE_FOLDER) &&
1413 messageview_is_visible(mainwin->messageview))
1414 prefs_common.summaryview_height = allocation->height;
1416 prefs_common.mainview_width = allocation->width;
1418 allocation = &mainwin->window->allocation;
1420 prefs_common.mainview_height = allocation->height;
1421 prefs_common.mainwin_width = allocation->width;
1422 prefs_common.mainwin_height = allocation->height;
1424 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1426 prefs_common.folderview_width = allocation->width;
1427 prefs_common.folderview_height = allocation->height;
1430 void main_window_get_position(MainWindow *mainwin)
1434 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1436 prefs_common.mainview_x = x;
1437 prefs_common.mainview_y = y;
1438 prefs_common.mainwin_x = x;
1439 prefs_common.mainwin_y = y;
1441 debug_print("window position: x = %d, y = %d\n", x, y);
1444 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1450 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1451 folder = FOLDER(list->data);
1452 if (folder && folder->trash && folder->trash->total > 0)
1456 if (!has_trash) return;
1459 if (alertpanel(_("Empty trash"),
1460 _("Empty all messages in trash?"),
1461 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1463 manage_window_focus_in(mainwin->window, NULL, NULL);
1466 procmsg_empty_trash();
1468 for (list = folder_get_list(); list != NULL; list = list->next) {
1469 folder = list->data;
1470 if (folder && folder->trash) {
1471 folder_update_item(folder->trash, TRUE);
1475 if (mainwin->summaryview->folder_item &&
1476 mainwin->summaryview->folder_item->stype == F_TRASH)
1477 gtk_widget_grab_focus(mainwin->folderview->ctree);
1480 void main_window_add_mailbox(MainWindow *mainwin)
1485 path = input_dialog(_("Add mailbox"),
1486 _("Input the location of mailbox.\n"
1487 "If the existing mailbox is specified, it will be\n"
1488 "scanned automatically."),
1491 if (folder_find_from_path(path)) {
1492 alertpanel_error(_("The mailbox `%s' already exists."), path);
1496 if (!strcmp(path, "Mail"))
1497 folder = folder_new(F_MH, _("Mailbox"), path);
1499 folder = folder_new(F_MH, g_basename(path), path);
1502 if (folder->create_tree(folder) < 0) {
1503 alertpanel_error(_("Creation of the mailbox failed.\n"
1504 "Maybe some files already exist, or you don't have the permission to write there."));
1505 folder_destroy(folder);
1510 folder_set_ui_func(folder, scan_tree_func, mainwin);
1511 folder_scan_tree(folder);
1512 folder_set_ui_func(folder, NULL, NULL);
1514 folderview_set(mainwin->folderview);
1517 void main_window_add_mbox(MainWindow *mainwin)
1523 path = input_dialog(_("Add mbox mailbox"),
1524 _("Input the location of mailbox."),
1529 if (folder_find_from_path(path)) {
1530 alertpanel_error(_("The mailbox `%s' already exists."), path);
1536 if (!strcmp(path, "Mail"))
1537 folder = folder_new(F_MBOX, _("Mailbox"), path);
1541 folder = folder_new(F_MBOX, g_basename(path), path);
1544 if (folder->create_tree(folder) < 0) {
1545 alertpanel_error(_("Creation of the mailbox failed."));
1546 folder_destroy(folder);
1552 item = folder_item_new(folder, folder->name, NULL);
1553 item->folder = folder;
1554 folder->node = g_node_new(item);
1556 folder_create_folder(item, "inbox");
1557 folder_create_folder(item, "outbox");
1558 folder_create_folder(item, "queue");
1559 folder_create_folder(item, "draft");
1560 folder_create_folder(item, "trash");
1562 folderview_set(mainwin->folderview);
1565 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1567 SensitiveCond state = 0;
1568 SummarySelection selection;
1569 FolderItem *item = mainwin->summaryview->folder_item;
1570 GList *account_list = account_get_list();
1572 selection = summary_get_selection_type(mainwin->summaryview);
1574 if (mainwin->lock_count == 0)
1575 state |= M_UNLOCKED;
1576 if (selection != SUMMARY_NONE)
1577 state |= M_MSG_EXIST;
1578 if (item && item->path && item->parent && !item->no_select) {
1580 /* if (item->folder->type != F_NEWS) */
1581 state |= M_ALLOW_DELETE;
1583 if (prefs_common.immediate_exec == 0
1584 && mainwin->lock_count == 0)
1585 state |= M_DELAY_EXEC;
1587 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1588 || selection != SUMMARY_NONE)
1589 state |= M_HIDE_READ_MSG;
1591 if (mainwin->summaryview->threaded)
1592 state |= M_THREADED;
1594 state |= M_UNTHREADED;
1595 if (selection == SUMMARY_SELECTED_SINGLE ||
1596 selection == SUMMARY_SELECTED_MULTIPLE)
1597 state |= M_TARGET_EXIST;
1598 if (selection == SUMMARY_SELECTED_SINGLE)
1599 state |= M_SINGLE_TARGET_EXIST;
1600 if (mainwin->summaryview->folder_item &&
1601 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1604 state |= M_NOT_NEWS;
1605 if (selection == SUMMARY_SELECTED_SINGLE &&
1607 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1608 item->stype == F_QUEUE)))
1609 state |= M_ALLOW_REEDIT;
1611 state |= M_HAVE_ACCOUNT;
1613 for ( ; account_list != NULL; account_list = account_list->next) {
1614 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1615 state |= M_HAVE_NEWS_ACCOUNT;
1620 if (inc_is_active())
1621 state |= M_INC_ACTIVE;
1628 void main_window_set_menu_sensitive(MainWindow *mainwin)
1630 GtkItemFactory *ifactory = mainwin->menu_factory;
1631 SensitiveCond state;
1633 GtkWidget *menuitem;
1634 SummaryView *summaryview;
1638 static const struct {
1642 {"/File/Add mailbox..." , M_UNLOCKED},
1643 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1644 {"/File/Check for new messages in all folders", M_UNLOCKED},
1645 {"/File/Folder" , M_UNLOCKED},
1646 {"/File/Import mbox file..." , M_UNLOCKED},
1647 {"/File/Export to mbox file..." , M_UNLOCKED},
1648 {"/File/Empty trash" , M_UNLOCKED},
1649 {"/File/Work offline" , M_UNLOCKED},
1651 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1652 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1653 /* {"/File/Close" , M_UNLOCKED}, */
1654 {"/File/Exit" , M_UNLOCKED},
1656 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1658 {"/View/Sort" , M_EXEC},
1659 {"/View/Thread view" , M_EXEC},
1660 {"/View/Expand all threads" , M_MSG_EXIST},
1661 {"/View/Collapse all threads" , M_MSG_EXIST},
1662 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1663 {"/View/Go to/Prev message" , M_MSG_EXIST},
1664 {"/View/Go to/Next message" , M_MSG_EXIST},
1665 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1666 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1667 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1668 {"/View/Go to/Next new message" , M_MSG_EXIST},
1669 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1670 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1671 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1672 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1673 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1674 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1675 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1677 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1678 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1679 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1680 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1681 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1682 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1683 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1684 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1685 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1686 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1687 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1688 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1689 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1690 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1691 {"/Message/Mark" , M_TARGET_EXIST},
1693 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1694 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1695 {"/Tools/Harvest addresses" , M_UNLOCKED},
1696 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1697 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1698 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1699 {"/Tools/Execute" , M_DELAY_EXEC},
1700 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1702 {"/Configuration", M_UNLOCKED},
1707 state = main_window_get_current_state(mainwin);
1709 for (i = 0; entry[i].entry != NULL; i++) {
1710 sensitive = ((entry[i].cond & state) == entry[i].cond);
1711 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1714 main_window_menu_callback_block(mainwin);
1716 #define SET_CHECK_MENU_ACTIVE(path, active) \
1718 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1719 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1722 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1723 messageview_is_visible(mainwin->messageview));
1725 summaryview = mainwin->summaryview;
1726 menu_path = "/View/Sort/Don't sort";
1728 switch (summaryview->sort_key) {
1729 case SORT_BY_NUMBER:
1730 menu_path = "/View/Sort/by number"; break;
1732 menu_path = "/View/Sort/by size"; break;
1734 menu_path = "/View/Sort/by date"; break;
1736 menu_path = "/View/Sort/by from"; break;
1737 case SORT_BY_SUBJECT:
1738 menu_path = "/View/Sort/by subject"; break;
1740 menu_path = "/View/Sort/by color label"; break;
1742 menu_path = "/View/Sort/by mark"; break;
1743 case SORT_BY_UNREAD:
1744 menu_path = "/View/Sort/by unread"; break;
1746 menu_path = "/View/Sort/by attachment"; break;
1748 menu_path = "/View/Sort/by score"; break;
1749 case SORT_BY_LOCKED:
1750 menu_path = "/View/Sort/by locked"; break;
1753 menu_path = "/View/Sort/Don't sort"; break;
1755 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1757 if (summaryview->sort_type == SORT_ASCENDING) {
1758 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1760 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1763 if (summaryview->sort_key != SORT_BY_NONE) {
1764 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1765 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1767 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1768 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1771 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1772 mainwin->messageview->textview->show_all_headers);
1773 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1775 #undef SET_CHECK_MENU_ACTIVE
1777 main_window_menu_callback_unblock(mainwin);
1780 void main_window_popup(MainWindow *mainwin)
1782 gtkut_window_popup(mainwin->window);
1784 switch (mainwin->type) {
1785 case SEPARATE_FOLDER:
1786 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1788 case SEPARATE_MESSAGE:
1789 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1792 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1793 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1800 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1802 GtkWidget *folderwin = NULL;
1803 GtkWidget *messagewin = NULL;
1806 GtkWidget *vbox_body = mainwin->vbox_body;
1807 GtkItemFactory *ifactory = mainwin->menu_factory;
1808 GtkWidget *menuitem;
1810 debug_print("Setting widgets...");
1812 /* create separated window(s) if needed */
1813 if (type & SEPARATE_FOLDER) {
1814 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1815 gtk_window_set_title(GTK_WINDOW(folderwin),
1816 _("Sylpheed - Folder View"));
1817 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1818 "folder_view", "Sylpheed");
1819 gtk_window_set_policy(GTK_WINDOW(folderwin),
1821 gtk_widget_set_usize(folderwin, -1,
1822 prefs_common.mainview_height);
1823 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1825 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1826 GTK_SIGNAL_FUNC(folder_window_close_cb),
1829 if (type & SEPARATE_MESSAGE) {
1830 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1831 gtk_window_set_title(GTK_WINDOW(messagewin),
1832 _("Sylpheed - Message View"));
1833 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1834 "message_view", "Sylpheed");
1835 gtk_window_set_policy(GTK_WINDOW(messagewin),
1837 gtk_widget_set_usize
1838 (messagewin, prefs_common.mainview_width,
1839 prefs_common.mainview_height
1840 - prefs_common.summaryview_height
1841 + DEFAULT_HEADERVIEW_HEIGHT);
1842 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1844 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1845 GTK_SIGNAL_FUNC(message_window_close_cb),
1851 hpaned = gtk_hpaned_new();
1852 gtk_widget_show(hpaned);
1853 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1854 gtk_paned_add1(GTK_PANED(hpaned),
1855 GTK_WIDGET_PTR(mainwin->folderview));
1857 vpaned = gtk_vpaned_new();
1858 if (messageview_is_visible(mainwin->messageview)) {
1859 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1860 gtk_paned_add1(GTK_PANED(vpaned),
1861 GTK_WIDGET_PTR(mainwin->summaryview));
1863 gtk_paned_add2(GTK_PANED(hpaned),
1864 GTK_WIDGET_PTR(mainwin->summaryview));
1865 gtk_widget_ref(vpaned);
1867 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1868 prefs_common.summaryview_width,
1869 prefs_common.summaryview_height);
1870 gtk_paned_add2(GTK_PANED(vpaned),
1871 GTK_WIDGET_PTR(mainwin->messageview));
1872 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1873 prefs_common.mainview_width, -1);
1874 gtk_widget_set_usize(mainwin->window,
1875 prefs_common.folderview_width +
1876 prefs_common.mainview_width,
1877 prefs_common.mainwin_height);
1878 gtk_widget_show_all(vpaned);
1880 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1881 * lose track of its visibility state */
1882 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1883 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1885 mainwin->win.sep_none.hpaned = hpaned;
1886 mainwin->win.sep_none.vpaned = vpaned;
1888 /* remove headerview if not in prefs */
1889 headerview_set_visibility(mainwin->messageview->headerview,
1890 prefs_common.display_header_pane);
1892 case SEPARATE_FOLDER:
1893 vpaned = gtk_vpaned_new();
1894 if (messageview_is_visible(mainwin->messageview)) {
1895 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1897 gtk_paned_add1(GTK_PANED(vpaned),
1898 GTK_WIDGET_PTR(mainwin->summaryview));
1900 gtk_box_pack_start(GTK_BOX(vbox_body),
1901 GTK_WIDGET_PTR(mainwin->summaryview),
1903 gtk_widget_ref(vpaned);
1905 gtk_paned_add2(GTK_PANED(vpaned),
1906 GTK_WIDGET_PTR(mainwin->messageview));
1907 gtk_widget_show_all(vpaned);
1908 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1909 prefs_common.summaryview_width,
1910 prefs_common.summaryview_height);
1911 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1912 prefs_common.mainview_width, -1);
1913 gtk_widget_set_usize(mainwin->window,
1914 prefs_common.mainview_width,
1915 prefs_common.mainview_height);
1917 gtk_container_add(GTK_CONTAINER(folderwin),
1918 GTK_WIDGET_PTR(mainwin->folderview));
1920 mainwin->win.sep_folder.folderwin = folderwin;
1921 mainwin->win.sep_folder.vpaned = vpaned;
1923 gtk_widget_show_all(folderwin);
1925 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1926 * lose track of its visibility state */
1927 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1928 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1930 /* remove headerview if not in prefs */
1931 headerview_set_visibility(mainwin->messageview->headerview,
1932 prefs_common.display_header_pane);
1935 case SEPARATE_MESSAGE:
1936 hpaned = gtk_hpaned_new();
1937 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1939 gtk_paned_add1(GTK_PANED(hpaned),
1940 GTK_WIDGET_PTR(mainwin->folderview));
1941 gtk_paned_add2(GTK_PANED(hpaned),
1942 GTK_WIDGET_PTR(mainwin->summaryview));
1943 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1944 prefs_common.summaryview_width,
1945 prefs_common.summaryview_height);
1946 gtk_widget_set_usize(mainwin->window,
1947 prefs_common.folderview_width +
1948 prefs_common.mainview_width,
1949 prefs_common.mainwin_height);
1950 gtk_widget_show_all(hpaned);
1951 gtk_container_add(GTK_CONTAINER(messagewin),
1952 GTK_WIDGET_PTR(mainwin->messageview));
1954 mainwin->win.sep_message.messagewin = messagewin;
1955 mainwin->win.sep_message.hpaned = hpaned;
1957 gtk_widget_show_all(messagewin);
1959 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1960 * lose track of its visibility state */
1961 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1962 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1965 gtk_box_pack_start(GTK_BOX(vbox_body),
1966 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.mainview_width,
1973 prefs_common.mainwin_height);
1974 gtk_container_add(GTK_CONTAINER(folderwin),
1975 GTK_WIDGET_PTR(mainwin->folderview));
1976 gtk_container_add(GTK_CONTAINER(messagewin),
1977 GTK_WIDGET_PTR(mainwin->messageview));
1979 mainwin->win.sep_both.folderwin = folderwin;
1980 mainwin->win.sep_both.messagewin = messagewin;
1982 gtk_widget_show_all(folderwin);
1983 gtk_widget_show_all(messagewin);
1985 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1986 * lose track of its visibility state */
1987 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1988 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1992 /* rehide quick search if necessary */
1993 if (!prefs_common.show_searchbar)
1994 gtk_widget_hide(mainwin->summaryview->hbox_search);
1996 mainwin->type = type;
1998 mainwin->messageview->visible = TRUE;
2000 /* toggle menu state */
2001 menuitem = gtk_item_factory_get_item
2002 (ifactory, "/View/Show or hide/Folder tree");
2003 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2004 menuitem = gtk_item_factory_get_item
2005 (ifactory, "/View/Show or hide/Message view");
2006 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2008 menuitem = gtk_item_factory_get_item
2009 (ifactory, "/View/Separate folder tree");
2010 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2011 ((type & SEPARATE_FOLDER) != 0));
2012 menuitem = gtk_item_factory_get_item
2013 (ifactory, "/View/Separate message view");
2014 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2015 ((type & SEPARATE_MESSAGE) != 0));
2017 debug_print("done.\n");
2020 void main_window_destroy_all(void)
2022 while (mainwin_list != NULL) {
2023 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2025 /* free toolbar stuff */
2026 toolbar_clear_list(TOOLBAR_MAIN);
2027 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2028 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2030 g_free(mainwin->toolbar);
2033 mainwin_list = g_list_remove(mainwin_list, mainwin);
2035 g_list_free(mainwin_list);
2039 static void toolbar_account_button_pressed(GtkWidget *widget,
2040 GdkEventButton *event,
2043 MainWindow *mainwin = (MainWindow *)data;
2046 if (event->button != 3) return;
2048 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2049 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2052 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2053 menu_button_position, widget,
2054 event->button, event->time);
2058 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2061 MainWindow *mainwin = (MainWindow *)data;
2065 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2066 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2069 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2070 menu_button_position, widget,
2071 event->button, event->time);
2074 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2076 MainWindow *mainwin = (MainWindow *)data;
2079 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2080 if (!button) return;
2081 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2082 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2083 manage_window_focus_in(mainwin->window, NULL, NULL);
2086 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2089 MainWindow *mainwin = (MainWindow *)data;
2091 if (mainwin->lock_count == 0)
2092 app_exit_cb(data, 0, widget);
2097 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2100 MainWindow *mainwin = (MainWindow *)data;
2101 GtkWidget *menuitem;
2103 menuitem = gtk_item_factory_get_item
2104 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2105 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2110 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2113 MainWindow *mainwin = (MainWindow *)data;
2114 GtkWidget *menuitem;
2116 menuitem = gtk_item_factory_get_item
2117 (mainwin->menu_factory, "/View/Show or hide/Message view");
2118 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2123 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2126 main_window_add_mailbox(mainwin);
2129 static void add_mbox_cb(MainWindow *mainwin, guint action,
2132 main_window_add_mbox(mainwin);
2135 static void update_folderview_cb(MainWindow *mainwin, guint action,
2138 summary_show(mainwin->summaryview, NULL);
2139 folderview_check_new_all();
2142 static void new_folder_cb(MainWindow *mainwin, guint action,
2145 folderview_new_folder(mainwin->folderview);
2148 static void rename_folder_cb(MainWindow *mainwin, guint action,
2151 folderview_rename_folder(mainwin->folderview);
2154 static void delete_folder_cb(MainWindow *mainwin, guint action,
2157 folderview_delete_folder(mainwin->folderview);
2160 static void import_mbox_cb(MainWindow *mainwin, guint action,
2163 import_mbox(mainwin->summaryview->folder_item);
2166 static void export_mbox_cb(MainWindow *mainwin, guint action,
2169 export_mbox(mainwin->summaryview->folder_item);
2172 static void empty_trash_cb(MainWindow *mainwin, guint action,
2175 main_window_empty_trash(mainwin, TRUE);
2178 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2180 summary_save_as(mainwin->summaryview);
2183 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2185 summary_print(mainwin->summaryview);
2188 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2190 if (prefs_common.confirm_on_exit) {
2191 if (alertpanel(_("Exit"), _("Exit this program?"),
2192 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2194 manage_window_focus_in(mainwin->window, NULL, NULL);
2197 app_will_exit(widget, mainwin);
2200 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2203 summary_search(mainwin->summaryview);
2205 message_search(mainwin->messageview);
2208 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2213 active = GTK_CHECK_MENU_ITEM(widget)->active;
2215 switch (mainwin->type) {
2217 case SEPARATE_MESSAGE:
2220 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2222 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2225 case SEPARATE_FOLDER:
2226 debug_print("separate folder\n");
2228 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2230 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2234 gtk_widget_show(mainwin->win.sep_both.folderwin);
2236 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2241 static void toggle_message_cb(MainWindow *mainwin, guint action,
2246 active = GTK_CHECK_MENU_ITEM(widget)->active;
2248 if (active != messageview_is_visible(mainwin->messageview))
2249 summary_toggle_view(mainwin->summaryview);
2252 /* Toolbar handling */
2253 static void toolbar_inc_cb(GtkWidget *widget,
2256 MainWindow *mainwin = (MainWindow *)data;
2258 inc_mail_cb(mainwin, 0, NULL);
2261 static void toolbar_inc_all_cb(GtkWidget *widget,
2264 MainWindow *mainwin = (MainWindow *)data;
2266 inc_all_account_mail_cb(mainwin, 0, NULL);
2269 static void toolbar_send_cb(GtkWidget *widget,
2272 MainWindow *mainwin = (MainWindow *)data;
2274 send_queue_cb(mainwin, 0, NULL);
2277 static void toolbar_compose_cb(GtkWidget *widget,
2280 MainWindow *mainwin = (MainWindow *)data;
2282 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
2283 compose_news_cb(mainwin, 0, NULL);
2285 compose_mail_cb(mainwin, 0, NULL);
2288 static void toolbar_reply_cb(GtkWidget *widget,
2291 MainWindow *mainwin = (MainWindow *)data;
2293 if (prefs_common.default_reply_list)
2295 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
2296 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
2300 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2301 : COMPOSE_REPLY_WITHOUT_QUOTE,
2305 static void toolbar_reply_to_all_cb(GtkWidget *widget,
2308 MainWindow *mainwin = (MainWindow *)data;
2311 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2312 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2316 static void toolbar_reply_to_list_cb(GtkWidget *widget,
2319 MainWindow *mainwin = (MainWindow *)data;
2322 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
2323 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
2327 static void toolbar_reply_to_sender_cb(GtkWidget *widget,
2330 MainWindow *mainwin = (MainWindow *)data;
2333 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2334 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2338 static void toolbar_forward_cb(GtkWidget *widget,
2341 MainWindow *mainwin = (MainWindow *)data;
2343 if (prefs_common.forward_as_attachment)
2344 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2346 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2349 static void toolbar_exec_cb(GtkWidget *widget,
2352 MainWindow *mainwin = (MainWindow *)data;
2354 summary_execute(mainwin->summaryview);
2357 static void toolbar_next_unread_cb(GtkWidget *widget,
2360 MainWindow *mainwin = (MainWindow *)data;
2362 next_unread_cb(mainwin, 0, NULL);
2365 /* popup callback functions */
2366 static void toolbar_reply_popup_cb(GtkWidget *widget,
2367 GdkEventButton *event,
2370 MainWindow *mainwindow = (MainWindow *) data;
2374 if (event->button == 3) {
2375 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2376 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->reply_popup), NULL, NULL,
2377 menu_button_position, widget,
2378 event->button, event->time);
2382 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2384 MainWindow *mainwin = (MainWindow *)data;
2386 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->reply_btn), GTK_RELIEF_NONE);
2387 manage_window_focus_in(mainwin->window, NULL, NULL);
2390 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2392 MainWindow *mainwindow = (MainWindow *) data;
2396 if (event->button == 3) {
2397 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2398 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replyall_popup), NULL, NULL,
2399 menu_button_position, widget,
2400 event->button, event->time);
2404 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2406 MainWindow *mainwin = (MainWindow *)data;
2408 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replyall_btn), GTK_RELIEF_NONE);
2409 manage_window_focus_in(mainwin->window, NULL, NULL);
2412 static void toolbar_reply_to_list_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2414 MainWindow *mainwindow = (MainWindow *) data;
2418 if (event->button == 3) {
2419 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2420 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replylist_popup), NULL, NULL,
2421 menu_button_position, widget,
2422 event->button, event->time);
2426 static void toolbar_reply_to_list_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2428 MainWindow *mainwin = (MainWindow *)data;
2430 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replylist_btn), GTK_RELIEF_NONE);
2431 manage_window_focus_in(mainwin->window, NULL, NULL);
2434 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2436 MainWindow *mainwindow = (MainWindow *) data;
2440 if (event->button == 3) {
2441 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2442 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replysender_popup), NULL, NULL,
2443 menu_button_position, widget,
2444 event->button, event->time);
2448 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2450 MainWindow *mainwin = (MainWindow *)data;
2452 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replysender_btn), GTK_RELIEF_NONE);
2453 manage_window_focus_in(mainwin->window, NULL, NULL);
2456 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2458 MainWindow *mainwindow = (MainWindow *) data;
2462 if (event->button == 3) {
2463 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2464 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->fwd_popup), NULL, NULL,
2465 menu_button_position, widget,
2466 event->button, event->time);
2470 static void toolbar_forward_popup_closed_cb (GtkMenuShell *menu_shell,
2473 MainWindow *mainwin = (MainWindow *)data;
2475 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->fwd_btn), GTK_RELIEF_NONE);
2476 manage_window_focus_in(mainwin->window, NULL, NULL);
2479 static void activate_compose_button (Toolbar *toolbar,
2481 ComposeButtonType type)
2483 if ((!toolbar->compose_mail_btn) || (!toolbar->compose_news_btn))
2486 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? toolbar->compose_mail_btn
2487 : toolbar->compose_news_btn);
2488 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? toolbar->compose_news_btn
2489 : toolbar->compose_mail_btn);
2490 toolbar->compose_btn_type = type;
2493 void toolbar_set_compose_button(Toolbar *toolbar,
2494 ComposeButtonType compose_btn_type)
2496 if (toolbar->compose_btn_type != compose_btn_type)
2497 activate_compose_button(toolbar,
2498 prefs_common.toolbar_style,
2502 static void toolbar_buttons_cb(GtkWidget *widget,
2507 void (*func)(GtkWidget *widget, gpointer data);
2508 } toolbar_action[] = {
2509 { A_RECEIVE_ALL, toolbar_inc_all_cb },
2510 { A_RECEIVE_CUR, toolbar_inc_cb },
2511 { A_SEND_QUEUED, toolbar_send_cb },
2512 { A_COMPOSE_EMAIL, toolbar_compose_cb },
2513 { A_REPLY_MESSAGE, toolbar_reply_cb },
2514 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
2515 { A_REPLY_ALL, toolbar_reply_to_all_cb },
2516 { A_REPLY_ML, toolbar_reply_to_list_cb },
2517 { A_FORWARD, toolbar_forward_cb },
2518 { A_DELETE, common_toolbar_delete_cb },
2519 { A_EXECUTE, toolbar_exec_cb },
2520 { A_GOTO_NEXT, toolbar_next_unread_cb },
2521 { A_SYL_ACTIONS, common_toolbar_actions_execute_cb },
2523 { A_COMPOSE_NEWS, toolbar_compose_cb },
2524 { A_SEPARATOR, NULL }};
2526 gint num_items = sizeof(toolbar_action)/sizeof(toolbar_action[0]);
2529 for (i = A_RECEIVE_ALL; i < num_items; i++) {
2531 if (toolbar_action[i].index == item->index) {
2532 if ((item->index == A_SYL_ACTIONS) || (item->index == A_DELETE))
2533 /* the common_toolbar_* stuff takes item->parent as data
2535 toolbar_action[i].func(widget, (gpointer)item->parent);
2536 else /* to be removed */
2537 toolbar_action[i].func(widget, (gpointer)item->parent->data);
2543 void toolbar_set_sensitive(MainWindow *mainwin)
2545 SensitiveCond state;
2547 Toolbar *toolbar = mainwin->toolbar;
2549 GSList *entry_list = NULL;
2551 typedef struct _Entry Entry;
2558 #define SET_WIDGET_COND(w, c) \
2560 Entry *e = g_new0(Entry, 1); \
2563 entry_list = g_slist_append(entry_list, e); \
2566 SET_WIDGET_COND(toolbar->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2567 SET_WIDGET_COND(toolbar->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2568 SET_WIDGET_COND(toolbar->compose_news_btn, M_HAVE_ACCOUNT);
2569 SET_WIDGET_COND(toolbar->reply_btn,
2570 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2571 SET_WIDGET_COND(toolbar->replyall_btn,
2572 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2573 SET_WIDGET_COND(toolbar->replylist_btn,
2574 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2575 SET_WIDGET_COND(toolbar->replysender_btn,
2576 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2577 SET_WIDGET_COND(toolbar->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
2579 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST);
2580 SET_WIDGET_COND(toolbar->delete_btn,
2581 M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
2582 SET_WIDGET_COND(toolbar->exec_btn, M_DELAY_EXEC);
2584 for (cur = toolbar->action_list; cur != NULL; cur = cur->next) {
2585 ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
2587 SET_WIDGET_COND(act->widget, M_TARGET_EXIST|M_UNLOCKED);
2590 #undef SET_WIDGET_COND
2592 state = main_window_get_current_state(mainwin);
2594 for (cur = entry_list; cur != NULL; cur = cur->next) {
2595 Entry *e = (Entry*) cur->data;
2597 if (e->widget != NULL) {
2598 sensitive = ((e->cond & state) == e->cond);
2599 gtk_widget_set_sensitive(e->widget, sensitive);
2603 while (entry_list != NULL) {
2604 Entry *e = (Entry*) entry_list->data;
2608 entry_list = g_slist_remove(entry_list, e);
2611 g_slist_free(entry_list);
2613 activate_compose_button(toolbar,
2614 prefs_common.toolbar_style,
2615 toolbar->compose_btn_type);
2618 static void toolbar_update(MainWindow *mainwin)
2620 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox),
2621 GTK_WIDGET(mainwin->toolbar->toolbar));
2623 mainwin->toolbar->toolbar = NULL;
2624 mainwin->toolbar->get_btn = NULL;
2625 mainwin->toolbar->getall_btn = NULL;
2626 mainwin->toolbar->send_btn = NULL;
2627 mainwin->toolbar->compose_mail_btn = NULL;
2628 mainwin->toolbar->compose_news_btn = NULL;
2629 mainwin->toolbar->reply_btn = NULL;
2630 mainwin->toolbar->replyall_btn = NULL;
2631 mainwin->toolbar->replylist_btn = NULL;
2632 mainwin->toolbar->replysender_btn = NULL;
2633 mainwin->toolbar->fwd_btn = NULL;
2634 mainwin->toolbar->delete_btn = NULL;
2635 mainwin->toolbar->next_btn = NULL;
2636 mainwin->toolbar->exec_btn = NULL;
2638 toolbar_clear_list(TOOLBAR_MAIN);
2639 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2640 toolbar_create(mainwin, mainwin->handlebox);
2641 toolbar_set_sensitive(mainwin);
2645 static void toolbar_create(MainWindow *mainwin,
2646 GtkWidget *container)
2648 ToolbarItem *toolbar_item;
2651 GtkWidget *icon_wid = NULL;
2652 GtkWidget *icon_news = NULL;
2653 GtkWidget *item_news = NULL;
2655 GtkTooltips *toolbar_tips;
2656 ToolbarSylpheedActions *action_item;
2658 GSList *toolbar_list;
2660 guint n_menu_entries;
2661 GtkWidget *reply_popup;
2662 GtkWidget *replyall_popup;
2663 GtkWidget *replylist_popup;
2664 GtkWidget *replysender_popup;
2665 GtkWidget *fwd_popup;
2667 toolbar_tips = gtk_tooltips_new();
2669 if (mainwin->toolbar != NULL) {
2670 toolbar_clear_list(TOOLBAR_MAIN);
2671 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2672 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2673 g_free(mainwin->toolbar);
2676 toolbar_read_config_file(TOOLBAR_MAIN);
2677 toolbar_list = toolbar_get_list(TOOLBAR_MAIN);
2679 mainwin->toolbar = g_new0(Toolbar, 1);
2681 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
2683 gtk_container_add(GTK_CONTAINER(container), toolbar);
2684 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
2685 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
2686 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
2687 GTK_TOOLBAR_SPACE_LINE);
2689 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2691 if (g_strcasecmp(((ToolbarItem*)cur->data)->file, SEPARATOR) == 0) {
2692 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2696 toolbar_item = g_new0(ToolbarItem, 1);
2697 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2698 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2699 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2701 toolbar_item->parent = g_new0(ToolbarParent, 1);
2702 toolbar_item->parent->data = (gpointer)mainwin;
2703 toolbar_item->parent->type = TOOLBAR_MAIN;
2705 /* collect toolbar items in list to keep track */
2706 mainwin->toolbar->item_list = g_slist_append(mainwin->toolbar->item_list,
2709 icon_wid = stock_pixmap_widget(container, stock_pixmap_get_icon(toolbar_item->file));
2710 item = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2714 icon_wid, toolbar_buttons_cb,
2717 switch (toolbar_item->index) {
2719 mainwin->toolbar->getall_btn = item;
2720 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2721 mainwin->toolbar->getall_btn,
2722 _("Receive Mail on all Accounts"), NULL);
2725 mainwin->toolbar->get_btn = item;
2726 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2727 mainwin->toolbar->get_btn,
2728 _("Receive Mail on current Account"), NULL);
2731 mainwin->toolbar->send_btn = item;
2732 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2733 mainwin->toolbar->send_btn,
2734 _("Send Queued Message(s)"), NULL);
2736 case A_COMPOSE_EMAIL:
2737 icon_news = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2738 item_news = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2742 icon_news, toolbar_buttons_cb,
2744 mainwin->toolbar->compose_mail_btn = item;
2745 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2746 mainwin->toolbar->compose_mail_btn,
2747 _("Compose Email"), NULL);
2748 mainwin->toolbar->compose_news_btn = item_news;
2749 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2750 mainwin->toolbar->compose_news_btn,
2751 _("Compose News"), NULL);
2753 case A_REPLY_MESSAGE:
2754 mainwin->toolbar->reply_btn = item;
2755 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2756 mainwin->toolbar->reply_btn,
2757 _("Reply to Message"), NULL);
2758 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->reply_btn),
2759 "button_press_event",
2760 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2762 n_menu_entries = sizeof(reply_popup_entries) /
2763 sizeof(reply_popup_entries[0]);
2764 reply_popup = popupmenu_create(mainwin->window, reply_popup_entries, n_menu_entries,
2765 "<ReplyPopup>", mainwin);
2766 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
2767 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
2768 mainwin->toolbar->reply_popup = reply_popup;
2770 case A_REPLY_SENDER:
2771 mainwin->toolbar->replysender_btn = item;
2772 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2773 mainwin->toolbar->replysender_btn,
2774 _("Reply to Sender"), NULL);
2775 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replysender_btn),
2776 "button_press_event",
2777 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2779 n_menu_entries = sizeof(replysender_popup_entries) /
2780 sizeof(replysender_popup_entries[0]);
2781 replysender_popup = popupmenu_create(mainwin->window,
2782 replysender_popup_entries, n_menu_entries,
2783 "<ReplySenderPopup>", mainwin);
2784 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
2785 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
2786 mainwin->toolbar->replysender_popup = replysender_popup;
2789 mainwin->toolbar->replyall_btn = item;
2790 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2791 mainwin->toolbar->replyall_btn,
2792 _("Reply to All"), NULL);
2793 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replyall_btn),
2794 "button_press_event",
2795 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2797 n_menu_entries = sizeof(replyall_popup_entries) /
2798 sizeof(replyall_popup_entries[0]);
2799 replyall_popup = popupmenu_create(mainwin->window,
2800 replyall_popup_entries, n_menu_entries,
2801 "<ReplyAllPopup>", mainwin);
2802 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
2803 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
2804 mainwin->toolbar->replyall_popup = replyall_popup;
2807 mainwin->toolbar->replylist_btn = item;
2808 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2809 mainwin->toolbar->replylist_btn,
2810 _("Reply to Mailing-list"), NULL);
2811 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replylist_btn),
2812 "button_press_event",
2813 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_cb),
2815 n_menu_entries = sizeof(replylist_popup_entries) /
2816 sizeof(replylist_popup_entries[0]);
2817 replylist_popup = popupmenu_create(mainwin->window,
2818 replylist_popup_entries, n_menu_entries,
2819 "<ReplyMlPopup>", mainwin);
2820 gtk_signal_connect(GTK_OBJECT(replylist_popup), "selection_done",
2821 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_closed_cb), mainwin);
2822 mainwin->toolbar->replylist_popup = replylist_popup;
2825 mainwin->toolbar->fwd_btn = item;
2826 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2827 mainwin->toolbar->fwd_btn,
2828 _("Forward Message"), NULL);
2829 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->fwd_btn),
2830 "button_press_event",
2831 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2833 n_menu_entries = sizeof(fwd_popup_entries) /
2834 sizeof(fwd_popup_entries[0]);
2835 fwd_popup = popupmenu_create(mainwin->window,
2836 fwd_popup_entries, n_menu_entries,
2837 "<ForwardPopup>", mainwin);
2838 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
2839 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
2840 mainwin->toolbar->fwd_popup = fwd_popup;
2843 mainwin->toolbar->delete_btn = item;
2844 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2845 mainwin->toolbar->delete_btn,
2846 _("Delete Message"), NULL);
2849 mainwin->toolbar->exec_btn = item;
2850 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2851 mainwin->toolbar->exec_btn,
2852 _("Execute"), NULL);
2855 mainwin->toolbar->next_btn = item;
2856 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2857 mainwin->toolbar->next_btn,
2858 _("Goto Next Message"), NULL);
2861 action_item = g_new0(ToolbarSylpheedActions, 1);
2862 action_item->widget = item;
2863 action_item->name = g_strdup(toolbar_item->text);
2865 mainwin->toolbar->action_list =
2866 g_slist_append(mainwin->toolbar->action_list,
2869 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2871 action_item->name, NULL);
2873 gtk_widget_show(item);
2880 mainwin->toolbar->toolbar = toolbar;
2882 activate_compose_button(mainwin->toolbar,
2883 prefs_common.toolbar_style,
2884 mainwin->toolbar->compose_btn_type);
2886 gtk_widget_show_all(toolbar);
2889 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2892 switch ((ToolbarStyle)action) {
2894 gtk_widget_hide(mainwin->handlebox);
2896 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2900 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2904 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2909 if (action != TOOLBAR_NONE) {
2910 gtk_widget_show(mainwin->handlebox);
2911 gtk_widget_queue_resize(mainwin->handlebox);
2914 mainwin->toolbar_style = (ToolbarStyle)action;
2915 prefs_common.toolbar_style = (ToolbarStyle)action;
2918 /* END Toolbar Stuff */
2920 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2923 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2924 gtk_widget_show(mainwin->hbox_stat);
2925 prefs_common.show_statusbar = TRUE;
2927 gtk_widget_hide(mainwin->hbox_stat);
2928 prefs_common.show_statusbar = FALSE;
2932 static void separate_widget_cb(MainWindow *mainwin, guint action,
2937 if (GTK_CHECK_MENU_ITEM(widget)->active)
2938 type = mainwin->type | action;
2940 type = mainwin->type & ~action;
2942 main_window_separation_change(mainwin, type);
2944 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2945 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2948 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2951 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2953 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2956 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2958 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2961 static void online_switch_clicked (GtkButton *btn, gpointer data)
2963 MainWindow *mainwin;
2964 GtkItemFactory *ifactory;
2965 GtkCheckMenuItem *menuitem;
2967 mainwin = (MainWindow *) data;
2969 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2970 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2972 g_return_if_fail(mainwin != NULL);
2973 g_return_if_fail(menuitem != NULL);
2975 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2977 gtk_widget_hide (mainwin->online_switch);
2978 gtk_widget_show (mainwin->offline_switch);
2979 menuitem->active = TRUE;
2980 prefs_common.work_offline = TRUE;
2981 inc_autocheck_timer_remove();
2984 gtk_widget_hide (mainwin->offline_switch);
2985 gtk_widget_show (mainwin->online_switch);
2986 menuitem->active = FALSE;
2987 prefs_common.work_offline = FALSE;
2988 inc_autocheck_timer_set();
2992 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2995 addressbook_open(NULL);
2998 static void log_window_show_cb(MainWindow *mainwin, guint action,
3001 log_window_show(mainwin->logwin);
3004 static void sel_download_cb(MainWindow *mainwin, guint action,
3007 selective_download(mainwin);
3010 static void prefs_toolbar_cb(MainWindow *mainwin, guint action,
3013 prefs_toolbar_open((ToolbarType)action);
3017 void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3019 inc_mail(mainwin, prefs_common.newmail_notify_manu);
3022 void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
3025 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
3028 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3033 void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3037 if (prefs_common.work_offline)
3038 if (alertpanel(_("Offline warning"),
3039 _("You're working offline. Override?"),
3040 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
3043 for (list = folder_get_list(); list != NULL; list = list->next) {
3044 Folder *folder = list->data;
3046 if (folder->queue) {
3047 if (procmsg_send_queue
3048 (folder->queue, prefs_common.savemsg) < 0)
3049 alertpanel_error(_("Some errors occurred while sending queued messages."));
3050 statusbar_pop_all();
3051 folder_item_scan(folder->queue);
3052 folder_update_item(folder->queue, TRUE);
3057 void compose_mail_cb(MainWindow *mainwin, guint action,
3060 PrefsAccount *ac = NULL;
3061 FolderItem *item = mainwin->summaryview->folder_item;
3066 ac = account_find_from_item(item);
3067 if (ac && ac->protocol != A_NNTP) {
3068 compose_new_with_folderitem(ac, item); /* CLAWS */
3074 * CLAWS - use current account
3076 if (cur_account && (cur_account->protocol != A_NNTP)) {
3077 compose_new_with_folderitem(cur_account, item);
3082 * CLAWS - just get the first one
3084 list = account_get_list();
3085 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3086 ac = (PrefsAccount *) cur->data;
3087 if (ac->protocol != A_NNTP) {
3088 compose_new_with_folderitem(ac, item);
3094 void compose_news_cb(MainWindow *mainwin, guint action,
3097 PrefsAccount * ac = NULL;
3101 if (mainwin->summaryview->folder_item) {
3102 ac = mainwin->summaryview->folder_item->folder->account;
3103 if (ac && ac->protocol == A_NNTP) {
3105 mainwin->summaryview->folder_item->path,
3111 list = account_get_list();
3112 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3113 ac = (PrefsAccount *) cur->data;
3114 if (ac->protocol == A_NNTP) {
3115 compose_new(ac, NULL, NULL);
3121 void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3123 summary_reply(mainwin->summaryview, (ComposeMode)action);
3126 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3128 summary_move_to(mainwin->summaryview);
3131 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3133 summary_copy_to(mainwin->summaryview);
3136 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3138 summary_delete(mainwin->summaryview);
3141 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3143 summary_cancel(mainwin->summaryview);
3146 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3148 summary_open_msg(mainwin->summaryview);
3151 static void view_source_cb(MainWindow *mainwin, guint action,
3154 summary_view_source(mainwin->summaryview);
3157 static void show_all_header_cb(MainWindow *mainwin, guint action,
3160 if (mainwin->menu_lock_count) return;
3161 summary_display_msg_selected(mainwin->summaryview,
3162 GTK_CHECK_MENU_ITEM(widget)->active);
3165 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3167 summary_reedit(mainwin->summaryview);
3170 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3172 summary_mark(mainwin->summaryview);
3175 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3177 summary_unmark(mainwin->summaryview);
3180 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3183 summary_mark_as_unread(mainwin->summaryview);
3186 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3189 summary_mark_as_read(mainwin->summaryview);
3192 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3195 summary_mark_all_read(mainwin->summaryview);
3198 static void add_address_cb(MainWindow *mainwin, guint action,
3201 summary_add_address(mainwin->summaryview);
3204 static void set_charset_cb(MainWindow *mainwin, guint action,
3209 str = conv_get_charset_str((CharSet)action);
3210 g_free(prefs_common.force_charset);
3211 prefs_common.force_charset = str ? g_strdup(str) : NULL;
3213 summary_redisplay_msg(mainwin->summaryview);
3215 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3218 static void hide_read_messages (MainWindow *mainwin, guint action,
3221 if (!mainwin->summaryview->folder_item
3222 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
3224 summary_toggle_show_read_messages(mainwin->summaryview);
3227 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3229 if (mainwin->menu_lock_count) return;
3230 if (!mainwin->summaryview->folder_item) return;
3232 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3233 summary_thread_build(mainwin->summaryview);
3234 /* mainwin->summaryview->folder_item->threaded = TRUE; */
3236 summary_unthread(mainwin->summaryview);
3237 /* mainwin->summaryview->folder_item->threaded = FALSE; */
3241 static void expand_threads_cb(MainWindow *mainwin, guint action,
3244 summary_expand_threads(mainwin->summaryview);
3247 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3250 summary_collapse_threads(mainwin->summaryview);
3253 static void set_display_item_cb(MainWindow *mainwin, guint action,
3256 prefs_summary_column_open();
3259 static void sort_summary_cb(MainWindow *mainwin, guint action,
3262 FolderItem *item = mainwin->summaryview->folder_item;
3263 GtkWidget *menuitem;
3265 if (mainwin->menu_lock_count) return;
3267 menuitem = gtk_item_factory_get_item
3268 (mainwin->menu_factory, "/View/Sort/Ascending");
3269 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3270 GTK_CHECK_MENU_ITEM(menuitem)->active
3271 ? SORT_ASCENDING : SORT_DESCENDING);
3275 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3278 FolderItem *item = mainwin->summaryview->folder_item;
3280 if (mainwin->menu_lock_count) return;
3282 summary_sort(mainwin->summaryview,
3283 item->sort_key, (FolderSortType)action);
3286 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3289 summary_attract_by_subject(mainwin->summaryview);
3292 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3295 summary_delete_duplicated(mainwin->summaryview);
3298 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3300 summary_filter(mainwin->summaryview);
3303 static void execute_summary_cb(MainWindow *mainwin, guint action,
3306 summary_execute(mainwin->summaryview);
3309 static void update_summary_cb(MainWindow *mainwin, guint action,
3313 FolderView *folderview = mainwin->folderview;
3315 if (!mainwin->summaryview->folder_item) return;
3316 if (!folderview->opened) return;
3318 folder_update_op_count();
3320 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3321 folderview->opened);
3324 folder_item_scan(fitem);
3325 summary_show(mainwin->summaryview, fitem);
3328 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3330 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3333 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3335 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3338 static void prev_unread_cb(MainWindow *mainwin, guint action,
3341 summary_select_prev_unread(mainwin->summaryview);
3344 void next_unread_cb(MainWindow *mainwin, guint action,
3347 summary_select_next_unread(mainwin->summaryview);
3350 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3352 summary_select_prev_new(mainwin->summaryview);
3355 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3357 summary_select_next_new(mainwin->summaryview);
3360 static void prev_marked_cb(MainWindow *mainwin, guint action,
3363 summary_select_prev_marked(mainwin->summaryview);
3366 static void next_marked_cb(MainWindow *mainwin, guint action,
3369 summary_select_next_marked(mainwin->summaryview);
3372 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3375 summary_select_prev_labeled(mainwin->summaryview);
3378 static void next_labeled_cb(MainWindow *mainwin, guint action,
3381 summary_select_next_labeled(mainwin->summaryview);
3384 static void goto_folder_cb(MainWindow *mainwin, guint action,
3387 FolderItem *to_folder;
3389 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3392 folderview_select(mainwin->folderview, to_folder);
3395 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3397 messageview_copy_clipboard(mainwin->messageview);
3400 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3402 MessageView *msgview = mainwin->messageview;
3404 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3405 summary_select_all(mainwin->summaryview);
3406 else if (messageview_is_visible(msgview) &&
3407 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
3408 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3409 messageview_select_all(mainwin->messageview);
3412 static void select_thread_cb(MainWindow *mainwin, guint action,
3415 summary_select_thread(mainwin->summaryview);
3418 static void create_filter_cb(MainWindow *mainwin, guint action,
3421 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3424 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3427 prefs_common_open();
3430 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3433 prefs_scoring_open(NULL);
3436 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3439 prefs_filtering_open(NULL, NULL, NULL);
3442 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3445 prefs_template_open();
3448 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3451 prefs_actions_open(mainwin);
3454 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3457 ssl_manager_open(mainwin);
3460 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3464 new_account_cb(mainwin, 0, widget);
3466 account_open(cur_account);
3470 static void new_account_cb(MainWindow *mainwin, guint action,
3473 account_edit_open();
3474 if (!compose_get_compose_list()) account_add();
3477 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3479 cur_account = (PrefsAccount *)data;
3480 main_window_reflect_prefs_all();
3483 static void manual_open_cb(MainWindow *mainwin, guint action,
3486 manual_open((ManualType)action);
3489 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3491 MainWindow *mainwin = (MainWindow *)data;
3495 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3496 LOCAL_FOLDER(folder)->rootpath,
3500 str = g_strdup_printf(_("Scanning folder %s ..."),
3501 LOCAL_FOLDER(folder)->rootpath);
3503 STATUSBAR_PUSH(mainwin, str);
3504 STATUSBAR_POP(mainwin);
3508 #define BREAK_ON_MODIFIER_KEY() \
3509 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3511 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3513 MainWindow *mainwin = (MainWindow*) data;
3515 if (!mainwin || !event) return;
3517 switch (event->keyval) {
3518 case GDK_Q: /* Quit */
3519 BREAK_ON_MODIFIER_KEY();
3521 app_exit_cb(mainwin, 0, NULL);
3524 if (mainwin->folderview && mainwin->summaryview
3525 && !mainwin->summaryview->displayed) {
3526 summary_lock(mainwin->summaryview);
3527 folderview_select_next_unread(mainwin->folderview);
3528 summary_unlock(mainwin->summaryview);
3536 #undef BREAK_ON_MODIFIER_KEY
3539 * Harvest addresses for selected folder.
3541 static void addr_harvest_cb( MainWindow *mainwin,
3545 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3549 * Harvest addresses for selected messages in summary view.
3551 static void addr_harvest_msg_cb( MainWindow *mainwin,
3555 summary_harvest_address( mainwin->summaryview );