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"
87 #define AC_LABEL_WIDTH 240
89 /* list of all instantiated MainWindow */
90 static GList *mainwin_list = NULL;
92 static GdkCursor *watch_cursor;
94 static void main_window_menu_callback_block (MainWindow *mainwin);
95 static void main_window_menu_callback_unblock (MainWindow *mainwin);
97 static void main_window_show_cur_account (MainWindow *mainwin);
99 static void main_window_set_widgets (MainWindow *mainwin,
103 static void toolbar_account_button_pressed (GtkWidget *widget,
104 GdkEventButton *event,
107 static void ac_label_button_pressed (GtkWidget *widget,
108 GdkEventButton *event,
110 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
113 static gint main_window_close_cb (GtkWidget *widget,
116 static gint folder_window_close_cb (GtkWidget *widget,
119 static gint message_window_close_cb (GtkWidget *widget,
123 static void add_mailbox_cb (MainWindow *mainwin,
126 static void add_mbox_cb (MainWindow *mainwin,
129 static void update_folderview_cb (MainWindow *mainwin,
132 static void new_folder_cb (MainWindow *mainwin,
135 static void rename_folder_cb (MainWindow *mainwin,
138 static void delete_folder_cb (MainWindow *mainwin,
141 static void import_mbox_cb (MainWindow *mainwin,
144 static void export_mbox_cb (MainWindow *mainwin,
147 static void empty_trash_cb (MainWindow *mainwin,
151 static void save_as_cb (MainWindow *mainwin,
154 static void print_cb (MainWindow *mainwin,
157 static void app_exit_cb (MainWindow *mainwin,
161 static void search_cb (MainWindow *mainwin,
165 static void toggle_folder_cb (MainWindow *mainwin,
168 static void toggle_message_cb (MainWindow *mainwin,
171 static void toggle_toolbar_cb (MainWindow *mainwin,
174 static void toggle_statusbar_cb (MainWindow *mainwin,
177 static void separate_widget_cb (MainWindow *mainwin,
181 static void addressbook_open_cb (MainWindow *mainwin,
184 static void log_window_show_cb (MainWindow *mainwin,
187 static void sel_download_cb (MainWindow *mainwin,
190 static void prefs_toolbar_cb (MainWindow *mainwin,
194 static void reply_cb (MainWindow *mainwin,
198 static void inc_mail_cb (MainWindow *mainwin,
202 static void inc_all_account_mail_cb (MainWindow *mainwin,
206 static void send_queue_cb (MainWindow *mainwin,
210 static void compose_mail_cb (MainWindow *mainwin,
214 static void compose_news_cb (MainWindow *mainwin,
218 static void next_unread_cb (MainWindow *mainwin,
222 static void toolbar_inc_cb (GtkWidget *widget,
225 static void toolbar_inc_all_cb (GtkWidget *widget,
228 static void toolbar_send_cb (GtkWidget *widget,
231 static void toolbar_compose_cb (GtkWidget *widget,
234 static void toolbar_reply_cb (GtkWidget *widget,
237 static void toolbar_reply_to_all_cb (GtkWidget *widget,
240 static void toolbar_reply_to_list_cb (GtkWidget *widget,
243 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
246 static void toolbar_forward_cb (GtkWidget *widget,
249 static void toolbar_exec_cb (GtkWidget *widget,
252 static void toolbar_next_unread_cb (GtkWidget *widget,
256 static void toolbar_reply_popup_cb (GtkWidget *widget,
257 GdkEventButton *event,
259 static void toolbar_reply_popup_closed_cb (GtkMenuShell *menu_shell,
262 static void toolbar_reply_to_all_popup_cb (GtkWidget *widget,
263 GdkEventButton *event,
266 static void toolbar_reply_to_all_popup_closed_cb
267 (GtkMenuShell *menu_shell,
270 static void toolbar_reply_to_list_popup_cb (GtkWidget *widget,
271 GdkEventButton *event,
274 static void toolbar_reply_to_list_popup_closed_cb
275 (GtkMenuShell *menu_shell,
278 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
279 GdkEventButton *event,
281 static void toolbar_reply_to_sender_popup_closed_cb
282 (GtkMenuShell *menu_shell,
285 static void toolbar_forward_popup_cb (GtkWidget *widget,
286 GdkEventButton *event,
289 static void toolbar_forward_popup_closed_cb
290 (GtkMenuShell *menu_shell,
293 static void activate_compose_button (Toolbar *toolbar,
295 ComposeButtonType type);
296 static void toolbar_buttons_cb (GtkWidget *widget,
298 static void toolbar_create (MainWindow *mainwin,
299 GtkWidget *container);
301 static void toolbar_update (MainWindow *mainwin);
303 static void inc_cancel_cb (MainWindow *mainwin,
307 static void open_msg_cb (MainWindow *mainwin,
311 static void view_source_cb (MainWindow *mainwin,
315 static void show_all_header_cb (MainWindow *mainwin,
319 static void reedit_cb (MainWindow *mainwin,
323 static void move_to_cb (MainWindow *mainwin,
326 static void copy_to_cb (MainWindow *mainwin,
329 static void delete_cb (MainWindow *mainwin,
333 static void cancel_cb (MainWindow *mainwin,
337 static void mark_cb (MainWindow *mainwin,
340 static void unmark_cb (MainWindow *mainwin,
344 static void mark_as_unread_cb (MainWindow *mainwin,
347 static void mark_as_read_cb (MainWindow *mainwin,
350 static void mark_all_read_cb (MainWindow *mainwin,
353 static void add_address_cb (MainWindow *mainwin,
357 static void set_charset_cb (MainWindow *mainwin,
361 static void hide_read_messages (MainWindow *mainwin,
365 static void thread_cb (MainWindow *mainwin,
368 static void expand_threads_cb (MainWindow *mainwin,
371 static void collapse_threads_cb (MainWindow *mainwin,
375 static void set_display_item_cb (MainWindow *mainwin,
378 static void sort_summary_cb (MainWindow *mainwin,
381 static void sort_summary_type_cb (MainWindow *mainwin,
384 static void attract_by_subject_cb(MainWindow *mainwin,
388 static void delete_duplicated_cb (MainWindow *mainwin,
391 static void filter_cb (MainWindow *mainwin,
394 static void execute_summary_cb (MainWindow *mainwin,
397 static void update_summary_cb (MainWindow *mainwin,
401 static void prev_cb (MainWindow *mainwin,
404 static void next_cb (MainWindow *mainwin,
408 static void prev_unread_cb (MainWindow *mainwin,
412 static void prev_new_cb (MainWindow *mainwin,
415 static void next_new_cb (MainWindow *mainwin,
418 static void prev_marked_cb (MainWindow *mainwin,
421 static void next_marked_cb (MainWindow *mainwin,
424 static void prev_labeled_cb (MainWindow *mainwin,
427 static void next_labeled_cb (MainWindow *mainwin,
431 static void goto_folder_cb (MainWindow *mainwin,
435 static void copy_cb (MainWindow *mainwin,
438 static void allsel_cb (MainWindow *mainwin,
441 static void select_thread_cb (MainWindow *mainwin,
445 static void create_filter_cb (MainWindow *mainwin,
449 static void prefs_common_open_cb (MainWindow *mainwin,
452 static void prefs_template_open_cb (MainWindow *mainwin,
455 static void prefs_actions_open_cb (MainWindow *mainwin,
458 static void prefs_account_open_cb (MainWindow *mainwin,
461 static void prefs_scoring_open_cb (MainWindow *mainwin,
464 static void prefs_filtering_open_cb (MainWindow *mainwin,
468 static void ssl_manager_open_cb (MainWindow *mainwin,
472 static void new_account_cb (MainWindow *mainwin,
476 static void account_menu_cb (GtkMenuItem *menuitem,
479 static void online_switch_clicked(GtkButton *btn,
482 static void manual_open_cb (MainWindow *mainwin,
486 static void scan_tree_func (Folder *folder,
490 static void key_pressed (GtkWidget *widget,
494 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
496 static void addr_harvest_cb ( MainWindow *mainwin,
500 static void addr_harvest_msg_cb ( MainWindow *mainwin,
504 #define SEPARATE_ACTION 500
506 static GtkItemFactoryEntry mainwin_entries[] =
508 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
509 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
510 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
511 {N_("/_File/_Check for new messages in all folders"),
512 NULL, update_folderview_cb, 0, NULL},
513 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
514 {N_("/_File/_Folder/Create _new folder..."),
515 NULL, new_folder_cb, 0, NULL},
516 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
517 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
518 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
519 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
520 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
521 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
522 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
523 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
524 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
525 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
526 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
527 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
529 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
530 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
531 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
532 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
533 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
534 {N_("/_Edit/_Find in current message..."),
535 "<control>F", search_cb, 0, NULL},
536 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
537 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
538 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
539 {N_("/_View/Show or hi_de/_Folder tree"),
540 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
541 {N_("/_View/Show or hi_de/_Message view"),
542 "V", toggle_message_cb, 0, "<ToggleItem>"},
543 {N_("/_View/Show or hi_de/_Toolbar"),
544 NULL, NULL, 0, "<Branch>"},
545 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
546 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
547 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
548 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
549 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
550 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
551 {N_("/_View/Show or hi_de/_Toolbar/_None"),
552 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
553 {N_("/_View/Show or hi_de/Status _bar"),
554 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
555 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
556 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
557 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
558 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
559 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
560 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
561 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
562 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
563 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
564 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
565 {N_("/_View/_Sort/by _color label"),
566 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
567 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
568 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
569 {N_("/_View/_Sort/by a_ttachment"),
570 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
571 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
572 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
573 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
574 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
575 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
576 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
577 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
578 {N_("/_View/_Sort/_Attract by subject"),
579 NULL, attract_by_subject_cb, 0, NULL},
580 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
581 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
582 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
583 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
584 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
586 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
587 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
588 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
589 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
590 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
591 {N_("/_View/_Go to/P_rev unread message"),
592 "<shift>P", prev_unread_cb, 0, NULL},
593 {N_("/_View/_Go to/N_ext unread message"),
594 "<shift>N", next_unread_cb, 0, NULL},
595 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
596 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
597 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
598 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
599 {N_("/_View/_Go to/Prev _marked message"),
600 NULL, prev_marked_cb, 0, NULL},
601 {N_("/_View/_Go to/Next m_arked message"),
602 NULL, next_marked_cb, 0, NULL},
603 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
604 {N_("/_View/_Go to/Prev _labeled message"),
605 NULL, prev_labeled_cb, 0, NULL},
606 {N_("/_View/_Go to/Next la_beled message"),
607 NULL, next_labeled_cb, 0, NULL},
608 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
609 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
610 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
612 #define CODESET_SEPARATOR \
613 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
614 #define CODESET_ACTION(action) \
615 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
617 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
618 {N_("/_View/_Code set/_Auto detect"),
619 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
620 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
621 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
622 CODESET_ACTION(C_US_ASCII)},
625 {N_("/_View/_Code set/Unicode (_UTF-8)"),
626 CODESET_ACTION(C_UTF_8)},
629 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
630 CODESET_ACTION(C_ISO_8859_1)},
631 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
632 CODESET_ACTION(C_ISO_8859_15)},
635 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
636 CODESET_ACTION(C_ISO_8859_2)},
638 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
639 CODESET_ACTION(C_ISO_8859_13)},
640 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
641 CODESET_ACTION(C_ISO_8859_4)},
643 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
644 CODESET_ACTION(C_ISO_8859_7)},
646 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
647 CODESET_ACTION(C_ISO_8859_9)},
649 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
650 CODESET_ACTION(C_ISO_8859_5)},
651 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
652 CODESET_ACTION(C_KOI8_R)},
653 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
654 CODESET_ACTION(C_WINDOWS_1251)},
657 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
658 CODESET_ACTION(C_ISO_2022_JP)},
660 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
661 CODESET_ACTION(C_ISO_2022_JP_2)},
663 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
664 CODESET_ACTION(C_EUC_JP)},
665 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
666 CODESET_ACTION(C_SHIFT_JIS)},
669 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
670 CODESET_ACTION(C_GB2312)},
671 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
672 CODESET_ACTION(C_BIG5)},
673 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
674 CODESET_ACTION(C_EUC_TW)},
675 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
676 CODESET_ACTION(C_ISO_2022_CN)},
678 {N_("/_View/_Code set/Korean (EUC-_KR)"),
679 CODESET_ACTION(C_EUC_KR)},
680 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
681 CODESET_ACTION(C_ISO_2022_KR)},
683 {N_("/_View/_Code set/Thai (TIS-620)"),
684 CODESET_ACTION(C_TIS_620)},
685 {N_("/_View/_Code set/Thai (Windows-874)"),
686 CODESET_ACTION(C_WINDOWS_874)},
689 #undef CODESET_SEPARATOR
690 #undef CODESET_ACTION
692 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
693 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
694 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
695 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
696 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
697 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
699 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
700 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
701 {N_("/_Message/Get from _all accounts"),
702 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
703 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
704 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
705 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
706 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
707 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
708 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
709 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
710 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
711 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
712 {N_("/_Message/Repl_y to/_sender"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
713 {N_("/_Message/Repl_y to/mailing _list"),
714 "<control>L", reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
715 {N_("/_Message/Follow-up and reply to"),NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
716 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
717 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
718 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
719 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
720 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
721 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
722 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
723 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
724 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
725 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
726 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
727 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
728 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
729 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
730 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
731 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
732 {N_("/_Message/_Mark/Mark as rea_d"),
733 NULL, mark_as_read_cb, 0, NULL},
734 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
736 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
737 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
738 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
739 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
740 {N_("/_Tools/Add sender to address boo_k"),
741 NULL, add_address_cb, 0, NULL},
742 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
743 {N_("/_Tools/_Harvest addresses/from _Folder..."),
744 NULL, addr_harvest_cb, 0, NULL},
745 {N_("/_Tools/_Harvest addresses/from _Messages..."),
746 NULL, addr_harvest_msg_cb, 0, NULL},
747 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
748 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
749 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
750 {N_("/_Tools/_Create filter rule/_Automatically"),
751 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
752 {N_("/_Tools/_Create filter rule/by _From"),
753 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
754 {N_("/_Tools/_Create filter rule/by _To"),
755 NULL, create_filter_cb, FILTER_BY_TO, NULL},
756 {N_("/_Tools/_Create filter rule/by _Subject"),
757 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
758 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
759 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
760 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
761 {N_("/_Tools/Delete du_plicated messages"),
762 NULL, delete_duplicated_cb, 0, NULL},
763 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
764 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
766 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
767 {N_("/_Tools/SSL certi_ficates..."),
768 NULL, ssl_manager_open_cb, 0, NULL},
770 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
771 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
773 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
774 {N_("/_Configuration/_Common preferences..."),
775 NULL, prefs_common_open_cb, 0, NULL},
776 {N_("/_Configuration/C_ustomize toolbars"),
777 NULL, NULL, 0, "<Branch>"},
778 {N_("/_Configuration/C_ustomize toolbars/_Main window..."),
779 NULL, prefs_toolbar_cb, TOOLBAR_MAIN, NULL},
780 {N_("/_Configuration/C_ustomize toolbars/_Compose window..."),
781 NULL, prefs_toolbar_cb, TOOLBAR_COMPOSE, NULL},
782 {N_("/_Configuration/C_ustomize toolbars/M_essage view..."),
783 NULL, prefs_toolbar_cb, TOOLBAR_MSGVIEW, NULL},
784 {N_("/_Configuration/_Scoring..."),
785 NULL, prefs_scoring_open_cb, 0, NULL},
786 {N_("/_Configuration/_Filtering..."),
787 NULL, prefs_filtering_open_cb, 0, NULL},
788 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
789 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
790 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
791 {N_("/_Configuration/_Preferences for current account..."),
792 NULL, prefs_account_open_cb, 0, NULL},
793 {N_("/_Configuration/Create _new account..."),
794 NULL, new_account_cb, 0, NULL},
795 {N_("/_Configuration/_Edit accounts..."),
796 NULL, account_edit_open, 0, NULL},
797 {N_("/_Configuration/C_hange current account"),
798 NULL, NULL, 0, "<Branch>"},
800 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
801 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
802 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
803 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
804 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
805 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
806 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
807 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
808 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
813 static GtkItemFactoryEntry reply_popup_entries[] =
815 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
816 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
818 static GtkItemFactoryEntry replyall_popup_entries[] =
820 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
821 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
823 static GtkItemFactoryEntry replylist_popup_entries[] =
825 {N_("/Reply to list with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE, NULL},
826 {N_("/_Reply to list without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE, NULL}
828 static GtkItemFactoryEntry replysender_popup_entries[] =
830 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
831 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
833 static GtkItemFactoryEntry fwd_popup_entries[] =
835 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
836 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
839 MainWindow *main_window_create(SeparateType type)
845 GtkWidget *handlebox;
846 GtkWidget *vbox_body;
847 GtkWidget *hbox_stat;
848 GtkWidget *statusbar;
849 GtkWidget *progressbar;
850 GtkWidget *statuslabel;
851 GtkWidget *ac_button;
853 GtkWidget *online_pixmap;
854 GtkWidget *offline_pixmap;
855 GtkWidget *online_switch;
856 GtkWidget *offline_switch;
858 FolderView *folderview;
859 SummaryView *summaryview;
860 MessageView *messageview;
861 GdkColormap *colormap;
864 GtkItemFactory *ifactory;
868 guint n_menu_entries;
870 static GdkGeometry geometry;
872 debug_print("Creating main window...\n");
873 mainwin = g_new0(MainWindow, 1);
876 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
877 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
878 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
879 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
881 if (!geometry.min_height) {
882 geometry.min_width = 320;
883 geometry.min_height = 200;
885 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
888 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
889 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
890 MANAGE_WINDOW_SIGNALS_CONNECT(window);
891 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
892 GTK_SIGNAL_FUNC(key_pressed), mainwin);
894 gtk_widget_realize(window);
895 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
898 gtkut_widget_set_app_icon(window);
900 vbox = gtk_vbox_new(FALSE, 0);
901 gtk_widget_show(vbox);
902 gtk_container_add(GTK_CONTAINER(window), vbox);
905 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
906 menubar = menubar_create(window, mainwin_entries,
907 n_menu_entries, "<Main>", mainwin);
908 gtk_widget_show(menubar);
909 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
910 ifactory = gtk_item_factory_from_widget(menubar);
912 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
913 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
915 handlebox = gtk_handle_box_new();
916 gtk_widget_show(handlebox);
917 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
919 /* link window to mainwin->window to avoid gdk warnings */
920 mainwin->window = window;
923 toolbar_create(mainwin, handlebox);
925 /* vbox that contains body */
926 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
927 gtk_widget_show(vbox_body);
928 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
929 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
931 hbox_stat = gtk_hbox_new(FALSE, 2);
932 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
934 statusbar = statusbar_create();
935 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
937 progressbar = gtk_progress_bar_new();
938 gtk_widget_set_usize(progressbar, 120, 1);
939 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
941 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
942 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
943 online_switch = gtk_button_new ();
944 offline_switch = gtk_button_new ();
945 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
946 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
947 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
948 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
949 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
950 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
951 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
952 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
954 statuslabel = gtk_label_new("");
955 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
957 ac_button = gtk_button_new();
958 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
959 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
960 gtk_widget_set_usize(ac_button, -1, 1);
961 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
962 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
963 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
965 ac_label = gtk_label_new("");
966 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
968 gtk_widget_show_all(hbox_stat);
970 gtk_widget_hide(offline_switch);
972 mainwin->folderview = folderview = folderview_create();
973 mainwin->summaryview = summaryview = summary_create();
974 mainwin->messageview = messageview = messageview_create(mainwin);
975 mainwin->logwin = log_window_create();
977 folderview->mainwin = mainwin;
978 folderview->summaryview = summaryview;
980 summaryview->mainwin = mainwin;
981 summaryview->folderview = folderview;
982 summaryview->messageview = messageview;
983 summaryview->window = window;
985 mainwin->vbox = vbox;
986 mainwin->menubar = menubar;
987 mainwin->menu_factory = ifactory;
988 mainwin->handlebox = handlebox;
989 mainwin->vbox_body = vbox_body;
990 mainwin->hbox_stat = hbox_stat;
991 mainwin->statusbar = statusbar;
992 mainwin->progressbar = progressbar;
993 mainwin->statuslabel = statuslabel;
994 mainwin->ac_button = ac_button;
995 mainwin->ac_label = ac_label;
997 mainwin->online_switch = online_switch;
998 mainwin->offline_switch = offline_switch;
999 mainwin->online_pixmap = online_pixmap;
1000 mainwin->offline_pixmap = offline_pixmap;
1002 /* set context IDs for status bar */
1003 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1004 (GTK_STATUSBAR(statusbar), "Main Window");
1005 mainwin->folderview_cid = gtk_statusbar_get_context_id
1006 (GTK_STATUSBAR(statusbar), "Folder View");
1007 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1008 (GTK_STATUSBAR(statusbar), "Summary View");
1010 /* allocate colors for summary view and folder view */
1011 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1012 summaryview->color_marked.blue = (guint16)65535;
1014 summaryview->color_dim.red = summaryview->color_dim.green =
1015 summaryview->color_dim.blue = COLOR_DIM;
1017 folderview->color_new.red = (guint16)55000;
1018 folderview->color_new.green = folderview->color_new.blue = 15000;
1020 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1021 &folderview->color_op);
1023 summaryview->color_important.red = 0;
1024 summaryview->color_important.green = 0;
1025 summaryview->color_important.blue = (guint16)65535;
1027 color[0] = summaryview->color_marked;
1028 color[1] = summaryview->color_dim;
1029 color[2] = folderview->color_new;
1030 color[3] = folderview->color_op;
1032 colormap = gdk_window_get_colormap(window->window);
1033 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1034 for (i = 0; i < 4; i++) {
1035 if (success[i] == FALSE)
1036 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1039 debug_print("done.\n");
1041 messageview->visible = TRUE;
1043 main_window_set_widgets(mainwin, type);
1045 /* set menu items */
1046 menuitem = gtk_item_factory_get_item
1047 (ifactory, "/View/Code set/Auto detect");
1048 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1050 switch (prefs_common.toolbar_style) {
1052 menuitem = gtk_item_factory_get_item
1053 (ifactory, "/View/Show or hide/Toolbar/None");
1056 menuitem = gtk_item_factory_get_item
1057 (ifactory, "/View/Show or hide/Toolbar/Icon");
1060 menuitem = gtk_item_factory_get_item
1061 (ifactory, "/View/Show or hide/Toolbar/Text");
1064 menuitem = gtk_item_factory_get_item
1065 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1067 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1069 gtk_widget_hide(mainwin->hbox_stat);
1070 menuitem = gtk_item_factory_get_item
1071 (ifactory, "/View/Show or hide/Status bar");
1072 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1073 prefs_common.show_statusbar);
1075 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
1077 if (prefs_common.show_searchbar)
1078 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
1081 /* set account selection menu */
1082 ac_menu = gtk_item_factory_get_widget
1083 (ifactory, "/Configuration/Change current account");
1084 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1085 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1086 mainwin->ac_menu = ac_menu;
1088 toolbar_set_sensitive(mainwin);
1090 /* create actions menu */
1091 update_mainwin_actions_menu(ifactory, mainwin);
1093 /* show main window */
1094 gtk_widget_set_uposition(mainwin->window,
1095 prefs_common.mainwin_x,
1096 prefs_common.mainwin_y);
1097 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1098 prefs_common.mainwin_height);
1099 gtk_widget_show(mainwin->window);
1101 /* initialize views */
1102 folderview_init(folderview);
1103 summary_init(summaryview);
1104 messageview_init(messageview);
1105 log_window_init(mainwin->logwin);
1107 mainwin->lock_count = 0;
1108 mainwin->menu_lock_count = 0;
1109 mainwin->cursor_count = 0;
1112 watch_cursor = gdk_cursor_new(GDK_WATCH);
1114 mainwin_list = g_list_append(mainwin_list, mainwin);
1116 /* init work_offline */
1117 if (prefs_common.work_offline)
1118 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1123 void main_window_cursor_wait(MainWindow *mainwin)
1126 if (mainwin->cursor_count == 0)
1127 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1129 mainwin->cursor_count++;
1134 void main_window_cursor_normal(MainWindow *mainwin)
1136 if (mainwin->cursor_count)
1137 mainwin->cursor_count--;
1139 if (mainwin->cursor_count == 0)
1140 gdk_window_set_cursor(mainwin->window->window, NULL);
1145 /* lock / unlock the user-interface */
1146 void main_window_lock(MainWindow *mainwin)
1148 if (mainwin->lock_count == 0)
1149 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1151 mainwin->lock_count++;
1153 main_window_set_menu_sensitive(mainwin);
1154 toolbar_set_sensitive(mainwin);
1157 void main_window_unlock(MainWindow *mainwin)
1159 if (mainwin->lock_count)
1160 mainwin->lock_count--;
1162 main_window_set_menu_sensitive(mainwin);
1163 toolbar_set_sensitive(mainwin);
1165 if (mainwin->lock_count == 0)
1166 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1169 static void main_window_menu_callback_block(MainWindow *mainwin)
1171 mainwin->menu_lock_count++;
1174 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1176 if (mainwin->menu_lock_count)
1177 mainwin->menu_lock_count--;
1180 void main_window_reflect_prefs_all(void)
1182 main_window_reflect_prefs_all_real(FALSE);
1185 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1188 MainWindow *mainwin;
1191 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1192 mainwin = (MainWindow *)cur->data;
1194 main_window_show_cur_account(mainwin);
1195 main_window_set_menu_sensitive(mainwin);
1196 toolbar_set_sensitive(mainwin);
1199 if (pixmap_theme_changed) {
1200 toolbar_update(mainwin);
1201 common_toolbar_set_style(mainwin, TOOLBAR_MAIN);
1202 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1203 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1205 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1206 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1207 mainwin->online_pixmap);
1208 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1209 gtk_widget_show(pixmap);
1210 mainwin->online_pixmap = pixmap;
1211 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1212 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1213 mainwin->offline_pixmap);
1214 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1215 gtk_widget_show(pixmap);
1216 mainwin->offline_pixmap = pixmap;
1219 summary_redisplay_msg(mainwin->summaryview);
1220 headerview_set_visibility(mainwin->messageview->headerview,
1221 prefs_common.display_header_pane);
1225 void main_window_set_summary_column(void)
1228 MainWindow *mainwin;
1230 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1231 mainwin = (MainWindow *)cur->data;
1232 summary_set_column_order(mainwin->summaryview);
1236 void main_window_set_account_menu(GList *account_list)
1238 GList *cur, *cur_ac, *cur_item;
1239 GtkWidget *menuitem;
1240 MainWindow *mainwin;
1241 PrefsAccount *ac_prefs;
1243 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1244 mainwin = (MainWindow *)cur->data;
1246 /* destroy all previous menu item */
1247 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1248 while (cur_item != NULL) {
1249 GList *next = cur_item->next;
1250 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1254 for (cur_ac = account_list; cur_ac != NULL;
1255 cur_ac = cur_ac->next) {
1256 ac_prefs = (PrefsAccount *)cur_ac->data;
1258 menuitem = gtk_menu_item_new_with_label
1259 (ac_prefs->account_name
1260 ? ac_prefs->account_name : _("Untitled"));
1261 gtk_widget_show(menuitem);
1262 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1263 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1264 GTK_SIGNAL_FUNC(account_menu_cb),
1270 static void main_window_show_cur_account(MainWindow *mainwin)
1275 ac_name = g_strdup(cur_account
1276 ? (cur_account->account_name
1277 ? cur_account->account_name : _("Untitled"))
1281 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1283 buf = g_strdup(PROG_VERSION);
1284 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1287 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1288 gtk_widget_queue_resize(mainwin->ac_button);
1293 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1295 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1296 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1297 //GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1298 GtkWidget *message_wid = mainwin->messageview->vbox;
1300 debug_print("Changing window separation type from %d to %d\n",
1301 mainwin->type, type);
1303 if (mainwin->type == type) return;
1305 /* remove widgets from those containers */
1306 gtk_widget_ref(folder_wid);
1307 gtk_widget_ref(summary_wid);
1308 gtk_widget_ref(message_wid);
1309 gtkut_container_remove
1310 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1311 gtkut_container_remove
1312 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1313 gtkut_container_remove
1314 (GTK_CONTAINER(message_wid->parent), message_wid);
1316 /* clean containers */
1317 switch (mainwin->type) {
1319 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1321 case SEPARATE_FOLDER:
1322 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1323 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1325 case SEPARATE_MESSAGE:
1326 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1327 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1330 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1331 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1335 gtk_widget_hide(mainwin->window);
1336 main_window_set_widgets(mainwin, type);
1337 gtk_widget_show(mainwin->window);
1339 gtk_widget_unref(folder_wid);
1340 gtk_widget_unref(summary_wid);
1341 gtk_widget_unref(message_wid);
1344 void main_window_toggle_message_view(MainWindow *mainwin)
1346 SummaryView *summaryview = mainwin->summaryview;
1347 union CompositeWin *cwin = &mainwin->win;
1348 GtkWidget *vpaned = NULL;
1349 GtkWidget *container = NULL;
1350 GtkWidget *msgwin = NULL;
1352 switch (mainwin->type) {
1354 vpaned = cwin->sep_none.vpaned;
1355 container = cwin->sep_none.hpaned;
1357 case SEPARATE_FOLDER:
1358 vpaned = cwin->sep_folder.vpaned;
1359 container = mainwin->vbox_body;
1361 case SEPARATE_MESSAGE:
1362 msgwin = mainwin->win.sep_message.messagewin;
1365 msgwin = mainwin->win.sep_both.messagewin;
1370 if (GTK_WIDGET_VISIBLE(msgwin)) {
1371 gtk_widget_hide(msgwin);
1372 mainwin->messageview->visible = FALSE;
1373 summaryview->displayed = NULL;
1375 gtk_widget_show(msgwin);
1376 mainwin->messageview->visible = TRUE;
1378 } else if (vpaned->parent != NULL) {
1379 mainwin->messageview->visible = FALSE;
1380 summaryview->displayed = NULL;
1381 gtk_widget_ref(vpaned);
1382 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1383 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1384 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1385 GTK_ARROW_UP, GTK_SHADOW_OUT);
1387 mainwin->messageview->visible = TRUE;
1388 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1389 gtk_container_add(GTK_CONTAINER(container), vpaned);
1390 gtk_widget_unref(vpaned);
1391 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1392 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1395 main_window_set_menu_sensitive(mainwin);
1397 gtk_widget_grab_focus(summaryview->ctree);
1400 void main_window_get_size(MainWindow *mainwin)
1402 GtkAllocation *allocation;
1404 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1406 prefs_common.summaryview_width = allocation->width;
1408 if ((mainwin->type == SEPARATE_NONE ||
1409 mainwin->type == SEPARATE_FOLDER) &&
1410 messageview_is_visible(mainwin->messageview))
1411 prefs_common.summaryview_height = allocation->height;
1413 prefs_common.mainview_width = allocation->width;
1415 allocation = &mainwin->window->allocation;
1417 prefs_common.mainview_height = allocation->height;
1418 prefs_common.mainwin_width = allocation->width;
1419 prefs_common.mainwin_height = allocation->height;
1421 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1423 prefs_common.folderview_width = allocation->width;
1424 prefs_common.folderview_height = allocation->height;
1427 void main_window_get_position(MainWindow *mainwin)
1431 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1433 prefs_common.mainview_x = x;
1434 prefs_common.mainview_y = y;
1435 prefs_common.mainwin_x = x;
1436 prefs_common.mainwin_y = y;
1438 debug_print("window position: x = %d, y = %d\n", x, y);
1441 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1447 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1448 folder = FOLDER(list->data);
1449 if (folder && folder->trash && folder->trash->total > 0)
1453 if (!has_trash) return;
1456 if (alertpanel(_("Empty trash"),
1457 _("Empty all messages in trash?"),
1458 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1460 manage_window_focus_in(mainwin->window, NULL, NULL);
1463 procmsg_empty_trash();
1465 for (list = folder_get_list(); list != NULL; list = list->next) {
1466 folder = list->data;
1467 if (folder && folder->trash) {
1468 folder_update_item(folder->trash, TRUE);
1472 if (mainwin->summaryview->folder_item &&
1473 mainwin->summaryview->folder_item->stype == F_TRASH)
1474 gtk_widget_grab_focus(mainwin->folderview->ctree);
1477 void main_window_add_mailbox(MainWindow *mainwin)
1482 path = input_dialog(_("Add mailbox"),
1483 _("Input the location of mailbox.\n"
1484 "If the existing mailbox is specified, it will be\n"
1485 "scanned automatically."),
1488 if (folder_find_from_path(path)) {
1489 alertpanel_error(_("The mailbox `%s' already exists."), path);
1493 if (!strcmp(path, "Mail"))
1494 folder = folder_new(F_MH, _("Mailbox"), path);
1496 folder = folder_new(F_MH, g_basename(path), path);
1499 if (folder->create_tree(folder) < 0) {
1500 alertpanel_error(_("Creation of the mailbox failed.\n"
1501 "Maybe some files already exist, or you don't have the permission to write there."));
1502 folder_destroy(folder);
1507 folder_set_ui_func(folder, scan_tree_func, mainwin);
1508 folder_scan_tree(folder);
1509 folder_set_ui_func(folder, NULL, NULL);
1511 folderview_set(mainwin->folderview);
1514 void main_window_add_mbox(MainWindow *mainwin)
1520 path = input_dialog(_("Add mbox mailbox"),
1521 _("Input the location of mailbox."),
1526 if (folder_find_from_path(path)) {
1527 alertpanel_error(_("The mailbox `%s' already exists."), path);
1533 if (!strcmp(path, "Mail"))
1534 folder = folder_new(F_MBOX, _("Mailbox"), path);
1538 folder = folder_new(F_MBOX, g_basename(path), path);
1541 if (folder->create_tree(folder) < 0) {
1542 alertpanel_error(_("Creation of the mailbox failed."));
1543 folder_destroy(folder);
1549 item = folder_item_new(folder, folder->name, NULL);
1550 item->folder = folder;
1551 folder->node = g_node_new(item);
1553 folder_create_folder(item, "inbox");
1554 folder_create_folder(item, "outbox");
1555 folder_create_folder(item, "queue");
1556 folder_create_folder(item, "draft");
1557 folder_create_folder(item, "trash");
1559 folderview_set(mainwin->folderview);
1562 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1564 SensitiveCond state = 0;
1565 SummarySelection selection;
1566 FolderItem *item = mainwin->summaryview->folder_item;
1567 GList *account_list = account_get_list();
1569 selection = summary_get_selection_type(mainwin->summaryview);
1571 if (mainwin->lock_count == 0)
1572 state |= M_UNLOCKED;
1573 if (selection != SUMMARY_NONE)
1574 state |= M_MSG_EXIST;
1575 if (item && item->path && item->parent && !item->no_select) {
1577 /* if (item->folder->type != F_NEWS) */
1578 state |= M_ALLOW_DELETE;
1580 if (prefs_common.immediate_exec == 0
1581 && mainwin->lock_count == 0)
1582 state |= M_DELAY_EXEC;
1584 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1585 || selection != SUMMARY_NONE)
1586 state |= M_HIDE_READ_MSG;
1588 if (mainwin->summaryview->threaded)
1589 state |= M_THREADED;
1591 state |= M_UNTHREADED;
1592 if (selection == SUMMARY_SELECTED_SINGLE ||
1593 selection == SUMMARY_SELECTED_MULTIPLE)
1594 state |= M_TARGET_EXIST;
1595 if (selection == SUMMARY_SELECTED_SINGLE)
1596 state |= M_SINGLE_TARGET_EXIST;
1597 if (mainwin->summaryview->folder_item &&
1598 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1601 state |= M_NOT_NEWS;
1602 if (selection == SUMMARY_SELECTED_SINGLE &&
1604 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1605 item->stype == F_QUEUE)))
1606 state |= M_ALLOW_REEDIT;
1608 state |= M_HAVE_ACCOUNT;
1610 for ( ; account_list != NULL; account_list = account_list->next) {
1611 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1612 state |= M_HAVE_NEWS_ACCOUNT;
1617 if (inc_is_active())
1618 state |= M_INC_ACTIVE;
1625 void main_window_set_menu_sensitive(MainWindow *mainwin)
1627 GtkItemFactory *ifactory = mainwin->menu_factory;
1628 SensitiveCond state;
1630 GtkWidget *menuitem;
1631 SummaryView *summaryview;
1635 static const struct {
1639 {"/File/Add mailbox..." , M_UNLOCKED},
1640 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1641 {"/File/Check for new messages in all folders", M_UNLOCKED},
1642 {"/File/Folder" , M_UNLOCKED},
1643 {"/File/Import mbox file..." , M_UNLOCKED},
1644 {"/File/Export to mbox file..." , M_UNLOCKED},
1645 {"/File/Empty trash" , M_UNLOCKED},
1646 {"/File/Work offline" , M_UNLOCKED},
1648 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1649 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1650 /* {"/File/Close" , M_UNLOCKED}, */
1651 {"/File/Exit" , M_UNLOCKED},
1653 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1655 {"/View/Sort" , M_EXEC},
1656 {"/View/Thread view" , M_EXEC},
1657 {"/View/Expand all threads" , M_MSG_EXIST},
1658 {"/View/Collapse all threads" , M_MSG_EXIST},
1659 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1660 {"/View/Go to/Prev message" , M_MSG_EXIST},
1661 {"/View/Go to/Next message" , M_MSG_EXIST},
1662 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1663 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1664 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1665 {"/View/Go to/Next new message" , M_MSG_EXIST},
1666 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1667 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1668 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1669 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1670 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1671 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1672 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1674 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1675 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1676 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1677 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1678 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1679 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1680 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1681 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1682 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1683 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1684 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1685 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1686 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1687 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1688 {"/Message/Mark" , M_TARGET_EXIST},
1690 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1691 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1692 {"/Tools/Harvest addresses" , M_UNLOCKED},
1693 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1694 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1695 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1696 {"/Tools/Execute" , M_DELAY_EXEC},
1697 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1699 {"/Configuration", M_UNLOCKED},
1704 state = main_window_get_current_state(mainwin);
1706 for (i = 0; entry[i].entry != NULL; i++) {
1707 sensitive = ((entry[i].cond & state) == entry[i].cond);
1708 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1711 main_window_menu_callback_block(mainwin);
1713 #define SET_CHECK_MENU_ACTIVE(path, active) \
1715 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1716 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1719 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1720 messageview_is_visible(mainwin->messageview));
1722 summaryview = mainwin->summaryview;
1723 menu_path = "/View/Sort/Don't sort";
1725 switch (summaryview->sort_key) {
1726 case SORT_BY_NUMBER:
1727 menu_path = "/View/Sort/by number"; break;
1729 menu_path = "/View/Sort/by size"; break;
1731 menu_path = "/View/Sort/by date"; break;
1733 menu_path = "/View/Sort/by from"; break;
1734 case SORT_BY_SUBJECT:
1735 menu_path = "/View/Sort/by subject"; break;
1737 menu_path = "/View/Sort/by color label"; break;
1739 menu_path = "/View/Sort/by mark"; break;
1740 case SORT_BY_UNREAD:
1741 menu_path = "/View/Sort/by unread"; break;
1743 menu_path = "/View/Sort/by attachment"; break;
1745 menu_path = "/View/Sort/by score"; break;
1746 case SORT_BY_LOCKED:
1747 menu_path = "/View/Sort/by locked"; break;
1750 menu_path = "/View/Sort/Don't sort"; break;
1752 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1754 if (summaryview->sort_type == SORT_ASCENDING) {
1755 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1757 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1760 if (summaryview->sort_key != SORT_BY_NONE) {
1761 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1762 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1764 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1765 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1768 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1769 mainwin->messageview->textview->show_all_headers);
1770 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1772 #undef SET_CHECK_MENU_ACTIVE
1774 main_window_menu_callback_unblock(mainwin);
1777 void main_window_popup(MainWindow *mainwin)
1783 gdk_window_get_origin(mainwin->window->window, &x, &y);
1784 sx = gdk_screen_width();
1785 sy = gdk_screen_height();
1786 x %= sx; if (x < 0) x = 0;
1787 y %= sy; if (y < 0) y = 0;
1788 gdk_window_move(mainwin->window->window, x, y);
1789 gdk_window_raise(mainwin->window->window);
1790 gdk_window_show(mainwin->window->window);
1792 debug_print("window position: x = %d, y = %d\n", x, y);
1794 switch (mainwin->type) {
1795 case SEPARATE_FOLDER:
1796 widget = mainwin->win.sep_folder.folderwin;
1797 gdk_window_get_origin(widget->window, &x, &y);
1798 x %= sx; if (x < 0) x = 0;
1799 y %= sy; if (y < 0) y = 0;
1800 gdk_window_move(widget->window, x, y);
1801 gdk_window_raise(widget->window);
1803 case SEPARATE_MESSAGE:
1804 widget = mainwin->win.sep_message.messagewin;
1805 gdk_window_get_origin(widget->window, &x, &y);
1806 x %= sx; if (x < 0) x = 0;
1807 y %= sy; if (y < 0) y = 0;
1808 gdk_window_move(widget->window, x, y);
1809 gdk_window_raise(widget->window);
1812 widget = mainwin->win.sep_both.folderwin;
1813 gdk_window_get_origin(widget->window, &x, &y);
1814 x %= sx; if (x < 0) x = 0;
1815 y %= sy; if (y < 0) y = 0;
1816 gdk_window_move(widget->window, x, y);
1817 gdk_window_raise(widget->window);
1818 widget = mainwin->win.sep_both.messagewin;
1819 gdk_window_get_origin(widget->window, &x, &y);
1820 x %= sx; if (x < 0) x = 0;
1821 y %= sy; if (y < 0) y = 0;
1822 gdk_window_move(widget->window, x, y);
1823 gdk_window_raise(widget->window);
1830 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1832 GtkWidget *folderwin = NULL;
1833 GtkWidget *messagewin = NULL;
1836 GtkWidget *vbox_body = mainwin->vbox_body;
1837 GtkItemFactory *ifactory = mainwin->menu_factory;
1838 GtkWidget *menuitem;
1840 debug_print("Setting widgets...");
1842 /* create separated window(s) if needed */
1843 if (type & SEPARATE_FOLDER) {
1844 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1845 gtk_window_set_title(GTK_WINDOW(folderwin),
1846 _("Sylpheed - Folder View"));
1847 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1848 "folder_view", "Sylpheed");
1849 gtk_window_set_policy(GTK_WINDOW(folderwin),
1851 gtk_widget_set_usize(folderwin, -1,
1852 prefs_common.mainview_height);
1853 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1855 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1856 GTK_SIGNAL_FUNC(folder_window_close_cb),
1859 if (type & SEPARATE_MESSAGE) {
1860 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1861 gtk_window_set_title(GTK_WINDOW(messagewin),
1862 _("Sylpheed - Message View"));
1863 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1864 "message_view", "Sylpheed");
1865 gtk_window_set_policy(GTK_WINDOW(messagewin),
1867 gtk_widget_set_usize
1868 (messagewin, prefs_common.mainview_width,
1869 prefs_common.mainview_height
1870 - prefs_common.summaryview_height
1871 + DEFAULT_HEADERVIEW_HEIGHT);
1872 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1874 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1875 GTK_SIGNAL_FUNC(message_window_close_cb),
1881 hpaned = gtk_hpaned_new();
1882 gtk_widget_show(hpaned);
1883 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1884 gtk_paned_add1(GTK_PANED(hpaned),
1885 GTK_WIDGET_PTR(mainwin->folderview));
1887 vpaned = gtk_vpaned_new();
1888 if (messageview_is_visible(mainwin->messageview)) {
1889 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1890 gtk_paned_add1(GTK_PANED(vpaned),
1891 GTK_WIDGET_PTR(mainwin->summaryview));
1893 gtk_paned_add2(GTK_PANED(hpaned),
1894 GTK_WIDGET_PTR(mainwin->summaryview));
1895 gtk_widget_ref(vpaned);
1897 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1898 prefs_common.summaryview_width,
1899 prefs_common.summaryview_height);
1900 gtk_paned_add2(GTK_PANED(vpaned),
1901 GTK_WIDGET_PTR(mainwin->messageview));
1902 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1903 prefs_common.mainview_width, -1);
1904 gtk_widget_set_usize(mainwin->window,
1905 prefs_common.folderview_width +
1906 prefs_common.mainview_width,
1907 prefs_common.mainwin_height);
1908 gtk_widget_show_all(vpaned);
1910 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1911 * lose track of its visibility state */
1912 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1913 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1915 mainwin->win.sep_none.hpaned = hpaned;
1916 mainwin->win.sep_none.vpaned = vpaned;
1918 /* remove headerview if not in prefs */
1919 headerview_set_visibility(mainwin->messageview->headerview,
1920 prefs_common.display_header_pane);
1922 case SEPARATE_FOLDER:
1923 vpaned = gtk_vpaned_new();
1924 if (messageview_is_visible(mainwin->messageview)) {
1925 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1927 gtk_paned_add1(GTK_PANED(vpaned),
1928 GTK_WIDGET_PTR(mainwin->summaryview));
1930 gtk_box_pack_start(GTK_BOX(vbox_body),
1931 GTK_WIDGET_PTR(mainwin->summaryview),
1933 gtk_widget_ref(vpaned);
1935 gtk_paned_add2(GTK_PANED(vpaned),
1936 GTK_WIDGET_PTR(mainwin->messageview));
1937 gtk_widget_show_all(vpaned);
1938 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1939 prefs_common.summaryview_width,
1940 prefs_common.summaryview_height);
1941 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1942 prefs_common.mainview_width, -1);
1943 gtk_widget_set_usize(mainwin->window,
1944 prefs_common.mainview_width,
1945 prefs_common.mainview_height);
1947 gtk_container_add(GTK_CONTAINER(folderwin),
1948 GTK_WIDGET_PTR(mainwin->folderview));
1950 mainwin->win.sep_folder.folderwin = folderwin;
1951 mainwin->win.sep_folder.vpaned = vpaned;
1953 gtk_widget_show_all(folderwin);
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));
1960 /* remove headerview if not in prefs */
1961 headerview_set_visibility(mainwin->messageview->headerview,
1962 prefs_common.display_header_pane);
1965 case SEPARATE_MESSAGE:
1966 hpaned = gtk_hpaned_new();
1967 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1969 gtk_paned_add1(GTK_PANED(hpaned),
1970 GTK_WIDGET_PTR(mainwin->folderview));
1971 gtk_paned_add2(GTK_PANED(hpaned),
1972 GTK_WIDGET_PTR(mainwin->summaryview));
1973 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1974 prefs_common.summaryview_width,
1975 prefs_common.summaryview_height);
1976 gtk_widget_set_usize(mainwin->window,
1977 prefs_common.folderview_width +
1978 prefs_common.mainview_width,
1979 prefs_common.mainwin_height);
1980 gtk_widget_show_all(hpaned);
1981 gtk_container_add(GTK_CONTAINER(messagewin),
1982 GTK_WIDGET_PTR(mainwin->messageview));
1984 mainwin->win.sep_message.messagewin = messagewin;
1985 mainwin->win.sep_message.hpaned = hpaned;
1987 gtk_widget_show_all(messagewin);
1989 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1990 * lose track of its visibility state */
1991 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1992 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1995 gtk_box_pack_start(GTK_BOX(vbox_body),
1996 GTK_WIDGET_PTR(mainwin->summaryview),
1998 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1999 prefs_common.summaryview_width,
2000 prefs_common.summaryview_height);
2001 gtk_widget_set_usize(mainwin->window,
2002 prefs_common.mainview_width,
2003 prefs_common.mainwin_height);
2004 gtk_container_add(GTK_CONTAINER(folderwin),
2005 GTK_WIDGET_PTR(mainwin->folderview));
2006 gtk_container_add(GTK_CONTAINER(messagewin),
2007 GTK_WIDGET_PTR(mainwin->messageview));
2009 mainwin->win.sep_both.folderwin = folderwin;
2010 mainwin->win.sep_both.messagewin = messagewin;
2012 gtk_widget_show_all(folderwin);
2013 gtk_widget_show_all(messagewin);
2015 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2016 * lose track of its visibility state */
2017 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2018 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2022 /* rehide quick search if necessary */
2023 if (!prefs_common.show_searchbar)
2024 gtk_widget_hide(mainwin->summaryview->hbox_search);
2026 mainwin->type = type;
2028 mainwin->messageview->visible = TRUE;
2030 /* toggle menu state */
2031 menuitem = gtk_item_factory_get_item
2032 (ifactory, "/View/Show or hide/Folder tree");
2033 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2034 menuitem = gtk_item_factory_get_item
2035 (ifactory, "/View/Show or hide/Message view");
2036 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2038 menuitem = gtk_item_factory_get_item
2039 (ifactory, "/View/Separate folder tree");
2040 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2041 ((type & SEPARATE_FOLDER) != 0));
2042 menuitem = gtk_item_factory_get_item
2043 (ifactory, "/View/Separate message view");
2044 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2045 ((type & SEPARATE_MESSAGE) != 0));
2047 debug_print("done.\n");
2050 void main_window_destroy_all(void)
2052 while (mainwin_list != NULL) {
2053 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2055 /* free toolbar stuff */
2056 toolbar_clear_list(TOOLBAR_MAIN);
2057 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2058 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2060 g_free(mainwin->toolbar);
2063 mainwin_list = g_list_remove(mainwin_list, mainwin);
2065 g_list_free(mainwin_list);
2069 static void toolbar_account_button_pressed(GtkWidget *widget,
2070 GdkEventButton *event,
2073 MainWindow *mainwin = (MainWindow *)data;
2076 if (event->button != 3) return;
2078 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2079 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2082 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2083 menu_button_position, widget,
2084 event->button, event->time);
2088 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2091 MainWindow *mainwin = (MainWindow *)data;
2095 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2096 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2099 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2100 menu_button_position, widget,
2101 event->button, event->time);
2104 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2106 MainWindow *mainwin = (MainWindow *)data;
2109 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2110 if (!button) return;
2111 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2112 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2113 manage_window_focus_in(mainwin->window, NULL, NULL);
2116 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2119 MainWindow *mainwin = (MainWindow *)data;
2121 if (mainwin->lock_count == 0)
2122 app_exit_cb(data, 0, widget);
2127 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2130 MainWindow *mainwin = (MainWindow *)data;
2131 GtkWidget *menuitem;
2133 menuitem = gtk_item_factory_get_item
2134 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2135 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2140 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2143 MainWindow *mainwin = (MainWindow *)data;
2144 GtkWidget *menuitem;
2146 menuitem = gtk_item_factory_get_item
2147 (mainwin->menu_factory, "/View/Show or hide/Message view");
2148 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2153 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2156 main_window_add_mailbox(mainwin);
2159 static void add_mbox_cb(MainWindow *mainwin, guint action,
2162 main_window_add_mbox(mainwin);
2165 static void update_folderview_cb(MainWindow *mainwin, guint action,
2168 summary_show(mainwin->summaryview, NULL);
2169 folderview_check_new_all();
2172 static void new_folder_cb(MainWindow *mainwin, guint action,
2175 folderview_new_folder(mainwin->folderview);
2178 static void rename_folder_cb(MainWindow *mainwin, guint action,
2181 folderview_rename_folder(mainwin->folderview);
2184 static void delete_folder_cb(MainWindow *mainwin, guint action,
2187 folderview_delete_folder(mainwin->folderview);
2190 static void import_mbox_cb(MainWindow *mainwin, guint action,
2193 import_mbox(mainwin->summaryview->folder_item);
2196 static void export_mbox_cb(MainWindow *mainwin, guint action,
2199 export_mbox(mainwin->summaryview->folder_item);
2202 static void empty_trash_cb(MainWindow *mainwin, guint action,
2205 main_window_empty_trash(mainwin, TRUE);
2208 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2210 summary_save_as(mainwin->summaryview);
2213 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2215 summary_print(mainwin->summaryview);
2218 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2220 if (prefs_common.confirm_on_exit) {
2221 if (alertpanel(_("Exit"), _("Exit this program?"),
2222 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2224 manage_window_focus_in(mainwin->window, NULL, NULL);
2227 app_will_exit(widget, mainwin);
2230 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2233 summary_search(mainwin->summaryview);
2235 message_search(mainwin->messageview);
2238 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2243 active = GTK_CHECK_MENU_ITEM(widget)->active;
2245 switch (mainwin->type) {
2247 case SEPARATE_MESSAGE:
2250 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2252 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2255 case SEPARATE_FOLDER:
2256 debug_print("separate folder\n");
2258 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2260 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2264 gtk_widget_show(mainwin->win.sep_both.folderwin);
2266 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2271 static void toggle_message_cb(MainWindow *mainwin, guint action,
2276 active = GTK_CHECK_MENU_ITEM(widget)->active;
2278 if (active != messageview_is_visible(mainwin->messageview))
2279 summary_toggle_view(mainwin->summaryview);
2282 /* Toolbar handling */
2283 static void toolbar_inc_cb(GtkWidget *widget,
2286 MainWindow *mainwin = (MainWindow *)data;
2288 inc_mail_cb(mainwin, 0, NULL);
2291 static void toolbar_inc_all_cb(GtkWidget *widget,
2294 MainWindow *mainwin = (MainWindow *)data;
2296 inc_all_account_mail_cb(mainwin, 0, NULL);
2299 static void toolbar_send_cb(GtkWidget *widget,
2302 MainWindow *mainwin = (MainWindow *)data;
2304 send_queue_cb(mainwin, 0, NULL);
2307 static void toolbar_compose_cb(GtkWidget *widget,
2310 MainWindow *mainwin = (MainWindow *)data;
2312 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
2313 compose_news_cb(mainwin, 0, NULL);
2315 compose_mail_cb(mainwin, 0, NULL);
2318 static void toolbar_reply_cb(GtkWidget *widget,
2321 MainWindow *mainwin = (MainWindow *)data;
2323 if (prefs_common.default_reply_list)
2325 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
2326 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
2330 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2331 : COMPOSE_REPLY_WITHOUT_QUOTE,
2335 static void toolbar_reply_to_all_cb(GtkWidget *widget,
2338 MainWindow *mainwin = (MainWindow *)data;
2341 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2342 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2346 static void toolbar_reply_to_list_cb(GtkWidget *widget,
2349 MainWindow *mainwin = (MainWindow *)data;
2352 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
2353 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
2357 static void toolbar_reply_to_sender_cb(GtkWidget *widget,
2360 MainWindow *mainwin = (MainWindow *)data;
2363 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2364 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2368 static void toolbar_forward_cb(GtkWidget *widget,
2371 MainWindow *mainwin = (MainWindow *)data;
2373 if (prefs_common.forward_as_attachment)
2374 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2376 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2379 static void toolbar_exec_cb(GtkWidget *widget,
2382 MainWindow *mainwin = (MainWindow *)data;
2384 summary_execute(mainwin->summaryview);
2387 static void toolbar_next_unread_cb(GtkWidget *widget,
2390 MainWindow *mainwin = (MainWindow *)data;
2392 next_unread_cb(mainwin, 0, NULL);
2395 /* popup callback functions */
2396 static void toolbar_reply_popup_cb(GtkWidget *widget,
2397 GdkEventButton *event,
2400 MainWindow *mainwindow = (MainWindow *) data;
2404 if (event->button == 3) {
2405 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2406 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->reply_popup), NULL, NULL,
2407 menu_button_position, widget,
2408 event->button, event->time);
2412 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2414 MainWindow *mainwin = (MainWindow *)data;
2416 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->reply_btn), GTK_RELIEF_NONE);
2417 manage_window_focus_in(mainwin->window, NULL, NULL);
2420 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2422 MainWindow *mainwindow = (MainWindow *) data;
2426 if (event->button == 3) {
2427 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2428 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replyall_popup), NULL, NULL,
2429 menu_button_position, widget,
2430 event->button, event->time);
2434 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2436 MainWindow *mainwin = (MainWindow *)data;
2438 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replyall_btn), GTK_RELIEF_NONE);
2439 manage_window_focus_in(mainwin->window, NULL, NULL);
2442 static void toolbar_reply_to_list_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2444 MainWindow *mainwindow = (MainWindow *) data;
2448 if (event->button == 3) {
2449 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2450 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replylist_popup), NULL, NULL,
2451 menu_button_position, widget,
2452 event->button, event->time);
2456 static void toolbar_reply_to_list_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2458 MainWindow *mainwin = (MainWindow *)data;
2460 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replylist_btn), GTK_RELIEF_NONE);
2461 manage_window_focus_in(mainwin->window, NULL, NULL);
2464 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2466 MainWindow *mainwindow = (MainWindow *) data;
2470 if (event->button == 3) {
2471 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2472 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replysender_popup), NULL, NULL,
2473 menu_button_position, widget,
2474 event->button, event->time);
2478 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2480 MainWindow *mainwin = (MainWindow *)data;
2482 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replysender_btn), GTK_RELIEF_NONE);
2483 manage_window_focus_in(mainwin->window, NULL, NULL);
2486 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2488 MainWindow *mainwindow = (MainWindow *) data;
2492 if (event->button == 3) {
2493 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2494 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->fwd_popup), NULL, NULL,
2495 menu_button_position, widget,
2496 event->button, event->time);
2500 static void toolbar_forward_popup_closed_cb (GtkMenuShell *menu_shell,
2503 MainWindow *mainwin = (MainWindow *)data;
2505 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->fwd_btn), GTK_RELIEF_NONE);
2506 manage_window_focus_in(mainwin->window, NULL, NULL);
2509 static void activate_compose_button (Toolbar *toolbar,
2511 ComposeButtonType type)
2513 if ((!toolbar->compose_mail_btn) || (!toolbar->compose_news_btn))
2516 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? toolbar->compose_mail_btn
2517 : toolbar->compose_news_btn);
2518 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? toolbar->compose_news_btn
2519 : toolbar->compose_mail_btn);
2520 toolbar->compose_btn_type = type;
2523 void toolbar_set_compose_button(Toolbar *toolbar,
2524 ComposeButtonType compose_btn_type)
2526 if (toolbar->compose_btn_type != compose_btn_type)
2527 activate_compose_button(toolbar,
2528 prefs_common.toolbar_style,
2532 static void toolbar_buttons_cb(GtkWidget *widget,
2537 void (*func)(GtkWidget *widget, gpointer data);
2538 } toolbar_action[] = {
2539 { A_RECEIVE_ALL, toolbar_inc_all_cb },
2540 { A_RECEIVE_CUR, toolbar_inc_cb },
2541 { A_SEND_QUEUED, toolbar_send_cb },
2542 { A_COMPOSE_EMAIL, toolbar_compose_cb },
2543 { A_REPLY_MESSAGE, toolbar_reply_cb },
2544 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
2545 { A_REPLY_ALL, toolbar_reply_to_all_cb },
2546 { A_REPLY_ML, toolbar_reply_to_list_cb },
2547 { A_FORWARD, toolbar_forward_cb },
2548 { A_DELETE, common_toolbar_delete_cb },
2549 { A_EXECUTE, toolbar_exec_cb },
2550 { A_GOTO_NEXT, toolbar_next_unread_cb },
2551 { A_SYL_ACTIONS, common_toolbar_actions_execute_cb },
2553 { A_COMPOSE_NEWS, toolbar_compose_cb },
2554 { A_SEPARATOR, NULL }};
2556 gint num_items = sizeof(toolbar_action)/sizeof(toolbar_action[0]);
2559 for (i = A_RECEIVE_ALL; i < num_items; i++) {
2561 if (toolbar_action[i].index == item->index) {
2562 if ((item->index == A_SYL_ACTIONS) || (item->index == A_DELETE))
2563 /* the common_toolbar_* stuff takes item->parent as data
2565 toolbar_action[i].func(widget, (gpointer)item->parent);
2566 else /* to be removed */
2567 toolbar_action[i].func(widget, (gpointer)item->parent->data);
2573 void toolbar_set_sensitive(MainWindow *mainwin)
2575 SensitiveCond state;
2577 Toolbar *toolbar = mainwin->toolbar;
2579 GSList *entry_list = NULL;
2581 typedef struct _Entry Entry;
2588 #define SET_WIDGET_COND(w, c) \
2590 Entry *e = g_new0(Entry, 1); \
2593 entry_list = g_slist_append(entry_list, e); \
2596 SET_WIDGET_COND(toolbar->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2597 SET_WIDGET_COND(toolbar->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2598 SET_WIDGET_COND(toolbar->compose_news_btn, M_HAVE_ACCOUNT);
2599 SET_WIDGET_COND(toolbar->reply_btn,
2600 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2601 SET_WIDGET_COND(toolbar->replyall_btn,
2602 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2603 SET_WIDGET_COND(toolbar->replylist_btn,
2604 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2605 SET_WIDGET_COND(toolbar->replysender_btn,
2606 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2607 SET_WIDGET_COND(toolbar->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
2609 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST);
2610 SET_WIDGET_COND(toolbar->delete_btn,
2611 M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
2612 SET_WIDGET_COND(toolbar->exec_btn, M_DELAY_EXEC);
2614 for (cur = toolbar->action_list; cur != NULL; cur = cur->next) {
2615 ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
2617 SET_WIDGET_COND(act->widget, M_TARGET_EXIST|M_UNLOCKED);
2620 #undef SET_WIDGET_COND
2622 state = main_window_get_current_state(mainwin);
2624 for (cur = entry_list; cur != NULL; cur = cur->next) {
2625 Entry *e = (Entry*) cur->data;
2627 if (e->widget != NULL) {
2628 sensitive = ((e->cond & state) == e->cond);
2629 gtk_widget_set_sensitive(e->widget, sensitive);
2633 while (entry_list != NULL) {
2634 Entry *e = (Entry*) entry_list->data;
2638 entry_list = g_slist_remove(entry_list, e);
2641 g_slist_free(entry_list);
2643 activate_compose_button(toolbar,
2644 prefs_common.toolbar_style,
2645 toolbar->compose_btn_type);
2648 static void toolbar_update(MainWindow *mainwin)
2650 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox),
2651 GTK_WIDGET(mainwin->toolbar->toolbar));
2653 mainwin->toolbar->toolbar = NULL;
2654 mainwin->toolbar->get_btn = NULL;
2655 mainwin->toolbar->getall_btn = NULL;
2656 mainwin->toolbar->send_btn = NULL;
2657 mainwin->toolbar->compose_mail_btn = NULL;
2658 mainwin->toolbar->compose_news_btn = NULL;
2659 mainwin->toolbar->reply_btn = NULL;
2660 mainwin->toolbar->replyall_btn = NULL;
2661 mainwin->toolbar->replylist_btn = NULL;
2662 mainwin->toolbar->replysender_btn = NULL;
2663 mainwin->toolbar->fwd_btn = NULL;
2664 mainwin->toolbar->delete_btn = NULL;
2665 mainwin->toolbar->next_btn = NULL;
2666 mainwin->toolbar->exec_btn = NULL;
2668 toolbar_clear_list(TOOLBAR_MAIN);
2669 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2670 toolbar_create(mainwin, mainwin->handlebox);
2671 toolbar_set_sensitive(mainwin);
2675 static void toolbar_create(MainWindow *mainwin,
2676 GtkWidget *container)
2678 ToolbarItem *toolbar_item;
2681 GtkWidget *icon_wid = NULL;
2682 GtkWidget *icon_news = NULL;
2683 GtkWidget *item_news = NULL;
2685 GtkTooltips *toolbar_tips;
2686 ToolbarSylpheedActions *action_item;
2688 GSList *toolbar_list;
2690 guint n_menu_entries;
2691 GtkWidget *reply_popup;
2692 GtkWidget *replyall_popup;
2693 GtkWidget *replylist_popup;
2694 GtkWidget *replysender_popup;
2695 GtkWidget *fwd_popup;
2697 toolbar_tips = gtk_tooltips_new();
2699 if (mainwin->toolbar != NULL) {
2700 toolbar_clear_list(TOOLBAR_MAIN);
2701 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2702 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2703 g_free(mainwin->toolbar);
2706 toolbar_read_config_file(TOOLBAR_MAIN);
2707 toolbar_list = toolbar_get_list(TOOLBAR_MAIN);
2709 mainwin->toolbar = g_new0(Toolbar, 1);
2711 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
2713 gtk_container_add(GTK_CONTAINER(container), toolbar);
2714 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
2715 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
2716 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
2717 GTK_TOOLBAR_SPACE_LINE);
2719 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2721 if (g_strcasecmp(((ToolbarItem*)cur->data)->file, SEPARATOR) == 0) {
2722 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2726 toolbar_item = g_new0(ToolbarItem, 1);
2727 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2728 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2729 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2731 toolbar_item->parent = g_new0(ToolbarParent, 1);
2732 toolbar_item->parent->data = (gpointer)mainwin;
2733 toolbar_item->parent->type = TOOLBAR_MAIN;
2735 /* collect toolbar items in list to keep track */
2736 mainwin->toolbar->item_list = g_slist_append(mainwin->toolbar->item_list,
2739 icon_wid = stock_pixmap_widget(container, stock_pixmap_get_icon(toolbar_item->file));
2740 item = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2744 icon_wid, toolbar_buttons_cb,
2747 switch (toolbar_item->index) {
2749 mainwin->toolbar->getall_btn = item;
2750 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2751 mainwin->toolbar->getall_btn,
2752 _("Receive Mail on all Accounts"), NULL);
2755 mainwin->toolbar->get_btn = item;
2756 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2757 mainwin->toolbar->get_btn,
2758 _("Receive Mail on current Account"), NULL);
2761 mainwin->toolbar->send_btn = item;
2762 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2763 mainwin->toolbar->send_btn,
2764 _("Send Queued Message(s)"), NULL);
2766 case A_COMPOSE_EMAIL:
2767 icon_news = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2768 item_news = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2772 icon_news, toolbar_buttons_cb,
2774 mainwin->toolbar->compose_mail_btn = item;
2775 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2776 mainwin->toolbar->compose_mail_btn,
2777 _("Compose Email"), NULL);
2778 mainwin->toolbar->compose_news_btn = item_news;
2779 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2780 mainwin->toolbar->compose_news_btn,
2781 _("Compose News"), NULL);
2783 case A_REPLY_MESSAGE:
2784 mainwin->toolbar->reply_btn = item;
2785 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2786 mainwin->toolbar->reply_btn,
2787 _("Reply to Message"), NULL);
2788 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->reply_btn),
2789 "button_press_event",
2790 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2792 n_menu_entries = sizeof(reply_popup_entries) /
2793 sizeof(reply_popup_entries[0]);
2794 reply_popup = popupmenu_create(mainwin->window, reply_popup_entries, n_menu_entries,
2795 "<ReplyPopup>", mainwin);
2796 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
2797 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
2798 mainwin->toolbar->reply_popup = reply_popup;
2800 case A_REPLY_SENDER:
2801 mainwin->toolbar->replysender_btn = item;
2802 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2803 mainwin->toolbar->replysender_btn,
2804 _("Reply to Sender"), NULL);
2805 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replysender_btn),
2806 "button_press_event",
2807 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2809 n_menu_entries = sizeof(replysender_popup_entries) /
2810 sizeof(replysender_popup_entries[0]);
2811 replysender_popup = popupmenu_create(mainwin->window,
2812 replysender_popup_entries, n_menu_entries,
2813 "<ReplySenderPopup>", mainwin);
2814 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
2815 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
2816 mainwin->toolbar->replysender_popup = replysender_popup;
2819 mainwin->toolbar->replyall_btn = item;
2820 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2821 mainwin->toolbar->replyall_btn,
2822 _("Reply to All"), NULL);
2823 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replyall_btn),
2824 "button_press_event",
2825 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2827 n_menu_entries = sizeof(replyall_popup_entries) /
2828 sizeof(replyall_popup_entries[0]);
2829 replyall_popup = popupmenu_create(mainwin->window,
2830 replyall_popup_entries, n_menu_entries,
2831 "<ReplyAllPopup>", mainwin);
2832 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
2833 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
2834 mainwin->toolbar->replyall_popup = replyall_popup;
2837 mainwin->toolbar->replylist_btn = item;
2838 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2839 mainwin->toolbar->replylist_btn,
2840 _("Reply to Mailing-list"), NULL);
2841 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replylist_btn),
2842 "button_press_event",
2843 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_cb),
2845 n_menu_entries = sizeof(replylist_popup_entries) /
2846 sizeof(replylist_popup_entries[0]);
2847 replylist_popup = popupmenu_create(mainwin->window,
2848 replylist_popup_entries, n_menu_entries,
2849 "<ReplyMlPopup>", mainwin);
2850 gtk_signal_connect(GTK_OBJECT(replylist_popup), "selection_done",
2851 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_closed_cb), mainwin);
2852 mainwin->toolbar->replylist_popup = replylist_popup;
2855 mainwin->toolbar->fwd_btn = item;
2856 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2857 mainwin->toolbar->fwd_btn,
2858 _("Forward Message"), NULL);
2859 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->fwd_btn),
2860 "button_press_event",
2861 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2863 n_menu_entries = sizeof(fwd_popup_entries) /
2864 sizeof(fwd_popup_entries[0]);
2865 fwd_popup = popupmenu_create(mainwin->window,
2866 fwd_popup_entries, n_menu_entries,
2867 "<ForwardPopup>", mainwin);
2868 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
2869 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
2870 mainwin->toolbar->fwd_popup = fwd_popup;
2873 mainwin->toolbar->delete_btn = item;
2874 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2875 mainwin->toolbar->delete_btn,
2876 _("Delete Message"), NULL);
2879 mainwin->toolbar->exec_btn = item;
2880 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2881 mainwin->toolbar->exec_btn,
2882 _("Execute"), NULL);
2885 mainwin->toolbar->next_btn = item;
2886 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2887 mainwin->toolbar->next_btn,
2888 _("Goto Next Message"), NULL);
2891 action_item = g_new0(ToolbarSylpheedActions, 1);
2892 action_item->widget = item;
2893 action_item->name = g_strdup(toolbar_item->text);
2895 mainwin->toolbar->action_list =
2896 g_slist_append(mainwin->toolbar->action_list,
2899 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2901 action_item->name, NULL);
2903 gtk_widget_show(item);
2910 mainwin->toolbar->toolbar = toolbar;
2912 activate_compose_button(mainwin->toolbar,
2913 prefs_common.toolbar_style,
2914 mainwin->toolbar->compose_btn_type);
2916 gtk_widget_show_all(toolbar);
2919 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2922 switch ((ToolbarStyle)action) {
2924 gtk_widget_hide(mainwin->handlebox);
2926 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2930 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2934 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2939 if (action != TOOLBAR_NONE) {
2940 gtk_widget_show(mainwin->handlebox);
2941 gtk_widget_queue_resize(mainwin->handlebox);
2944 mainwin->toolbar_style = (ToolbarStyle)action;
2945 prefs_common.toolbar_style = (ToolbarStyle)action;
2948 /* END Toolbar Stuff */
2950 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2953 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2954 gtk_widget_show(mainwin->hbox_stat);
2955 prefs_common.show_statusbar = TRUE;
2957 gtk_widget_hide(mainwin->hbox_stat);
2958 prefs_common.show_statusbar = FALSE;
2962 static void separate_widget_cb(MainWindow *mainwin, guint action,
2967 if (GTK_CHECK_MENU_ITEM(widget)->active)
2968 type = mainwin->type | action;
2970 type = mainwin->type & ~action;
2972 main_window_separation_change(mainwin, type);
2974 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2975 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2978 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2981 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2983 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2986 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2988 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2991 static void online_switch_clicked (GtkButton *btn, gpointer data)
2993 MainWindow *mainwin;
2994 GtkItemFactory *ifactory;
2995 GtkCheckMenuItem *menuitem;
2997 mainwin = (MainWindow *) data;
2999 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3000 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3002 g_return_if_fail(mainwin != NULL);
3003 g_return_if_fail(menuitem != NULL);
3005 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3007 gtk_widget_hide (mainwin->online_switch);
3008 gtk_widget_show (mainwin->offline_switch);
3009 menuitem->active = TRUE;
3010 prefs_common.work_offline = TRUE;
3011 inc_autocheck_timer_remove();
3014 gtk_widget_hide (mainwin->offline_switch);
3015 gtk_widget_show (mainwin->online_switch);
3016 menuitem->active = FALSE;
3017 prefs_common.work_offline = FALSE;
3018 inc_autocheck_timer_set();
3022 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3025 addressbook_open(NULL);
3028 static void log_window_show_cb(MainWindow *mainwin, guint action,
3031 log_window_show(mainwin->logwin);
3034 static void sel_download_cb(MainWindow *mainwin, guint action,
3037 selective_download(mainwin);
3040 static void prefs_toolbar_cb(MainWindow *mainwin, guint action,
3043 prefs_toolbar_open((ToolbarType)action);
3047 void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3049 inc_mail(mainwin, prefs_common.newmail_notify_manu);
3052 void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
3055 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
3058 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3063 void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3067 if (prefs_common.work_offline)
3068 if (alertpanel(_("Offline warning"),
3069 _("You're working offline. Override?"),
3070 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
3073 for (list = folder_get_list(); list != NULL; list = list->next) {
3074 Folder *folder = list->data;
3076 if (folder->queue) {
3077 if (procmsg_send_queue
3078 (folder->queue, prefs_common.savemsg) < 0)
3079 alertpanel_error(_("Some errors occurred while sending queued messages."));
3080 statusbar_pop_all();
3081 folder_item_scan(folder->queue);
3082 folder_update_item(folder->queue, TRUE);
3087 void compose_mail_cb(MainWindow *mainwin, guint action,
3090 PrefsAccount *ac = NULL;
3091 FolderItem *item = mainwin->summaryview->folder_item;
3096 ac = account_find_from_item(item);
3097 if (ac && ac->protocol != A_NNTP) {
3098 compose_new_with_folderitem(ac, item); /* CLAWS */
3104 * CLAWS - use current account
3106 if (cur_account && (cur_account->protocol != A_NNTP)) {
3107 compose_new_with_folderitem(cur_account, item);
3112 * CLAWS - just get the first one
3114 list = account_get_list();
3115 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3116 ac = (PrefsAccount *) cur->data;
3117 if (ac->protocol != A_NNTP) {
3118 compose_new_with_folderitem(ac, item);
3124 void compose_news_cb(MainWindow *mainwin, guint action,
3127 PrefsAccount * ac = NULL;
3131 if (mainwin->summaryview->folder_item) {
3132 ac = mainwin->summaryview->folder_item->folder->account;
3133 if (ac && ac->protocol == A_NNTP) {
3135 mainwin->summaryview->folder_item->path,
3141 list = account_get_list();
3142 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3143 ac = (PrefsAccount *) cur->data;
3144 if (ac->protocol == A_NNTP) {
3145 compose_new(ac, NULL, NULL);
3151 void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3153 summary_reply(mainwin->summaryview, (ComposeMode)action);
3156 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3158 summary_move_to(mainwin->summaryview);
3161 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3163 summary_copy_to(mainwin->summaryview);
3166 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3168 summary_delete(mainwin->summaryview);
3171 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3173 summary_cancel(mainwin->summaryview);
3176 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3178 summary_open_msg(mainwin->summaryview);
3181 static void view_source_cb(MainWindow *mainwin, guint action,
3184 summary_view_source(mainwin->summaryview);
3187 static void show_all_header_cb(MainWindow *mainwin, guint action,
3190 if (mainwin->menu_lock_count) return;
3191 summary_display_msg_selected(mainwin->summaryview,
3192 GTK_CHECK_MENU_ITEM(widget)->active);
3195 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3197 summary_reedit(mainwin->summaryview);
3200 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3202 summary_mark(mainwin->summaryview);
3205 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3207 summary_unmark(mainwin->summaryview);
3210 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3213 summary_mark_as_unread(mainwin->summaryview);
3216 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3219 summary_mark_as_read(mainwin->summaryview);
3222 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3225 summary_mark_all_read(mainwin->summaryview);
3228 static void add_address_cb(MainWindow *mainwin, guint action,
3231 summary_add_address(mainwin->summaryview);
3234 static void set_charset_cb(MainWindow *mainwin, guint action,
3239 str = conv_get_charset_str((CharSet)action);
3240 g_free(prefs_common.force_charset);
3241 prefs_common.force_charset = str ? g_strdup(str) : NULL;
3243 summary_redisplay_msg(mainwin->summaryview);
3245 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3248 static void hide_read_messages (MainWindow *mainwin, guint action,
3251 if (!mainwin->summaryview->folder_item
3252 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
3254 summary_toggle_show_read_messages(mainwin->summaryview);
3257 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3259 if (mainwin->menu_lock_count) return;
3260 if (!mainwin->summaryview->folder_item) return;
3262 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3263 summary_thread_build(mainwin->summaryview);
3264 /* mainwin->summaryview->folder_item->threaded = TRUE; */
3266 summary_unthread(mainwin->summaryview);
3267 /* mainwin->summaryview->folder_item->threaded = FALSE; */
3271 static void expand_threads_cb(MainWindow *mainwin, guint action,
3274 summary_expand_threads(mainwin->summaryview);
3277 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3280 summary_collapse_threads(mainwin->summaryview);
3283 static void set_display_item_cb(MainWindow *mainwin, guint action,
3286 prefs_summary_column_open();
3289 static void sort_summary_cb(MainWindow *mainwin, guint action,
3292 FolderItem *item = mainwin->summaryview->folder_item;
3293 GtkWidget *menuitem;
3295 if (mainwin->menu_lock_count) return;
3297 menuitem = gtk_item_factory_get_item
3298 (mainwin->menu_factory, "/View/Sort/Ascending");
3299 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3300 GTK_CHECK_MENU_ITEM(menuitem)->active
3301 ? SORT_ASCENDING : SORT_DESCENDING);
3305 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3308 FolderItem *item = mainwin->summaryview->folder_item;
3310 if (mainwin->menu_lock_count) return;
3312 summary_sort(mainwin->summaryview,
3313 item->sort_key, (FolderSortType)action);
3316 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3319 summary_attract_by_subject(mainwin->summaryview);
3322 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3325 summary_delete_duplicated(mainwin->summaryview);
3328 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3330 summary_filter(mainwin->summaryview);
3333 static void execute_summary_cb(MainWindow *mainwin, guint action,
3336 summary_execute(mainwin->summaryview);
3339 static void update_summary_cb(MainWindow *mainwin, guint action,
3343 FolderView *folderview = mainwin->folderview;
3345 if (!mainwin->summaryview->folder_item) return;
3346 if (!folderview->opened) return;
3348 folder_update_op_count();
3350 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3351 folderview->opened);
3354 folder_item_scan(fitem);
3355 summary_show(mainwin->summaryview, fitem);
3358 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3360 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3363 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3365 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3368 static void prev_unread_cb(MainWindow *mainwin, guint action,
3371 summary_select_prev_unread(mainwin->summaryview);
3374 void next_unread_cb(MainWindow *mainwin, guint action,
3377 summary_select_next_unread(mainwin->summaryview);
3380 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3382 summary_select_prev_new(mainwin->summaryview);
3385 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3387 summary_select_next_new(mainwin->summaryview);
3390 static void prev_marked_cb(MainWindow *mainwin, guint action,
3393 summary_select_prev_marked(mainwin->summaryview);
3396 static void next_marked_cb(MainWindow *mainwin, guint action,
3399 summary_select_next_marked(mainwin->summaryview);
3402 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3405 summary_select_prev_labeled(mainwin->summaryview);
3408 static void next_labeled_cb(MainWindow *mainwin, guint action,
3411 summary_select_next_labeled(mainwin->summaryview);
3414 static void goto_folder_cb(MainWindow *mainwin, guint action,
3417 FolderItem *to_folder;
3419 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3422 folderview_select(mainwin->folderview, to_folder);
3425 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3427 messageview_copy_clipboard(mainwin->messageview);
3430 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3432 MessageView *msgview = mainwin->messageview;
3434 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3435 summary_select_all(mainwin->summaryview);
3436 else if (messageview_is_visible(msgview) &&
3437 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
3438 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3439 messageview_select_all(mainwin->messageview);
3442 static void select_thread_cb(MainWindow *mainwin, guint action,
3445 summary_select_thread(mainwin->summaryview);
3448 static void create_filter_cb(MainWindow *mainwin, guint action,
3451 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3454 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3457 prefs_common_open();
3460 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3463 prefs_scoring_open(NULL);
3466 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3469 prefs_filtering_open(NULL, NULL, NULL);
3472 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3475 prefs_template_open();
3478 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3481 prefs_actions_open(mainwin);
3484 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3487 ssl_manager_open(mainwin);
3490 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3494 new_account_cb(mainwin, 0, widget);
3496 account_open(cur_account);
3500 static void new_account_cb(MainWindow *mainwin, guint action,
3503 account_edit_open();
3504 if (!compose_get_compose_list()) account_add();
3507 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3509 cur_account = (PrefsAccount *)data;
3510 main_window_reflect_prefs_all();
3513 static void manual_open_cb(MainWindow *mainwin, guint action,
3516 manual_open((ManualType)action);
3519 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3521 MainWindow *mainwin = (MainWindow *)data;
3525 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3526 LOCAL_FOLDER(folder)->rootpath,
3530 str = g_strdup_printf(_("Scanning folder %s ..."),
3531 LOCAL_FOLDER(folder)->rootpath);
3533 STATUSBAR_PUSH(mainwin, str);
3534 STATUSBAR_POP(mainwin);
3538 #define BREAK_ON_MODIFIER_KEY() \
3539 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3541 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3543 MainWindow *mainwin = (MainWindow*) data;
3545 if (!mainwin || !event) return;
3547 switch (event->keyval) {
3548 case GDK_Q: /* Quit */
3549 BREAK_ON_MODIFIER_KEY();
3551 app_exit_cb(mainwin, 0, NULL);
3554 if (mainwin->folderview && mainwin->summaryview
3555 && !mainwin->summaryview->displayed) {
3556 summary_lock(mainwin->summaryview);
3557 folderview_select_next_unread(mainwin->folderview);
3558 summary_unlock(mainwin->summaryview);
3566 #undef BREAK_ON_MODIFIER_KEY
3569 * Harvest addresses for selected folder.
3571 static void addr_harvest_cb( MainWindow *mainwin,
3575 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3579 * Harvest addresses for selected messages in summary view.
3581 static void addr_harvest_msg_cb( MainWindow *mainwin,
3585 summary_harvest_address( mainwin->summaryview );