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 toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
493 static void addr_harvest_cb ( MainWindow *mainwin,
497 static void addr_harvest_msg_cb ( MainWindow *mainwin,
501 #define SEPARATE_ACTION 500
503 static GtkItemFactoryEntry mainwin_entries[] =
505 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
506 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
507 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
508 {N_("/_File/_Check for new messages in all folders"),
509 NULL, update_folderview_cb, 0, NULL},
510 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
511 {N_("/_File/_Folder/Create _new folder..."),
512 NULL, new_folder_cb, 0, NULL},
513 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
514 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
515 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
516 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
517 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
518 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
519 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
520 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
521 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
522 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
523 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
524 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
526 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
527 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
528 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
529 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
530 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
531 {N_("/_Edit/_Find in current message..."),
532 "<control>F", search_cb, 0, NULL},
533 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
534 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
535 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
536 {N_("/_View/Show or hi_de/_Folder tree"),
537 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
538 {N_("/_View/Show or hi_de/_Message view"),
539 "V", toggle_message_cb, 0, "<ToggleItem>"},
540 {N_("/_View/Show or hi_de/_Toolbar"),
541 NULL, NULL, 0, "<Branch>"},
542 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
543 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
544 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
545 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
546 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
547 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
548 {N_("/_View/Show or hi_de/_Toolbar/_None"),
549 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
550 {N_("/_View/Show or hi_de/Status _bar"),
551 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
552 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
553 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
554 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
555 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
556 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
557 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
558 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
559 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
560 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
561 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
562 {N_("/_View/_Sort/by _color label"),
563 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
564 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
565 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
566 {N_("/_View/_Sort/by a_ttachment"),
567 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
568 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
569 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
570 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
571 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
572 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
573 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
574 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
575 {N_("/_View/_Sort/_Attract by subject"),
576 NULL, attract_by_subject_cb, 0, NULL},
577 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
578 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
579 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
580 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
581 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
583 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
584 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
585 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
586 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
587 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
588 {N_("/_View/_Go to/P_rev unread message"),
589 "<shift>P", prev_unread_cb, 0, NULL},
590 {N_("/_View/_Go to/N_ext unread message"),
591 "<shift>N", next_unread_cb, 0, NULL},
592 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
593 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
594 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
595 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
596 {N_("/_View/_Go to/Prev _marked message"),
597 NULL, prev_marked_cb, 0, NULL},
598 {N_("/_View/_Go to/Next m_arked message"),
599 NULL, next_marked_cb, 0, NULL},
600 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
601 {N_("/_View/_Go to/Prev _labeled message"),
602 NULL, prev_labeled_cb, 0, NULL},
603 {N_("/_View/_Go to/Next la_beled message"),
604 NULL, next_labeled_cb, 0, NULL},
605 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
606 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
607 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
609 #define CODESET_SEPARATOR \
610 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
611 #define CODESET_ACTION(action) \
612 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
614 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
615 {N_("/_View/_Code set/_Auto detect"),
616 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
617 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
618 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
619 CODESET_ACTION(C_US_ASCII)},
622 {N_("/_View/_Code set/Unicode (_UTF-8)"),
623 CODESET_ACTION(C_UTF_8)},
626 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
627 CODESET_ACTION(C_ISO_8859_1)},
628 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
629 CODESET_ACTION(C_ISO_8859_15)},
632 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
633 CODESET_ACTION(C_ISO_8859_2)},
635 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
636 CODESET_ACTION(C_ISO_8859_13)},
637 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
638 CODESET_ACTION(C_ISO_8859_4)},
640 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
641 CODESET_ACTION(C_ISO_8859_7)},
643 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
644 CODESET_ACTION(C_ISO_8859_9)},
646 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
647 CODESET_ACTION(C_ISO_8859_5)},
648 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
649 CODESET_ACTION(C_KOI8_R)},
650 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
651 CODESET_ACTION(C_WINDOWS_1251)},
654 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
655 CODESET_ACTION(C_ISO_2022_JP)},
657 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
658 CODESET_ACTION(C_ISO_2022_JP_2)},
660 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
661 CODESET_ACTION(C_EUC_JP)},
662 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
663 CODESET_ACTION(C_SHIFT_JIS)},
666 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
667 CODESET_ACTION(C_GB2312)},
668 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
669 CODESET_ACTION(C_BIG5)},
670 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
671 CODESET_ACTION(C_EUC_TW)},
672 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
673 CODESET_ACTION(C_ISO_2022_CN)},
675 {N_("/_View/_Code set/Korean (EUC-_KR)"),
676 CODESET_ACTION(C_EUC_KR)},
677 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
678 CODESET_ACTION(C_ISO_2022_KR)},
680 {N_("/_View/_Code set/Thai (TIS-620)"),
681 CODESET_ACTION(C_TIS_620)},
682 {N_("/_View/_Code set/Thai (Windows-874)"),
683 CODESET_ACTION(C_WINDOWS_874)},
686 #undef CODESET_SEPARATOR
687 #undef CODESET_ACTION
689 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
690 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
691 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
692 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
693 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
694 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
696 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
697 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
698 {N_("/_Message/Get from _all accounts"),
699 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
700 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
701 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
702 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
703 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
704 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
705 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
706 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
707 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
708 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
709 {N_("/_Message/Repl_y to/_sender"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
710 {N_("/_Message/Repl_y to/mailing _list"),
711 "<control>L", reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
712 {N_("/_Message/Follow-up and reply to"),NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
713 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
714 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
715 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
716 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
717 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
718 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
719 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
720 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
721 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
722 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
723 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
724 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
725 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
726 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
727 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
728 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
729 {N_("/_Message/_Mark/Mark as rea_d"),
730 NULL, mark_as_read_cb, 0, NULL},
731 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
733 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
734 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
735 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
736 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
737 {N_("/_Tools/Add sender to address boo_k"),
738 NULL, add_address_cb, 0, NULL},
739 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
740 {N_("/_Tools/_Harvest addresses/from _Folder..."),
741 NULL, addr_harvest_cb, 0, NULL},
742 {N_("/_Tools/_Harvest addresses/from _Messages..."),
743 NULL, addr_harvest_msg_cb, 0, NULL},
744 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
745 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
746 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
747 {N_("/_Tools/_Create filter rule/_Automatically"),
748 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
749 {N_("/_Tools/_Create filter rule/by _From"),
750 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
751 {N_("/_Tools/_Create filter rule/by _To"),
752 NULL, create_filter_cb, FILTER_BY_TO, NULL},
753 {N_("/_Tools/_Create filter rule/by _Subject"),
754 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
755 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
756 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
757 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
758 {N_("/_Tools/Delete du_plicated messages"),
759 NULL, delete_duplicated_cb, 0, NULL},
760 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
761 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
763 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
764 {N_("/_Tools/SSL certi_ficates..."),
765 NULL, ssl_manager_open_cb, 0, NULL},
767 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
768 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
770 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
771 {N_("/_Configuration/_Common preferences..."),
772 NULL, prefs_common_open_cb, 0, NULL},
773 {N_("/_Configuration/C_ustomize toolbars"),
774 NULL, NULL, 0, "<Branch>"},
775 {N_("/_Configuration/C_ustomize toolbars/_Main window..."),
776 NULL, prefs_toolbar_cb, TOOLBAR_MAIN, NULL},
777 {N_("/_Configuration/C_ustomize toolbars/_Compose window..."),
778 NULL, prefs_toolbar_cb, TOOLBAR_COMPOSE, NULL},
779 {N_("/_Configuration/C_ustomize toolbars/M_essage view..."),
780 NULL, prefs_toolbar_cb, TOOLBAR_MSGVIEW, NULL},
781 {N_("/_Configuration/_Scoring..."),
782 NULL, prefs_scoring_open_cb, 0, NULL},
783 {N_("/_Configuration/_Filtering..."),
784 NULL, prefs_filtering_open_cb, 0, NULL},
785 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
786 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
787 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
788 {N_("/_Configuration/_Preferences for current account..."),
789 NULL, prefs_account_open_cb, 0, NULL},
790 {N_("/_Configuration/Create _new account..."),
791 NULL, new_account_cb, 0, NULL},
792 {N_("/_Configuration/_Edit accounts..."),
793 NULL, account_edit_open, 0, NULL},
794 {N_("/_Configuration/C_hange current account"),
795 NULL, NULL, 0, "<Branch>"},
797 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
798 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
799 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
800 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
801 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
802 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
803 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
804 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
805 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
810 static GtkItemFactoryEntry reply_popup_entries[] =
812 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
813 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
815 static GtkItemFactoryEntry replyall_popup_entries[] =
817 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
818 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
820 static GtkItemFactoryEntry replylist_popup_entries[] =
822 {N_("/Reply to list with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE, NULL},
823 {N_("/_Reply to list without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE, NULL}
825 static GtkItemFactoryEntry replysender_popup_entries[] =
827 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
828 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
830 static GtkItemFactoryEntry fwd_popup_entries[] =
832 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
833 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
836 MainWindow *main_window_create(SeparateType type)
842 GtkWidget *handlebox;
843 GtkWidget *vbox_body;
844 GtkWidget *hbox_stat;
845 GtkWidget *statusbar;
846 GtkWidget *progressbar;
847 GtkWidget *statuslabel;
848 GtkWidget *ac_button;
850 GtkWidget *online_pixmap;
851 GtkWidget *offline_pixmap;
852 GtkWidget *online_switch;
853 GtkWidget *offline_switch;
855 FolderView *folderview;
856 SummaryView *summaryview;
857 MessageView *messageview;
858 GdkColormap *colormap;
861 GtkItemFactory *ifactory;
865 guint n_menu_entries;
867 static GdkGeometry geometry;
869 debug_print("Creating main window...\n");
870 mainwin = g_new0(MainWindow, 1);
873 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
874 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
875 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
876 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
878 if (!geometry.min_height) {
879 geometry.min_width = 320;
880 geometry.min_height = 200;
882 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
885 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
886 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
887 MANAGE_WINDOW_SIGNALS_CONNECT(window);
888 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
889 GTK_SIGNAL_FUNC(mainwindow_key_pressed), mainwin);
891 gtk_widget_realize(window);
892 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
895 gtkut_widget_set_app_icon(window);
897 vbox = gtk_vbox_new(FALSE, 0);
898 gtk_widget_show(vbox);
899 gtk_container_add(GTK_CONTAINER(window), vbox);
902 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
903 menubar = menubar_create(window, mainwin_entries,
904 n_menu_entries, "<Main>", mainwin);
905 gtk_widget_show(menubar);
906 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
907 ifactory = gtk_item_factory_from_widget(menubar);
909 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
910 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
912 handlebox = gtk_handle_box_new();
913 gtk_widget_show(handlebox);
914 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
916 /* link window to mainwin->window to avoid gdk warnings */
917 mainwin->window = window;
920 toolbar_create(mainwin, handlebox);
922 /* vbox that contains body */
923 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
924 gtk_widget_show(vbox_body);
925 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
926 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
928 hbox_stat = gtk_hbox_new(FALSE, 2);
929 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
931 statusbar = statusbar_create();
932 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
934 progressbar = gtk_progress_bar_new();
935 gtk_widget_set_usize(progressbar, 120, 1);
936 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
938 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
939 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
940 online_switch = gtk_button_new ();
941 offline_switch = gtk_button_new ();
942 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
943 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
944 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
945 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
946 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
947 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
948 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
949 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
951 statuslabel = gtk_label_new("");
952 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
954 ac_button = gtk_button_new();
955 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
956 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
957 gtk_widget_set_usize(ac_button, -1, 1);
958 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
959 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
960 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
962 ac_label = gtk_label_new("");
963 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
965 gtk_widget_show_all(hbox_stat);
967 gtk_widget_hide(offline_switch);
969 mainwin->folderview = folderview = folderview_create();
970 mainwin->summaryview = summaryview = summary_create();
971 mainwin->messageview = messageview = messageview_create(mainwin);
972 mainwin->logwin = log_window_create();
974 folderview->mainwin = mainwin;
975 folderview->summaryview = summaryview;
977 summaryview->mainwin = mainwin;
978 summaryview->folderview = folderview;
979 summaryview->messageview = messageview;
980 summaryview->window = window;
982 mainwin->vbox = vbox;
983 mainwin->menubar = menubar;
984 mainwin->menu_factory = ifactory;
985 mainwin->handlebox = handlebox;
986 mainwin->vbox_body = vbox_body;
987 mainwin->hbox_stat = hbox_stat;
988 mainwin->statusbar = statusbar;
989 mainwin->progressbar = progressbar;
990 mainwin->statuslabel = statuslabel;
991 mainwin->ac_button = ac_button;
992 mainwin->ac_label = ac_label;
994 mainwin->online_switch = online_switch;
995 mainwin->offline_switch = offline_switch;
996 mainwin->online_pixmap = online_pixmap;
997 mainwin->offline_pixmap = offline_pixmap;
999 /* set context IDs for status bar */
1000 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1001 (GTK_STATUSBAR(statusbar), "Main Window");
1002 mainwin->folderview_cid = gtk_statusbar_get_context_id
1003 (GTK_STATUSBAR(statusbar), "Folder View");
1004 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1005 (GTK_STATUSBAR(statusbar), "Summary View");
1007 /* allocate colors for summary view and folder view */
1008 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1009 summaryview->color_marked.blue = (guint16)65535;
1011 summaryview->color_dim.red = summaryview->color_dim.green =
1012 summaryview->color_dim.blue = COLOR_DIM;
1014 folderview->color_new.red = (guint16)55000;
1015 folderview->color_new.green = folderview->color_new.blue = 15000;
1017 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1018 &folderview->color_op);
1020 summaryview->color_important.red = 0;
1021 summaryview->color_important.green = 0;
1022 summaryview->color_important.blue = (guint16)65535;
1024 color[0] = summaryview->color_marked;
1025 color[1] = summaryview->color_dim;
1026 color[2] = folderview->color_new;
1027 color[3] = folderview->color_op;
1029 colormap = gdk_window_get_colormap(window->window);
1030 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1031 for (i = 0; i < 4; i++) {
1032 if (success[i] == FALSE)
1033 g_warning("MainWindow: color allocation %d failed\n", i);
1036 debug_print("done.\n");
1038 messageview->visible = TRUE;
1040 main_window_set_widgets(mainwin, type);
1042 /* set menu items */
1043 menuitem = gtk_item_factory_get_item
1044 (ifactory, "/View/Code set/Auto detect");
1045 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1047 switch (prefs_common.toolbar_style) {
1049 menuitem = gtk_item_factory_get_item
1050 (ifactory, "/View/Show or hide/Toolbar/None");
1053 menuitem = gtk_item_factory_get_item
1054 (ifactory, "/View/Show or hide/Toolbar/Icon");
1057 menuitem = gtk_item_factory_get_item
1058 (ifactory, "/View/Show or hide/Toolbar/Text");
1061 menuitem = gtk_item_factory_get_item
1062 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1064 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1066 gtk_widget_hide(mainwin->hbox_stat);
1067 menuitem = gtk_item_factory_get_item
1068 (ifactory, "/View/Show or hide/Status bar");
1069 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1070 prefs_common.show_statusbar);
1072 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
1074 if (prefs_common.show_searchbar)
1075 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
1078 /* set account selection menu */
1079 ac_menu = gtk_item_factory_get_widget
1080 (ifactory, "/Configuration/Change current account");
1081 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1082 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1083 mainwin->ac_menu = ac_menu;
1085 toolbar_set_sensitive(mainwin);
1087 /* create actions menu */
1088 update_mainwin_actions_menu(ifactory, mainwin);
1090 /* show main window */
1091 gtk_widget_set_uposition(mainwin->window,
1092 prefs_common.mainwin_x,
1093 prefs_common.mainwin_y);
1094 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1095 prefs_common.mainwin_height);
1096 gtk_widget_show(mainwin->window);
1098 /* initialize views */
1099 folderview_init(folderview);
1100 summary_init(summaryview);
1101 messageview_init(messageview);
1102 log_window_init(mainwin->logwin);
1104 sslcertwindow_register_hook();
1106 mainwin->lock_count = 0;
1107 mainwin->menu_lock_count = 0;
1108 mainwin->cursor_count = 0;
1111 watch_cursor = gdk_cursor_new(GDK_WATCH);
1113 mainwin_list = g_list_append(mainwin_list, mainwin);
1115 /* init work_offline */
1116 if (prefs_common.work_offline)
1117 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1122 void main_window_cursor_wait(MainWindow *mainwin)
1125 if (mainwin->cursor_count == 0)
1126 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1128 mainwin->cursor_count++;
1133 void main_window_cursor_normal(MainWindow *mainwin)
1135 if (mainwin->cursor_count)
1136 mainwin->cursor_count--;
1138 if (mainwin->cursor_count == 0)
1139 gdk_window_set_cursor(mainwin->window->window, NULL);
1144 /* lock / unlock the user-interface */
1145 void main_window_lock(MainWindow *mainwin)
1147 if (mainwin->lock_count == 0)
1148 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1150 mainwin->lock_count++;
1152 main_window_set_menu_sensitive(mainwin);
1153 toolbar_set_sensitive(mainwin);
1156 void main_window_unlock(MainWindow *mainwin)
1158 if (mainwin->lock_count)
1159 mainwin->lock_count--;
1161 main_window_set_menu_sensitive(mainwin);
1162 toolbar_set_sensitive(mainwin);
1164 if (mainwin->lock_count == 0)
1165 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1168 static void main_window_menu_callback_block(MainWindow *mainwin)
1170 mainwin->menu_lock_count++;
1173 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1175 if (mainwin->menu_lock_count)
1176 mainwin->menu_lock_count--;
1179 void main_window_reflect_prefs_all(void)
1181 main_window_reflect_prefs_all_real(FALSE);
1184 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1187 MainWindow *mainwin;
1190 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1191 mainwin = (MainWindow *)cur->data;
1193 main_window_show_cur_account(mainwin);
1194 main_window_set_menu_sensitive(mainwin);
1195 toolbar_set_sensitive(mainwin);
1198 if (pixmap_theme_changed) {
1199 toolbar_update(mainwin);
1200 common_toolbar_set_style(mainwin, TOOLBAR_MAIN);
1201 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1202 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1204 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1205 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1206 mainwin->online_pixmap);
1207 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1208 gtk_widget_show(pixmap);
1209 mainwin->online_pixmap = pixmap;
1210 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1211 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1212 mainwin->offline_pixmap);
1213 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1214 gtk_widget_show(pixmap);
1215 mainwin->offline_pixmap = pixmap;
1218 summary_redisplay_msg(mainwin->summaryview);
1219 headerview_set_visibility(mainwin->messageview->headerview,
1220 prefs_common.display_header_pane);
1224 void main_window_set_summary_column(void)
1227 MainWindow *mainwin;
1229 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1230 mainwin = (MainWindow *)cur->data;
1231 summary_set_column_order(mainwin->summaryview);
1235 void main_window_set_account_menu(GList *account_list)
1237 GList *cur, *cur_ac, *cur_item;
1238 GtkWidget *menuitem;
1239 MainWindow *mainwin;
1240 PrefsAccount *ac_prefs;
1242 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1243 mainwin = (MainWindow *)cur->data;
1245 /* destroy all previous menu item */
1246 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1247 while (cur_item != NULL) {
1248 GList *next = cur_item->next;
1249 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1253 for (cur_ac = account_list; cur_ac != NULL;
1254 cur_ac = cur_ac->next) {
1255 ac_prefs = (PrefsAccount *)cur_ac->data;
1257 menuitem = gtk_menu_item_new_with_label
1258 (ac_prefs->account_name
1259 ? ac_prefs->account_name : _("Untitled"));
1260 gtk_widget_show(menuitem);
1261 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1262 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1263 GTK_SIGNAL_FUNC(account_menu_cb),
1269 static void main_window_show_cur_account(MainWindow *mainwin)
1274 ac_name = g_strdup(cur_account
1275 ? (cur_account->account_name
1276 ? cur_account->account_name : _("Untitled"))
1280 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1282 buf = g_strdup(PROG_VERSION);
1283 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1286 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1287 gtk_widget_queue_resize(mainwin->ac_button);
1292 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1294 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1295 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1296 //GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1297 GtkWidget *message_wid = mainwin->messageview->vbox;
1299 debug_print("Changing window separation type from %d to %d\n",
1300 mainwin->type, type);
1302 if (mainwin->type == type) return;
1304 /* remove widgets from those containers */
1305 gtk_widget_ref(folder_wid);
1306 gtk_widget_ref(summary_wid);
1307 gtk_widget_ref(message_wid);
1308 gtkut_container_remove
1309 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1310 gtkut_container_remove
1311 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1312 gtkut_container_remove
1313 (GTK_CONTAINER(message_wid->parent), message_wid);
1315 /* clean containers */
1316 switch (mainwin->type) {
1318 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1320 case SEPARATE_FOLDER:
1321 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1322 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1324 case SEPARATE_MESSAGE:
1325 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1326 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1329 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1330 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1334 gtk_widget_hide(mainwin->window);
1335 main_window_set_widgets(mainwin, type);
1336 gtk_widget_show(mainwin->window);
1338 gtk_widget_unref(folder_wid);
1339 gtk_widget_unref(summary_wid);
1340 gtk_widget_unref(message_wid);
1343 void main_window_toggle_message_view(MainWindow *mainwin)
1345 SummaryView *summaryview = mainwin->summaryview;
1346 union CompositeWin *cwin = &mainwin->win;
1347 GtkWidget *vpaned = NULL;
1348 GtkWidget *container = NULL;
1349 GtkWidget *msgwin = NULL;
1351 switch (mainwin->type) {
1353 vpaned = cwin->sep_none.vpaned;
1354 container = cwin->sep_none.hpaned;
1356 case SEPARATE_FOLDER:
1357 vpaned = cwin->sep_folder.vpaned;
1358 container = mainwin->vbox_body;
1360 case SEPARATE_MESSAGE:
1361 msgwin = mainwin->win.sep_message.messagewin;
1364 msgwin = mainwin->win.sep_both.messagewin;
1369 if (GTK_WIDGET_VISIBLE(msgwin)) {
1370 gtk_widget_hide(msgwin);
1371 mainwin->messageview->visible = FALSE;
1372 summaryview->displayed = NULL;
1374 gtk_widget_show(msgwin);
1375 mainwin->messageview->visible = TRUE;
1377 } else if (vpaned->parent != NULL) {
1378 mainwin->messageview->visible = FALSE;
1379 summaryview->displayed = NULL;
1380 gtk_widget_ref(vpaned);
1381 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1382 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1383 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1384 GTK_ARROW_UP, GTK_SHADOW_OUT);
1386 mainwin->messageview->visible = TRUE;
1387 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1388 gtk_container_add(GTK_CONTAINER(container), vpaned);
1389 gtk_widget_unref(vpaned);
1390 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1391 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1394 main_window_set_menu_sensitive(mainwin);
1396 gtk_widget_grab_focus(summaryview->ctree);
1399 void main_window_get_size(MainWindow *mainwin)
1401 GtkAllocation *allocation;
1403 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1405 prefs_common.summaryview_width = allocation->width;
1407 if ((mainwin->type == SEPARATE_NONE ||
1408 mainwin->type == SEPARATE_FOLDER) &&
1409 messageview_is_visible(mainwin->messageview))
1410 prefs_common.summaryview_height = allocation->height;
1412 prefs_common.mainview_width = allocation->width;
1414 allocation = &mainwin->window->allocation;
1416 prefs_common.mainview_height = allocation->height;
1417 prefs_common.mainwin_width = allocation->width;
1418 prefs_common.mainwin_height = allocation->height;
1420 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1422 prefs_common.folderview_width = allocation->width;
1423 prefs_common.folderview_height = allocation->height;
1426 void main_window_get_position(MainWindow *mainwin)
1430 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1432 prefs_common.mainview_x = x;
1433 prefs_common.mainview_y = y;
1434 prefs_common.mainwin_x = x;
1435 prefs_common.mainwin_y = y;
1437 debug_print("window position: x = %d, y = %d\n", x, y);
1440 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1446 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1447 folder = FOLDER(list->data);
1448 if (folder && folder->trash && folder->trash->total > 0)
1452 if (!has_trash) return;
1455 if (alertpanel(_("Empty trash"),
1456 _("Empty all messages in trash?"),
1457 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1459 manage_window_focus_in(mainwin->window, NULL, NULL);
1462 procmsg_empty_trash();
1464 for (list = folder_get_list(); list != NULL; list = list->next) {
1465 folder = list->data;
1466 if (folder && folder->trash) {
1467 folder_update_item(folder->trash, TRUE);
1471 if (mainwin->summaryview->folder_item &&
1472 mainwin->summaryview->folder_item->stype == F_TRASH)
1473 gtk_widget_grab_focus(mainwin->folderview->ctree);
1476 void main_window_add_mailbox(MainWindow *mainwin)
1481 path = input_dialog(_("Add mailbox"),
1482 _("Input the location of mailbox.\n"
1483 "If the existing mailbox is specified, it will be\n"
1484 "scanned automatically."),
1487 if (folder_find_from_path(path)) {
1488 alertpanel_error(_("The mailbox `%s' already exists."), path);
1492 if (!strcmp(path, "Mail"))
1493 folder = folder_new(F_MH, _("Mailbox"), path);
1495 folder = folder_new(F_MH, g_basename(path), path);
1498 if (folder->create_tree(folder) < 0) {
1499 alertpanel_error(_("Creation of the mailbox failed.\n"
1500 "Maybe some files already exist, or you don't have the permission to write there."));
1501 folder_destroy(folder);
1506 folder_set_ui_func(folder, scan_tree_func, mainwin);
1507 folder_scan_tree(folder);
1508 folder_set_ui_func(folder, NULL, NULL);
1510 folderview_set(mainwin->folderview);
1513 void main_window_add_mbox(MainWindow *mainwin)
1519 path = input_dialog(_("Add mbox mailbox"),
1520 _("Input the location of mailbox."),
1525 if (folder_find_from_path(path)) {
1526 alertpanel_error(_("The mailbox `%s' already exists."), path);
1532 if (!strcmp(path, "Mail"))
1533 folder = folder_new(F_MBOX, _("Mailbox"), path);
1537 folder = folder_new(F_MBOX, g_basename(path), path);
1540 if (folder->create_tree(folder) < 0) {
1541 alertpanel_error(_("Creation of the mailbox failed."));
1542 folder_destroy(folder);
1548 item = folder_item_new(folder, folder->name, NULL);
1549 item->folder = folder;
1550 folder->node = g_node_new(item);
1552 folder_create_folder(item, "inbox");
1553 folder_create_folder(item, "outbox");
1554 folder_create_folder(item, "queue");
1555 folder_create_folder(item, "draft");
1556 folder_create_folder(item, "trash");
1558 folderview_set(mainwin->folderview);
1561 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1563 SensitiveCond state = 0;
1564 SummarySelection selection;
1565 FolderItem *item = mainwin->summaryview->folder_item;
1566 GList *account_list = account_get_list();
1568 selection = summary_get_selection_type(mainwin->summaryview);
1570 if (mainwin->lock_count == 0)
1571 state |= M_UNLOCKED;
1572 if (selection != SUMMARY_NONE)
1573 state |= M_MSG_EXIST;
1574 if (item && item->path && item->parent && !item->no_select) {
1576 /* if (item->folder->type != F_NEWS) */
1577 state |= M_ALLOW_DELETE;
1579 if (prefs_common.immediate_exec == 0
1580 && mainwin->lock_count == 0)
1581 state |= M_DELAY_EXEC;
1583 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1584 || selection != SUMMARY_NONE)
1585 state |= M_HIDE_READ_MSG;
1587 if (mainwin->summaryview->threaded)
1588 state |= M_THREADED;
1590 state |= M_UNTHREADED;
1591 if (selection == SUMMARY_SELECTED_SINGLE ||
1592 selection == SUMMARY_SELECTED_MULTIPLE)
1593 state |= M_TARGET_EXIST;
1594 if (selection == SUMMARY_SELECTED_SINGLE)
1595 state |= M_SINGLE_TARGET_EXIST;
1596 if (mainwin->summaryview->folder_item &&
1597 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1600 state |= M_NOT_NEWS;
1601 if (selection == SUMMARY_SELECTED_SINGLE &&
1603 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1604 item->stype == F_QUEUE)))
1605 state |= M_ALLOW_REEDIT;
1607 state |= M_HAVE_ACCOUNT;
1609 for ( ; account_list != NULL; account_list = account_list->next) {
1610 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1611 state |= M_HAVE_NEWS_ACCOUNT;
1616 if (inc_is_active())
1617 state |= M_INC_ACTIVE;
1624 void main_window_set_menu_sensitive(MainWindow *mainwin)
1626 GtkItemFactory *ifactory = mainwin->menu_factory;
1627 SensitiveCond state;
1629 GtkWidget *menuitem;
1630 SummaryView *summaryview;
1634 static const struct {
1638 {"/File/Add mailbox..." , M_UNLOCKED},
1639 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1640 {"/File/Check for new messages in all folders", M_UNLOCKED},
1641 {"/File/Folder" , M_UNLOCKED},
1642 {"/File/Import mbox file..." , M_UNLOCKED},
1643 {"/File/Export to mbox file..." , M_UNLOCKED},
1644 {"/File/Empty trash" , M_UNLOCKED},
1645 {"/File/Work offline" , M_UNLOCKED},
1647 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1648 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1649 /* {"/File/Close" , M_UNLOCKED}, */
1650 {"/File/Exit" , M_UNLOCKED},
1652 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1654 {"/View/Sort" , M_EXEC},
1655 {"/View/Thread view" , M_EXEC},
1656 {"/View/Expand all threads" , M_MSG_EXIST},
1657 {"/View/Collapse all threads" , M_MSG_EXIST},
1658 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1659 {"/View/Go to/Prev message" , M_MSG_EXIST},
1660 {"/View/Go to/Next message" , M_MSG_EXIST},
1661 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1662 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1663 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1664 {"/View/Go to/Next new message" , M_MSG_EXIST},
1665 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1666 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1667 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1668 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1669 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1670 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1671 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1673 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1674 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1675 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1676 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1677 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1678 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1679 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1680 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1681 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1682 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1683 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1684 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1685 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1686 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1687 {"/Message/Mark" , M_TARGET_EXIST},
1689 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1690 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1691 {"/Tools/Harvest addresses" , M_UNLOCKED},
1692 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1693 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1694 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1695 {"/Tools/Execute" , M_DELAY_EXEC},
1696 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1698 {"/Configuration", M_UNLOCKED},
1703 state = main_window_get_current_state(mainwin);
1705 for (i = 0; entry[i].entry != NULL; i++) {
1706 sensitive = ((entry[i].cond & state) == entry[i].cond);
1707 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1710 main_window_menu_callback_block(mainwin);
1712 #define SET_CHECK_MENU_ACTIVE(path, active) \
1714 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1715 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1718 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1719 messageview_is_visible(mainwin->messageview));
1721 summaryview = mainwin->summaryview;
1722 menu_path = "/View/Sort/Don't sort";
1724 switch (summaryview->sort_key) {
1725 case SORT_BY_NUMBER:
1726 menu_path = "/View/Sort/by number"; break;
1728 menu_path = "/View/Sort/by size"; break;
1730 menu_path = "/View/Sort/by date"; break;
1732 menu_path = "/View/Sort/by from"; break;
1733 case SORT_BY_SUBJECT:
1734 menu_path = "/View/Sort/by subject"; break;
1736 menu_path = "/View/Sort/by color label"; break;
1738 menu_path = "/View/Sort/by mark"; break;
1739 case SORT_BY_UNREAD:
1740 menu_path = "/View/Sort/by unread"; break;
1742 menu_path = "/View/Sort/by attachment"; break;
1744 menu_path = "/View/Sort/by score"; break;
1745 case SORT_BY_LOCKED:
1746 menu_path = "/View/Sort/by locked"; break;
1749 menu_path = "/View/Sort/Don't sort"; break;
1751 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1753 if (summaryview->sort_type == SORT_ASCENDING) {
1754 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1756 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1759 if (summaryview->sort_key != SORT_BY_NONE) {
1760 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1761 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1763 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1764 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1767 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1768 mainwin->messageview->textview->show_all_headers);
1769 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1771 #undef SET_CHECK_MENU_ACTIVE
1773 main_window_menu_callback_unblock(mainwin);
1776 void main_window_popup(MainWindow *mainwin)
1778 gtkut_window_popup(mainwin->window);
1780 switch (mainwin->type) {
1781 case SEPARATE_FOLDER:
1782 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1784 case SEPARATE_MESSAGE:
1785 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1788 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1789 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1796 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1798 GtkWidget *folderwin = NULL;
1799 GtkWidget *messagewin = NULL;
1802 GtkWidget *vbox_body = mainwin->vbox_body;
1803 GtkItemFactory *ifactory = mainwin->menu_factory;
1804 GtkWidget *menuitem;
1806 debug_print("Setting widgets...");
1808 /* create separated window(s) if needed */
1809 if (type & SEPARATE_FOLDER) {
1810 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1811 gtk_window_set_title(GTK_WINDOW(folderwin),
1812 _("Sylpheed - Folder View"));
1813 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1814 "folder_view", "Sylpheed");
1815 gtk_window_set_policy(GTK_WINDOW(folderwin),
1817 gtk_widget_set_usize(folderwin, -1,
1818 prefs_common.mainview_height);
1819 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1821 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1822 GTK_SIGNAL_FUNC(folder_window_close_cb),
1825 if (type & SEPARATE_MESSAGE) {
1826 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1827 gtk_window_set_title(GTK_WINDOW(messagewin),
1828 _("Sylpheed - Message View"));
1829 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1830 "message_view", "Sylpheed");
1831 gtk_window_set_policy(GTK_WINDOW(messagewin),
1833 gtk_widget_set_usize
1834 (messagewin, prefs_common.mainview_width,
1835 prefs_common.mainview_height
1836 - prefs_common.summaryview_height
1837 + DEFAULT_HEADERVIEW_HEIGHT);
1838 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1840 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1841 GTK_SIGNAL_FUNC(message_window_close_cb),
1847 hpaned = gtk_hpaned_new();
1848 gtk_widget_show(hpaned);
1849 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1850 gtk_paned_add1(GTK_PANED(hpaned),
1851 GTK_WIDGET_PTR(mainwin->folderview));
1853 vpaned = gtk_vpaned_new();
1854 if (messageview_is_visible(mainwin->messageview)) {
1855 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1856 gtk_paned_add1(GTK_PANED(vpaned),
1857 GTK_WIDGET_PTR(mainwin->summaryview));
1859 gtk_paned_add2(GTK_PANED(hpaned),
1860 GTK_WIDGET_PTR(mainwin->summaryview));
1861 gtk_widget_ref(vpaned);
1863 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1864 prefs_common.summaryview_width,
1865 prefs_common.summaryview_height);
1866 gtk_paned_add2(GTK_PANED(vpaned),
1867 GTK_WIDGET_PTR(mainwin->messageview));
1868 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1869 prefs_common.mainview_width, -1);
1870 gtk_widget_set_usize(mainwin->window,
1871 prefs_common.folderview_width +
1872 prefs_common.mainview_width,
1873 prefs_common.mainwin_height);
1874 gtk_widget_show_all(vpaned);
1876 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1877 * lose track of its visibility state */
1878 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1879 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1881 mainwin->win.sep_none.hpaned = hpaned;
1882 mainwin->win.sep_none.vpaned = vpaned;
1884 /* remove headerview if not in prefs */
1885 headerview_set_visibility(mainwin->messageview->headerview,
1886 prefs_common.display_header_pane);
1888 case SEPARATE_FOLDER:
1889 vpaned = gtk_vpaned_new();
1890 if (messageview_is_visible(mainwin->messageview)) {
1891 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1893 gtk_paned_add1(GTK_PANED(vpaned),
1894 GTK_WIDGET_PTR(mainwin->summaryview));
1896 gtk_box_pack_start(GTK_BOX(vbox_body),
1897 GTK_WIDGET_PTR(mainwin->summaryview),
1899 gtk_widget_ref(vpaned);
1901 gtk_paned_add2(GTK_PANED(vpaned),
1902 GTK_WIDGET_PTR(mainwin->messageview));
1903 gtk_widget_show_all(vpaned);
1904 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1905 prefs_common.summaryview_width,
1906 prefs_common.summaryview_height);
1907 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1908 prefs_common.mainview_width, -1);
1909 gtk_widget_set_usize(mainwin->window,
1910 prefs_common.mainview_width,
1911 prefs_common.mainview_height);
1913 gtk_container_add(GTK_CONTAINER(folderwin),
1914 GTK_WIDGET_PTR(mainwin->folderview));
1916 mainwin->win.sep_folder.folderwin = folderwin;
1917 mainwin->win.sep_folder.vpaned = vpaned;
1919 gtk_widget_show_all(folderwin);
1921 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1922 * lose track of its visibility state */
1923 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1924 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1926 /* remove headerview if not in prefs */
1927 headerview_set_visibility(mainwin->messageview->headerview,
1928 prefs_common.display_header_pane);
1931 case SEPARATE_MESSAGE:
1932 hpaned = gtk_hpaned_new();
1933 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1935 gtk_paned_add1(GTK_PANED(hpaned),
1936 GTK_WIDGET_PTR(mainwin->folderview));
1937 gtk_paned_add2(GTK_PANED(hpaned),
1938 GTK_WIDGET_PTR(mainwin->summaryview));
1939 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1940 prefs_common.summaryview_width,
1941 prefs_common.summaryview_height);
1942 gtk_widget_set_usize(mainwin->window,
1943 prefs_common.folderview_width +
1944 prefs_common.mainview_width,
1945 prefs_common.mainwin_height);
1946 gtk_widget_show_all(hpaned);
1947 gtk_container_add(GTK_CONTAINER(messagewin),
1948 GTK_WIDGET_PTR(mainwin->messageview));
1950 mainwin->win.sep_message.messagewin = messagewin;
1951 mainwin->win.sep_message.hpaned = hpaned;
1953 gtk_widget_show_all(messagewin);
1955 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1956 * lose track of its visibility state */
1957 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1958 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1961 gtk_box_pack_start(GTK_BOX(vbox_body),
1962 GTK_WIDGET_PTR(mainwin->summaryview),
1964 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1965 prefs_common.summaryview_width,
1966 prefs_common.summaryview_height);
1967 gtk_widget_set_usize(mainwin->window,
1968 prefs_common.mainview_width,
1969 prefs_common.mainwin_height);
1970 gtk_container_add(GTK_CONTAINER(folderwin),
1971 GTK_WIDGET_PTR(mainwin->folderview));
1972 gtk_container_add(GTK_CONTAINER(messagewin),
1973 GTK_WIDGET_PTR(mainwin->messageview));
1975 mainwin->win.sep_both.folderwin = folderwin;
1976 mainwin->win.sep_both.messagewin = messagewin;
1978 gtk_widget_show_all(folderwin);
1979 gtk_widget_show_all(messagewin);
1981 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1982 * lose track of its visibility state */
1983 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1984 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1988 /* rehide quick search if necessary */
1989 if (!prefs_common.show_searchbar)
1990 gtk_widget_hide(mainwin->summaryview->hbox_search);
1992 mainwin->type = type;
1994 mainwin->messageview->visible = TRUE;
1996 /* toggle menu state */
1997 menuitem = gtk_item_factory_get_item
1998 (ifactory, "/View/Show or hide/Folder tree");
1999 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2000 menuitem = gtk_item_factory_get_item
2001 (ifactory, "/View/Show or hide/Message view");
2002 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2004 menuitem = gtk_item_factory_get_item
2005 (ifactory, "/View/Separate folder tree");
2006 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2007 ((type & SEPARATE_FOLDER) != 0));
2008 menuitem = gtk_item_factory_get_item
2009 (ifactory, "/View/Separate message view");
2010 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2011 ((type & SEPARATE_MESSAGE) != 0));
2013 debug_print("done.\n");
2016 void main_window_destroy_all(void)
2018 while (mainwin_list != NULL) {
2019 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2021 /* free toolbar stuff */
2022 toolbar_clear_list(TOOLBAR_MAIN);
2023 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2024 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2026 g_free(mainwin->toolbar);
2029 mainwin_list = g_list_remove(mainwin_list, mainwin);
2031 g_list_free(mainwin_list);
2035 static void toolbar_account_button_pressed(GtkWidget *widget,
2036 GdkEventButton *event,
2039 MainWindow *mainwin = (MainWindow *)data;
2042 if (event->button != 3) return;
2044 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2045 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2048 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2049 menu_button_position, widget,
2050 event->button, event->time);
2054 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2057 MainWindow *mainwin = (MainWindow *)data;
2061 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2062 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2065 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2066 menu_button_position, widget,
2067 event->button, event->time);
2070 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2072 MainWindow *mainwin = (MainWindow *)data;
2075 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2076 if (!button) return;
2077 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2078 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2079 manage_window_focus_in(mainwin->window, NULL, NULL);
2082 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2085 MainWindow *mainwin = (MainWindow *)data;
2087 if (mainwin->lock_count == 0)
2088 app_exit_cb(data, 0, widget);
2093 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2096 MainWindow *mainwin = (MainWindow *)data;
2097 GtkWidget *menuitem;
2099 menuitem = gtk_item_factory_get_item
2100 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2101 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2106 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2109 MainWindow *mainwin = (MainWindow *)data;
2110 GtkWidget *menuitem;
2112 menuitem = gtk_item_factory_get_item
2113 (mainwin->menu_factory, "/View/Show or hide/Message view");
2114 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2119 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2122 main_window_add_mailbox(mainwin);
2125 static void add_mbox_cb(MainWindow *mainwin, guint action,
2128 main_window_add_mbox(mainwin);
2131 static void update_folderview_cb(MainWindow *mainwin, guint action,
2134 summary_show(mainwin->summaryview, NULL);
2135 folderview_check_new_all();
2138 static void new_folder_cb(MainWindow *mainwin, guint action,
2141 folderview_new_folder(mainwin->folderview);
2144 static void rename_folder_cb(MainWindow *mainwin, guint action,
2147 folderview_rename_folder(mainwin->folderview);
2150 static void delete_folder_cb(MainWindow *mainwin, guint action,
2153 folderview_delete_folder(mainwin->folderview);
2156 static void import_mbox_cb(MainWindow *mainwin, guint action,
2159 import_mbox(mainwin->summaryview->folder_item);
2162 static void export_mbox_cb(MainWindow *mainwin, guint action,
2165 export_mbox(mainwin->summaryview->folder_item);
2168 static void empty_trash_cb(MainWindow *mainwin, guint action,
2171 main_window_empty_trash(mainwin, TRUE);
2174 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2176 summary_save_as(mainwin->summaryview);
2179 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2181 summary_print(mainwin->summaryview);
2184 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2186 if (prefs_common.confirm_on_exit) {
2187 if (alertpanel(_("Exit"), _("Exit this program?"),
2188 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2190 manage_window_focus_in(mainwin->window, NULL, NULL);
2193 app_will_exit(widget, mainwin);
2196 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2199 summary_search(mainwin->summaryview);
2201 message_search(mainwin->messageview);
2204 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2209 active = GTK_CHECK_MENU_ITEM(widget)->active;
2211 switch (mainwin->type) {
2213 case SEPARATE_MESSAGE:
2216 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2218 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2221 case SEPARATE_FOLDER:
2222 debug_print("separate folder\n");
2224 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2226 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2230 gtk_widget_show(mainwin->win.sep_both.folderwin);
2232 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2237 static void toggle_message_cb(MainWindow *mainwin, guint action,
2242 active = GTK_CHECK_MENU_ITEM(widget)->active;
2244 if (active != messageview_is_visible(mainwin->messageview))
2245 summary_toggle_view(mainwin->summaryview);
2248 /* Toolbar handling */
2249 static void toolbar_inc_cb(GtkWidget *widget,
2252 MainWindow *mainwin = (MainWindow *)data;
2254 inc_mail_cb(mainwin, 0, NULL);
2257 static void toolbar_inc_all_cb(GtkWidget *widget,
2260 MainWindow *mainwin = (MainWindow *)data;
2262 inc_all_account_mail_cb(mainwin, 0, NULL);
2265 static void toolbar_send_cb(GtkWidget *widget,
2268 MainWindow *mainwin = (MainWindow *)data;
2270 send_queue_cb(mainwin, 0, NULL);
2273 static void toolbar_compose_cb(GtkWidget *widget,
2276 MainWindow *mainwin = (MainWindow *)data;
2278 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
2279 compose_news_cb(mainwin, 0, NULL);
2281 compose_mail_cb(mainwin, 0, NULL);
2284 static void toolbar_reply_cb(GtkWidget *widget,
2287 MainWindow *mainwin = (MainWindow *)data;
2289 if (prefs_common.default_reply_list)
2291 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
2292 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
2296 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2297 : COMPOSE_REPLY_WITHOUT_QUOTE,
2301 static void toolbar_reply_to_all_cb(GtkWidget *widget,
2304 MainWindow *mainwin = (MainWindow *)data;
2307 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2308 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2312 static void toolbar_reply_to_list_cb(GtkWidget *widget,
2315 MainWindow *mainwin = (MainWindow *)data;
2318 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
2319 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
2323 static void toolbar_reply_to_sender_cb(GtkWidget *widget,
2326 MainWindow *mainwin = (MainWindow *)data;
2329 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2330 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2334 static void toolbar_forward_cb(GtkWidget *widget,
2337 MainWindow *mainwin = (MainWindow *)data;
2339 if (prefs_common.forward_as_attachment)
2340 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2342 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2345 static void toolbar_exec_cb(GtkWidget *widget,
2348 MainWindow *mainwin = (MainWindow *)data;
2350 summary_execute(mainwin->summaryview);
2353 static void toolbar_next_unread_cb(GtkWidget *widget,
2356 MainWindow *mainwin = (MainWindow *)data;
2358 next_unread_cb(mainwin, 0, NULL);
2361 /* popup callback functions */
2362 static void toolbar_reply_popup_cb(GtkWidget *widget,
2363 GdkEventButton *event,
2366 MainWindow *mainwindow = (MainWindow *) data;
2370 if (event->button == 3) {
2371 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2372 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->reply_popup), NULL, NULL,
2373 menu_button_position, widget,
2374 event->button, event->time);
2378 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2380 MainWindow *mainwin = (MainWindow *)data;
2382 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->reply_btn), GTK_RELIEF_NONE);
2383 manage_window_focus_in(mainwin->window, NULL, NULL);
2386 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2388 MainWindow *mainwindow = (MainWindow *) data;
2392 if (event->button == 3) {
2393 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2394 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replyall_popup), NULL, NULL,
2395 menu_button_position, widget,
2396 event->button, event->time);
2400 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2402 MainWindow *mainwin = (MainWindow *)data;
2404 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replyall_btn), GTK_RELIEF_NONE);
2405 manage_window_focus_in(mainwin->window, NULL, NULL);
2408 static void toolbar_reply_to_list_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2410 MainWindow *mainwindow = (MainWindow *) data;
2414 if (event->button == 3) {
2415 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2416 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replylist_popup), NULL, NULL,
2417 menu_button_position, widget,
2418 event->button, event->time);
2422 static void toolbar_reply_to_list_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2424 MainWindow *mainwin = (MainWindow *)data;
2426 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replylist_btn), GTK_RELIEF_NONE);
2427 manage_window_focus_in(mainwin->window, NULL, NULL);
2430 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2432 MainWindow *mainwindow = (MainWindow *) data;
2436 if (event->button == 3) {
2437 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2438 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replysender_popup), NULL, NULL,
2439 menu_button_position, widget,
2440 event->button, event->time);
2444 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2446 MainWindow *mainwin = (MainWindow *)data;
2448 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replysender_btn), GTK_RELIEF_NONE);
2449 manage_window_focus_in(mainwin->window, NULL, NULL);
2452 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2454 MainWindow *mainwindow = (MainWindow *) data;
2458 if (event->button == 3) {
2459 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2460 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->fwd_popup), NULL, NULL,
2461 menu_button_position, widget,
2462 event->button, event->time);
2466 static void toolbar_forward_popup_closed_cb (GtkMenuShell *menu_shell,
2469 MainWindow *mainwin = (MainWindow *)data;
2471 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->fwd_btn), GTK_RELIEF_NONE);
2472 manage_window_focus_in(mainwin->window, NULL, NULL);
2475 static void activate_compose_button (Toolbar *toolbar,
2477 ComposeButtonType type)
2479 if ((!toolbar->compose_mail_btn) || (!toolbar->compose_news_btn))
2482 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? toolbar->compose_mail_btn
2483 : toolbar->compose_news_btn);
2484 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? toolbar->compose_news_btn
2485 : toolbar->compose_mail_btn);
2486 toolbar->compose_btn_type = type;
2489 void toolbar_set_compose_button(Toolbar *toolbar,
2490 ComposeButtonType compose_btn_type)
2492 if (toolbar->compose_btn_type != compose_btn_type)
2493 activate_compose_button(toolbar,
2494 prefs_common.toolbar_style,
2498 static void toolbar_buttons_cb(GtkWidget *widget,
2503 void (*func)(GtkWidget *widget, gpointer data);
2504 } toolbar_action[] = {
2505 { A_RECEIVE_ALL, toolbar_inc_all_cb },
2506 { A_RECEIVE_CUR, toolbar_inc_cb },
2507 { A_SEND_QUEUED, toolbar_send_cb },
2508 { A_COMPOSE_EMAIL, toolbar_compose_cb },
2509 { A_REPLY_MESSAGE, toolbar_reply_cb },
2510 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
2511 { A_REPLY_ALL, toolbar_reply_to_all_cb },
2512 { A_REPLY_ML, toolbar_reply_to_list_cb },
2513 { A_FORWARD, toolbar_forward_cb },
2514 { A_DELETE, common_toolbar_delete_cb },
2515 { A_EXECUTE, toolbar_exec_cb },
2516 { A_GOTO_NEXT, toolbar_next_unread_cb },
2517 { A_SYL_ACTIONS, common_toolbar_actions_execute_cb },
2519 { A_COMPOSE_NEWS, toolbar_compose_cb },
2520 { A_SEPARATOR, NULL }};
2522 gint num_items = sizeof(toolbar_action)/sizeof(toolbar_action[0]);
2525 for (i = A_RECEIVE_ALL; i < num_items; i++) {
2527 if (toolbar_action[i].index == item->index) {
2528 if ((item->index == A_SYL_ACTIONS) || (item->index == A_DELETE))
2529 /* the common_toolbar_* stuff takes item->parent as data
2531 toolbar_action[i].func(widget, (gpointer)item->parent);
2532 else /* to be removed */
2533 toolbar_action[i].func(widget, (gpointer)item->parent->data);
2539 void toolbar_set_sensitive(MainWindow *mainwin)
2541 SensitiveCond state;
2543 Toolbar *toolbar = mainwin->toolbar;
2545 GSList *entry_list = NULL;
2547 typedef struct _Entry Entry;
2554 #define SET_WIDGET_COND(w, c) \
2556 Entry *e = g_new0(Entry, 1); \
2559 entry_list = g_slist_append(entry_list, e); \
2562 SET_WIDGET_COND(toolbar->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2563 SET_WIDGET_COND(toolbar->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2564 SET_WIDGET_COND(toolbar->compose_news_btn, M_HAVE_ACCOUNT);
2565 SET_WIDGET_COND(toolbar->reply_btn,
2566 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2567 SET_WIDGET_COND(toolbar->replyall_btn,
2568 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2569 SET_WIDGET_COND(toolbar->replylist_btn,
2570 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2571 SET_WIDGET_COND(toolbar->replysender_btn,
2572 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2573 SET_WIDGET_COND(toolbar->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
2575 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST);
2576 SET_WIDGET_COND(toolbar->delete_btn,
2577 M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
2578 SET_WIDGET_COND(toolbar->exec_btn, M_DELAY_EXEC);
2580 for (cur = toolbar->action_list; cur != NULL; cur = cur->next) {
2581 ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
2583 SET_WIDGET_COND(act->widget, M_TARGET_EXIST|M_UNLOCKED);
2586 #undef SET_WIDGET_COND
2588 state = main_window_get_current_state(mainwin);
2590 for (cur = entry_list; cur != NULL; cur = cur->next) {
2591 Entry *e = (Entry*) cur->data;
2593 if (e->widget != NULL) {
2594 sensitive = ((e->cond & state) == e->cond);
2595 gtk_widget_set_sensitive(e->widget, sensitive);
2599 while (entry_list != NULL) {
2600 Entry *e = (Entry*) entry_list->data;
2604 entry_list = g_slist_remove(entry_list, e);
2607 g_slist_free(entry_list);
2609 activate_compose_button(toolbar,
2610 prefs_common.toolbar_style,
2611 toolbar->compose_btn_type);
2614 static void toolbar_update(MainWindow *mainwin)
2616 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox),
2617 GTK_WIDGET(mainwin->toolbar->toolbar));
2619 mainwin->toolbar->toolbar = NULL;
2620 mainwin->toolbar->get_btn = NULL;
2621 mainwin->toolbar->getall_btn = NULL;
2622 mainwin->toolbar->send_btn = NULL;
2623 mainwin->toolbar->compose_mail_btn = NULL;
2624 mainwin->toolbar->compose_news_btn = NULL;
2625 mainwin->toolbar->reply_btn = NULL;
2626 mainwin->toolbar->replyall_btn = NULL;
2627 mainwin->toolbar->replylist_btn = NULL;
2628 mainwin->toolbar->replysender_btn = NULL;
2629 mainwin->toolbar->fwd_btn = NULL;
2630 mainwin->toolbar->delete_btn = NULL;
2631 mainwin->toolbar->next_btn = NULL;
2632 mainwin->toolbar->exec_btn = NULL;
2634 toolbar_clear_list(TOOLBAR_MAIN);
2635 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2636 toolbar_create(mainwin, mainwin->handlebox);
2637 toolbar_set_sensitive(mainwin);
2641 static void toolbar_create(MainWindow *mainwin,
2642 GtkWidget *container)
2644 ToolbarItem *toolbar_item;
2647 GtkWidget *icon_wid = NULL;
2648 GtkWidget *icon_news = NULL;
2649 GtkWidget *item_news = NULL;
2651 GtkTooltips *toolbar_tips;
2652 ToolbarSylpheedActions *action_item;
2654 GSList *toolbar_list;
2656 guint n_menu_entries;
2657 GtkWidget *reply_popup;
2658 GtkWidget *replyall_popup;
2659 GtkWidget *replylist_popup;
2660 GtkWidget *replysender_popup;
2661 GtkWidget *fwd_popup;
2663 toolbar_tips = gtk_tooltips_new();
2665 if (mainwin->toolbar != NULL) {
2666 toolbar_clear_list(TOOLBAR_MAIN);
2667 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2668 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2669 g_free(mainwin->toolbar);
2672 toolbar_read_config_file(TOOLBAR_MAIN);
2673 toolbar_list = toolbar_get_list(TOOLBAR_MAIN);
2675 mainwin->toolbar = g_new0(Toolbar, 1);
2677 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
2679 gtk_container_add(GTK_CONTAINER(container), toolbar);
2680 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
2681 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
2682 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
2683 GTK_TOOLBAR_SPACE_LINE);
2685 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2687 if (g_strcasecmp(((ToolbarItem*)cur->data)->file, SEPARATOR) == 0) {
2688 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2692 toolbar_item = g_new0(ToolbarItem, 1);
2693 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2694 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2695 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2697 toolbar_item->parent = g_new0(ToolbarParent, 1);
2698 toolbar_item->parent->data = (gpointer)mainwin;
2699 toolbar_item->parent->type = TOOLBAR_MAIN;
2701 /* collect toolbar items in list to keep track */
2702 mainwin->toolbar->item_list = g_slist_append(mainwin->toolbar->item_list,
2705 icon_wid = stock_pixmap_widget(container, stock_pixmap_get_icon(toolbar_item->file));
2706 item = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2710 icon_wid, toolbar_buttons_cb,
2713 switch (toolbar_item->index) {
2715 mainwin->toolbar->getall_btn = item;
2716 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2717 mainwin->toolbar->getall_btn,
2718 _("Receive Mail on all Accounts"), NULL);
2721 mainwin->toolbar->get_btn = item;
2722 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2723 mainwin->toolbar->get_btn,
2724 _("Receive Mail on current Account"), NULL);
2727 mainwin->toolbar->send_btn = item;
2728 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2729 mainwin->toolbar->send_btn,
2730 _("Send Queued Message(s)"), NULL);
2732 case A_COMPOSE_EMAIL:
2733 icon_news = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2734 item_news = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2738 icon_news, toolbar_buttons_cb,
2740 mainwin->toolbar->compose_mail_btn = item;
2741 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2742 mainwin->toolbar->compose_mail_btn,
2743 _("Compose Email"), NULL);
2744 mainwin->toolbar->compose_news_btn = item_news;
2745 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2746 mainwin->toolbar->compose_news_btn,
2747 _("Compose News"), NULL);
2749 case A_REPLY_MESSAGE:
2750 mainwin->toolbar->reply_btn = item;
2751 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2752 mainwin->toolbar->reply_btn,
2753 _("Reply to Message"), NULL);
2754 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->reply_btn),
2755 "button_press_event",
2756 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2758 n_menu_entries = sizeof(reply_popup_entries) /
2759 sizeof(reply_popup_entries[0]);
2760 reply_popup = popupmenu_create(mainwin->window, reply_popup_entries, n_menu_entries,
2761 "<ReplyPopup>", mainwin);
2762 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
2763 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
2764 mainwin->toolbar->reply_popup = reply_popup;
2766 case A_REPLY_SENDER:
2767 mainwin->toolbar->replysender_btn = item;
2768 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2769 mainwin->toolbar->replysender_btn,
2770 _("Reply to Sender"), NULL);
2771 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replysender_btn),
2772 "button_press_event",
2773 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2775 n_menu_entries = sizeof(replysender_popup_entries) /
2776 sizeof(replysender_popup_entries[0]);
2777 replysender_popup = popupmenu_create(mainwin->window,
2778 replysender_popup_entries, n_menu_entries,
2779 "<ReplySenderPopup>", mainwin);
2780 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
2781 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
2782 mainwin->toolbar->replysender_popup = replysender_popup;
2785 mainwin->toolbar->replyall_btn = item;
2786 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2787 mainwin->toolbar->replyall_btn,
2788 _("Reply to All"), NULL);
2789 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replyall_btn),
2790 "button_press_event",
2791 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2793 n_menu_entries = sizeof(replyall_popup_entries) /
2794 sizeof(replyall_popup_entries[0]);
2795 replyall_popup = popupmenu_create(mainwin->window,
2796 replyall_popup_entries, n_menu_entries,
2797 "<ReplyAllPopup>", mainwin);
2798 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
2799 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
2800 mainwin->toolbar->replyall_popup = replyall_popup;
2803 mainwin->toolbar->replylist_btn = item;
2804 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2805 mainwin->toolbar->replylist_btn,
2806 _("Reply to Mailing-list"), NULL);
2807 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replylist_btn),
2808 "button_press_event",
2809 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_cb),
2811 n_menu_entries = sizeof(replylist_popup_entries) /
2812 sizeof(replylist_popup_entries[0]);
2813 replylist_popup = popupmenu_create(mainwin->window,
2814 replylist_popup_entries, n_menu_entries,
2815 "<ReplyMlPopup>", mainwin);
2816 gtk_signal_connect(GTK_OBJECT(replylist_popup), "selection_done",
2817 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_closed_cb), mainwin);
2818 mainwin->toolbar->replylist_popup = replylist_popup;
2821 mainwin->toolbar->fwd_btn = item;
2822 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2823 mainwin->toolbar->fwd_btn,
2824 _("Forward Message"), NULL);
2825 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->fwd_btn),
2826 "button_press_event",
2827 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2829 n_menu_entries = sizeof(fwd_popup_entries) /
2830 sizeof(fwd_popup_entries[0]);
2831 fwd_popup = popupmenu_create(mainwin->window,
2832 fwd_popup_entries, n_menu_entries,
2833 "<ForwardPopup>", mainwin);
2834 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
2835 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
2836 mainwin->toolbar->fwd_popup = fwd_popup;
2839 mainwin->toolbar->delete_btn = item;
2840 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2841 mainwin->toolbar->delete_btn,
2842 _("Delete Message"), NULL);
2845 mainwin->toolbar->exec_btn = item;
2846 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2847 mainwin->toolbar->exec_btn,
2848 _("Execute"), NULL);
2851 mainwin->toolbar->next_btn = item;
2852 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2853 mainwin->toolbar->next_btn,
2854 _("Goto Next Message"), NULL);
2857 action_item = g_new0(ToolbarSylpheedActions, 1);
2858 action_item->widget = item;
2859 action_item->name = g_strdup(toolbar_item->text);
2861 mainwin->toolbar->action_list =
2862 g_slist_append(mainwin->toolbar->action_list,
2865 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2867 action_item->name, NULL);
2869 gtk_widget_show(item);
2876 mainwin->toolbar->toolbar = toolbar;
2878 activate_compose_button(mainwin->toolbar,
2879 prefs_common.toolbar_style,
2880 mainwin->toolbar->compose_btn_type);
2882 gtk_widget_show_all(toolbar);
2885 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2888 switch ((ToolbarStyle)action) {
2890 gtk_widget_hide(mainwin->handlebox);
2892 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2896 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2900 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2905 if (action != TOOLBAR_NONE) {
2906 gtk_widget_show(mainwin->handlebox);
2907 gtk_widget_queue_resize(mainwin->handlebox);
2910 mainwin->toolbar_style = (ToolbarStyle)action;
2911 prefs_common.toolbar_style = (ToolbarStyle)action;
2914 /* END Toolbar Stuff */
2916 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2919 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2920 gtk_widget_show(mainwin->hbox_stat);
2921 prefs_common.show_statusbar = TRUE;
2923 gtk_widget_hide(mainwin->hbox_stat);
2924 prefs_common.show_statusbar = FALSE;
2928 static void separate_widget_cb(MainWindow *mainwin, guint action,
2933 if (GTK_CHECK_MENU_ITEM(widget)->active)
2934 type = mainwin->type | action;
2936 type = mainwin->type & ~action;
2938 main_window_separation_change(mainwin, type);
2940 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2941 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2944 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2947 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2949 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2952 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2954 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2957 static void online_switch_clicked (GtkButton *btn, gpointer data)
2959 MainWindow *mainwin;
2960 GtkItemFactory *ifactory;
2961 GtkCheckMenuItem *menuitem;
2963 mainwin = (MainWindow *) data;
2965 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2966 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2968 g_return_if_fail(mainwin != NULL);
2969 g_return_if_fail(menuitem != NULL);
2971 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2973 gtk_widget_hide (mainwin->online_switch);
2974 gtk_widget_show (mainwin->offline_switch);
2975 menuitem->active = TRUE;
2976 prefs_common.work_offline = TRUE;
2977 inc_autocheck_timer_remove();
2980 gtk_widget_hide (mainwin->offline_switch);
2981 gtk_widget_show (mainwin->online_switch);
2982 menuitem->active = FALSE;
2983 prefs_common.work_offline = FALSE;
2984 inc_autocheck_timer_set();
2988 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2991 addressbook_open(NULL);
2994 static void log_window_show_cb(MainWindow *mainwin, guint action,
2997 log_window_show(mainwin->logwin);
3000 static void sel_download_cb(MainWindow *mainwin, guint action,
3003 selective_download(mainwin);
3006 static void prefs_toolbar_cb(MainWindow *mainwin, guint action,
3009 prefs_toolbar_open((ToolbarType)action);
3013 void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3015 inc_mail(mainwin, prefs_common.newmail_notify_manu);
3018 void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
3021 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
3024 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3029 void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3033 if (prefs_common.work_offline)
3034 if (alertpanel(_("Offline warning"),
3035 _("You're working offline. Override?"),
3036 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
3039 for (list = folder_get_list(); list != NULL; list = list->next) {
3040 Folder *folder = list->data;
3042 if (folder->queue) {
3043 if (procmsg_send_queue
3044 (folder->queue, prefs_common.savemsg) < 0)
3045 alertpanel_error(_("Some errors occurred while sending queued messages."));
3046 folder_item_scan(folder->queue);
3047 folder_update_item(folder->queue, TRUE);
3052 void compose_mail_cb(MainWindow *mainwin, guint action,
3055 PrefsAccount *ac = NULL;
3056 FolderItem *item = mainwin->summaryview->folder_item;
3061 ac = account_find_from_item(item);
3062 if (ac && ac->protocol != A_NNTP) {
3063 compose_new_with_folderitem(ac, item); /* CLAWS */
3069 * CLAWS - use current account
3071 if (cur_account && (cur_account->protocol != A_NNTP)) {
3072 compose_new_with_folderitem(cur_account, item);
3077 * CLAWS - just get the first one
3079 list = account_get_list();
3080 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3081 ac = (PrefsAccount *) cur->data;
3082 if (ac->protocol != A_NNTP) {
3083 compose_new_with_folderitem(ac, item);
3089 void compose_news_cb(MainWindow *mainwin, guint action,
3092 PrefsAccount * ac = NULL;
3096 if (mainwin->summaryview->folder_item) {
3097 ac = mainwin->summaryview->folder_item->folder->account;
3098 if (ac && ac->protocol == A_NNTP) {
3100 mainwin->summaryview->folder_item->path,
3106 list = account_get_list();
3107 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3108 ac = (PrefsAccount *) cur->data;
3109 if (ac->protocol == A_NNTP) {
3110 compose_new(ac, NULL, NULL);
3116 void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3118 summary_reply(mainwin->summaryview, (ComposeMode)action);
3121 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3123 summary_move_to(mainwin->summaryview);
3126 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3128 summary_copy_to(mainwin->summaryview);
3131 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3133 summary_delete(mainwin->summaryview);
3136 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3138 summary_cancel(mainwin->summaryview);
3141 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3143 summary_open_msg(mainwin->summaryview);
3146 static void view_source_cb(MainWindow *mainwin, guint action,
3149 summary_view_source(mainwin->summaryview);
3152 static void show_all_header_cb(MainWindow *mainwin, guint action,
3155 if (mainwin->menu_lock_count) return;
3156 summary_display_msg_selected(mainwin->summaryview,
3157 GTK_CHECK_MENU_ITEM(widget)->active);
3160 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3162 summary_reedit(mainwin->summaryview);
3165 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3167 summary_mark(mainwin->summaryview);
3170 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3172 summary_unmark(mainwin->summaryview);
3175 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3178 summary_mark_as_unread(mainwin->summaryview);
3181 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3184 summary_mark_as_read(mainwin->summaryview);
3187 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3190 summary_mark_all_read(mainwin->summaryview);
3193 static void add_address_cb(MainWindow *mainwin, guint action,
3196 summary_add_address(mainwin->summaryview);
3199 static void set_charset_cb(MainWindow *mainwin, guint action,
3204 str = conv_get_charset_str((CharSet)action);
3205 g_free(prefs_common.force_charset);
3206 prefs_common.force_charset = str ? g_strdup(str) : NULL;
3208 summary_redisplay_msg(mainwin->summaryview);
3210 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3213 static void hide_read_messages (MainWindow *mainwin, guint action,
3216 if (!mainwin->summaryview->folder_item
3217 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
3219 summary_toggle_show_read_messages(mainwin->summaryview);
3222 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3224 if (mainwin->menu_lock_count) return;
3225 if (!mainwin->summaryview->folder_item) return;
3227 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3228 summary_thread_build(mainwin->summaryview);
3229 /* mainwin->summaryview->folder_item->threaded = TRUE; */
3231 summary_unthread(mainwin->summaryview);
3232 /* mainwin->summaryview->folder_item->threaded = FALSE; */
3236 static void expand_threads_cb(MainWindow *mainwin, guint action,
3239 summary_expand_threads(mainwin->summaryview);
3242 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3245 summary_collapse_threads(mainwin->summaryview);
3248 static void set_display_item_cb(MainWindow *mainwin, guint action,
3251 prefs_summary_column_open();
3254 static void sort_summary_cb(MainWindow *mainwin, guint action,
3257 FolderItem *item = mainwin->summaryview->folder_item;
3258 GtkWidget *menuitem;
3260 if (mainwin->menu_lock_count) return;
3262 menuitem = gtk_item_factory_get_item
3263 (mainwin->menu_factory, "/View/Sort/Ascending");
3264 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3265 GTK_CHECK_MENU_ITEM(menuitem)->active
3266 ? SORT_ASCENDING : SORT_DESCENDING);
3270 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3273 FolderItem *item = mainwin->summaryview->folder_item;
3275 if (mainwin->menu_lock_count) return;
3277 summary_sort(mainwin->summaryview,
3278 item->sort_key, (FolderSortType)action);
3281 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3284 summary_attract_by_subject(mainwin->summaryview);
3287 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3290 summary_delete_duplicated(mainwin->summaryview);
3293 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3295 summary_filter(mainwin->summaryview);
3298 static void execute_summary_cb(MainWindow *mainwin, guint action,
3301 summary_execute(mainwin->summaryview);
3304 static void update_summary_cb(MainWindow *mainwin, guint action,
3308 FolderView *folderview = mainwin->folderview;
3310 if (!mainwin->summaryview->folder_item) return;
3311 if (!folderview->opened) return;
3313 folder_update_op_count();
3315 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3316 folderview->opened);
3319 folder_item_scan(fitem);
3320 summary_show(mainwin->summaryview, fitem);
3323 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3325 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3328 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3330 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3333 static void prev_unread_cb(MainWindow *mainwin, guint action,
3336 summary_select_prev_unread(mainwin->summaryview);
3339 void next_unread_cb(MainWindow *mainwin, guint action,
3342 summary_select_next_unread(mainwin->summaryview);
3345 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3347 summary_select_prev_new(mainwin->summaryview);
3350 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3352 summary_select_next_new(mainwin->summaryview);
3355 static void prev_marked_cb(MainWindow *mainwin, guint action,
3358 summary_select_prev_marked(mainwin->summaryview);
3361 static void next_marked_cb(MainWindow *mainwin, guint action,
3364 summary_select_next_marked(mainwin->summaryview);
3367 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3370 summary_select_prev_labeled(mainwin->summaryview);
3373 static void next_labeled_cb(MainWindow *mainwin, guint action,
3376 summary_select_next_labeled(mainwin->summaryview);
3379 static void goto_folder_cb(MainWindow *mainwin, guint action,
3382 FolderItem *to_folder;
3384 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3387 folderview_select(mainwin->folderview, to_folder);
3390 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3392 messageview_copy_clipboard(mainwin->messageview);
3395 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3397 MessageView *msgview = mainwin->messageview;
3399 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3400 summary_select_all(mainwin->summaryview);
3401 else if (messageview_is_visible(msgview) &&
3402 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
3403 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3404 messageview_select_all(mainwin->messageview);
3407 static void select_thread_cb(MainWindow *mainwin, guint action,
3410 summary_select_thread(mainwin->summaryview);
3413 static void create_filter_cb(MainWindow *mainwin, guint action,
3416 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3419 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3422 prefs_common_open();
3425 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3428 prefs_scoring_open(NULL);
3431 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3434 prefs_filtering_open(NULL, NULL, NULL);
3437 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3440 prefs_template_open();
3443 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3446 prefs_actions_open(mainwin);
3449 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3452 ssl_manager_open(mainwin);
3455 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3459 new_account_cb(mainwin, 0, widget);
3461 account_open(cur_account);
3465 static void new_account_cb(MainWindow *mainwin, guint action,
3468 account_edit_open();
3469 if (!compose_get_compose_list()) account_add();
3472 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3474 cur_account = (PrefsAccount *)data;
3475 main_window_reflect_prefs_all();
3478 static void manual_open_cb(MainWindow *mainwin, guint action,
3481 manual_open((ManualType)action);
3484 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3486 MainWindow *mainwin = (MainWindow *)data;
3490 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3491 LOCAL_FOLDER(folder)->rootpath,
3495 str = g_strdup_printf(_("Scanning folder %s ..."),
3496 LOCAL_FOLDER(folder)->rootpath);
3498 STATUSBAR_PUSH(mainwin, str);
3499 STATUSBAR_POP(mainwin);
3503 #define BREAK_ON_MODIFIER_KEY() \
3504 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3506 void mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3509 MainWindow *mainwin = (MainWindow*) data;
3511 if (!mainwin || !event) return;
3513 switch (event->keyval) {
3514 case GDK_Q: /* Quit */
3515 BREAK_ON_MODIFIER_KEY();
3517 app_exit_cb(mainwin, 0, NULL);
3520 if (mainwin->folderview && mainwin->summaryview
3521 && !mainwin->summaryview->displayed) {
3522 summary_lock(mainwin->summaryview);
3523 folderview_select_next_unread(mainwin->folderview);
3524 summary_unlock(mainwin->summaryview);
3532 #undef BREAK_ON_MODIFIER_KEY
3535 * Harvest addresses for selected folder.
3537 static void addr_harvest_cb( MainWindow *mainwin,
3541 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3545 * Harvest addresses for selected messages in summary view.
3547 static void addr_harvest_msg_cb( MainWindow *mainwin,
3551 summary_harvest_address( mainwin->summaryview );