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_delete_cb (GtkWidget *widget,
252 static void toolbar_exec_cb (GtkWidget *widget,
255 static void toolbar_next_unread_cb (GtkWidget *widget,
259 static void toolbar_reply_popup_cb (GtkWidget *widget,
260 GdkEventButton *event,
262 static void toolbar_reply_popup_closed_cb (GtkMenuShell *menu_shell,
265 static void toolbar_reply_to_all_popup_cb (GtkWidget *widget,
266 GdkEventButton *event,
269 static void toolbar_reply_to_all_popup_closed_cb
270 (GtkMenuShell *menu_shell,
273 static void toolbar_reply_to_list_popup_cb (GtkWidget *widget,
274 GdkEventButton *event,
277 static void toolbar_reply_to_list_popup_closed_cb
278 (GtkMenuShell *menu_shell,
281 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
282 GdkEventButton *event,
284 static void toolbar_reply_to_sender_popup_closed_cb
285 (GtkMenuShell *menu_shell,
288 static void toolbar_forward_popup_cb (GtkWidget *widget,
289 GdkEventButton *event,
292 static void toolbar_forward_popup_closed_cb
293 (GtkMenuShell *menu_shell,
296 static void activate_compose_button (MainToolbar *toolbar,
298 ComposeButtonType type);
299 static void toolbar_actions_execute_cb (GtkWidget *widget,
301 static void toolbar_buttons_cb (GtkWidget *widget,
302 ToolbarItem *toolbar_item);
303 static void toolbar_create (MainWindow *mainwin,
304 GtkWidget *container);
306 static void toolbar_update (MainWindow *mainwin);
308 static void inc_cancel_cb (MainWindow *mainwin,
312 static void open_msg_cb (MainWindow *mainwin,
316 static void view_source_cb (MainWindow *mainwin,
320 static void show_all_header_cb (MainWindow *mainwin,
324 static void reedit_cb (MainWindow *mainwin,
328 static void move_to_cb (MainWindow *mainwin,
331 static void copy_to_cb (MainWindow *mainwin,
334 static void delete_cb (MainWindow *mainwin,
338 static void cancel_cb (MainWindow *mainwin,
342 static void mark_cb (MainWindow *mainwin,
345 static void unmark_cb (MainWindow *mainwin,
349 static void mark_as_unread_cb (MainWindow *mainwin,
352 static void mark_as_read_cb (MainWindow *mainwin,
355 static void mark_all_read_cb (MainWindow *mainwin,
358 static void add_address_cb (MainWindow *mainwin,
362 static void set_charset_cb (MainWindow *mainwin,
366 static void hide_read_messages (MainWindow *mainwin,
370 static void thread_cb (MainWindow *mainwin,
373 static void expand_threads_cb (MainWindow *mainwin,
376 static void collapse_threads_cb (MainWindow *mainwin,
380 static void set_display_item_cb (MainWindow *mainwin,
383 static void sort_summary_cb (MainWindow *mainwin,
386 static void sort_summary_type_cb (MainWindow *mainwin,
389 static void attract_by_subject_cb(MainWindow *mainwin,
393 static void delete_duplicated_cb (MainWindow *mainwin,
396 static void filter_cb (MainWindow *mainwin,
399 static void execute_summary_cb (MainWindow *mainwin,
402 static void update_summary_cb (MainWindow *mainwin,
406 static void prev_cb (MainWindow *mainwin,
409 static void next_cb (MainWindow *mainwin,
413 static void prev_unread_cb (MainWindow *mainwin,
417 static void prev_new_cb (MainWindow *mainwin,
420 static void next_new_cb (MainWindow *mainwin,
423 static void prev_marked_cb (MainWindow *mainwin,
426 static void next_marked_cb (MainWindow *mainwin,
429 static void prev_labeled_cb (MainWindow *mainwin,
432 static void next_labeled_cb (MainWindow *mainwin,
436 static void goto_folder_cb (MainWindow *mainwin,
440 static void copy_cb (MainWindow *mainwin,
443 static void allsel_cb (MainWindow *mainwin,
446 static void select_thread_cb (MainWindow *mainwin,
450 static void create_filter_cb (MainWindow *mainwin,
454 static void prefs_common_open_cb (MainWindow *mainwin,
457 static void prefs_template_open_cb (MainWindow *mainwin,
460 static void prefs_actions_open_cb (MainWindow *mainwin,
463 static void prefs_account_open_cb (MainWindow *mainwin,
466 static void prefs_scoring_open_cb (MainWindow *mainwin,
469 static void prefs_filtering_open_cb (MainWindow *mainwin,
473 static void ssl_manager_open_cb (MainWindow *mainwin,
477 static void new_account_cb (MainWindow *mainwin,
481 static void account_menu_cb (GtkMenuItem *menuitem,
484 static void online_switch_clicked(GtkButton *btn,
487 static void manual_open_cb (MainWindow *mainwin,
491 static void scan_tree_func (Folder *folder,
495 static void key_pressed (GtkWidget *widget,
499 static void set_toolbar_style(MainWindow *mainwin);
501 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
503 static void addr_harvest_cb ( MainWindow *mainwin,
507 static void addr_harvest_msg_cb ( MainWindow *mainwin,
511 #define SEPARATE_ACTION 500
513 static GtkItemFactoryEntry mainwin_entries[] =
515 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
516 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
517 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
518 {N_("/_File/_Check for new messages in all folders"),
519 NULL, update_folderview_cb, 0, NULL},
520 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
521 {N_("/_File/_Folder/Create _new folder..."),
522 NULL, new_folder_cb, 0, NULL},
523 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
524 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
525 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
526 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
527 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
528 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
529 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
530 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
531 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
532 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
533 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
534 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
536 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
537 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
538 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
539 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
540 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
541 {N_("/_Edit/_Find in current message..."),
542 "<control>F", search_cb, 0, NULL},
543 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
544 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
545 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
546 {N_("/_View/Show or hi_de/_Folder tree"),
547 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
548 {N_("/_View/Show or hi_de/_Message view"),
549 "V", toggle_message_cb, 0, "<ToggleItem>"},
550 {N_("/_View/Show or hi_de/_Toolbar"),
551 NULL, NULL, 0, "<Branch>"},
552 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
553 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
554 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
555 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
556 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
557 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
558 {N_("/_View/Show or hi_de/_Toolbar/_None"),
559 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
560 {N_("/_View/Show or hi_de/Status _bar"),
561 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
562 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
563 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
564 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
565 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
566 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
567 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
568 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
569 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
570 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
571 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
572 {N_("/_View/_Sort/by _color label"),
573 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
574 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
575 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
576 {N_("/_View/_Sort/by a_ttachment"),
577 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
578 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
579 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
580 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
581 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
582 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
583 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
584 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
585 {N_("/_View/_Sort/_Attract by subject"),
586 NULL, attract_by_subject_cb, 0, NULL},
587 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
588 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
589 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
590 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
591 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
593 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
594 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
595 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
596 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
597 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
598 {N_("/_View/_Go to/P_rev unread message"),
599 "<shift>P", prev_unread_cb, 0, NULL},
600 {N_("/_View/_Go to/N_ext unread message"),
601 "<shift>N", next_unread_cb, 0, NULL},
602 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
603 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
604 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
605 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
606 {N_("/_View/_Go to/Prev _marked message"),
607 NULL, prev_marked_cb, 0, NULL},
608 {N_("/_View/_Go to/Next m_arked message"),
609 NULL, next_marked_cb, 0, NULL},
610 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
611 {N_("/_View/_Go to/Prev _labeled message"),
612 NULL, prev_labeled_cb, 0, NULL},
613 {N_("/_View/_Go to/Next la_beled message"),
614 NULL, next_labeled_cb, 0, NULL},
615 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
616 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
617 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
619 #define CODESET_SEPARATOR \
620 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
621 #define CODESET_ACTION(action) \
622 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
624 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
625 {N_("/_View/_Code set/_Auto detect"),
626 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
627 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
628 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
629 CODESET_ACTION(C_US_ASCII)},
632 {N_("/_View/_Code set/Unicode (_UTF-8)"),
633 CODESET_ACTION(C_UTF_8)},
636 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
637 CODESET_ACTION(C_ISO_8859_1)},
638 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
639 CODESET_ACTION(C_ISO_8859_15)},
642 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
643 CODESET_ACTION(C_ISO_8859_2)},
645 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
646 CODESET_ACTION(C_ISO_8859_13)},
647 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
648 CODESET_ACTION(C_ISO_8859_4)},
650 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
651 CODESET_ACTION(C_ISO_8859_7)},
653 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
654 CODESET_ACTION(C_ISO_8859_9)},
656 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
657 CODESET_ACTION(C_ISO_8859_5)},
658 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
659 CODESET_ACTION(C_KOI8_R)},
660 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
661 CODESET_ACTION(C_WINDOWS_1251)},
664 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
665 CODESET_ACTION(C_ISO_2022_JP)},
667 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
668 CODESET_ACTION(C_ISO_2022_JP_2)},
670 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
671 CODESET_ACTION(C_EUC_JP)},
672 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
673 CODESET_ACTION(C_SHIFT_JIS)},
676 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
677 CODESET_ACTION(C_GB2312)},
678 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
679 CODESET_ACTION(C_BIG5)},
680 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
681 CODESET_ACTION(C_EUC_TW)},
682 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
683 CODESET_ACTION(C_ISO_2022_CN)},
685 {N_("/_View/_Code set/Korean (EUC-_KR)"),
686 CODESET_ACTION(C_EUC_KR)},
687 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
688 CODESET_ACTION(C_ISO_2022_KR)},
690 {N_("/_View/_Code set/Thai (TIS-620)"),
691 CODESET_ACTION(C_TIS_620)},
692 {N_("/_View/_Code set/Thai (Windows-874)"),
693 CODESET_ACTION(C_WINDOWS_874)},
696 #undef CODESET_SEPARATOR
697 #undef CODESET_ACTION
699 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
700 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
701 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
702 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
703 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
704 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
706 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
707 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
708 {N_("/_Message/Get from _all accounts"),
709 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
710 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
711 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
712 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
713 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
714 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
715 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
716 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
717 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
718 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
719 {N_("/_Message/Repl_y to/_sender"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
720 {N_("/_Message/Repl_y to/mailing _list"),
721 "<control>L", reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
722 {N_("/_Message/Follow-up and reply to"),NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
723 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
724 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
725 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
726 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
727 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
728 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
729 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
730 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
731 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
732 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
733 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
734 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
735 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
736 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
737 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
738 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
739 {N_("/_Message/_Mark/Mark as rea_d"),
740 NULL, mark_as_read_cb, 0, NULL},
741 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
743 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
744 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
745 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
746 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
747 {N_("/_Tools/Add sender to address boo_k"),
748 NULL, add_address_cb, 0, NULL},
749 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
750 {N_("/_Tools/_Harvest addresses/from _Folder..."),
751 NULL, addr_harvest_cb, 0, NULL},
752 {N_("/_Tools/_Harvest addresses/from _Messages..."),
753 NULL, addr_harvest_msg_cb, 0, NULL},
754 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
755 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
756 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
757 {N_("/_Tools/_Create filter rule/_Automatically"),
758 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
759 {N_("/_Tools/_Create filter rule/by _From"),
760 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
761 {N_("/_Tools/_Create filter rule/by _To"),
762 NULL, create_filter_cb, FILTER_BY_TO, NULL},
763 {N_("/_Tools/_Create filter rule/by _Subject"),
764 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
765 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
766 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
767 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
768 {N_("/_Tools/Delete du_plicated messages"),
769 NULL, delete_duplicated_cb, 0, NULL},
770 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
771 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
773 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
774 {N_("/_Tools/SSL certi_ficates..."),
775 NULL, ssl_manager_open_cb, 0, NULL},
777 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
778 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
780 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
781 {N_("/_Configuration/_Common preferences..."),
782 NULL, prefs_common_open_cb, 0, NULL},
783 {N_("/_Configuration/C_ustomize toolbar"),
784 NULL, NULL, 0, "<Branch>"},
785 {N_("/_Configuration/C_ustomize toolbar/_Main toolbar..."),
786 NULL, prefs_toolbar_cb, TOOLBAR_MAIN, NULL},
787 {N_("/_Configuration/C_ustomize toolbar/_Compose toolbar..."),
788 NULL, prefs_toolbar_cb, TOOLBAR_COMPOSE, NULL},
789 {N_("/_Configuration/_Scoring..."),
790 NULL, prefs_scoring_open_cb, 0, NULL},
791 {N_("/_Configuration/_Filtering..."),
792 NULL, prefs_filtering_open_cb, 0, NULL},
793 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
794 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
795 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
796 {N_("/_Configuration/_Preferences for current account..."),
797 NULL, prefs_account_open_cb, 0, NULL},
798 {N_("/_Configuration/Create _new account..."),
799 NULL, new_account_cb, 0, NULL},
800 {N_("/_Configuration/_Edit accounts..."),
801 NULL, account_edit_open, 0, NULL},
802 {N_("/_Configuration/C_hange current account"),
803 NULL, NULL, 0, "<Branch>"},
805 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
806 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
807 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
808 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
809 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
810 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
811 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
812 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
813 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
818 static GtkItemFactoryEntry reply_popup_entries[] =
820 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
821 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
823 static GtkItemFactoryEntry replyall_popup_entries[] =
825 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
826 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
828 static GtkItemFactoryEntry replylist_popup_entries[] =
830 {N_("/Reply to list with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE, NULL},
831 {N_("/_Reply to list without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE, NULL}
833 static GtkItemFactoryEntry replysender_popup_entries[] =
835 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
836 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
838 static GtkItemFactoryEntry fwd_popup_entries[] =
840 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
841 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
844 MainWindow *main_window_create(SeparateType type)
850 GtkWidget *handlebox;
851 GtkWidget *vbox_body;
852 GtkWidget *hbox_stat;
853 GtkWidget *statusbar;
854 GtkWidget *progressbar;
855 GtkWidget *statuslabel;
856 GtkWidget *ac_button;
858 GtkWidget *online_pixmap;
859 GtkWidget *offline_pixmap;
860 GtkWidget *online_switch;
861 GtkWidget *offline_switch;
863 FolderView *folderview;
864 SummaryView *summaryview;
865 MessageView *messageview;
866 GdkColormap *colormap;
869 GtkItemFactory *ifactory;
873 guint n_menu_entries;
875 static GdkGeometry geometry;
877 debug_print("Creating main window...\n");
878 mainwin = g_new0(MainWindow, 1);
881 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
882 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
883 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
884 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
886 if (!geometry.min_height) {
887 geometry.min_width = 320;
888 geometry.min_height = 200;
890 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
893 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
894 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
895 MANAGE_WINDOW_SIGNALS_CONNECT(window);
896 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
897 GTK_SIGNAL_FUNC(key_pressed), mainwin);
899 gtk_widget_realize(window);
900 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
903 gtkut_widget_set_app_icon(window);
905 vbox = gtk_vbox_new(FALSE, 0);
906 gtk_widget_show(vbox);
907 gtk_container_add(GTK_CONTAINER(window), vbox);
910 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
911 menubar = menubar_create(window, mainwin_entries,
912 n_menu_entries, "<Main>", mainwin);
913 gtk_widget_show(menubar);
914 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
915 ifactory = gtk_item_factory_from_widget(menubar);
917 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
918 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
920 handlebox = gtk_handle_box_new();
921 gtk_widget_show(handlebox);
922 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
924 /* link window to mainwin->window to avoid gdk warnings */
925 mainwin->window = window;
928 toolbar_create(mainwin, handlebox);
930 /* vbox that contains body */
931 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
932 gtk_widget_show(vbox_body);
933 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
934 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
936 hbox_stat = gtk_hbox_new(FALSE, 2);
937 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
939 statusbar = statusbar_create();
940 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
942 progressbar = gtk_progress_bar_new();
943 gtk_widget_set_usize(progressbar, 120, 1);
944 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
946 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
947 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
948 online_switch = gtk_button_new ();
949 offline_switch = gtk_button_new ();
950 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
951 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
952 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
953 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
954 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
955 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
956 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
957 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
959 statuslabel = gtk_label_new("");
960 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
962 ac_button = gtk_button_new();
963 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
964 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
965 gtk_widget_set_usize(ac_button, -1, 1);
966 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
967 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
968 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
970 ac_label = gtk_label_new("");
971 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
973 gtk_widget_show_all(hbox_stat);
975 gtk_widget_hide(offline_switch);
977 mainwin->folderview = folderview = folderview_create();
978 mainwin->summaryview = summaryview = summary_create();
979 mainwin->messageview = messageview = messageview_create(mainwin);
980 mainwin->logwin = log_window_create();
982 folderview->mainwin = mainwin;
983 folderview->summaryview = summaryview;
985 summaryview->mainwin = mainwin;
986 summaryview->folderview = folderview;
987 summaryview->messageview = messageview;
988 summaryview->window = window;
990 messageview->mainwin = mainwin;
992 mainwin->vbox = vbox;
993 mainwin->menubar = menubar;
994 mainwin->menu_factory = ifactory;
995 mainwin->handlebox = handlebox;
996 mainwin->vbox_body = vbox_body;
997 mainwin->hbox_stat = hbox_stat;
998 mainwin->statusbar = statusbar;
999 mainwin->progressbar = progressbar;
1000 mainwin->statuslabel = statuslabel;
1001 mainwin->ac_button = ac_button;
1002 mainwin->ac_label = ac_label;
1004 mainwin->online_switch = online_switch;
1005 mainwin->offline_switch = offline_switch;
1006 mainwin->online_pixmap = online_pixmap;
1007 mainwin->offline_pixmap = offline_pixmap;
1009 /* set context IDs for status bar */
1010 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1011 (GTK_STATUSBAR(statusbar), "Main Window");
1012 mainwin->folderview_cid = gtk_statusbar_get_context_id
1013 (GTK_STATUSBAR(statusbar), "Folder View");
1014 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1015 (GTK_STATUSBAR(statusbar), "Summary View");
1017 /* allocate colors for summary view and folder view */
1018 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1019 summaryview->color_marked.blue = (guint16)65535;
1021 summaryview->color_dim.red = summaryview->color_dim.green =
1022 summaryview->color_dim.blue = COLOR_DIM;
1024 folderview->color_new.red = (guint16)55000;
1025 folderview->color_new.green = folderview->color_new.blue = 15000;
1027 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1028 &folderview->color_op);
1030 summaryview->color_important.red = 0;
1031 summaryview->color_important.green = 0;
1032 summaryview->color_important.blue = (guint16)65535;
1034 color[0] = summaryview->color_marked;
1035 color[1] = summaryview->color_dim;
1036 color[2] = folderview->color_new;
1037 color[3] = folderview->color_op;
1039 colormap = gdk_window_get_colormap(window->window);
1040 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1041 for (i = 0; i < 4; i++) {
1042 if (success[i] == FALSE)
1043 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1046 debug_print("done.\n");
1048 messageview->visible = TRUE;
1050 main_window_set_widgets(mainwin, type);
1052 /* set menu items */
1053 menuitem = gtk_item_factory_get_item
1054 (ifactory, "/View/Code set/Auto detect");
1055 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1057 switch (prefs_common.toolbar_style) {
1059 menuitem = gtk_item_factory_get_item
1060 (ifactory, "/View/Show or hide/Toolbar/None");
1063 menuitem = gtk_item_factory_get_item
1064 (ifactory, "/View/Show or hide/Toolbar/Icon");
1067 menuitem = gtk_item_factory_get_item
1068 (ifactory, "/View/Show or hide/Toolbar/Text");
1071 menuitem = gtk_item_factory_get_item
1072 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1074 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1076 gtk_widget_hide(mainwin->hbox_stat);
1077 menuitem = gtk_item_factory_get_item
1078 (ifactory, "/View/Show or hide/Status bar");
1079 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1080 prefs_common.show_statusbar);
1082 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
1084 if (prefs_common.show_searchbar)
1085 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
1088 /* set account selection menu */
1089 ac_menu = gtk_item_factory_get_widget
1090 (ifactory, "/Configuration/Change current account");
1091 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1092 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1093 mainwin->ac_menu = ac_menu;
1095 toolbar_set_sensitive(mainwin);
1097 /* create actions menu */
1098 update_mainwin_actions_menu(ifactory, mainwin);
1100 /* show main window */
1101 gtk_widget_set_uposition(mainwin->window,
1102 prefs_common.mainwin_x,
1103 prefs_common.mainwin_y);
1104 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1105 prefs_common.mainwin_height);
1106 gtk_widget_show(mainwin->window);
1108 /* initialize views */
1109 folderview_init(folderview);
1110 summary_init(summaryview);
1111 messageview_init(messageview);
1112 log_window_init(mainwin->logwin);
1114 mainwin->lock_count = 0;
1115 mainwin->menu_lock_count = 0;
1116 mainwin->cursor_count = 0;
1119 watch_cursor = gdk_cursor_new(GDK_WATCH);
1121 mainwin_list = g_list_append(mainwin_list, mainwin);
1123 /* init work_offline */
1124 if (prefs_common.work_offline)
1125 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1130 void main_window_cursor_wait(MainWindow *mainwin)
1133 if (mainwin->cursor_count == 0)
1134 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1136 mainwin->cursor_count++;
1141 void main_window_cursor_normal(MainWindow *mainwin)
1143 if (mainwin->cursor_count)
1144 mainwin->cursor_count--;
1146 if (mainwin->cursor_count == 0)
1147 gdk_window_set_cursor(mainwin->window->window, NULL);
1152 /* lock / unlock the user-interface */
1153 void main_window_lock(MainWindow *mainwin)
1155 if (mainwin->lock_count == 0)
1156 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1158 mainwin->lock_count++;
1160 main_window_set_menu_sensitive(mainwin);
1161 toolbar_set_sensitive(mainwin);
1164 void main_window_unlock(MainWindow *mainwin)
1166 if (mainwin->lock_count)
1167 mainwin->lock_count--;
1169 main_window_set_menu_sensitive(mainwin);
1170 toolbar_set_sensitive(mainwin);
1172 if (mainwin->lock_count == 0)
1173 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1176 static void main_window_menu_callback_block(MainWindow *mainwin)
1178 mainwin->menu_lock_count++;
1181 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1183 if (mainwin->menu_lock_count)
1184 mainwin->menu_lock_count--;
1187 void main_window_reflect_prefs_all(void)
1189 main_window_reflect_prefs_all_real(FALSE);
1192 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1195 MainWindow *mainwin;
1198 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1199 mainwin = (MainWindow *)cur->data;
1201 main_window_show_cur_account(mainwin);
1202 main_window_set_menu_sensitive(mainwin);
1203 toolbar_set_sensitive(mainwin);
1206 if (pixmap_theme_changed) {
1207 toolbar_update(mainwin);
1208 set_toolbar_style(mainwin);
1209 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1210 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1212 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1213 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1214 mainwin->online_pixmap);
1215 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1216 gtk_widget_show(pixmap);
1217 mainwin->online_pixmap = pixmap;
1218 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1219 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1220 mainwin->offline_pixmap);
1221 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1222 gtk_widget_show(pixmap);
1223 mainwin->offline_pixmap = pixmap;
1226 summary_redisplay_msg(mainwin->summaryview);
1227 headerview_set_visibility(mainwin->messageview->headerview,
1228 prefs_common.display_header_pane);
1232 void main_window_set_summary_column(void)
1235 MainWindow *mainwin;
1237 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1238 mainwin = (MainWindow *)cur->data;
1239 summary_set_column_order(mainwin->summaryview);
1243 void main_window_set_account_menu(GList *account_list)
1245 GList *cur, *cur_ac, *cur_item;
1246 GtkWidget *menuitem;
1247 MainWindow *mainwin;
1248 PrefsAccount *ac_prefs;
1250 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1251 mainwin = (MainWindow *)cur->data;
1253 /* destroy all previous menu item */
1254 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1255 while (cur_item != NULL) {
1256 GList *next = cur_item->next;
1257 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1261 for (cur_ac = account_list; cur_ac != NULL;
1262 cur_ac = cur_ac->next) {
1263 ac_prefs = (PrefsAccount *)cur_ac->data;
1265 menuitem = gtk_menu_item_new_with_label
1266 (ac_prefs->account_name
1267 ? ac_prefs->account_name : _("Untitled"));
1268 gtk_widget_show(menuitem);
1269 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1270 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1271 GTK_SIGNAL_FUNC(account_menu_cb),
1277 static void main_window_show_cur_account(MainWindow *mainwin)
1282 ac_name = g_strdup(cur_account
1283 ? (cur_account->account_name
1284 ? cur_account->account_name : _("Untitled"))
1288 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1290 buf = g_strdup(PROG_VERSION);
1291 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1294 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1295 gtk_widget_queue_resize(mainwin->ac_button);
1300 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1302 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1303 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1304 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1306 debug_print("Changing window separation type from %d to %d\n",
1307 mainwin->type, type);
1309 if (mainwin->type == type) return;
1311 /* remove widgets from those containers */
1312 gtk_widget_ref(folder_wid);
1313 gtk_widget_ref(summary_wid);
1314 gtk_widget_ref(message_wid);
1315 gtkut_container_remove
1316 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1317 gtkut_container_remove
1318 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1319 gtkut_container_remove
1320 (GTK_CONTAINER(message_wid->parent), message_wid);
1322 /* clean containers */
1323 switch (mainwin->type) {
1325 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1327 case SEPARATE_FOLDER:
1328 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1329 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1331 case SEPARATE_MESSAGE:
1332 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1333 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1336 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1337 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1341 gtk_widget_hide(mainwin->window);
1342 main_window_set_widgets(mainwin, type);
1343 gtk_widget_show(mainwin->window);
1345 gtk_widget_unref(folder_wid);
1346 gtk_widget_unref(summary_wid);
1347 gtk_widget_unref(message_wid);
1350 void main_window_toggle_message_view(MainWindow *mainwin)
1352 SummaryView *summaryview = mainwin->summaryview;
1353 union CompositeWin *cwin = &mainwin->win;
1354 GtkWidget *vpaned = NULL;
1355 GtkWidget *container = NULL;
1356 GtkWidget *msgwin = NULL;
1358 switch (mainwin->type) {
1360 vpaned = cwin->sep_none.vpaned;
1361 container = cwin->sep_none.hpaned;
1363 case SEPARATE_FOLDER:
1364 vpaned = cwin->sep_folder.vpaned;
1365 container = mainwin->vbox_body;
1367 case SEPARATE_MESSAGE:
1368 msgwin = mainwin->win.sep_message.messagewin;
1371 msgwin = mainwin->win.sep_both.messagewin;
1376 if (GTK_WIDGET_VISIBLE(msgwin)) {
1377 gtk_widget_hide(msgwin);
1378 mainwin->messageview->visible = FALSE;
1379 summaryview->displayed = NULL;
1381 gtk_widget_show(msgwin);
1382 mainwin->messageview->visible = TRUE;
1384 } else if (vpaned->parent != NULL) {
1385 mainwin->messageview->visible = FALSE;
1386 summaryview->displayed = NULL;
1387 gtk_widget_ref(vpaned);
1388 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1389 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1390 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1391 GTK_ARROW_UP, GTK_SHADOW_OUT);
1393 mainwin->messageview->visible = TRUE;
1394 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1395 gtk_container_add(GTK_CONTAINER(container), vpaned);
1396 gtk_widget_unref(vpaned);
1397 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1398 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1401 main_window_set_menu_sensitive(mainwin);
1403 gtk_widget_grab_focus(summaryview->ctree);
1406 void main_window_get_size(MainWindow *mainwin)
1408 GtkAllocation *allocation;
1410 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1412 prefs_common.summaryview_width = allocation->width;
1414 if ((mainwin->type == SEPARATE_NONE ||
1415 mainwin->type == SEPARATE_FOLDER) &&
1416 messageview_is_visible(mainwin->messageview))
1417 prefs_common.summaryview_height = allocation->height;
1419 prefs_common.mainview_width = allocation->width;
1421 allocation = &mainwin->window->allocation;
1423 prefs_common.mainview_height = allocation->height;
1424 prefs_common.mainwin_width = allocation->width;
1425 prefs_common.mainwin_height = allocation->height;
1427 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1429 prefs_common.folderview_width = allocation->width;
1430 prefs_common.folderview_height = allocation->height;
1433 void main_window_get_position(MainWindow *mainwin)
1437 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1439 prefs_common.mainview_x = x;
1440 prefs_common.mainview_y = y;
1441 prefs_common.mainwin_x = x;
1442 prefs_common.mainwin_y = y;
1444 debug_print("window position: x = %d, y = %d\n", x, y);
1447 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1453 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1454 folder = FOLDER(list->data);
1455 if (folder && folder->trash && folder->trash->total > 0)
1459 if (!has_trash) return;
1462 if (alertpanel(_("Empty trash"),
1463 _("Empty all messages in trash?"),
1464 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1466 manage_window_focus_in(mainwin->window, NULL, NULL);
1469 procmsg_empty_trash();
1471 for (list = folder_get_list(); list != NULL; list = list->next) {
1472 folder = list->data;
1473 if (folder && folder->trash) {
1474 folder_update_item(folder->trash, TRUE);
1478 if (mainwin->summaryview->folder_item &&
1479 mainwin->summaryview->folder_item->stype == F_TRASH)
1480 gtk_widget_grab_focus(mainwin->folderview->ctree);
1483 void main_window_add_mailbox(MainWindow *mainwin)
1488 path = input_dialog(_("Add mailbox"),
1489 _("Input the location of mailbox.\n"
1490 "If the existing mailbox is specified, it will be\n"
1491 "scanned automatically."),
1494 if (folder_find_from_path(path)) {
1495 alertpanel_error(_("The mailbox `%s' already exists."), path);
1499 if (!strcmp(path, "Mail"))
1500 folder = folder_new(F_MH, _("Mailbox"), path);
1502 folder = folder_new(F_MH, g_basename(path), path);
1505 if (folder->create_tree(folder) < 0) {
1506 alertpanel_error(_("Creation of the mailbox failed.\n"
1507 "Maybe some files already exist, or you don't have the permission to write there."));
1508 folder_destroy(folder);
1513 folder_set_ui_func(folder, scan_tree_func, mainwin);
1514 folder_scan_tree(folder);
1515 folder_set_ui_func(folder, NULL, NULL);
1517 folderview_set(mainwin->folderview);
1520 void main_window_add_mbox(MainWindow *mainwin)
1526 path = input_dialog(_("Add mbox mailbox"),
1527 _("Input the location of mailbox."),
1532 if (folder_find_from_path(path)) {
1533 alertpanel_error(_("The mailbox `%s' already exists."), path);
1539 if (!strcmp(path, "Mail"))
1540 folder = folder_new(F_MBOX, _("Mailbox"), path);
1544 folder = folder_new(F_MBOX, g_basename(path), path);
1547 if (folder->create_tree(folder) < 0) {
1548 alertpanel_error(_("Creation of the mailbox failed."));
1549 folder_destroy(folder);
1555 item = folder_item_new(folder, folder->name, NULL);
1556 item->folder = folder;
1557 folder->node = g_node_new(item);
1559 folder_create_folder(item, "inbox");
1560 folder_create_folder(item, "outbox");
1561 folder_create_folder(item, "queue");
1562 folder_create_folder(item, "draft");
1563 folder_create_folder(item, "trash");
1565 folderview_set(mainwin->folderview);
1568 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1570 SensitiveCond state = 0;
1571 SummarySelection selection;
1572 FolderItem *item = mainwin->summaryview->folder_item;
1573 GList *account_list = account_get_list();
1575 selection = summary_get_selection_type(mainwin->summaryview);
1577 if (mainwin->lock_count == 0)
1578 state |= M_UNLOCKED;
1579 if (selection != SUMMARY_NONE)
1580 state |= M_MSG_EXIST;
1581 if (item && item->path && item->parent && !item->no_select) {
1583 /* if (item->folder->type != F_NEWS) */
1584 state |= M_ALLOW_DELETE;
1586 if (prefs_common.immediate_exec == 0
1587 && mainwin->lock_count == 0)
1588 state |= M_DELAY_EXEC;
1590 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1591 || selection != SUMMARY_NONE)
1592 state |= M_HIDE_READ_MSG;
1594 if (mainwin->summaryview->threaded)
1595 state |= M_THREADED;
1597 state |= M_UNTHREADED;
1598 if (selection == SUMMARY_SELECTED_SINGLE ||
1599 selection == SUMMARY_SELECTED_MULTIPLE)
1600 state |= M_TARGET_EXIST;
1601 if (selection == SUMMARY_SELECTED_SINGLE)
1602 state |= M_SINGLE_TARGET_EXIST;
1603 if (mainwin->summaryview->folder_item &&
1604 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1607 state |= M_NOT_NEWS;
1608 if (selection == SUMMARY_SELECTED_SINGLE &&
1610 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1611 item->stype == F_QUEUE)))
1612 state |= M_ALLOW_REEDIT;
1614 state |= M_HAVE_ACCOUNT;
1616 for ( ; account_list != NULL; account_list = account_list->next) {
1617 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1618 state |= M_HAVE_NEWS_ACCOUNT;
1623 if (inc_is_active())
1624 state |= M_INC_ACTIVE;
1631 void main_window_set_menu_sensitive(MainWindow *mainwin)
1633 GtkItemFactory *ifactory = mainwin->menu_factory;
1634 SensitiveCond state;
1636 GtkWidget *menuitem;
1637 SummaryView *summaryview;
1641 static const struct {
1645 {"/File/Add mailbox..." , M_UNLOCKED},
1646 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1647 {"/File/Check for new messages in all folders", M_UNLOCKED},
1648 {"/File/Folder" , M_UNLOCKED},
1649 {"/File/Import mbox file..." , M_UNLOCKED},
1650 {"/File/Export to mbox file..." , M_UNLOCKED},
1651 {"/File/Empty trash" , M_UNLOCKED},
1652 {"/File/Work offline" , M_UNLOCKED},
1654 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1655 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1656 /* {"/File/Close" , M_UNLOCKED}, */
1657 {"/File/Exit" , M_UNLOCKED},
1659 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1661 {"/View/Sort" , M_EXEC},
1662 {"/View/Thread view" , M_EXEC},
1663 {"/View/Expand all threads" , M_MSG_EXIST},
1664 {"/View/Collapse all threads" , M_MSG_EXIST},
1665 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1666 {"/View/Go to/Prev message" , M_MSG_EXIST},
1667 {"/View/Go to/Next message" , M_MSG_EXIST},
1668 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1669 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1670 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1671 {"/View/Go to/Next new message" , M_MSG_EXIST},
1672 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1673 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1674 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1675 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1676 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1677 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1678 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1680 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1681 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1682 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1683 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1684 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1685 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1686 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1687 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1688 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1689 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1690 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1691 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1692 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1693 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1694 {"/Message/Mark" , M_TARGET_EXIST},
1696 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1697 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1698 {"/Tools/Harvest addresses" , M_UNLOCKED},
1699 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1700 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1701 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1702 {"/Tools/Execute" , M_DELAY_EXEC},
1703 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1705 {"/Configuration", M_UNLOCKED},
1710 state = main_window_get_current_state(mainwin);
1712 for (i = 0; entry[i].entry != NULL; i++) {
1713 sensitive = ((entry[i].cond & state) == entry[i].cond);
1714 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1717 main_window_menu_callback_block(mainwin);
1719 #define SET_CHECK_MENU_ACTIVE(path, active) \
1721 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1722 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1725 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1726 messageview_is_visible(mainwin->messageview));
1728 summaryview = mainwin->summaryview;
1729 menu_path = "/View/Sort/Don't sort";
1731 switch (summaryview->sort_key) {
1732 case SORT_BY_NUMBER:
1733 menu_path = "/View/Sort/by number"; break;
1735 menu_path = "/View/Sort/by size"; break;
1737 menu_path = "/View/Sort/by date"; break;
1739 menu_path = "/View/Sort/by from"; break;
1740 case SORT_BY_SUBJECT:
1741 menu_path = "/View/Sort/by subject"; break;
1743 menu_path = "/View/Sort/by color label"; break;
1745 menu_path = "/View/Sort/by mark"; break;
1746 case SORT_BY_UNREAD:
1747 menu_path = "/View/Sort/by unread"; break;
1749 menu_path = "/View/Sort/by attachment"; break;
1751 menu_path = "/View/Sort/by score"; break;
1752 case SORT_BY_LOCKED:
1753 menu_path = "/View/Sort/by locked"; break;
1756 menu_path = "/View/Sort/Don't sort"; break;
1758 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1760 if (summaryview->sort_type == SORT_ASCENDING) {
1761 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1763 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1766 if (summaryview->sort_key != SORT_BY_NONE) {
1767 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1768 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1770 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1771 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1774 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1775 mainwin->messageview->textview->show_all_headers);
1776 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1778 #undef SET_CHECK_MENU_ACTIVE
1780 main_window_menu_callback_unblock(mainwin);
1783 void main_window_popup(MainWindow *mainwin)
1789 gdk_window_get_origin(mainwin->window->window, &x, &y);
1790 sx = gdk_screen_width();
1791 sy = gdk_screen_height();
1792 x %= sx; if (x < 0) x = 0;
1793 y %= sy; if (y < 0) y = 0;
1794 gdk_window_move(mainwin->window->window, x, y);
1795 gdk_window_raise(mainwin->window->window);
1796 gdk_window_show(mainwin->window->window);
1798 debug_print("window position: x = %d, y = %d\n", x, y);
1800 switch (mainwin->type) {
1801 case SEPARATE_FOLDER:
1802 widget = mainwin->win.sep_folder.folderwin;
1803 gdk_window_get_origin(widget->window, &x, &y);
1804 x %= sx; if (x < 0) x = 0;
1805 y %= sy; if (y < 0) y = 0;
1806 gdk_window_move(widget->window, x, y);
1807 gdk_window_raise(widget->window);
1809 case SEPARATE_MESSAGE:
1810 widget = mainwin->win.sep_message.messagewin;
1811 gdk_window_get_origin(widget->window, &x, &y);
1812 x %= sx; if (x < 0) x = 0;
1813 y %= sy; if (y < 0) y = 0;
1814 gdk_window_move(widget->window, x, y);
1815 gdk_window_raise(widget->window);
1818 widget = mainwin->win.sep_both.folderwin;
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);
1824 widget = mainwin->win.sep_both.messagewin;
1825 gdk_window_get_origin(widget->window, &x, &y);
1826 x %= sx; if (x < 0) x = 0;
1827 y %= sy; if (y < 0) y = 0;
1828 gdk_window_move(widget->window, x, y);
1829 gdk_window_raise(widget->window);
1836 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1838 GtkWidget *folderwin = NULL;
1839 GtkWidget *messagewin = NULL;
1842 GtkWidget *vbox_body = mainwin->vbox_body;
1843 GtkItemFactory *ifactory = mainwin->menu_factory;
1844 GtkWidget *menuitem;
1846 debug_print("Setting widgets...");
1848 /* create separated window(s) if needed */
1849 if (type & SEPARATE_FOLDER) {
1850 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1851 gtk_window_set_title(GTK_WINDOW(folderwin),
1852 _("Sylpheed - Folder View"));
1853 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1854 "folder_view", "Sylpheed");
1855 gtk_window_set_policy(GTK_WINDOW(folderwin),
1857 gtk_widget_set_usize(folderwin, -1,
1858 prefs_common.mainview_height);
1859 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1861 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1862 GTK_SIGNAL_FUNC(folder_window_close_cb),
1865 if (type & SEPARATE_MESSAGE) {
1866 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1867 gtk_window_set_title(GTK_WINDOW(messagewin),
1868 _("Sylpheed - Message View"));
1869 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1870 "message_view", "Sylpheed");
1871 gtk_window_set_policy(GTK_WINDOW(messagewin),
1873 gtk_widget_set_usize
1874 (messagewin, prefs_common.mainview_width,
1875 prefs_common.mainview_height
1876 - prefs_common.summaryview_height
1877 + DEFAULT_HEADERVIEW_HEIGHT);
1878 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1880 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1881 GTK_SIGNAL_FUNC(message_window_close_cb),
1887 hpaned = gtk_hpaned_new();
1888 gtk_widget_show(hpaned);
1889 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1890 gtk_paned_add1(GTK_PANED(hpaned),
1891 GTK_WIDGET_PTR(mainwin->folderview));
1893 vpaned = gtk_vpaned_new();
1894 if (messageview_is_visible(mainwin->messageview)) {
1895 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1896 gtk_paned_add1(GTK_PANED(vpaned),
1897 GTK_WIDGET_PTR(mainwin->summaryview));
1899 gtk_paned_add2(GTK_PANED(hpaned),
1900 GTK_WIDGET_PTR(mainwin->summaryview));
1901 gtk_widget_ref(vpaned);
1903 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1904 prefs_common.summaryview_width,
1905 prefs_common.summaryview_height);
1906 gtk_paned_add2(GTK_PANED(vpaned),
1907 GTK_WIDGET_PTR(mainwin->messageview));
1908 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1909 prefs_common.mainview_width, -1);
1910 gtk_widget_set_usize(mainwin->window,
1911 prefs_common.folderview_width +
1912 prefs_common.mainview_width,
1913 prefs_common.mainwin_height);
1914 gtk_widget_show_all(vpaned);
1916 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1917 * lose track of its visibility state */
1918 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1919 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1921 mainwin->win.sep_none.hpaned = hpaned;
1922 mainwin->win.sep_none.vpaned = vpaned;
1924 /* remove headerview if not in prefs */
1925 headerview_set_visibility(mainwin->messageview->headerview,
1926 prefs_common.display_header_pane);
1928 case SEPARATE_FOLDER:
1929 vpaned = gtk_vpaned_new();
1930 if (messageview_is_visible(mainwin->messageview)) {
1931 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1933 gtk_paned_add1(GTK_PANED(vpaned),
1934 GTK_WIDGET_PTR(mainwin->summaryview));
1936 gtk_box_pack_start(GTK_BOX(vbox_body),
1937 GTK_WIDGET_PTR(mainwin->summaryview),
1939 gtk_widget_ref(vpaned);
1941 gtk_paned_add2(GTK_PANED(vpaned),
1942 GTK_WIDGET_PTR(mainwin->messageview));
1943 gtk_widget_show_all(vpaned);
1944 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1945 prefs_common.summaryview_width,
1946 prefs_common.summaryview_height);
1947 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1948 prefs_common.mainview_width, -1);
1949 gtk_widget_set_usize(mainwin->window,
1950 prefs_common.mainview_width,
1951 prefs_common.mainview_height);
1953 gtk_container_add(GTK_CONTAINER(folderwin),
1954 GTK_WIDGET_PTR(mainwin->folderview));
1956 mainwin->win.sep_folder.folderwin = folderwin;
1957 mainwin->win.sep_folder.vpaned = vpaned;
1959 gtk_widget_show_all(folderwin);
1961 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1962 * lose track of its visibility state */
1963 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1964 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1966 /* remove headerview if not in prefs */
1967 headerview_set_visibility(mainwin->messageview->headerview,
1968 prefs_common.display_header_pane);
1971 case SEPARATE_MESSAGE:
1972 hpaned = gtk_hpaned_new();
1973 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1975 gtk_paned_add1(GTK_PANED(hpaned),
1976 GTK_WIDGET_PTR(mainwin->folderview));
1977 gtk_paned_add2(GTK_PANED(hpaned),
1978 GTK_WIDGET_PTR(mainwin->summaryview));
1979 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1980 prefs_common.summaryview_width,
1981 prefs_common.summaryview_height);
1982 gtk_widget_set_usize(mainwin->window,
1983 prefs_common.folderview_width +
1984 prefs_common.mainview_width,
1985 prefs_common.mainwin_height);
1986 gtk_widget_show_all(hpaned);
1987 gtk_container_add(GTK_CONTAINER(messagewin),
1988 GTK_WIDGET_PTR(mainwin->messageview));
1990 mainwin->win.sep_message.messagewin = messagewin;
1991 mainwin->win.sep_message.hpaned = hpaned;
1993 gtk_widget_show_all(messagewin);
1995 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1996 * lose track of its visibility state */
1997 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1998 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2001 gtk_box_pack_start(GTK_BOX(vbox_body),
2002 GTK_WIDGET_PTR(mainwin->summaryview),
2004 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
2005 prefs_common.summaryview_width,
2006 prefs_common.summaryview_height);
2007 gtk_widget_set_usize(mainwin->window,
2008 prefs_common.mainview_width,
2009 prefs_common.mainwin_height);
2010 gtk_container_add(GTK_CONTAINER(folderwin),
2011 GTK_WIDGET_PTR(mainwin->folderview));
2012 gtk_container_add(GTK_CONTAINER(messagewin),
2013 GTK_WIDGET_PTR(mainwin->messageview));
2015 mainwin->win.sep_both.folderwin = folderwin;
2016 mainwin->win.sep_both.messagewin = messagewin;
2018 gtk_widget_show_all(folderwin);
2019 gtk_widget_show_all(messagewin);
2021 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2022 * lose track of its visibility state */
2023 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2024 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2028 /* rehide quick search if necessary */
2029 if (!prefs_common.show_searchbar)
2030 gtk_widget_hide(mainwin->summaryview->hbox_search);
2032 mainwin->type = type;
2034 mainwin->messageview->visible = TRUE;
2036 /* toggle menu state */
2037 menuitem = gtk_item_factory_get_item
2038 (ifactory, "/View/Show or hide/Folder tree");
2039 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2040 menuitem = gtk_item_factory_get_item
2041 (ifactory, "/View/Show or hide/Message view");
2042 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2044 menuitem = gtk_item_factory_get_item
2045 (ifactory, "/View/Separate folder tree");
2046 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2047 ((type & SEPARATE_FOLDER) != 0));
2048 menuitem = gtk_item_factory_get_item
2049 (ifactory, "/View/Separate message view");
2050 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2051 ((type & SEPARATE_MESSAGE) != 0));
2053 debug_print("done.\n");
2056 void main_window_destroy_all(void)
2058 while (mainwin_list != NULL) {
2059 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2061 /* free toolbar stuff */
2062 toolbar_clear_list(TOOLBAR_MAIN);
2063 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->t_action_list);
2064 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->t_item_list);
2066 g_free(mainwin->toolbar);
2069 mainwin_list = g_list_remove(mainwin_list, mainwin);
2071 g_list_free(mainwin_list);
2075 static void toolbar_account_button_pressed(GtkWidget *widget,
2076 GdkEventButton *event,
2079 MainWindow *mainwin = (MainWindow *)data;
2082 if (event->button != 3) return;
2084 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2085 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2088 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2089 menu_button_position, widget,
2090 event->button, event->time);
2094 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2097 MainWindow *mainwin = (MainWindow *)data;
2101 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2102 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2105 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2106 menu_button_position, widget,
2107 event->button, event->time);
2110 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2112 MainWindow *mainwin = (MainWindow *)data;
2115 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2116 if (!button) return;
2117 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2118 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2119 manage_window_focus_in(mainwin->window, NULL, NULL);
2122 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2125 MainWindow *mainwin = (MainWindow *)data;
2127 if (mainwin->lock_count == 0)
2128 app_exit_cb(data, 0, widget);
2133 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2136 MainWindow *mainwin = (MainWindow *)data;
2137 GtkWidget *menuitem;
2139 menuitem = gtk_item_factory_get_item
2140 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2141 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2146 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2149 MainWindow *mainwin = (MainWindow *)data;
2150 GtkWidget *menuitem;
2152 menuitem = gtk_item_factory_get_item
2153 (mainwin->menu_factory, "/View/Show or hide/Message view");
2154 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2159 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2162 main_window_add_mailbox(mainwin);
2165 static void add_mbox_cb(MainWindow *mainwin, guint action,
2168 main_window_add_mbox(mainwin);
2171 static void update_folderview_cb(MainWindow *mainwin, guint action,
2174 summary_show(mainwin->summaryview, NULL);
2175 folderview_check_new_all();
2178 static void new_folder_cb(MainWindow *mainwin, guint action,
2181 folderview_new_folder(mainwin->folderview);
2184 static void rename_folder_cb(MainWindow *mainwin, guint action,
2187 folderview_rename_folder(mainwin->folderview);
2190 static void delete_folder_cb(MainWindow *mainwin, guint action,
2193 folderview_delete_folder(mainwin->folderview);
2196 static void import_mbox_cb(MainWindow *mainwin, guint action,
2199 import_mbox(mainwin->summaryview->folder_item);
2202 static void export_mbox_cb(MainWindow *mainwin, guint action,
2205 export_mbox(mainwin->summaryview->folder_item);
2208 static void empty_trash_cb(MainWindow *mainwin, guint action,
2211 main_window_empty_trash(mainwin, TRUE);
2214 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2216 summary_save_as(mainwin->summaryview);
2219 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2221 summary_print(mainwin->summaryview);
2224 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2226 if (prefs_common.confirm_on_exit) {
2227 if (alertpanel(_("Exit"), _("Exit this program?"),
2228 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2230 manage_window_focus_in(mainwin->window, NULL, NULL);
2233 app_will_exit(widget, mainwin);
2236 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2239 summary_search(mainwin->summaryview);
2241 message_search(mainwin->messageview);
2244 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2249 active = GTK_CHECK_MENU_ITEM(widget)->active;
2251 switch (mainwin->type) {
2253 case SEPARATE_MESSAGE:
2256 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2258 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2261 case SEPARATE_FOLDER:
2262 debug_print("separate folder\n");
2264 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2266 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2270 gtk_widget_show(mainwin->win.sep_both.folderwin);
2272 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2277 static void toggle_message_cb(MainWindow *mainwin, guint action,
2282 active = GTK_CHECK_MENU_ITEM(widget)->active;
2284 if (active != messageview_is_visible(mainwin->messageview))
2285 summary_toggle_view(mainwin->summaryview);
2288 /* Toolbar handling */
2289 static void toolbar_inc_cb(GtkWidget *widget,
2292 MainWindow *mainwin = (MainWindow *)data;
2294 inc_mail_cb(mainwin, 0, NULL);
2297 static void toolbar_inc_all_cb(GtkWidget *widget,
2300 MainWindow *mainwin = (MainWindow *)data;
2302 inc_all_account_mail_cb(mainwin, 0, NULL);
2305 static void toolbar_send_cb(GtkWidget *widget,
2308 MainWindow *mainwin = (MainWindow *)data;
2310 send_queue_cb(mainwin, 0, NULL);
2313 static void toolbar_compose_cb(GtkWidget *widget,
2316 MainWindow *mainwin = (MainWindow *)data;
2318 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
2319 compose_news_cb(mainwin, 0, NULL);
2321 compose_mail_cb(mainwin, 0, NULL);
2324 static void toolbar_reply_cb(GtkWidget *widget,
2327 MainWindow *mainwin = (MainWindow *)data;
2329 if (prefs_common.default_reply_list)
2331 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
2332 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
2336 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2337 : COMPOSE_REPLY_WITHOUT_QUOTE,
2341 static void toolbar_reply_to_all_cb(GtkWidget *widget,
2344 MainWindow *mainwin = (MainWindow *)data;
2347 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2348 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2352 static void toolbar_reply_to_list_cb(GtkWidget *widget,
2355 MainWindow *mainwin = (MainWindow *)data;
2358 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
2359 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
2363 static void toolbar_reply_to_sender_cb(GtkWidget *widget,
2366 MainWindow *mainwin = (MainWindow *)data;
2369 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2370 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2374 static void toolbar_forward_cb(GtkWidget *widget,
2377 MainWindow *mainwin = (MainWindow *)data;
2379 if (prefs_common.forward_as_attachment)
2380 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2382 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2385 static void toolbar_delete_cb(GtkWidget *widget,
2388 MainWindow *mainwin = (MainWindow *)data;
2390 summary_delete(mainwin->summaryview);
2393 static void toolbar_exec_cb(GtkWidget *widget,
2396 MainWindow *mainwin = (MainWindow *)data;
2398 summary_execute(mainwin->summaryview);
2401 static void toolbar_next_unread_cb(GtkWidget *widget,
2404 MainWindow *mainwin = (MainWindow *)data;
2406 next_unread_cb(mainwin, 0, NULL);
2409 /* popup callback functions */
2410 static void toolbar_reply_popup_cb(GtkWidget *widget,
2411 GdkEventButton *event,
2414 MainWindow *mainwindow = (MainWindow *) data;
2418 if (event->button == 3) {
2419 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2420 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->reply_popup), NULL, NULL,
2421 menu_button_position, widget,
2422 event->button, event->time);
2426 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2428 MainWindow *mainwin = (MainWindow *)data;
2430 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->reply_btn), GTK_RELIEF_NONE);
2431 manage_window_focus_in(mainwin->window, NULL, NULL);
2434 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2436 MainWindow *mainwindow = (MainWindow *) data;
2440 if (event->button == 3) {
2441 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2442 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replyall_popup), NULL, NULL,
2443 menu_button_position, widget,
2444 event->button, event->time);
2448 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2450 MainWindow *mainwin = (MainWindow *)data;
2452 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replyall_btn), GTK_RELIEF_NONE);
2453 manage_window_focus_in(mainwin->window, NULL, NULL);
2456 static void toolbar_reply_to_list_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2458 MainWindow *mainwindow = (MainWindow *) data;
2462 if (event->button == 3) {
2463 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2464 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replylist_popup), NULL, NULL,
2465 menu_button_position, widget,
2466 event->button, event->time);
2470 static void toolbar_reply_to_list_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2472 MainWindow *mainwin = (MainWindow *)data;
2474 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replylist_btn), GTK_RELIEF_NONE);
2475 manage_window_focus_in(mainwin->window, NULL, NULL);
2478 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2480 MainWindow *mainwindow = (MainWindow *) data;
2484 if (event->button == 3) {
2485 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2486 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replysender_popup), NULL, NULL,
2487 menu_button_position, widget,
2488 event->button, event->time);
2492 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2494 MainWindow *mainwin = (MainWindow *)data;
2496 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replysender_btn), GTK_RELIEF_NONE);
2497 manage_window_focus_in(mainwin->window, NULL, NULL);
2500 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2502 MainWindow *mainwindow = (MainWindow *) data;
2506 if (event->button == 3) {
2507 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2508 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->fwd_popup), NULL, NULL,
2509 menu_button_position, widget,
2510 event->button, event->time);
2514 static void toolbar_forward_popup_closed_cb (GtkMenuShell *menu_shell,
2517 MainWindow *mainwin = (MainWindow *)data;
2519 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->fwd_btn), GTK_RELIEF_NONE);
2520 manage_window_focus_in(mainwin->window, NULL, NULL);
2523 static void activate_compose_button (MainToolbar *toolbar,
2525 ComposeButtonType type)
2527 if ((!toolbar->compose_mail_btn) || (!toolbar->compose_news_btn))
2530 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? toolbar->compose_mail_btn
2531 : toolbar->compose_news_btn);
2532 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? toolbar->compose_news_btn
2533 : toolbar->compose_mail_btn);
2534 toolbar->compose_btn_type = type;
2537 void toolbar_set_compose_button(MainToolbar *toolbar,
2538 ComposeButtonType compose_btn_type)
2540 if (toolbar->compose_btn_type != compose_btn_type)
2541 activate_compose_button(toolbar,
2542 prefs_common.toolbar_style,
2546 static void toolbar_buttons_cb(GtkWidget *widget,
2547 ToolbarItem *t_item)
2551 void (*func)(GtkWidget *widget, gpointer data);
2552 } toolbar_action[] = {
2553 { A_RECEIVE_ALL, toolbar_inc_all_cb },
2554 { A_RECEIVE_CUR, toolbar_inc_cb },
2555 { A_SEND_QUEUED, toolbar_send_cb },
2556 { A_COMPOSE_EMAIL, toolbar_compose_cb },
2557 { A_REPLY_MESSAGE, toolbar_reply_cb },
2558 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
2559 { A_REPLY_ALL, toolbar_reply_to_all_cb },
2560 { A_REPLY_ML, toolbar_reply_to_list_cb },
2561 { A_FORWARD, toolbar_forward_cb },
2562 { A_DELETE, toolbar_delete_cb },
2563 { A_EXECUTE, toolbar_exec_cb },
2564 { A_GOTO_NEXT, toolbar_next_unread_cb },
2565 { A_SYL_ACTIONS, toolbar_actions_execute_cb },
2567 { A_COMPOSE_NEWS, toolbar_compose_cb },
2568 { A_SEPARATOR, NULL }};
2570 gint num_items = sizeof(toolbar_action)/sizeof(toolbar_action[0]);
2573 for (i = A_RECEIVE_ALL; i < num_items; i++) {
2575 if (toolbar_action[i].index == t_item->index) {
2576 MainWindow *mainwin = (MainWindow*)t_item->parent;
2577 toolbar_action[i].func(widget, mainwin);
2583 static void toolbar_actions_execute_cb(GtkWidget *widget,
2586 MainWindow *mainwin = (MainWindow*)data;
2588 toolbar_action_execute(widget, mainwin->toolbar->t_action_list, data, TOOLBAR_MAIN);
2591 void toolbar_set_sensitive(MainWindow *mainwin)
2593 SensitiveCond state;
2595 MainToolbar *toolbar = mainwin->toolbar;
2597 GSList *entry_list = NULL;
2599 typedef struct _Entry Entry;
2606 #define SET_WIDGET_COND(w, c) \
2608 Entry *e = g_new0(Entry, 1); \
2611 entry_list = g_slist_append(entry_list, e); \
2614 SET_WIDGET_COND(toolbar->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2615 SET_WIDGET_COND(toolbar->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2616 SET_WIDGET_COND(toolbar->compose_news_btn, M_HAVE_ACCOUNT);
2617 SET_WIDGET_COND(toolbar->reply_btn,
2618 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2619 SET_WIDGET_COND(toolbar->replyall_btn,
2620 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2621 SET_WIDGET_COND(toolbar->replylist_btn,
2622 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2623 SET_WIDGET_COND(toolbar->replysender_btn,
2624 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2625 SET_WIDGET_COND(toolbar->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
2627 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST);
2628 SET_WIDGET_COND(toolbar->delete_btn,
2629 M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
2630 SET_WIDGET_COND(toolbar->exec_btn, M_DELAY_EXEC);
2632 for (cur = toolbar->t_action_list; cur != NULL; cur = cur->next) {
2633 ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
2635 SET_WIDGET_COND(act->widget, M_TARGET_EXIST|M_UNLOCKED);
2638 #undef SET_WIDGET_COND
2640 state = main_window_get_current_state(mainwin);
2642 for (cur = entry_list; cur != NULL; cur = cur->next) {
2643 Entry *e = (Entry*) cur->data;
2645 if (e->widget != NULL) {
2646 sensitive = ((e->cond & state) == e->cond);
2647 gtk_widget_set_sensitive(e->widget, sensitive);
2651 while (entry_list != NULL) {
2652 Entry *e = (Entry*) entry_list->data;
2656 entry_list = g_slist_remove(entry_list, e);
2659 g_slist_free(entry_list);
2661 activate_compose_button(toolbar,
2662 prefs_common.toolbar_style,
2663 toolbar->compose_btn_type);
2666 static void toolbar_update(MainWindow *mainwin)
2668 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox),
2669 GTK_WIDGET(mainwin->toolbar->toolbar));
2671 mainwin->toolbar->toolbar = NULL;
2672 mainwin->toolbar->get_btn = NULL;
2673 mainwin->toolbar->getall_btn = NULL;
2674 mainwin->toolbar->send_btn = NULL;
2675 mainwin->toolbar->compose_mail_btn = NULL;
2676 mainwin->toolbar->compose_news_btn = NULL;
2677 mainwin->toolbar->reply_btn = NULL;
2678 mainwin->toolbar->replyall_btn = NULL;
2679 mainwin->toolbar->replylist_btn = NULL;
2680 mainwin->toolbar->replysender_btn = NULL;
2681 mainwin->toolbar->fwd_btn = NULL;
2682 mainwin->toolbar->delete_btn = NULL;
2683 mainwin->toolbar->next_btn = NULL;
2684 mainwin->toolbar->exec_btn = NULL;
2686 toolbar_clear_list(TOOLBAR_MAIN);
2687 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->t_action_list);
2688 toolbar_create(mainwin, mainwin->handlebox);
2689 toolbar_set_sensitive(mainwin);
2693 static void toolbar_create(MainWindow *mainwin,
2694 GtkWidget *container)
2696 ToolbarItem *toolbar_item;
2699 GtkWidget *icon_wid = NULL;
2700 GtkWidget *icon_news = NULL;
2701 GtkWidget *item_news = NULL;
2703 GtkTooltips *toolbar_tips;
2704 ToolbarSylpheedActions *t_action_item;
2706 GSList *toolbar_list;
2708 guint n_menu_entries;
2709 GtkWidget *reply_popup;
2710 GtkWidget *replyall_popup;
2711 GtkWidget *replylist_popup;
2712 GtkWidget *replysender_popup;
2713 GtkWidget *fwd_popup;
2715 toolbar_tips = gtk_tooltips_new();
2717 if (mainwin->toolbar != NULL) {
2718 toolbar_clear_list(TOOLBAR_MAIN);
2719 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->t_action_list);
2720 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->t_item_list);
2721 g_free(mainwin->toolbar);
2724 toolbar_read_config_file(TOOLBAR_MAIN);
2725 toolbar_list = toolbar_get_list(TOOLBAR_MAIN);
2727 mainwin->toolbar = g_new0(MainToolbar, 1);
2729 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
2731 gtk_container_add(GTK_CONTAINER(container), toolbar);
2732 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
2733 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
2734 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
2735 GTK_TOOLBAR_SPACE_LINE);
2737 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2739 if (g_strcasecmp(((ToolbarItem*)cur->data)->file, SEPARATOR) == 0) {
2740 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2744 toolbar_item = g_new0(ToolbarItem, 1);
2745 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2746 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2747 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2749 toolbar_item->parent = (gpointer)mainwin;
2751 /* collect toolbar items in list to keep track */
2752 mainwin->toolbar->t_item_list = g_slist_append(mainwin->toolbar->t_item_list,
2755 icon_wid = stock_pixmap_widget(container, stock_pixmap_get_icon(toolbar_item->file));
2756 item = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2760 icon_wid, toolbar_buttons_cb,
2763 switch (toolbar_item->index) {
2765 mainwin->toolbar->getall_btn = item;
2766 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2767 mainwin->toolbar->getall_btn,
2768 _("Receive Mail on all Accounts"), NULL);
2771 mainwin->toolbar->get_btn = item;
2772 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2773 mainwin->toolbar->get_btn,
2774 _("Receive Mail on current Account"), NULL);
2777 mainwin->toolbar->send_btn = item;
2778 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2779 mainwin->toolbar->send_btn,
2780 _("Send Queued Message(s)"), NULL);
2782 case A_COMPOSE_EMAIL:
2783 icon_news = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2784 item_news = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2788 icon_news, toolbar_buttons_cb,
2790 mainwin->toolbar->compose_mail_btn = item;
2791 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2792 mainwin->toolbar->compose_mail_btn,
2793 _("Compose Email"), NULL);
2794 mainwin->toolbar->compose_news_btn = item_news;
2795 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2796 mainwin->toolbar->compose_news_btn,
2797 _("Compose News"), NULL);
2799 case A_REPLY_MESSAGE:
2800 mainwin->toolbar->reply_btn = item;
2801 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2802 mainwin->toolbar->reply_btn,
2803 _("Reply to Message"), NULL);
2804 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->reply_btn),
2805 "button_press_event",
2806 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2808 n_menu_entries = sizeof(reply_popup_entries) /
2809 sizeof(reply_popup_entries[0]);
2810 reply_popup = popupmenu_create(mainwin->window, reply_popup_entries, n_menu_entries,
2811 "<ReplyPopup>", mainwin);
2812 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
2813 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
2814 mainwin->toolbar->reply_popup = reply_popup;
2816 case A_REPLY_SENDER:
2817 mainwin->toolbar->replysender_btn = item;
2818 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2819 mainwin->toolbar->replysender_btn,
2820 _("Reply to Sender"), NULL);
2821 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replysender_btn),
2822 "button_press_event",
2823 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2825 n_menu_entries = sizeof(replysender_popup_entries) /
2826 sizeof(replysender_popup_entries[0]);
2827 replysender_popup = popupmenu_create(mainwin->window,
2828 replysender_popup_entries, n_menu_entries,
2829 "<ReplySenderPopup>", mainwin);
2830 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
2831 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
2832 mainwin->toolbar->replysender_popup = replysender_popup;
2835 mainwin->toolbar->replyall_btn = item;
2836 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2837 mainwin->toolbar->replyall_btn,
2838 _("Reply to All"), NULL);
2839 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replyall_btn),
2840 "button_press_event",
2841 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2843 n_menu_entries = sizeof(replyall_popup_entries) /
2844 sizeof(replyall_popup_entries[0]);
2845 replyall_popup = popupmenu_create(mainwin->window,
2846 replyall_popup_entries, n_menu_entries,
2847 "<ReplyAllPopup>", mainwin);
2848 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
2849 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
2850 mainwin->toolbar->replyall_popup = replyall_popup;
2853 mainwin->toolbar->replylist_btn = item;
2854 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2855 mainwin->toolbar->replylist_btn,
2856 _("Reply to Mailing-list"), NULL);
2857 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replylist_btn),
2858 "button_press_event",
2859 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_cb),
2861 n_menu_entries = sizeof(replylist_popup_entries) /
2862 sizeof(replylist_popup_entries[0]);
2863 replylist_popup = popupmenu_create(mainwin->window,
2864 replylist_popup_entries, n_menu_entries,
2865 "<ReplyMlPopup>", mainwin);
2866 gtk_signal_connect(GTK_OBJECT(replylist_popup), "selection_done",
2867 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_closed_cb), mainwin);
2868 mainwin->toolbar->replylist_popup = replylist_popup;
2871 mainwin->toolbar->fwd_btn = item;
2872 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2873 mainwin->toolbar->fwd_btn,
2874 _("Forward Message"), NULL);
2875 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->fwd_btn),
2876 "button_press_event",
2877 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2879 n_menu_entries = sizeof(fwd_popup_entries) /
2880 sizeof(fwd_popup_entries[0]);
2881 fwd_popup = popupmenu_create(mainwin->window,
2882 fwd_popup_entries, n_menu_entries,
2883 "<ForwardPopup>", mainwin);
2884 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
2885 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
2886 mainwin->toolbar->fwd_popup = fwd_popup;
2889 mainwin->toolbar->delete_btn = item;
2890 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2891 mainwin->toolbar->delete_btn,
2892 _("Delete Message"), NULL);
2895 mainwin->toolbar->exec_btn = item;
2896 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2897 mainwin->toolbar->exec_btn,
2898 _("Execute"), NULL);
2901 mainwin->toolbar->next_btn = item;
2902 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2903 mainwin->toolbar->next_btn,
2904 _("Goto Next Message"), NULL);
2907 t_action_item = g_new0(ToolbarSylpheedActions, 1);
2908 t_action_item->widget = item;
2909 t_action_item->name = g_strdup(toolbar_item->text);
2911 mainwin->toolbar->t_action_list =
2912 g_slist_append(mainwin->toolbar->t_action_list,
2915 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2917 t_action_item->name, NULL);
2919 gtk_widget_show(item);
2926 mainwin->toolbar->toolbar = toolbar;
2928 activate_compose_button(mainwin->toolbar,
2929 prefs_common.toolbar_style,
2930 mainwin->toolbar->compose_btn_type);
2932 gtk_widget_show_all(toolbar);
2935 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2938 switch ((ToolbarStyle)action) {
2940 gtk_widget_hide(mainwin->handlebox);
2942 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2946 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2950 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2955 if (action != TOOLBAR_NONE) {
2956 gtk_widget_show(mainwin->handlebox);
2957 gtk_widget_queue_resize(mainwin->handlebox);
2960 mainwin->toolbar_style = (ToolbarStyle)action;
2961 prefs_common.toolbar_style = (ToolbarStyle)action;
2964 /* END Toolbar Stuff */
2966 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2969 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2970 gtk_widget_show(mainwin->hbox_stat);
2971 prefs_common.show_statusbar = TRUE;
2973 gtk_widget_hide(mainwin->hbox_stat);
2974 prefs_common.show_statusbar = FALSE;
2978 static void separate_widget_cb(MainWindow *mainwin, guint action,
2983 if (GTK_CHECK_MENU_ITEM(widget)->active)
2984 type = mainwin->type | action;
2986 type = mainwin->type & ~action;
2988 main_window_separation_change(mainwin, type);
2990 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2991 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2994 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2997 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2999 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3002 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
3004 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
3007 static void online_switch_clicked (GtkButton *btn, gpointer data)
3009 MainWindow *mainwin;
3010 GtkItemFactory *ifactory;
3011 GtkCheckMenuItem *menuitem;
3013 mainwin = (MainWindow *) data;
3015 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3016 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3018 g_return_if_fail(mainwin != NULL);
3019 g_return_if_fail(menuitem != NULL);
3021 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3023 gtk_widget_hide (mainwin->online_switch);
3024 gtk_widget_show (mainwin->offline_switch);
3025 menuitem->active = TRUE;
3026 prefs_common.work_offline = TRUE;
3027 inc_autocheck_timer_remove();
3030 gtk_widget_hide (mainwin->offline_switch);
3031 gtk_widget_show (mainwin->online_switch);
3032 menuitem->active = FALSE;
3033 prefs_common.work_offline = FALSE;
3034 inc_autocheck_timer_set();
3038 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3041 addressbook_open(NULL);
3044 static void log_window_show_cb(MainWindow *mainwin, guint action,
3047 log_window_show(mainwin->logwin);
3050 static void sel_download_cb(MainWindow *mainwin, guint action,
3053 selective_download(mainwin);
3056 static void prefs_toolbar_cb(MainWindow *mainwin, guint action,
3059 prefs_toolbar(action);
3063 void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3065 inc_mail(mainwin, prefs_common.newmail_notify_manu);
3068 void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
3071 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
3074 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3079 void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3083 if (prefs_common.work_offline)
3084 if (alertpanel(_("Offline warning"),
3085 _("You're working offline. Override?"),
3086 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
3089 for (list = folder_get_list(); list != NULL; list = list->next) {
3090 Folder *folder = list->data;
3092 if (folder->queue) {
3093 if (procmsg_send_queue
3094 (folder->queue, prefs_common.savemsg) < 0)
3095 alertpanel_error(_("Some errors occurred while sending queued messages."));
3096 statusbar_pop_all();
3097 folder_item_scan(folder->queue);
3098 folder_update_item(folder->queue, TRUE);
3103 void compose_mail_cb(MainWindow *mainwin, guint action,
3106 PrefsAccount *ac = NULL;
3107 FolderItem *item = mainwin->summaryview->folder_item;
3112 ac = account_find_from_item(item);
3113 if (ac && ac->protocol != A_NNTP) {
3114 compose_new_with_folderitem(ac, item); /* CLAWS */
3120 * CLAWS - use current account
3122 if (cur_account && (cur_account->protocol != A_NNTP)) {
3123 compose_new_with_folderitem(cur_account, item);
3128 * CLAWS - just get the first one
3130 list = account_get_list();
3131 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3132 ac = (PrefsAccount *) cur->data;
3133 if (ac->protocol != A_NNTP) {
3134 compose_new_with_folderitem(ac, item);
3140 void compose_news_cb(MainWindow *mainwin, guint action,
3143 PrefsAccount * ac = NULL;
3147 if (mainwin->summaryview->folder_item) {
3148 ac = mainwin->summaryview->folder_item->folder->account;
3149 if (ac && ac->protocol == A_NNTP) {
3151 mainwin->summaryview->folder_item->path,
3157 list = account_get_list();
3158 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3159 ac = (PrefsAccount *) cur->data;
3160 if (ac->protocol == A_NNTP) {
3161 compose_new(ac, NULL, NULL);
3167 void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3169 summary_reply(mainwin->summaryview, (ComposeMode)action);
3172 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3174 summary_move_to(mainwin->summaryview);
3177 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3179 summary_copy_to(mainwin->summaryview);
3182 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3184 summary_delete(mainwin->summaryview);
3187 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3189 summary_cancel(mainwin->summaryview);
3192 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3194 summary_open_msg(mainwin->summaryview);
3197 static void view_source_cb(MainWindow *mainwin, guint action,
3200 summary_view_source(mainwin->summaryview);
3203 static void show_all_header_cb(MainWindow *mainwin, guint action,
3206 if (mainwin->menu_lock_count) return;
3207 summary_display_msg_selected(mainwin->summaryview,
3208 GTK_CHECK_MENU_ITEM(widget)->active);
3211 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3213 summary_reedit(mainwin->summaryview);
3216 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3218 summary_mark(mainwin->summaryview);
3221 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3223 summary_unmark(mainwin->summaryview);
3226 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3229 summary_mark_as_unread(mainwin->summaryview);
3232 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3235 summary_mark_as_read(mainwin->summaryview);
3238 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3241 summary_mark_all_read(mainwin->summaryview);
3244 static void add_address_cb(MainWindow *mainwin, guint action,
3247 summary_add_address(mainwin->summaryview);
3250 static void set_charset_cb(MainWindow *mainwin, guint action,
3255 str = conv_get_charset_str((CharSet)action);
3256 g_free(prefs_common.force_charset);
3257 prefs_common.force_charset = str ? g_strdup(str) : NULL;
3259 summary_redisplay_msg(mainwin->summaryview);
3261 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3264 static void hide_read_messages (MainWindow *mainwin, guint action,
3267 if (!mainwin->summaryview->folder_item
3268 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
3270 summary_toggle_show_read_messages(mainwin->summaryview);
3273 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3275 if (mainwin->menu_lock_count) return;
3276 if (!mainwin->summaryview->folder_item) return;
3278 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3279 summary_thread_build(mainwin->summaryview);
3280 /* mainwin->summaryview->folder_item->threaded = TRUE; */
3282 summary_unthread(mainwin->summaryview);
3283 /* mainwin->summaryview->folder_item->threaded = FALSE; */
3287 static void expand_threads_cb(MainWindow *mainwin, guint action,
3290 summary_expand_threads(mainwin->summaryview);
3293 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3296 summary_collapse_threads(mainwin->summaryview);
3299 static void set_display_item_cb(MainWindow *mainwin, guint action,
3302 prefs_summary_column_open();
3305 static void sort_summary_cb(MainWindow *mainwin, guint action,
3308 FolderItem *item = mainwin->summaryview->folder_item;
3309 GtkWidget *menuitem;
3311 if (mainwin->menu_lock_count) return;
3313 menuitem = gtk_item_factory_get_item
3314 (mainwin->menu_factory, "/View/Sort/Ascending");
3315 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3316 GTK_CHECK_MENU_ITEM(menuitem)->active
3317 ? SORT_ASCENDING : SORT_DESCENDING);
3321 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3324 FolderItem *item = mainwin->summaryview->folder_item;
3326 if (mainwin->menu_lock_count) return;
3328 summary_sort(mainwin->summaryview,
3329 item->sort_key, (FolderSortType)action);
3332 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3335 summary_attract_by_subject(mainwin->summaryview);
3338 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3341 summary_delete_duplicated(mainwin->summaryview);
3344 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3346 summary_filter(mainwin->summaryview);
3349 static void execute_summary_cb(MainWindow *mainwin, guint action,
3352 summary_execute(mainwin->summaryview);
3355 static void update_summary_cb(MainWindow *mainwin, guint action,
3359 FolderView *folderview = mainwin->folderview;
3361 if (!mainwin->summaryview->folder_item) return;
3362 if (!folderview->opened) return;
3364 folder_update_op_count();
3366 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3367 folderview->opened);
3370 folder_item_scan(fitem);
3371 summary_show(mainwin->summaryview, fitem);
3374 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3376 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3379 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3381 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3384 static void prev_unread_cb(MainWindow *mainwin, guint action,
3387 summary_select_prev_unread(mainwin->summaryview);
3390 void next_unread_cb(MainWindow *mainwin, guint action,
3393 summary_select_next_unread(mainwin->summaryview);
3396 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3398 summary_select_prev_new(mainwin->summaryview);
3401 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3403 summary_select_next_new(mainwin->summaryview);
3406 static void prev_marked_cb(MainWindow *mainwin, guint action,
3409 summary_select_prev_marked(mainwin->summaryview);
3412 static void next_marked_cb(MainWindow *mainwin, guint action,
3415 summary_select_next_marked(mainwin->summaryview);
3418 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3421 summary_select_prev_labeled(mainwin->summaryview);
3424 static void next_labeled_cb(MainWindow *mainwin, guint action,
3427 summary_select_next_labeled(mainwin->summaryview);
3430 static void goto_folder_cb(MainWindow *mainwin, guint action,
3433 FolderItem *to_folder;
3435 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3438 folderview_select(mainwin->folderview, to_folder);
3441 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3443 messageview_copy_clipboard(mainwin->messageview);
3446 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3448 MessageView *msgview = mainwin->messageview;
3450 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3451 summary_select_all(mainwin->summaryview);
3452 else if (messageview_is_visible(msgview) &&
3453 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
3454 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3455 messageview_select_all(mainwin->messageview);
3458 static void select_thread_cb(MainWindow *mainwin, guint action,
3461 summary_select_thread(mainwin->summaryview);
3464 static void create_filter_cb(MainWindow *mainwin, guint action,
3467 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3470 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3473 prefs_common_open();
3476 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3479 prefs_scoring_open(NULL);
3482 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3485 prefs_filtering_open(NULL, NULL, NULL);
3488 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3491 prefs_template_open();
3494 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3497 prefs_actions_open(mainwin);
3500 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3503 ssl_manager_open(mainwin);
3506 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3510 new_account_cb(mainwin, 0, widget);
3512 account_open(cur_account);
3516 static void new_account_cb(MainWindow *mainwin, guint action,
3519 account_edit_open();
3520 if (!compose_get_compose_list()) account_add();
3523 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3525 cur_account = (PrefsAccount *)data;
3526 main_window_reflect_prefs_all();
3529 static void manual_open_cb(MainWindow *mainwin, guint action,
3532 manual_open((ManualType)action);
3535 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3537 MainWindow *mainwin = (MainWindow *)data;
3541 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3542 LOCAL_FOLDER(folder)->rootpath,
3546 str = g_strdup_printf(_("Scanning folder %s ..."),
3547 LOCAL_FOLDER(folder)->rootpath);
3549 STATUSBAR_PUSH(mainwin, str);
3550 STATUSBAR_POP(mainwin);
3554 #define BREAK_ON_MODIFIER_KEY() \
3555 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3557 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3559 MainWindow *mainwin = (MainWindow*) data;
3561 if (!mainwin || !event) return;
3563 switch (event->keyval) {
3564 case GDK_Q: /* Quit */
3565 BREAK_ON_MODIFIER_KEY();
3567 app_exit_cb(mainwin, 0, NULL);
3570 if (mainwin->folderview && mainwin->summaryview
3571 && !mainwin->summaryview->displayed) {
3572 summary_lock(mainwin->summaryview);
3573 folderview_select_next_unread(mainwin->folderview);
3574 summary_unlock(mainwin->summaryview);
3582 #undef BREAK_ON_MODIFIER_KEY
3584 static void set_toolbar_style(MainWindow *mainwin)
3586 switch (prefs_common.toolbar_style) {
3588 gtk_widget_hide(mainwin->handlebox);
3591 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
3595 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
3599 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
3604 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3605 gtk_widget_show(mainwin->handlebox);
3606 gtk_widget_queue_resize(mainwin->handlebox);
3611 * Harvest addresses for selected folder.
3613 static void addr_harvest_cb( MainWindow *mainwin,
3617 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3621 * Harvest addresses for selected messages in summary view.
3623 static void addr_harvest_msg_cb( MainWindow *mainwin,
3627 summary_harvest_address( mainwin->summaryview );