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"
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 new_account_cb (MainWindow *mainwin,
477 static void account_menu_cb (GtkMenuItem *menuitem,
480 static void online_switch_clicked(GtkButton *btn,
483 static void manual_open_cb (MainWindow *mainwin,
487 static void scan_tree_func (Folder *folder,
491 static void key_pressed (GtkWidget *widget,
495 static void set_toolbar_style(MainWindow *mainwin);
497 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
499 static void addr_harvest_cb ( MainWindow *mainwin,
503 static void addr_harvest_msg_cb ( MainWindow *mainwin,
507 #define SEPARATE_ACTION 500
509 static GtkItemFactoryEntry mainwin_entries[] =
511 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
512 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
513 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
514 {N_("/_File/_Check for new messages in all folders"),
515 NULL, update_folderview_cb, 0, NULL},
516 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
517 {N_("/_File/_Folder/Create _new folder..."),
518 NULL, new_folder_cb, 0, NULL},
519 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
520 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
521 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
522 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
523 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
524 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
525 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
526 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
527 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
528 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
529 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
530 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
532 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
533 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
534 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
535 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
536 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
537 {N_("/_Edit/_Find in current message..."),
538 "<control>F", search_cb, 0, NULL},
539 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
540 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
541 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
542 {N_("/_View/Show or hi_de/_Folder tree"),
543 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
544 {N_("/_View/Show or hi_de/_Message view"),
545 "V", toggle_message_cb, 0, "<ToggleItem>"},
546 {N_("/_View/Show or hi_de/_Toolbar"),
547 NULL, NULL, 0, "<Branch>"},
548 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
549 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
550 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
551 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
552 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
553 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
554 {N_("/_View/Show or hi_de/_Toolbar/_None"),
555 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
556 {N_("/_View/Show or hi_de/Status _bar"),
557 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
558 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
559 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
560 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
561 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
562 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
563 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
564 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
565 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
566 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
567 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
568 {N_("/_View/_Sort/by _color label"),
569 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
570 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
571 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
572 {N_("/_View/_Sort/by a_ttachment"),
573 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
574 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
575 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
576 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
577 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
578 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
579 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
580 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
581 {N_("/_View/_Sort/_Attract by subject"),
582 NULL, attract_by_subject_cb, 0, NULL},
583 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
584 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
585 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
586 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
587 {N_("/_View/Set displayed _items..."), NULL, set_display_item_cb, 0, NULL},
589 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
590 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
591 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
592 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
593 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
594 {N_("/_View/_Go to/P_rev unread message"),
595 "<shift>P", prev_unread_cb, 0, NULL},
596 {N_("/_View/_Go to/N_ext unread message"),
597 "<shift>N", next_unread_cb, 0, NULL},
598 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
599 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
600 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
601 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
602 {N_("/_View/_Go to/Prev _marked message"),
603 NULL, prev_marked_cb, 0, NULL},
604 {N_("/_View/_Go to/Next m_arked message"),
605 NULL, next_marked_cb, 0, NULL},
606 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
607 {N_("/_View/_Go to/Prev _labeled message"),
608 NULL, prev_labeled_cb, 0, NULL},
609 {N_("/_View/_Go to/Next la_beled message"),
610 NULL, next_labeled_cb, 0, NULL},
611 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
612 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
613 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
615 #define CODESET_SEPARATOR \
616 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
617 #define CODESET_ACTION(action) \
618 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
620 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
621 {N_("/_View/_Code set/_Auto detect"),
622 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
623 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
624 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
625 CODESET_ACTION(C_US_ASCII)},
628 {N_("/_View/_Code set/Unicode (_UTF-8)"),
629 CODESET_ACTION(C_UTF_8)},
632 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
633 CODESET_ACTION(C_ISO_8859_1)},
634 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
635 CODESET_ACTION(C_ISO_8859_15)},
638 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
639 CODESET_ACTION(C_ISO_8859_2)},
641 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
642 CODESET_ACTION(C_ISO_8859_13)},
643 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
644 CODESET_ACTION(C_ISO_8859_4)},
646 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
647 CODESET_ACTION(C_ISO_8859_7)},
649 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
650 CODESET_ACTION(C_ISO_8859_9)},
652 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
653 CODESET_ACTION(C_ISO_8859_5)},
654 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
655 CODESET_ACTION(C_KOI8_R)},
656 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
657 CODESET_ACTION(C_WINDOWS_1251)},
660 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
661 CODESET_ACTION(C_ISO_2022_JP)},
663 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
664 CODESET_ACTION(C_ISO_2022_JP_2)},
666 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
667 CODESET_ACTION(C_EUC_JP)},
668 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
669 CODESET_ACTION(C_SHIFT_JIS)},
672 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
673 CODESET_ACTION(C_GB2312)},
674 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
675 CODESET_ACTION(C_BIG5)},
676 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
677 CODESET_ACTION(C_EUC_TW)},
678 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
679 CODESET_ACTION(C_ISO_2022_CN)},
681 {N_("/_View/_Code set/Korean (EUC-_KR)"),
682 CODESET_ACTION(C_EUC_KR)},
683 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
684 CODESET_ACTION(C_ISO_2022_KR)},
686 {N_("/_View/_Code set/Thai (TIS-620)"),
687 CODESET_ACTION(C_TIS_620)},
688 {N_("/_View/_Code set/Thai (Windows-874)"),
689 CODESET_ACTION(C_WINDOWS_874)},
692 #undef CODESET_SEPARATOR
693 #undef CODESET_ACTION
695 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
696 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
697 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
698 {N_("/_View/Show all _headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
699 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
700 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
702 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
703 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
704 {N_("/_Message/Get from _all accounts"),
705 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
706 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
707 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
708 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
709 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
710 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
711 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
712 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
713 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
714 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
715 {N_("/_Message/Repl_y to/_sender"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
716 {N_("/_Message/Repl_y to/mailing _list"),
717 "<control>L", reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
718 {N_("/_Message/Follow-up and reply to"),NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
719 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
720 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
721 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
722 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
723 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
724 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
725 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
726 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
727 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
728 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
729 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
730 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
731 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
732 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
733 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
734 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
735 {N_("/_Message/_Mark/Mark as rea_d"),
736 NULL, mark_as_read_cb, 0, NULL},
737 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
739 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
740 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
741 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
742 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
743 {N_("/_Tools/Add sender to address boo_k"),
744 NULL, add_address_cb, 0, NULL},
745 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
746 {N_("/_Tools/_Harvest addresses/from _Folder..."),
747 NULL, addr_harvest_cb, 0, NULL},
748 {N_("/_Tools/_Harvest addresses/from _Messages..."),
749 NULL, addr_harvest_msg_cb, 0, NULL},
750 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
751 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
752 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
753 {N_("/_Tools/_Create filter rule/_Automatically"),
754 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
755 {N_("/_Tools/_Create filter rule/by _From"),
756 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
757 {N_("/_Tools/_Create filter rule/by _To"),
758 NULL, create_filter_cb, FILTER_BY_TO, NULL},
759 {N_("/_Tools/_Create filter rule/by _Subject"),
760 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
761 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
762 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
763 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
764 {N_("/_Tools/Delete du_plicated messages"),
765 NULL, delete_duplicated_cb, 0, NULL},
766 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
767 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
768 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
769 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
771 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
772 {N_("/_Configuration/_Common preferences..."),
773 NULL, prefs_common_open_cb, 0, NULL},
774 {N_("/_Configuration/C_ustomize toolbar"),
775 NULL, NULL, 0, "<Branch>"},
776 {N_("/_Configuration/C_ustomize toolbar/_Main toolbar..."),
777 NULL, prefs_toolbar_cb, TOOLBAR_MAIN, NULL},
778 {N_("/_Configuration/C_ustomize toolbar/_Compose toolbar..."),
779 NULL, prefs_toolbar_cb, TOOLBAR_COMPOSE, NULL},
780 {N_("/_Configuration/_Scoring..."),
781 NULL, prefs_scoring_open_cb, 0, NULL},
782 {N_("/_Configuration/_Filtering..."),
783 NULL, prefs_filtering_open_cb, 0, NULL},
784 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
785 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
786 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
787 {N_("/_Configuration/_Preferences for current account..."),
788 NULL, prefs_account_open_cb, 0, NULL},
789 {N_("/_Configuration/Create _new account..."),
790 NULL, new_account_cb, 0, NULL},
791 {N_("/_Configuration/_Edit accounts..."),
792 NULL, account_edit_open, 0, NULL},
793 {N_("/_Configuration/C_hange current account"),
794 NULL, NULL, 0, "<Branch>"},
796 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
797 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
798 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
799 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
800 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
801 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
802 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
803 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
804 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
809 static GtkItemFactoryEntry reply_popup_entries[] =
811 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
812 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
814 static GtkItemFactoryEntry replyall_popup_entries[] =
816 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
817 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
819 static GtkItemFactoryEntry replylist_popup_entries[] =
821 {N_("/Reply to list with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE, NULL},
822 {N_("/_Reply to list without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE, NULL}
824 static GtkItemFactoryEntry replysender_popup_entries[] =
826 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
827 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
829 static GtkItemFactoryEntry fwd_popup_entries[] =
831 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
832 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
835 MainWindow *main_window_create(SeparateType type)
841 GtkWidget *handlebox;
842 GtkWidget *vbox_body;
843 GtkWidget *hbox_stat;
844 GtkWidget *statusbar;
845 GtkWidget *progressbar;
846 GtkWidget *statuslabel;
847 GtkWidget *ac_button;
849 GtkWidget *online_pixmap;
850 GtkWidget *offline_pixmap;
851 GtkWidget *online_switch;
852 GtkWidget *offline_switch;
854 FolderView *folderview;
855 SummaryView *summaryview;
856 MessageView *messageview;
857 GdkColormap *colormap;
860 GtkItemFactory *ifactory;
864 guint n_menu_entries;
866 static GdkGeometry geometry;
868 debug_print("Creating main window...\n");
869 mainwin = g_new0(MainWindow, 1);
872 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
873 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
874 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
875 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
877 if (!geometry.min_height) {
878 geometry.min_width = 320;
879 geometry.min_height = 200;
881 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
884 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
885 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
886 MANAGE_WINDOW_SIGNALS_CONNECT(window);
887 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
888 GTK_SIGNAL_FUNC(key_pressed), mainwin);
890 gtk_widget_realize(window);
891 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
894 gtkut_widget_set_app_icon(window);
896 vbox = gtk_vbox_new(FALSE, 0);
897 gtk_widget_show(vbox);
898 gtk_container_add(GTK_CONTAINER(window), vbox);
901 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
902 menubar = menubar_create(window, mainwin_entries,
903 n_menu_entries, "<Main>", mainwin);
904 gtk_widget_show(menubar);
905 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
906 ifactory = gtk_item_factory_from_widget(menubar);
908 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
909 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
911 handlebox = gtk_handle_box_new();
912 gtk_widget_show(handlebox);
913 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
915 /* link window to mainwin->window to avoid gdk warnings */
916 mainwin->window = window;
919 toolbar_create(mainwin, handlebox);
921 /* vbox that contains body */
922 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
923 gtk_widget_show(vbox_body);
924 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
925 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
927 hbox_stat = gtk_hbox_new(FALSE, 2);
928 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
930 statusbar = statusbar_create();
931 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
933 progressbar = gtk_progress_bar_new();
934 gtk_widget_set_usize(progressbar, 120, 1);
935 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
937 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
938 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
939 online_switch = gtk_button_new ();
940 offline_switch = gtk_button_new ();
941 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
942 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
943 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
944 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
945 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
946 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
947 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
948 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
950 statuslabel = gtk_label_new("");
951 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
953 ac_button = gtk_button_new();
954 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
955 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
956 gtk_widget_set_usize(ac_button, -1, 1);
957 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
958 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
959 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
961 ac_label = gtk_label_new("");
962 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
964 gtk_widget_show_all(hbox_stat);
966 gtk_widget_hide(offline_switch);
968 mainwin->folderview = folderview = folderview_create();
969 mainwin->summaryview = summaryview = summary_create();
970 mainwin->messageview = messageview = messageview_create(mainwin);
971 mainwin->logwin = log_window_create();
973 folderview->mainwin = mainwin;
974 folderview->summaryview = summaryview;
976 summaryview->mainwin = mainwin;
977 summaryview->folderview = folderview;
978 summaryview->messageview = messageview;
979 summaryview->window = window;
981 messageview->mainwin = mainwin;
983 mainwin->vbox = vbox;
984 mainwin->menubar = menubar;
985 mainwin->menu_factory = ifactory;
986 mainwin->handlebox = handlebox;
987 mainwin->vbox_body = vbox_body;
988 mainwin->hbox_stat = hbox_stat;
989 mainwin->statusbar = statusbar;
990 mainwin->progressbar = progressbar;
991 mainwin->statuslabel = statuslabel;
992 mainwin->ac_button = ac_button;
993 mainwin->ac_label = ac_label;
995 mainwin->online_switch = online_switch;
996 mainwin->offline_switch = offline_switch;
997 mainwin->online_pixmap = online_pixmap;
998 mainwin->offline_pixmap = offline_pixmap;
1000 /* set context IDs for status bar */
1001 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1002 (GTK_STATUSBAR(statusbar), "Main Window");
1003 mainwin->folderview_cid = gtk_statusbar_get_context_id
1004 (GTK_STATUSBAR(statusbar), "Folder View");
1005 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1006 (GTK_STATUSBAR(statusbar), "Summary View");
1008 /* allocate colors for summary view and folder view */
1009 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1010 summaryview->color_marked.blue = (guint16)65535;
1012 summaryview->color_dim.red = summaryview->color_dim.green =
1013 summaryview->color_dim.blue = COLOR_DIM;
1015 folderview->color_new.red = (guint16)55000;
1016 folderview->color_new.green = folderview->color_new.blue = 15000;
1018 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1019 &folderview->color_op);
1021 summaryview->color_important.red = 0;
1022 summaryview->color_important.green = 0;
1023 summaryview->color_important.blue = (guint16)65535;
1025 color[0] = summaryview->color_marked;
1026 color[1] = summaryview->color_dim;
1027 color[2] = folderview->color_new;
1028 color[3] = folderview->color_op;
1030 colormap = gdk_window_get_colormap(window->window);
1031 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1032 for (i = 0; i < 4; i++) {
1033 if (success[i] == FALSE)
1034 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1037 debug_print("done.\n");
1039 messageview->visible = TRUE;
1041 main_window_set_widgets(mainwin, type);
1043 /* set menu items */
1044 menuitem = gtk_item_factory_get_item
1045 (ifactory, "/View/Code set/Auto detect");
1046 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1048 switch (prefs_common.toolbar_style) {
1050 menuitem = gtk_item_factory_get_item
1051 (ifactory, "/View/Show or hide/Toolbar/None");
1054 menuitem = gtk_item_factory_get_item
1055 (ifactory, "/View/Show or hide/Toolbar/Icon");
1058 menuitem = gtk_item_factory_get_item
1059 (ifactory, "/View/Show or hide/Toolbar/Text");
1062 menuitem = gtk_item_factory_get_item
1063 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1065 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1067 gtk_widget_hide(mainwin->hbox_stat);
1068 menuitem = gtk_item_factory_get_item
1069 (ifactory, "/View/Show or hide/Status bar");
1070 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1071 prefs_common.show_statusbar);
1073 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
1075 if (prefs_common.show_searchbar)
1076 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
1079 /* set account selection menu */
1080 ac_menu = gtk_item_factory_get_widget
1081 (ifactory, "/Configuration/Change current account");
1082 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1083 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1084 mainwin->ac_menu = ac_menu;
1086 toolbar_set_sensitive(mainwin);
1088 /* create actions menu */
1089 update_mainwin_actions_menu(ifactory, mainwin);
1091 /* show main window */
1092 gtk_widget_set_uposition(mainwin->window,
1093 prefs_common.mainwin_x,
1094 prefs_common.mainwin_y);
1095 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1096 prefs_common.mainwin_height);
1097 gtk_widget_show(mainwin->window);
1099 /* initialize views */
1100 folderview_init(folderview);
1101 summary_init(summaryview);
1102 messageview_init(messageview);
1103 log_window_init(mainwin->logwin);
1105 mainwin->lock_count = 0;
1106 mainwin->menu_lock_count = 0;
1107 mainwin->cursor_count = 0;
1110 watch_cursor = gdk_cursor_new(GDK_WATCH);
1112 mainwin_list = g_list_append(mainwin_list, mainwin);
1114 /* init work_offline */
1115 if (prefs_common.work_offline)
1116 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1121 void main_window_cursor_wait(MainWindow *mainwin)
1124 if (mainwin->cursor_count == 0)
1125 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1127 mainwin->cursor_count++;
1132 void main_window_cursor_normal(MainWindow *mainwin)
1134 if (mainwin->cursor_count)
1135 mainwin->cursor_count--;
1137 if (mainwin->cursor_count == 0)
1138 gdk_window_set_cursor(mainwin->window->window, NULL);
1143 /* lock / unlock the user-interface */
1144 void main_window_lock(MainWindow *mainwin)
1146 if (mainwin->lock_count == 0)
1147 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1149 mainwin->lock_count++;
1151 main_window_set_menu_sensitive(mainwin);
1152 toolbar_set_sensitive(mainwin);
1155 void main_window_unlock(MainWindow *mainwin)
1157 if (mainwin->lock_count)
1158 mainwin->lock_count--;
1160 main_window_set_menu_sensitive(mainwin);
1161 toolbar_set_sensitive(mainwin);
1163 if (mainwin->lock_count == 0)
1164 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1167 static void main_window_menu_callback_block(MainWindow *mainwin)
1169 mainwin->menu_lock_count++;
1172 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1174 if (mainwin->menu_lock_count)
1175 mainwin->menu_lock_count--;
1178 void main_window_reflect_prefs_all(void)
1180 main_window_reflect_prefs_all_real(FALSE);
1183 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1186 MainWindow *mainwin;
1189 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1190 mainwin = (MainWindow *)cur->data;
1192 main_window_show_cur_account(mainwin);
1193 main_window_set_menu_sensitive(mainwin);
1194 toolbar_set_sensitive(mainwin);
1197 if (pixmap_theme_changed) {
1198 toolbar_update(mainwin);
1199 set_toolbar_style(mainwin);
1200 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1201 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1203 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1204 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1205 mainwin->online_pixmap);
1206 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1207 gtk_widget_show(pixmap);
1208 mainwin->online_pixmap = pixmap;
1209 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1210 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1211 mainwin->offline_pixmap);
1212 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1213 gtk_widget_show(pixmap);
1214 mainwin->offline_pixmap = pixmap;
1217 summary_redisplay_msg(mainwin->summaryview);
1218 headerview_set_visibility(mainwin->messageview->headerview,
1219 prefs_common.display_header_pane);
1223 void main_window_set_summary_column(void)
1226 MainWindow *mainwin;
1228 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1229 mainwin = (MainWindow *)cur->data;
1230 summary_set_column_order(mainwin->summaryview);
1234 void main_window_set_account_menu(GList *account_list)
1236 GList *cur, *cur_ac, *cur_item;
1237 GtkWidget *menuitem;
1238 MainWindow *mainwin;
1239 PrefsAccount *ac_prefs;
1241 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1242 mainwin = (MainWindow *)cur->data;
1244 /* destroy all previous menu item */
1245 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1246 while (cur_item != NULL) {
1247 GList *next = cur_item->next;
1248 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1252 for (cur_ac = account_list; cur_ac != NULL;
1253 cur_ac = cur_ac->next) {
1254 ac_prefs = (PrefsAccount *)cur_ac->data;
1256 menuitem = gtk_menu_item_new_with_label
1257 (ac_prefs->account_name
1258 ? ac_prefs->account_name : _("Untitled"));
1259 gtk_widget_show(menuitem);
1260 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1261 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1262 GTK_SIGNAL_FUNC(account_menu_cb),
1268 static void main_window_show_cur_account(MainWindow *mainwin)
1273 ac_name = g_strdup(cur_account
1274 ? (cur_account->account_name
1275 ? cur_account->account_name : _("Untitled"))
1279 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1281 buf = g_strdup(PROG_VERSION);
1282 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1285 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1286 gtk_widget_queue_resize(mainwin->ac_button);
1291 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1293 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1294 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1295 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1297 debug_print("Changing window separation type from %d to %d\n",
1298 mainwin->type, type);
1300 if (mainwin->type == type) return;
1302 /* remove widgets from those containers */
1303 gtk_widget_ref(folder_wid);
1304 gtk_widget_ref(summary_wid);
1305 gtk_widget_ref(message_wid);
1306 gtkut_container_remove
1307 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1308 gtkut_container_remove
1309 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1310 gtkut_container_remove
1311 (GTK_CONTAINER(message_wid->parent), message_wid);
1313 /* clean containers */
1314 switch (mainwin->type) {
1316 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1318 case SEPARATE_FOLDER:
1319 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1320 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1322 case SEPARATE_MESSAGE:
1323 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1324 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1327 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1328 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1332 gtk_widget_hide(mainwin->window);
1333 main_window_set_widgets(mainwin, type);
1334 gtk_widget_show(mainwin->window);
1336 gtk_widget_unref(folder_wid);
1337 gtk_widget_unref(summary_wid);
1338 gtk_widget_unref(message_wid);
1341 void main_window_toggle_message_view(MainWindow *mainwin)
1343 SummaryView *summaryview = mainwin->summaryview;
1344 union CompositeWin *cwin = &mainwin->win;
1345 GtkWidget *vpaned = NULL;
1346 GtkWidget *container = NULL;
1347 GtkWidget *msgwin = NULL;
1349 switch (mainwin->type) {
1351 vpaned = cwin->sep_none.vpaned;
1352 container = cwin->sep_none.hpaned;
1354 case SEPARATE_FOLDER:
1355 vpaned = cwin->sep_folder.vpaned;
1356 container = mainwin->vbox_body;
1358 case SEPARATE_MESSAGE:
1359 msgwin = mainwin->win.sep_message.messagewin;
1362 msgwin = mainwin->win.sep_both.messagewin;
1367 if (GTK_WIDGET_VISIBLE(msgwin)) {
1368 gtk_widget_hide(msgwin);
1369 mainwin->messageview->visible = FALSE;
1370 summaryview->displayed = NULL;
1372 gtk_widget_show(msgwin);
1373 mainwin->messageview->visible = TRUE;
1375 } else if (vpaned->parent != NULL) {
1376 mainwin->messageview->visible = FALSE;
1377 summaryview->displayed = NULL;
1378 gtk_widget_ref(vpaned);
1379 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1380 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1381 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1382 GTK_ARROW_UP, GTK_SHADOW_OUT);
1384 mainwin->messageview->visible = TRUE;
1385 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1386 gtk_container_add(GTK_CONTAINER(container), vpaned);
1387 gtk_widget_unref(vpaned);
1388 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1389 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1392 main_window_set_menu_sensitive(mainwin);
1394 gtk_widget_grab_focus(summaryview->ctree);
1397 void main_window_get_size(MainWindow *mainwin)
1399 GtkAllocation *allocation;
1401 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1403 prefs_common.summaryview_width = allocation->width;
1405 if ((mainwin->type == SEPARATE_NONE ||
1406 mainwin->type == SEPARATE_FOLDER) &&
1407 messageview_is_visible(mainwin->messageview))
1408 prefs_common.summaryview_height = allocation->height;
1410 prefs_common.mainview_width = allocation->width;
1412 allocation = &mainwin->window->allocation;
1414 prefs_common.mainview_height = allocation->height;
1415 prefs_common.mainwin_width = allocation->width;
1416 prefs_common.mainwin_height = allocation->height;
1418 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1420 prefs_common.folderview_width = allocation->width;
1421 prefs_common.folderview_height = allocation->height;
1424 void main_window_get_position(MainWindow *mainwin)
1428 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1430 prefs_common.mainview_x = x;
1431 prefs_common.mainview_y = y;
1432 prefs_common.mainwin_x = x;
1433 prefs_common.mainwin_y = y;
1435 debug_print("window position: x = %d, y = %d\n", x, y);
1438 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1444 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1445 folder = FOLDER(list->data);
1446 if (folder && folder->trash && folder->trash->total > 0)
1450 if (!has_trash) return;
1453 if (alertpanel(_("Empty trash"),
1454 _("Empty all messages in trash?"),
1455 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1457 manage_window_focus_in(mainwin->window, NULL, NULL);
1460 procmsg_empty_trash();
1462 for (list = folder_get_list(); list != NULL; list = list->next) {
1463 folder = list->data;
1464 if (folder && folder->trash) {
1465 folderview_update_item(folder->trash, TRUE);
1469 if (mainwin->summaryview->folder_item &&
1470 mainwin->summaryview->folder_item->stype == F_TRASH)
1471 gtk_widget_grab_focus(mainwin->folderview->ctree);
1474 void main_window_add_mailbox(MainWindow *mainwin)
1479 path = input_dialog(_("Add mailbox"),
1480 _("Input the location of mailbox.\n"
1481 "If the existing mailbox is specified, it will be\n"
1482 "scanned automatically."),
1485 if (folder_find_from_path(path)) {
1486 alertpanel_error(_("The mailbox `%s' already exists."), path);
1490 if (!strcmp(path, "Mail"))
1491 folder = folder_new(F_MH, _("Mailbox"), path);
1493 folder = folder_new(F_MH, g_basename(path), path);
1496 if (folder->create_tree(folder) < 0) {
1497 alertpanel_error(_("Creation of the mailbox failed.\n"
1498 "Maybe some files already exist, or you don't have the permission to write there."));
1499 folder_destroy(folder);
1504 folder_set_ui_func(folder, scan_tree_func, mainwin);
1505 folder_scan_tree(folder);
1506 folder_set_ui_func(folder, NULL, NULL);
1508 folderview_set(mainwin->folderview);
1511 void main_window_add_mbox(MainWindow *mainwin)
1517 path = input_dialog(_("Add mbox mailbox"),
1518 _("Input the location of mailbox."),
1523 if (folder_find_from_path(path)) {
1524 alertpanel_error(_("The mailbox `%s' already exists."), path);
1530 if (!strcmp(path, "Mail"))
1531 folder = folder_new(F_MBOX, _("Mailbox"), path);
1535 folder = folder_new(F_MBOX, g_basename(path), path);
1538 if (folder->create_tree(folder) < 0) {
1539 alertpanel_error(_("Creation of the mailbox failed."));
1540 folder_destroy(folder);
1546 item = folder_item_new(folder, folder->name, NULL);
1547 item->folder = folder;
1548 folder->node = g_node_new(item);
1550 folder_create_folder(item, "inbox");
1551 folder_create_folder(item, "outbox");
1552 folder_create_folder(item, "queue");
1553 folder_create_folder(item, "draft");
1554 folder_create_folder(item, "trash");
1556 folderview_set(mainwin->folderview);
1559 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1561 SensitiveCond state = 0;
1562 SummarySelection selection;
1563 FolderItem *item = mainwin->summaryview->folder_item;
1564 GList *account_list = account_get_list();
1566 selection = summary_get_selection_type(mainwin->summaryview);
1568 if (mainwin->lock_count == 0)
1569 state |= M_UNLOCKED;
1570 if (selection != SUMMARY_NONE)
1571 state |= M_MSG_EXIST;
1572 if (item && item->path && item->parent && !item->no_select) {
1574 /* if (item->folder->type != F_NEWS) */
1575 state |= M_ALLOW_DELETE;
1577 if (prefs_common.immediate_exec == 0
1578 && mainwin->lock_count == 0)
1579 state |= M_DELAY_EXEC;
1581 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1582 || selection != SUMMARY_NONE)
1583 state |= M_HIDE_READ_MSG;
1585 if (mainwin->summaryview->threaded)
1586 state |= M_THREADED;
1588 state |= M_UNTHREADED;
1589 if (selection == SUMMARY_SELECTED_SINGLE ||
1590 selection == SUMMARY_SELECTED_MULTIPLE)
1591 state |= M_TARGET_EXIST;
1592 if (selection == SUMMARY_SELECTED_SINGLE)
1593 state |= M_SINGLE_TARGET_EXIST;
1594 if (mainwin->summaryview->folder_item &&
1595 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1598 state |= M_NOT_NEWS;
1599 if (selection == SUMMARY_SELECTED_SINGLE &&
1601 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1602 item->stype == F_QUEUE)))
1603 state |= M_ALLOW_REEDIT;
1605 state |= M_HAVE_ACCOUNT;
1607 for ( ; account_list != NULL; account_list = account_list->next) {
1608 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1609 state |= M_HAVE_NEWS_ACCOUNT;
1614 if (inc_is_active())
1615 state |= M_INC_ACTIVE;
1622 void main_window_set_menu_sensitive(MainWindow *mainwin)
1624 GtkItemFactory *ifactory = mainwin->menu_factory;
1625 SensitiveCond state;
1627 GtkWidget *menuitem;
1628 SummaryView *summaryview;
1632 static const struct {
1636 {"/File/Add mailbox..." , M_UNLOCKED},
1637 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1638 {"/File/Check for new messages in all folders", M_UNLOCKED},
1639 {"/File/Folder" , M_UNLOCKED},
1640 {"/File/Import mbox file..." , M_UNLOCKED},
1641 {"/File/Export to mbox file..." , M_UNLOCKED},
1642 {"/File/Empty trash" , M_UNLOCKED},
1643 {"/File/Work offline" , M_UNLOCKED},
1645 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1646 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1647 /* {"/File/Close" , M_UNLOCKED}, */
1648 {"/File/Exit" , M_UNLOCKED},
1650 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1652 {"/View/Sort" , M_EXEC},
1653 {"/View/Thread view" , M_EXEC},
1654 {"/View/Expand all threads" , M_MSG_EXIST},
1655 {"/View/Collapse all threads" , M_MSG_EXIST},
1656 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1657 {"/View/Go to/Prev message" , M_MSG_EXIST},
1658 {"/View/Go to/Next message" , M_MSG_EXIST},
1659 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1660 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1661 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1662 {"/View/Go to/Next new message" , M_MSG_EXIST},
1663 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1664 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1665 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1666 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1667 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1668 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1669 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1671 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1672 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1673 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1674 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1675 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1676 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1677 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1678 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1679 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1680 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1681 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1682 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1683 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1684 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1685 {"/Message/Mark" , M_TARGET_EXIST},
1687 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1688 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1689 {"/Tools/Harvest addresses" , M_UNLOCKED},
1690 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1691 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1692 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1693 {"/Tools/Execute" , M_DELAY_EXEC},
1694 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1696 {"/Configuration", M_UNLOCKED},
1701 state = main_window_get_current_state(mainwin);
1703 for (i = 0; entry[i].entry != NULL; i++) {
1704 sensitive = ((entry[i].cond & state) == entry[i].cond);
1705 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1708 main_window_menu_callback_block(mainwin);
1710 #define SET_CHECK_MENU_ACTIVE(path, active) \
1712 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1713 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1716 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1717 messageview_is_visible(mainwin->messageview));
1719 summaryview = mainwin->summaryview;
1720 menu_path = "/View/Sort/Don't sort";
1722 switch (summaryview->sort_key) {
1723 case SORT_BY_NUMBER:
1724 menu_path = "/View/Sort/by number"; break;
1726 menu_path = "/View/Sort/by size"; break;
1728 menu_path = "/View/Sort/by date"; break;
1730 menu_path = "/View/Sort/by from"; break;
1731 case SORT_BY_SUBJECT:
1732 menu_path = "/View/Sort/by subject"; break;
1734 menu_path = "/View/Sort/by color label"; break;
1736 menu_path = "/View/Sort/by mark"; break;
1737 case SORT_BY_UNREAD:
1738 menu_path = "/View/Sort/by unread"; break;
1740 menu_path = "/View/Sort/by attachment"; break;
1742 menu_path = "/View/Sort/by score"; break;
1743 case SORT_BY_LOCKED:
1744 menu_path = "/View/Sort/by locked"; break;
1747 menu_path = "/View/Sort/Don't sort"; break;
1749 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1751 if (summaryview->sort_type == SORT_ASCENDING) {
1752 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1754 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1757 if (summaryview->sort_key != SORT_BY_NONE) {
1758 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1759 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1761 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1762 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1765 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1766 mainwin->messageview->textview->show_all_headers);
1767 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1769 #undef SET_CHECK_MENU_ACTIVE
1771 main_window_menu_callback_unblock(mainwin);
1774 void main_window_popup(MainWindow *mainwin)
1780 gdk_window_get_origin(mainwin->window->window, &x, &y);
1781 sx = gdk_screen_width();
1782 sy = gdk_screen_height();
1783 x %= sx; if (x < 0) x = 0;
1784 y %= sy; if (y < 0) y = 0;
1785 gdk_window_move(mainwin->window->window, x, y);
1786 gdk_window_raise(mainwin->window->window);
1787 gdk_window_show(mainwin->window->window);
1789 debug_print("window position: x = %d, y = %d\n", x, y);
1791 switch (mainwin->type) {
1792 case SEPARATE_FOLDER:
1793 widget = mainwin->win.sep_folder.folderwin;
1794 gdk_window_get_origin(widget->window, &x, &y);
1795 x %= sx; if (x < 0) x = 0;
1796 y %= sy; if (y < 0) y = 0;
1797 gdk_window_move(widget->window, x, y);
1798 gdk_window_raise(widget->window);
1800 case SEPARATE_MESSAGE:
1801 widget = mainwin->win.sep_message.messagewin;
1802 gdk_window_get_origin(widget->window, &x, &y);
1803 x %= sx; if (x < 0) x = 0;
1804 y %= sy; if (y < 0) y = 0;
1805 gdk_window_move(widget->window, x, y);
1806 gdk_window_raise(widget->window);
1809 widget = mainwin->win.sep_both.folderwin;
1810 gdk_window_get_origin(widget->window, &x, &y);
1811 x %= sx; if (x < 0) x = 0;
1812 y %= sy; if (y < 0) y = 0;
1813 gdk_window_move(widget->window, x, y);
1814 gdk_window_raise(widget->window);
1815 widget = mainwin->win.sep_both.messagewin;
1816 gdk_window_get_origin(widget->window, &x, &y);
1817 x %= sx; if (x < 0) x = 0;
1818 y %= sy; if (y < 0) y = 0;
1819 gdk_window_move(widget->window, x, y);
1820 gdk_window_raise(widget->window);
1827 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1829 GtkWidget *folderwin = NULL;
1830 GtkWidget *messagewin = NULL;
1833 GtkWidget *vbox_body = mainwin->vbox_body;
1834 GtkItemFactory *ifactory = mainwin->menu_factory;
1835 GtkWidget *menuitem;
1837 debug_print("Setting widgets...");
1839 /* create separated window(s) if needed */
1840 if (type & SEPARATE_FOLDER) {
1841 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1842 gtk_window_set_title(GTK_WINDOW(folderwin),
1843 _("Sylpheed - Folder View"));
1844 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1845 "folder_view", "Sylpheed");
1846 gtk_window_set_policy(GTK_WINDOW(folderwin),
1848 gtk_widget_set_usize(folderwin, -1,
1849 prefs_common.mainview_height);
1850 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1852 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1853 GTK_SIGNAL_FUNC(folder_window_close_cb),
1856 if (type & SEPARATE_MESSAGE) {
1857 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1858 gtk_window_set_title(GTK_WINDOW(messagewin),
1859 _("Sylpheed - Message View"));
1860 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1861 "message_view", "Sylpheed");
1862 gtk_window_set_policy(GTK_WINDOW(messagewin),
1864 gtk_widget_set_usize
1865 (messagewin, prefs_common.mainview_width,
1866 prefs_common.mainview_height
1867 - prefs_common.summaryview_height
1868 + DEFAULT_HEADERVIEW_HEIGHT);
1869 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1871 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1872 GTK_SIGNAL_FUNC(message_window_close_cb),
1878 hpaned = gtk_hpaned_new();
1879 gtk_widget_show(hpaned);
1880 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1881 gtk_paned_add1(GTK_PANED(hpaned),
1882 GTK_WIDGET_PTR(mainwin->folderview));
1884 vpaned = gtk_vpaned_new();
1885 if (messageview_is_visible(mainwin->messageview)) {
1886 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1887 gtk_paned_add1(GTK_PANED(vpaned),
1888 GTK_WIDGET_PTR(mainwin->summaryview));
1890 gtk_paned_add2(GTK_PANED(hpaned),
1891 GTK_WIDGET_PTR(mainwin->summaryview));
1892 gtk_widget_ref(vpaned);
1894 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1895 prefs_common.summaryview_width,
1896 prefs_common.summaryview_height);
1897 gtk_paned_add2(GTK_PANED(vpaned),
1898 GTK_WIDGET_PTR(mainwin->messageview));
1899 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1900 prefs_common.mainview_width, -1);
1901 gtk_widget_set_usize(mainwin->window,
1902 prefs_common.folderview_width +
1903 prefs_common.mainview_width,
1904 prefs_common.mainwin_height);
1905 gtk_widget_show_all(vpaned);
1907 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1908 * lose track of its visibility state */
1909 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1910 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1912 mainwin->win.sep_none.hpaned = hpaned;
1913 mainwin->win.sep_none.vpaned = vpaned;
1915 /* remove headerview if not in prefs */
1916 headerview_set_visibility(mainwin->messageview->headerview,
1917 prefs_common.display_header_pane);
1919 case SEPARATE_FOLDER:
1920 vpaned = gtk_vpaned_new();
1921 if (messageview_is_visible(mainwin->messageview)) {
1922 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1924 gtk_paned_add1(GTK_PANED(vpaned),
1925 GTK_WIDGET_PTR(mainwin->summaryview));
1927 gtk_box_pack_start(GTK_BOX(vbox_body),
1928 GTK_WIDGET_PTR(mainwin->summaryview),
1930 gtk_widget_ref(vpaned);
1932 gtk_paned_add2(GTK_PANED(vpaned),
1933 GTK_WIDGET_PTR(mainwin->messageview));
1934 gtk_widget_show_all(vpaned);
1935 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1936 prefs_common.summaryview_width,
1937 prefs_common.summaryview_height);
1938 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1939 prefs_common.mainview_width, -1);
1940 gtk_widget_set_usize(mainwin->window,
1941 prefs_common.mainview_width,
1942 prefs_common.mainview_height);
1944 gtk_container_add(GTK_CONTAINER(folderwin),
1945 GTK_WIDGET_PTR(mainwin->folderview));
1947 mainwin->win.sep_folder.folderwin = folderwin;
1948 mainwin->win.sep_folder.vpaned = vpaned;
1950 gtk_widget_show_all(folderwin);
1952 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1953 * lose track of its visibility state */
1954 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1955 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1957 /* remove headerview if not in prefs */
1958 headerview_set_visibility(mainwin->messageview->headerview,
1959 prefs_common.display_header_pane);
1962 case SEPARATE_MESSAGE:
1963 hpaned = gtk_hpaned_new();
1964 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1966 gtk_paned_add1(GTK_PANED(hpaned),
1967 GTK_WIDGET_PTR(mainwin->folderview));
1968 gtk_paned_add2(GTK_PANED(hpaned),
1969 GTK_WIDGET_PTR(mainwin->summaryview));
1970 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1971 prefs_common.summaryview_width,
1972 prefs_common.summaryview_height);
1973 gtk_widget_set_usize(mainwin->window,
1974 prefs_common.folderview_width +
1975 prefs_common.mainview_width,
1976 prefs_common.mainwin_height);
1977 gtk_widget_show_all(hpaned);
1978 gtk_container_add(GTK_CONTAINER(messagewin),
1979 GTK_WIDGET_PTR(mainwin->messageview));
1981 mainwin->win.sep_message.messagewin = messagewin;
1982 mainwin->win.sep_message.hpaned = hpaned;
1984 gtk_widget_show_all(messagewin);
1986 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1987 * lose track of its visibility state */
1988 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1989 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1992 gtk_box_pack_start(GTK_BOX(vbox_body),
1993 GTK_WIDGET_PTR(mainwin->summaryview),
1995 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1996 prefs_common.summaryview_width,
1997 prefs_common.summaryview_height);
1998 gtk_widget_set_usize(mainwin->window,
1999 prefs_common.mainview_width,
2000 prefs_common.mainwin_height);
2001 gtk_container_add(GTK_CONTAINER(folderwin),
2002 GTK_WIDGET_PTR(mainwin->folderview));
2003 gtk_container_add(GTK_CONTAINER(messagewin),
2004 GTK_WIDGET_PTR(mainwin->messageview));
2006 mainwin->win.sep_both.folderwin = folderwin;
2007 mainwin->win.sep_both.messagewin = messagewin;
2009 gtk_widget_show_all(folderwin);
2010 gtk_widget_show_all(messagewin);
2012 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2013 * lose track of its visibility state */
2014 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2015 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2019 /* rehide quick search if necessary */
2020 if (!prefs_common.show_searchbar)
2021 gtk_widget_hide(mainwin->summaryview->hbox_search);
2023 mainwin->type = type;
2025 mainwin->messageview->visible = TRUE;
2027 /* toggle menu state */
2028 menuitem = gtk_item_factory_get_item
2029 (ifactory, "/View/Show or hide/Folder tree");
2030 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2031 menuitem = gtk_item_factory_get_item
2032 (ifactory, "/View/Show or hide/Message view");
2033 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2035 menuitem = gtk_item_factory_get_item
2036 (ifactory, "/View/Separate folder tree");
2037 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2038 ((type & SEPARATE_FOLDER) != 0));
2039 menuitem = gtk_item_factory_get_item
2040 (ifactory, "/View/Separate message view");
2041 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2042 ((type & SEPARATE_MESSAGE) != 0));
2044 debug_print("done.\n");
2047 void main_window_destroy_all(void)
2049 while (mainwin_list != NULL) {
2050 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2052 /* free toolbar stuff */
2053 toolbar_clear_list(TOOLBAR_MAIN);
2054 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->t_action_list);
2055 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->t_item_list);
2057 g_free(mainwin->toolbar);
2060 mainwin_list = g_list_remove(mainwin_list, mainwin);
2062 g_list_free(mainwin_list);
2066 static void toolbar_account_button_pressed(GtkWidget *widget,
2067 GdkEventButton *event,
2070 MainWindow *mainwin = (MainWindow *)data;
2073 if (event->button != 3) return;
2075 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2076 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2079 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2080 menu_button_position, widget,
2081 event->button, event->time);
2085 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2088 MainWindow *mainwin = (MainWindow *)data;
2092 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2093 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2096 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2097 menu_button_position, widget,
2098 event->button, event->time);
2101 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2103 MainWindow *mainwin = (MainWindow *)data;
2106 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2107 if (!button) return;
2108 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2109 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2110 manage_window_focus_in(mainwin->window, NULL, NULL);
2113 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2116 MainWindow *mainwin = (MainWindow *)data;
2118 if (mainwin->lock_count == 0)
2119 app_exit_cb(data, 0, widget);
2124 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2127 MainWindow *mainwin = (MainWindow *)data;
2128 GtkWidget *menuitem;
2130 menuitem = gtk_item_factory_get_item
2131 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2132 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2137 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2140 MainWindow *mainwin = (MainWindow *)data;
2141 GtkWidget *menuitem;
2143 menuitem = gtk_item_factory_get_item
2144 (mainwin->menu_factory, "/View/Show or hide/Message view");
2145 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2150 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2153 main_window_add_mailbox(mainwin);
2156 static void add_mbox_cb(MainWindow *mainwin, guint action,
2159 main_window_add_mbox(mainwin);
2162 static void update_folderview_cb(MainWindow *mainwin, guint action,
2165 summary_show(mainwin->summaryview, NULL);
2166 folderview_check_new_all();
2169 static void new_folder_cb(MainWindow *mainwin, guint action,
2172 folderview_new_folder(mainwin->folderview);
2175 static void rename_folder_cb(MainWindow *mainwin, guint action,
2178 folderview_rename_folder(mainwin->folderview);
2181 static void delete_folder_cb(MainWindow *mainwin, guint action,
2184 folderview_delete_folder(mainwin->folderview);
2187 static void import_mbox_cb(MainWindow *mainwin, guint action,
2190 import_mbox(mainwin->summaryview->folder_item);
2193 static void export_mbox_cb(MainWindow *mainwin, guint action,
2196 export_mbox(mainwin->summaryview->folder_item);
2199 static void empty_trash_cb(MainWindow *mainwin, guint action,
2202 main_window_empty_trash(mainwin, TRUE);
2205 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2207 summary_save_as(mainwin->summaryview);
2210 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2212 summary_print(mainwin->summaryview);
2215 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2217 if (prefs_common.confirm_on_exit) {
2218 if (alertpanel(_("Exit"), _("Exit this program?"),
2219 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2221 manage_window_focus_in(mainwin->window, NULL, NULL);
2224 app_will_exit(widget, mainwin);
2227 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2230 summary_search(mainwin->summaryview);
2232 message_search(mainwin->messageview);
2235 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2240 active = GTK_CHECK_MENU_ITEM(widget)->active;
2242 switch (mainwin->type) {
2244 case SEPARATE_MESSAGE:
2247 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2249 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2252 case SEPARATE_FOLDER:
2253 debug_print("separate folder\n");
2255 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2257 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2261 gtk_widget_show(mainwin->win.sep_both.folderwin);
2263 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2268 static void toggle_message_cb(MainWindow *mainwin, guint action,
2273 active = GTK_CHECK_MENU_ITEM(widget)->active;
2275 if (active != messageview_is_visible(mainwin->messageview))
2276 summary_toggle_view(mainwin->summaryview);
2279 /* Toolbar handling */
2280 static void toolbar_inc_cb(GtkWidget *widget,
2283 MainWindow *mainwin = (MainWindow *)data;
2285 inc_mail_cb(mainwin, 0, NULL);
2288 static void toolbar_inc_all_cb(GtkWidget *widget,
2291 MainWindow *mainwin = (MainWindow *)data;
2293 inc_all_account_mail_cb(mainwin, 0, NULL);
2296 static void toolbar_send_cb(GtkWidget *widget,
2299 MainWindow *mainwin = (MainWindow *)data;
2301 send_queue_cb(mainwin, 0, NULL);
2304 static void toolbar_compose_cb(GtkWidget *widget,
2307 MainWindow *mainwin = (MainWindow *)data;
2309 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
2310 compose_news_cb(mainwin, 0, NULL);
2312 compose_mail_cb(mainwin, 0, NULL);
2315 static void toolbar_reply_cb(GtkWidget *widget,
2318 MainWindow *mainwin = (MainWindow *)data;
2320 if (prefs_common.default_reply_list)
2322 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
2323 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
2327 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2328 : COMPOSE_REPLY_WITHOUT_QUOTE,
2332 static void toolbar_reply_to_all_cb(GtkWidget *widget,
2335 MainWindow *mainwin = (MainWindow *)data;
2338 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2339 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2343 static void toolbar_reply_to_list_cb(GtkWidget *widget,
2346 MainWindow *mainwin = (MainWindow *)data;
2349 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
2350 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
2354 static void toolbar_reply_to_sender_cb(GtkWidget *widget,
2357 MainWindow *mainwin = (MainWindow *)data;
2360 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2361 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2365 static void toolbar_forward_cb(GtkWidget *widget,
2368 MainWindow *mainwin = (MainWindow *)data;
2370 if (prefs_common.forward_as_attachment)
2371 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2373 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2376 static void toolbar_delete_cb(GtkWidget *widget,
2379 MainWindow *mainwin = (MainWindow *)data;
2381 summary_delete(mainwin->summaryview);
2384 static void toolbar_exec_cb(GtkWidget *widget,
2387 MainWindow *mainwin = (MainWindow *)data;
2389 summary_execute(mainwin->summaryview);
2392 static void toolbar_next_unread_cb(GtkWidget *widget,
2395 MainWindow *mainwin = (MainWindow *)data;
2397 next_unread_cb(mainwin, 0, NULL);
2400 /* popup callback functions */
2401 static void toolbar_reply_popup_cb(GtkWidget *widget,
2402 GdkEventButton *event,
2405 MainWindow *mainwindow = (MainWindow *) data;
2409 if (event->button == 3) {
2410 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2411 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->reply_popup), NULL, NULL,
2412 menu_button_position, widget,
2413 event->button, event->time);
2417 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2419 MainWindow *mainwin = (MainWindow *)data;
2421 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->reply_btn), GTK_RELIEF_NONE);
2422 manage_window_focus_in(mainwin->window, NULL, NULL);
2425 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2427 MainWindow *mainwindow = (MainWindow *) data;
2431 if (event->button == 3) {
2432 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2433 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replyall_popup), NULL, NULL,
2434 menu_button_position, widget,
2435 event->button, event->time);
2439 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2441 MainWindow *mainwin = (MainWindow *)data;
2443 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replyall_btn), GTK_RELIEF_NONE);
2444 manage_window_focus_in(mainwin->window, NULL, NULL);
2447 static void toolbar_reply_to_list_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2449 MainWindow *mainwindow = (MainWindow *) data;
2453 if (event->button == 3) {
2454 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2455 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replylist_popup), NULL, NULL,
2456 menu_button_position, widget,
2457 event->button, event->time);
2461 static void toolbar_reply_to_list_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2463 MainWindow *mainwin = (MainWindow *)data;
2465 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replylist_btn), GTK_RELIEF_NONE);
2466 manage_window_focus_in(mainwin->window, NULL, NULL);
2469 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2471 MainWindow *mainwindow = (MainWindow *) data;
2475 if (event->button == 3) {
2476 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2477 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replysender_popup), NULL, NULL,
2478 menu_button_position, widget,
2479 event->button, event->time);
2483 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2485 MainWindow *mainwin = (MainWindow *)data;
2487 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replysender_btn), GTK_RELIEF_NONE);
2488 manage_window_focus_in(mainwin->window, NULL, NULL);
2491 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2493 MainWindow *mainwindow = (MainWindow *) data;
2497 if (event->button == 3) {
2498 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2499 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->fwd_popup), NULL, NULL,
2500 menu_button_position, widget,
2501 event->button, event->time);
2505 static void toolbar_forward_popup_closed_cb (GtkMenuShell *menu_shell,
2508 MainWindow *mainwin = (MainWindow *)data;
2510 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->fwd_btn), GTK_RELIEF_NONE);
2511 manage_window_focus_in(mainwin->window, NULL, NULL);
2514 static void activate_compose_button (MainToolbar *toolbar,
2516 ComposeButtonType type)
2518 if ((!toolbar->compose_mail_btn) || (!toolbar->compose_news_btn))
2521 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? toolbar->compose_mail_btn
2522 : toolbar->compose_news_btn);
2523 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? toolbar->compose_news_btn
2524 : toolbar->compose_mail_btn);
2525 toolbar->compose_btn_type = type;
2528 void toolbar_set_compose_button(MainToolbar *toolbar,
2529 ComposeButtonType compose_btn_type)
2531 if (toolbar->compose_btn_type != compose_btn_type)
2532 activate_compose_button(toolbar,
2533 prefs_common.toolbar_style,
2537 static void toolbar_buttons_cb(GtkWidget *widget,
2538 ToolbarItem *t_item)
2542 void (*func)(GtkWidget *widget, gpointer data);
2543 } toolbar_action[] = {
2544 { A_RECEIVE_ALL, toolbar_inc_all_cb },
2545 { A_RECEIVE_CUR, toolbar_inc_cb },
2546 { A_SEND_QUEUED, toolbar_send_cb },
2547 { A_COMPOSE_EMAIL, toolbar_compose_cb },
2548 { A_REPLY_MESSAGE, toolbar_reply_cb },
2549 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
2550 { A_REPLY_ALL, toolbar_reply_to_all_cb },
2551 { A_REPLY_ML, toolbar_reply_to_list_cb },
2552 { A_FORWARD, toolbar_forward_cb },
2553 { A_DELETE, toolbar_delete_cb },
2554 { A_EXECUTE, toolbar_exec_cb },
2555 { A_GOTO_NEXT, toolbar_next_unread_cb },
2556 { A_SYL_ACTIONS, toolbar_actions_execute_cb },
2558 { A_COMPOSE_NEWS, toolbar_compose_cb },
2559 { A_SEPARATOR, NULL }};
2561 gint num_items = sizeof(toolbar_action)/sizeof(toolbar_action[0]);
2564 for (i = A_RECEIVE_ALL; i < num_items; i++) {
2566 if (toolbar_action[i].index == t_item->index) {
2567 MainWindow *mainwin = (MainWindow*)t_item->parent;
2568 toolbar_action[i].func(widget, mainwin);
2574 static void toolbar_actions_execute_cb(GtkWidget *widget,
2577 MainWindow *mainwin = (MainWindow*)data;
2579 toolbar_action_execute(widget, mainwin->toolbar->t_action_list, data, TOOLBAR_MAIN);
2582 void toolbar_set_sensitive(MainWindow *mainwin)
2584 SensitiveCond state;
2586 MainToolbar *toolbar = mainwin->toolbar;
2588 GSList *entry_list = NULL;
2590 typedef struct _Entry Entry;
2597 #define SET_WIDGET_COND(w, c) \
2599 Entry *e = g_new0(Entry, 1); \
2602 entry_list = g_slist_append(entry_list, e); \
2605 SET_WIDGET_COND(toolbar->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2606 SET_WIDGET_COND(toolbar->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2607 SET_WIDGET_COND(toolbar->compose_news_btn, M_HAVE_ACCOUNT);
2608 SET_WIDGET_COND(toolbar->reply_btn,
2609 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2610 SET_WIDGET_COND(toolbar->replyall_btn,
2611 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2612 SET_WIDGET_COND(toolbar->replylist_btn,
2613 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2614 SET_WIDGET_COND(toolbar->replysender_btn,
2615 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2616 SET_WIDGET_COND(toolbar->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
2618 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST);
2619 SET_WIDGET_COND(toolbar->delete_btn,
2620 M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
2621 SET_WIDGET_COND(toolbar->exec_btn, M_DELAY_EXEC);
2623 for (cur = toolbar->t_action_list; cur != NULL; cur = cur->next) {
2624 ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
2626 SET_WIDGET_COND(act->widget, M_TARGET_EXIST|M_UNLOCKED);
2629 #undef SET_WIDGET_COND
2631 state = main_window_get_current_state(mainwin);
2633 for (cur = entry_list; cur != NULL; cur = cur->next) {
2634 Entry *e = (Entry*) cur->data;
2636 if (e->widget != NULL) {
2637 sensitive = ((e->cond & state) == e->cond);
2638 gtk_widget_set_sensitive(e->widget, sensitive);
2642 while (entry_list != NULL) {
2643 Entry *e = (Entry*) entry_list->data;
2647 entry_list = g_slist_remove(entry_list, e);
2650 g_slist_free(entry_list);
2652 activate_compose_button(toolbar,
2653 prefs_common.toolbar_style,
2654 toolbar->compose_btn_type);
2657 static void toolbar_update(MainWindow *mainwin)
2659 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox),
2660 GTK_WIDGET(mainwin->toolbar->toolbar));
2662 mainwin->toolbar->toolbar = NULL;
2663 mainwin->toolbar->get_btn = NULL;
2664 mainwin->toolbar->getall_btn = NULL;
2665 mainwin->toolbar->send_btn = NULL;
2666 mainwin->toolbar->compose_mail_btn = NULL;
2667 mainwin->toolbar->compose_news_btn = NULL;
2668 mainwin->toolbar->reply_btn = NULL;
2669 mainwin->toolbar->replyall_btn = NULL;
2670 mainwin->toolbar->replylist_btn = NULL;
2671 mainwin->toolbar->replysender_btn = NULL;
2672 mainwin->toolbar->fwd_btn = NULL;
2673 mainwin->toolbar->delete_btn = NULL;
2674 mainwin->toolbar->next_btn = NULL;
2675 mainwin->toolbar->exec_btn = NULL;
2677 toolbar_clear_list(TOOLBAR_MAIN);
2678 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->t_action_list);
2679 toolbar_create(mainwin, mainwin->handlebox);
2680 toolbar_set_sensitive(mainwin);
2684 static void toolbar_create(MainWindow *mainwin,
2685 GtkWidget *container)
2687 ToolbarItem *toolbar_item;
2690 GtkWidget *icon_wid = NULL;
2691 GtkWidget *icon_news = NULL;
2692 GtkWidget *item_news = NULL;
2694 GtkTooltips *toolbar_tips;
2695 ToolbarSylpheedActions *t_action_item;
2697 GSList *toolbar_list;
2699 guint n_menu_entries;
2700 GtkWidget *reply_popup;
2701 GtkWidget *replyall_popup;
2702 GtkWidget *replylist_popup;
2703 GtkWidget *replysender_popup;
2704 GtkWidget *fwd_popup;
2706 toolbar_tips = gtk_tooltips_new();
2708 if (mainwin->toolbar != NULL) {
2709 toolbar_clear_list(TOOLBAR_MAIN);
2710 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->t_action_list);
2711 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->t_item_list);
2712 g_free(mainwin->toolbar);
2715 toolbar_read_config_file(TOOLBAR_MAIN);
2716 toolbar_list = toolbar_get_list(TOOLBAR_MAIN);
2718 mainwin->toolbar = g_new0(MainToolbar, 1);
2720 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
2722 gtk_container_add(GTK_CONTAINER(container), toolbar);
2723 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
2724 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
2725 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
2726 GTK_TOOLBAR_SPACE_LINE);
2728 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2730 if (g_strcasecmp(((ToolbarItem*)cur->data)->file, SEPARATOR) == 0) {
2731 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2735 toolbar_item = g_new0(ToolbarItem, 1);
2736 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2737 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2738 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2740 toolbar_item->parent = (gpointer)mainwin;
2742 /* collect toolbar items in list to keep track */
2743 mainwin->toolbar->t_item_list = g_slist_append(mainwin->toolbar->t_item_list,
2746 icon_wid = stock_pixmap_widget(container, stock_pixmap_get_icon(toolbar_item->file));
2747 item = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2751 icon_wid, toolbar_buttons_cb,
2754 switch (toolbar_item->index) {
2756 mainwin->toolbar->getall_btn = item;
2757 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2758 mainwin->toolbar->getall_btn,
2759 _("Receive Mail on all Accounts"), NULL);
2762 mainwin->toolbar->get_btn = item;
2763 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2764 mainwin->toolbar->get_btn,
2765 _("Receive Mail on current Account"), NULL);
2768 mainwin->toolbar->send_btn = item;
2769 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2770 mainwin->toolbar->send_btn,
2771 _("Send Queued Message(s)"), NULL);
2773 case A_COMPOSE_EMAIL:
2774 icon_news = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2775 item_news = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2779 icon_news, toolbar_buttons_cb,
2781 mainwin->toolbar->compose_mail_btn = item;
2782 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2783 mainwin->toolbar->compose_mail_btn,
2784 _("Compose Email"), NULL);
2785 mainwin->toolbar->compose_news_btn = item_news;
2786 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2787 mainwin->toolbar->compose_news_btn,
2788 _("Compose News"), NULL);
2790 case A_REPLY_MESSAGE:
2791 mainwin->toolbar->reply_btn = item;
2792 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2793 mainwin->toolbar->reply_btn,
2794 _("Reply to Message"), NULL);
2795 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->reply_btn),
2796 "button_press_event",
2797 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2799 n_menu_entries = sizeof(reply_popup_entries) /
2800 sizeof(reply_popup_entries[0]);
2801 reply_popup = popupmenu_create(mainwin->window, reply_popup_entries, n_menu_entries,
2802 "<ReplyPopup>", mainwin);
2803 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
2804 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
2805 mainwin->toolbar->reply_popup = reply_popup;
2807 case A_REPLY_SENDER:
2808 mainwin->toolbar->replysender_btn = item;
2809 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2810 mainwin->toolbar->replysender_btn,
2811 _("Reply to Sender"), NULL);
2812 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replysender_btn),
2813 "button_press_event",
2814 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2816 n_menu_entries = sizeof(replysender_popup_entries) /
2817 sizeof(replysender_popup_entries[0]);
2818 replysender_popup = popupmenu_create(mainwin->window,
2819 replysender_popup_entries, n_menu_entries,
2820 "<ReplySenderPopup>", mainwin);
2821 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
2822 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
2823 mainwin->toolbar->replysender_popup = replysender_popup;
2826 mainwin->toolbar->replyall_btn = item;
2827 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2828 mainwin->toolbar->replyall_btn,
2829 _("Reply to All"), NULL);
2830 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replyall_btn),
2831 "button_press_event",
2832 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2834 n_menu_entries = sizeof(replyall_popup_entries) /
2835 sizeof(replyall_popup_entries[0]);
2836 replyall_popup = popupmenu_create(mainwin->window,
2837 replyall_popup_entries, n_menu_entries,
2838 "<ReplyAllPopup>", mainwin);
2839 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
2840 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
2841 mainwin->toolbar->replyall_popup = replyall_popup;
2844 mainwin->toolbar->replylist_btn = item;
2845 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2846 mainwin->toolbar->replylist_btn,
2847 _("Reply to Mailing-list"), NULL);
2848 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replylist_btn),
2849 "button_press_event",
2850 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_cb),
2852 n_menu_entries = sizeof(replylist_popup_entries) /
2853 sizeof(replylist_popup_entries[0]);
2854 replylist_popup = popupmenu_create(mainwin->window,
2855 replylist_popup_entries, n_menu_entries,
2856 "<ReplyMlPopup>", mainwin);
2857 gtk_signal_connect(GTK_OBJECT(replylist_popup), "selection_done",
2858 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_closed_cb), mainwin);
2859 mainwin->toolbar->replylist_popup = replylist_popup;
2862 mainwin->toolbar->fwd_btn = item;
2863 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2864 mainwin->toolbar->fwd_btn,
2865 _("Forward Message"), NULL);
2866 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->fwd_btn),
2867 "button_press_event",
2868 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2870 n_menu_entries = sizeof(fwd_popup_entries) /
2871 sizeof(fwd_popup_entries[0]);
2872 fwd_popup = popupmenu_create(mainwin->window,
2873 fwd_popup_entries, n_menu_entries,
2874 "<ForwardPopup>", mainwin);
2875 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
2876 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
2877 mainwin->toolbar->fwd_popup = fwd_popup;
2880 mainwin->toolbar->delete_btn = item;
2881 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2882 mainwin->toolbar->delete_btn,
2883 _("Delete Message"), NULL);
2886 mainwin->toolbar->exec_btn = item;
2887 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2888 mainwin->toolbar->exec_btn,
2889 _("Execute"), NULL);
2892 mainwin->toolbar->next_btn = item;
2893 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2894 mainwin->toolbar->next_btn,
2895 _("Goto Next Message"), NULL);
2898 t_action_item = g_new0(ToolbarSylpheedActions, 1);
2899 t_action_item->widget = item;
2900 t_action_item->name = g_strdup(toolbar_item->text);
2902 mainwin->toolbar->t_action_list =
2903 g_slist_append(mainwin->toolbar->t_action_list,
2906 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2908 t_action_item->name, NULL);
2910 gtk_widget_show(item);
2917 mainwin->toolbar->toolbar = toolbar;
2919 activate_compose_button(mainwin->toolbar,
2920 prefs_common.toolbar_style,
2921 mainwin->toolbar->compose_btn_type);
2923 gtk_widget_show_all(toolbar);
2926 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2929 switch ((ToolbarStyle)action) {
2931 gtk_widget_hide(mainwin->handlebox);
2933 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2937 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2941 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2946 if (action != TOOLBAR_NONE) {
2947 gtk_widget_show(mainwin->handlebox);
2948 gtk_widget_queue_resize(mainwin->handlebox);
2951 mainwin->toolbar_style = (ToolbarStyle)action;
2952 prefs_common.toolbar_style = (ToolbarStyle)action;
2955 /* END Toolbar Stuff */
2957 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2960 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2961 gtk_widget_show(mainwin->hbox_stat);
2962 prefs_common.show_statusbar = TRUE;
2964 gtk_widget_hide(mainwin->hbox_stat);
2965 prefs_common.show_statusbar = FALSE;
2969 static void separate_widget_cb(MainWindow *mainwin, guint action,
2974 if (GTK_CHECK_MENU_ITEM(widget)->active)
2975 type = mainwin->type | action;
2977 type = mainwin->type & ~action;
2979 main_window_separation_change(mainwin, type);
2981 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2982 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2985 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2988 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2990 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2993 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2995 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
2998 static void online_switch_clicked (GtkButton *btn, gpointer data)
3000 MainWindow *mainwin;
3001 GtkItemFactory *ifactory;
3002 GtkCheckMenuItem *menuitem;
3004 mainwin = (MainWindow *) data;
3006 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3007 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3009 g_return_if_fail(mainwin != NULL);
3010 g_return_if_fail(menuitem != NULL);
3012 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3014 gtk_widget_hide (mainwin->online_switch);
3015 gtk_widget_show (mainwin->offline_switch);
3016 menuitem->active = TRUE;
3017 prefs_common.work_offline = TRUE;
3018 inc_autocheck_timer_remove();
3021 gtk_widget_hide (mainwin->offline_switch);
3022 gtk_widget_show (mainwin->online_switch);
3023 menuitem->active = FALSE;
3024 prefs_common.work_offline = FALSE;
3025 inc_autocheck_timer_set();
3029 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3032 addressbook_open(NULL);
3035 static void log_window_show_cb(MainWindow *mainwin, guint action,
3038 log_window_show(mainwin->logwin);
3041 static void sel_download_cb(MainWindow *mainwin, guint action,
3044 selective_download(mainwin);
3047 static void prefs_toolbar_cb(MainWindow *mainwin, guint action,
3050 prefs_toolbar(action);
3054 void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3056 inc_mail(mainwin, prefs_common.newmail_notify_manu);
3059 void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
3062 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
3065 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3070 void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3074 if (prefs_common.work_offline)
3075 if (alertpanel(_("Offline warning"),
3076 _("You're working offline. Override?"),
3077 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
3080 for (list = folder_get_list(); list != NULL; list = list->next) {
3081 Folder *folder = list->data;
3083 if (folder->queue) {
3084 if (procmsg_send_queue
3085 (folder->queue, prefs_common.savemsg) < 0)
3086 alertpanel_error(_("Some errors occurred while sending queued messages."));
3087 statusbar_pop_all();
3088 folder_item_scan(folder->queue);
3089 folderview_update_item(folder->queue, TRUE);
3094 void compose_mail_cb(MainWindow *mainwin, guint action,
3097 PrefsAccount *ac = NULL;
3098 FolderItem *item = mainwin->summaryview->folder_item;
3103 ac = account_find_from_item(item);
3104 if (ac && ac->protocol != A_NNTP) {
3105 compose_new_with_folderitem(ac, item); /* CLAWS */
3111 * CLAWS - use current account
3113 if (cur_account && (cur_account->protocol != A_NNTP)) {
3114 compose_new_with_folderitem(cur_account, item);
3119 * CLAWS - just get the first one
3121 list = account_get_list();
3122 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3123 ac = (PrefsAccount *) cur->data;
3124 if (ac->protocol != A_NNTP) {
3125 compose_new_with_folderitem(ac, item);
3131 void compose_news_cb(MainWindow *mainwin, guint action,
3134 PrefsAccount * ac = NULL;
3138 if (mainwin->summaryview->folder_item) {
3139 ac = mainwin->summaryview->folder_item->folder->account;
3140 if (ac && ac->protocol == A_NNTP) {
3142 mainwin->summaryview->folder_item->path,
3148 list = account_get_list();
3149 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3150 ac = (PrefsAccount *) cur->data;
3151 if (ac->protocol == A_NNTP) {
3152 compose_new(ac, NULL, NULL);
3158 void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3160 summary_reply(mainwin->summaryview, (ComposeMode)action);
3163 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3165 summary_move_to(mainwin->summaryview);
3168 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3170 summary_copy_to(mainwin->summaryview);
3173 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3175 summary_delete(mainwin->summaryview);
3178 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3180 summary_cancel(mainwin->summaryview);
3183 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3185 summary_open_msg(mainwin->summaryview);
3188 static void view_source_cb(MainWindow *mainwin, guint action,
3191 summary_view_source(mainwin->summaryview);
3194 static void show_all_header_cb(MainWindow *mainwin, guint action,
3197 if (mainwin->menu_lock_count) return;
3198 summary_display_msg_selected(mainwin->summaryview,
3199 GTK_CHECK_MENU_ITEM(widget)->active);
3202 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3204 summary_reedit(mainwin->summaryview);
3207 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3209 summary_mark(mainwin->summaryview);
3212 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3214 summary_unmark(mainwin->summaryview);
3217 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3220 summary_mark_as_unread(mainwin->summaryview);
3223 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3226 summary_mark_as_read(mainwin->summaryview);
3229 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3232 summary_mark_all_read(mainwin->summaryview);
3235 static void add_address_cb(MainWindow *mainwin, guint action,
3238 summary_add_address(mainwin->summaryview);
3241 static void set_charset_cb(MainWindow *mainwin, guint action,
3246 str = conv_get_charset_str((CharSet)action);
3247 g_free(prefs_common.force_charset);
3248 prefs_common.force_charset = str ? g_strdup(str) : NULL;
3250 summary_redisplay_msg(mainwin->summaryview);
3252 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3255 static void hide_read_messages (MainWindow *mainwin, guint action,
3258 if (!mainwin->summaryview->folder_item
3259 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
3261 summary_toggle_show_read_messages(mainwin->summaryview);
3264 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3266 if (mainwin->menu_lock_count) return;
3267 if (!mainwin->summaryview->folder_item) return;
3269 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3270 summary_thread_build(mainwin->summaryview);
3271 /* mainwin->summaryview->folder_item->threaded = TRUE; */
3273 summary_unthread(mainwin->summaryview);
3274 /* mainwin->summaryview->folder_item->threaded = FALSE; */
3278 static void expand_threads_cb(MainWindow *mainwin, guint action,
3281 summary_expand_threads(mainwin->summaryview);
3284 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3287 summary_collapse_threads(mainwin->summaryview);
3290 static void set_display_item_cb(MainWindow *mainwin, guint action,
3293 prefs_summary_column_open();
3296 static void sort_summary_cb(MainWindow *mainwin, guint action,
3299 FolderItem *item = mainwin->summaryview->folder_item;
3300 GtkWidget *menuitem;
3302 if (mainwin->menu_lock_count) return;
3304 menuitem = gtk_item_factory_get_item
3305 (mainwin->menu_factory, "/View/Sort/Ascending");
3306 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3307 GTK_CHECK_MENU_ITEM(menuitem)->active
3308 ? SORT_ASCENDING : SORT_DESCENDING);
3312 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3315 FolderItem *item = mainwin->summaryview->folder_item;
3317 if (mainwin->menu_lock_count) return;
3319 summary_sort(mainwin->summaryview,
3320 item->sort_key, (FolderSortType)action);
3323 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3326 summary_attract_by_subject(mainwin->summaryview);
3329 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3332 summary_delete_duplicated(mainwin->summaryview);
3335 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3337 summary_filter(mainwin->summaryview);
3340 static void execute_summary_cb(MainWindow *mainwin, guint action,
3343 summary_execute(mainwin->summaryview);
3346 static void update_summary_cb(MainWindow *mainwin, guint action,
3350 FolderView *folderview = mainwin->folderview;
3352 if (!mainwin->summaryview->folder_item) return;
3353 if (!folderview->opened) return;
3355 folder_update_op_count();
3357 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3358 folderview->opened);
3361 folder_item_scan(fitem);
3362 summary_show(mainwin->summaryview, fitem);
3365 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3367 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3370 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3372 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3375 static void prev_unread_cb(MainWindow *mainwin, guint action,
3378 summary_select_prev_unread(mainwin->summaryview);
3381 void next_unread_cb(MainWindow *mainwin, guint action,
3384 summary_select_next_unread(mainwin->summaryview);
3387 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3389 summary_select_prev_new(mainwin->summaryview);
3392 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3394 summary_select_next_new(mainwin->summaryview);
3397 static void prev_marked_cb(MainWindow *mainwin, guint action,
3400 summary_select_prev_marked(mainwin->summaryview);
3403 static void next_marked_cb(MainWindow *mainwin, guint action,
3406 summary_select_next_marked(mainwin->summaryview);
3409 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3412 summary_select_prev_labeled(mainwin->summaryview);
3415 static void next_labeled_cb(MainWindow *mainwin, guint action,
3418 summary_select_next_labeled(mainwin->summaryview);
3421 static void goto_folder_cb(MainWindow *mainwin, guint action,
3424 FolderItem *to_folder;
3426 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3429 folderview_select(mainwin->folderview, to_folder);
3432 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3434 messageview_copy_clipboard(mainwin->messageview);
3437 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3439 MessageView *msgview = mainwin->messageview;
3441 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3442 summary_select_all(mainwin->summaryview);
3443 else if (messageview_is_visible(msgview) &&
3444 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
3445 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3446 messageview_select_all(mainwin->messageview);
3449 static void select_thread_cb(MainWindow *mainwin, guint action,
3452 summary_select_thread(mainwin->summaryview);
3455 static void create_filter_cb(MainWindow *mainwin, guint action,
3458 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3461 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3464 prefs_common_open();
3467 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3470 prefs_scoring_open(NULL);
3473 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3476 prefs_filtering_open(NULL, NULL, NULL);
3479 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3482 prefs_template_open();
3485 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3488 prefs_actions_open(mainwin);
3491 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3495 new_account_cb(mainwin, 0, widget);
3497 account_open(cur_account);
3501 static void new_account_cb(MainWindow *mainwin, guint action,
3504 account_edit_open();
3505 if (!compose_get_compose_list()) account_add();
3508 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3510 cur_account = (PrefsAccount *)data;
3511 main_window_reflect_prefs_all();
3514 static void manual_open_cb(MainWindow *mainwin, guint action,
3517 manual_open((ManualType)action);
3520 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3522 MainWindow *mainwin = (MainWindow *)data;
3526 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3527 LOCAL_FOLDER(folder)->rootpath,
3531 str = g_strdup_printf(_("Scanning folder %s ..."),
3532 LOCAL_FOLDER(folder)->rootpath);
3534 STATUSBAR_PUSH(mainwin, str);
3535 STATUSBAR_POP(mainwin);
3539 #define BREAK_ON_MODIFIER_KEY() \
3540 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3542 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3544 MainWindow *mainwin = (MainWindow*) data;
3546 if (!mainwin || !event) return;
3548 switch (event->keyval) {
3549 case GDK_Q: /* Quit */
3550 BREAK_ON_MODIFIER_KEY();
3552 app_exit_cb(mainwin, 0, NULL);
3555 if (mainwin->folderview && mainwin->summaryview
3556 && !mainwin->summaryview->displayed) {
3557 summary_lock(mainwin->summaryview);
3558 folderview_select_next_unread(mainwin->folderview);
3559 summary_unlock(mainwin->summaryview);
3567 #undef BREAK_ON_MODIFIER_KEY
3569 static void set_toolbar_style(MainWindow *mainwin)
3571 switch (prefs_common.toolbar_style) {
3573 gtk_widget_hide(mainwin->handlebox);
3576 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
3580 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
3584 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
3589 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3590 gtk_widget_show(mainwin->handlebox);
3591 gtk_widget_queue_resize(mainwin->handlebox);
3596 * Harvest addresses for selected folder.
3598 static void addr_harvest_cb( MainWindow *mainwin,
3602 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3606 * Harvest addresses for selected messages in summary view.
3608 static void addr_harvest_msg_cb( MainWindow *mainwin,
3612 summary_harvest_address( mainwin->summaryview );