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},
781 {N_("/_Configuration/_Filter setting..."),
782 NULL, prefs_filter_open_cb, 0, NULL},
784 {N_("/_Configuration/_Scoring..."),
785 NULL, prefs_scoring_open_cb, 0, NULL},
786 {N_("/_Configuration/_Filtering..."),
787 NULL, prefs_filtering_open_cb, 0, NULL},
788 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
789 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
790 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
791 {N_("/_Configuration/_Preferences for current account..."),
792 NULL, prefs_account_open_cb, 0, NULL},
793 {N_("/_Configuration/Create _new account..."),
794 NULL, new_account_cb, 0, NULL},
795 {N_("/_Configuration/_Edit accounts..."),
796 NULL, account_edit_open, 0, NULL},
797 {N_("/_Configuration/C_hange current account"),
798 NULL, NULL, 0, "<Branch>"},
800 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
801 {N_("/_Help/_Manual (Local)"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
802 {N_("/_Help/_Manual (Sylpheed Doc Homepage)"),
803 NULL, manual_open_cb, MANUAL_MANUAL_SYLDOC, NULL},
804 {N_("/_Help/_FAQ (Local)"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
805 {N_("/_Help/_FAQ (Sylpheed Doc Homepage)"),
806 NULL, manual_open_cb, MANUAL_FAQ_SYLDOC, NULL},
807 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
808 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
813 static GtkItemFactoryEntry reply_popup_entries[] =
815 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
816 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
818 static GtkItemFactoryEntry replyall_popup_entries[] =
820 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
821 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
823 static GtkItemFactoryEntry replylist_popup_entries[] =
825 {N_("/Reply to list with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITH_QUOTE, NULL},
826 {N_("/_Reply to list without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE, NULL}
828 static GtkItemFactoryEntry replysender_popup_entries[] =
830 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
831 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
833 static GtkItemFactoryEntry fwd_popup_entries[] =
835 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
836 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
839 MainWindow *main_window_create(SeparateType type)
845 GtkWidget *handlebox;
846 GtkWidget *vbox_body;
847 GtkWidget *hbox_stat;
848 GtkWidget *statusbar;
849 GtkWidget *progressbar;
850 GtkWidget *statuslabel;
851 GtkWidget *ac_button;
853 GtkWidget *online_pixmap;
854 GtkWidget *offline_pixmap;
855 GtkWidget *online_switch;
856 GtkWidget *offline_switch;
858 FolderView *folderview;
859 SummaryView *summaryview;
860 MessageView *messageview;
861 GdkColormap *colormap;
864 GtkItemFactory *ifactory;
868 guint n_menu_entries;
870 static GdkGeometry geometry;
872 debug_print("Creating main window...\n");
873 mainwin = g_new0(MainWindow, 1);
876 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
877 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
878 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
879 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
881 if (!geometry.min_height) {
882 geometry.min_width = 320;
883 geometry.min_height = 200;
885 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
888 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
889 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
890 MANAGE_WINDOW_SIGNALS_CONNECT(window);
891 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
892 GTK_SIGNAL_FUNC(key_pressed), mainwin);
894 gtk_widget_realize(window);
895 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
898 gtkut_widget_set_app_icon(window);
900 vbox = gtk_vbox_new(FALSE, 0);
901 gtk_widget_show(vbox);
902 gtk_container_add(GTK_CONTAINER(window), vbox);
905 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
906 menubar = menubar_create(window, mainwin_entries,
907 n_menu_entries, "<Main>", mainwin);
908 gtk_widget_show(menubar);
909 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
910 ifactory = gtk_item_factory_from_widget(menubar);
912 menu_set_sensitive(ifactory, "/Help/Manual (Local)", manual_available(MANUAL_MANUAL_LOCAL));
913 menu_set_sensitive(ifactory, "/Help/FAQ (Local)", manual_available(MANUAL_FAQ_LOCAL));
915 handlebox = gtk_handle_box_new();
916 gtk_widget_show(handlebox);
917 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
919 /* link window to mainwin->window to avoid gdk warnings */
920 mainwin->window = window;
923 toolbar_create(mainwin, handlebox);
925 /* vbox that contains body */
926 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
927 gtk_widget_show(vbox_body);
928 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
929 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
931 hbox_stat = gtk_hbox_new(FALSE, 2);
932 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
934 statusbar = statusbar_create();
935 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
937 progressbar = gtk_progress_bar_new();
938 gtk_widget_set_usize(progressbar, 120, 1);
939 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
941 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
942 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
943 online_switch = gtk_button_new ();
944 offline_switch = gtk_button_new ();
945 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
946 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
947 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
948 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
949 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
950 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
951 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
952 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
954 statuslabel = gtk_label_new("");
955 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
957 ac_button = gtk_button_new();
958 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
959 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
960 gtk_widget_set_usize(ac_button, -1, 1);
961 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
962 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
963 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
965 ac_label = gtk_label_new("");
966 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
968 gtk_widget_show_all(hbox_stat);
970 gtk_widget_hide(offline_switch);
972 mainwin->folderview = folderview = folderview_create();
973 mainwin->summaryview = summaryview = summary_create();
974 mainwin->messageview = messageview = messageview_create(mainwin);
975 mainwin->logwin = log_window_create();
977 folderview->mainwin = mainwin;
978 folderview->summaryview = summaryview;
980 summaryview->mainwin = mainwin;
981 summaryview->folderview = folderview;
982 summaryview->messageview = messageview;
983 summaryview->window = window;
985 messageview->mainwin = mainwin;
987 mainwin->vbox = vbox;
988 mainwin->menubar = menubar;
989 mainwin->menu_factory = ifactory;
990 mainwin->handlebox = handlebox;
991 mainwin->vbox_body = vbox_body;
992 mainwin->hbox_stat = hbox_stat;
993 mainwin->statusbar = statusbar;
994 mainwin->progressbar = progressbar;
995 mainwin->statuslabel = statuslabel;
996 mainwin->ac_button = ac_button;
997 mainwin->ac_label = ac_label;
999 mainwin->online_switch = online_switch;
1000 mainwin->offline_switch = offline_switch;
1001 mainwin->online_pixmap = online_pixmap;
1002 mainwin->offline_pixmap = offline_pixmap;
1004 /* set context IDs for status bar */
1005 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1006 (GTK_STATUSBAR(statusbar), "Main Window");
1007 mainwin->folderview_cid = gtk_statusbar_get_context_id
1008 (GTK_STATUSBAR(statusbar), "Folder View");
1009 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1010 (GTK_STATUSBAR(statusbar), "Summary View");
1012 /* allocate colors for summary view and folder view */
1013 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1014 summaryview->color_marked.blue = (guint16)65535;
1016 summaryview->color_dim.red = summaryview->color_dim.green =
1017 summaryview->color_dim.blue = COLOR_DIM;
1019 folderview->color_new.red = (guint16)55000;
1020 folderview->color_new.green = folderview->color_new.blue = 15000;
1022 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1023 &folderview->color_op);
1025 summaryview->color_important.red = 0;
1026 summaryview->color_important.green = 0;
1027 summaryview->color_important.blue = (guint16)65535;
1029 color[0] = summaryview->color_marked;
1030 color[1] = summaryview->color_dim;
1031 color[2] = folderview->color_new;
1032 color[3] = folderview->color_op;
1034 colormap = gdk_window_get_colormap(window->window);
1035 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1036 for (i = 0; i < 4; i++) {
1037 if (success[i] == FALSE)
1038 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1041 debug_print("done.\n");
1043 messageview->visible = TRUE;
1045 main_window_set_widgets(mainwin, type);
1047 /* set menu items */
1048 menuitem = gtk_item_factory_get_item
1049 (ifactory, "/View/Code set/Auto detect");
1050 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1052 switch (prefs_common.toolbar_style) {
1054 menuitem = gtk_item_factory_get_item
1055 (ifactory, "/View/Show or hide/Toolbar/None");
1058 menuitem = gtk_item_factory_get_item
1059 (ifactory, "/View/Show or hide/Toolbar/Icon");
1062 menuitem = gtk_item_factory_get_item
1063 (ifactory, "/View/Show or hide/Toolbar/Text");
1066 menuitem = gtk_item_factory_get_item
1067 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1069 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1071 gtk_widget_hide(mainwin->hbox_stat);
1072 menuitem = gtk_item_factory_get_item
1073 (ifactory, "/View/Show or hide/Status bar");
1074 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1075 prefs_common.show_statusbar);
1077 gtk_widget_hide(GTK_WIDGET(mainwin->summaryview->hbox_search));
1079 if (prefs_common.show_searchbar)
1080 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainwin->summaryview->toggle_search), TRUE);
1083 /* set account selection menu */
1084 ac_menu = gtk_item_factory_get_widget
1085 (ifactory, "/Configuration/Change current account");
1086 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1087 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1088 mainwin->ac_menu = ac_menu;
1090 toolbar_set_sensitive(mainwin);
1092 /* create actions menu */
1093 update_mainwin_actions_menu(ifactory, mainwin);
1095 /* show main window */
1096 gtk_widget_set_uposition(mainwin->window,
1097 prefs_common.mainwin_x,
1098 prefs_common.mainwin_y);
1099 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1100 prefs_common.mainwin_height);
1101 gtk_widget_show(mainwin->window);
1103 /* initialize views */
1104 folderview_init(folderview);
1105 summary_init(summaryview);
1106 messageview_init(messageview);
1107 log_window_init(mainwin->logwin);
1109 mainwin->lock_count = 0;
1110 mainwin->menu_lock_count = 0;
1111 mainwin->cursor_count = 0;
1114 watch_cursor = gdk_cursor_new(GDK_WATCH);
1116 mainwin_list = g_list_append(mainwin_list, mainwin);
1118 /* init work_offline */
1119 if (prefs_common.work_offline)
1120 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1125 void main_window_cursor_wait(MainWindow *mainwin)
1128 if (mainwin->cursor_count == 0)
1129 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1131 mainwin->cursor_count++;
1136 void main_window_cursor_normal(MainWindow *mainwin)
1138 if (mainwin->cursor_count)
1139 mainwin->cursor_count--;
1141 if (mainwin->cursor_count == 0)
1142 gdk_window_set_cursor(mainwin->window->window, NULL);
1147 /* lock / unlock the user-interface */
1148 void main_window_lock(MainWindow *mainwin)
1150 if (mainwin->lock_count == 0)
1151 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1153 mainwin->lock_count++;
1155 main_window_set_menu_sensitive(mainwin);
1156 toolbar_set_sensitive(mainwin);
1159 void main_window_unlock(MainWindow *mainwin)
1161 if (mainwin->lock_count)
1162 mainwin->lock_count--;
1164 main_window_set_menu_sensitive(mainwin);
1165 toolbar_set_sensitive(mainwin);
1167 if (mainwin->lock_count == 0)
1168 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1171 static void main_window_menu_callback_block(MainWindow *mainwin)
1173 mainwin->menu_lock_count++;
1176 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1178 if (mainwin->menu_lock_count)
1179 mainwin->menu_lock_count--;
1182 void main_window_reflect_prefs_all(void)
1184 main_window_reflect_prefs_all_real(FALSE);
1187 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1190 MainWindow *mainwin;
1193 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1194 mainwin = (MainWindow *)cur->data;
1196 main_window_show_cur_account(mainwin);
1197 main_window_set_menu_sensitive(mainwin);
1198 toolbar_set_sensitive(mainwin);
1201 if (pixmap_theme_changed) {
1202 toolbar_update(mainwin);
1203 set_toolbar_style(mainwin);
1204 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1205 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1207 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
1208 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1209 mainwin->online_pixmap);
1210 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1211 gtk_widget_show(pixmap);
1212 mainwin->online_pixmap = pixmap;
1213 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
1214 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1215 mainwin->offline_pixmap);
1216 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1217 gtk_widget_show(pixmap);
1218 mainwin->offline_pixmap = pixmap;
1221 summary_redisplay_msg(mainwin->summaryview);
1222 headerview_set_visibility(mainwin->messageview->headerview,
1223 prefs_common.display_header_pane);
1227 void main_window_set_summary_column(void)
1230 MainWindow *mainwin;
1232 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1233 mainwin = (MainWindow *)cur->data;
1234 summary_set_column_order(mainwin->summaryview);
1238 void main_window_set_account_menu(GList *account_list)
1240 GList *cur, *cur_ac, *cur_item;
1241 GtkWidget *menuitem;
1242 MainWindow *mainwin;
1243 PrefsAccount *ac_prefs;
1245 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1246 mainwin = (MainWindow *)cur->data;
1248 /* destroy all previous menu item */
1249 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1250 while (cur_item != NULL) {
1251 GList *next = cur_item->next;
1252 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1256 for (cur_ac = account_list; cur_ac != NULL;
1257 cur_ac = cur_ac->next) {
1258 ac_prefs = (PrefsAccount *)cur_ac->data;
1260 menuitem = gtk_menu_item_new_with_label
1261 (ac_prefs->account_name
1262 ? ac_prefs->account_name : _("Untitled"));
1263 gtk_widget_show(menuitem);
1264 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1265 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1266 GTK_SIGNAL_FUNC(account_menu_cb),
1272 static void main_window_show_cur_account(MainWindow *mainwin)
1277 ac_name = g_strdup(cur_account
1278 ? (cur_account->account_name
1279 ? cur_account->account_name : _("Untitled"))
1283 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1285 buf = g_strdup(PROG_VERSION);
1286 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1289 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1290 gtk_widget_queue_resize(mainwin->ac_button);
1295 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1297 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1298 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1299 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1301 debug_print("Changing window separation type from %d to %d\n",
1302 mainwin->type, type);
1304 if (mainwin->type == type) return;
1306 /* remove widgets from those containers */
1307 gtk_widget_ref(folder_wid);
1308 gtk_widget_ref(summary_wid);
1309 gtk_widget_ref(message_wid);
1310 gtkut_container_remove
1311 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1312 gtkut_container_remove
1313 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1314 gtkut_container_remove
1315 (GTK_CONTAINER(message_wid->parent), message_wid);
1317 /* clean containers */
1318 switch (mainwin->type) {
1320 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1322 case SEPARATE_FOLDER:
1323 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1324 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1326 case SEPARATE_MESSAGE:
1327 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1328 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1331 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1332 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1336 gtk_widget_hide(mainwin->window);
1337 main_window_set_widgets(mainwin, type);
1338 gtk_widget_show(mainwin->window);
1340 gtk_widget_unref(folder_wid);
1341 gtk_widget_unref(summary_wid);
1342 gtk_widget_unref(message_wid);
1345 void main_window_toggle_message_view(MainWindow *mainwin)
1347 SummaryView *summaryview = mainwin->summaryview;
1348 union CompositeWin *cwin = &mainwin->win;
1349 GtkWidget *vpaned = NULL;
1350 GtkWidget *container = NULL;
1351 GtkWidget *msgwin = NULL;
1353 switch (mainwin->type) {
1355 vpaned = cwin->sep_none.vpaned;
1356 container = cwin->sep_none.hpaned;
1358 case SEPARATE_FOLDER:
1359 vpaned = cwin->sep_folder.vpaned;
1360 container = mainwin->vbox_body;
1362 case SEPARATE_MESSAGE:
1363 msgwin = mainwin->win.sep_message.messagewin;
1366 msgwin = mainwin->win.sep_both.messagewin;
1371 if (GTK_WIDGET_VISIBLE(msgwin)) {
1372 gtk_widget_hide(msgwin);
1373 mainwin->messageview->visible = FALSE;
1374 summaryview->displayed = NULL;
1376 gtk_widget_show(msgwin);
1377 mainwin->messageview->visible = TRUE;
1379 } else if (vpaned->parent != NULL) {
1380 mainwin->messageview->visible = FALSE;
1381 summaryview->displayed = NULL;
1382 gtk_widget_ref(vpaned);
1383 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1384 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1385 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1386 GTK_ARROW_UP, GTK_SHADOW_OUT);
1388 mainwin->messageview->visible = TRUE;
1389 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1390 gtk_container_add(GTK_CONTAINER(container), vpaned);
1391 gtk_widget_unref(vpaned);
1392 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1393 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1396 main_window_set_menu_sensitive(mainwin);
1398 gtk_widget_grab_focus(summaryview->ctree);
1401 void main_window_get_size(MainWindow *mainwin)
1403 GtkAllocation *allocation;
1405 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1407 prefs_common.summaryview_width = allocation->width;
1409 if ((mainwin->type == SEPARATE_NONE ||
1410 mainwin->type == SEPARATE_FOLDER) &&
1411 messageview_is_visible(mainwin->messageview))
1412 prefs_common.summaryview_height = allocation->height;
1414 prefs_common.mainview_width = allocation->width;
1416 allocation = &mainwin->window->allocation;
1418 prefs_common.mainview_height = allocation->height;
1419 prefs_common.mainwin_width = allocation->width;
1420 prefs_common.mainwin_height = allocation->height;
1422 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1424 prefs_common.folderview_width = allocation->width;
1425 prefs_common.folderview_height = allocation->height;
1428 void main_window_get_position(MainWindow *mainwin)
1432 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1434 prefs_common.mainview_x = x;
1435 prefs_common.mainview_y = y;
1436 prefs_common.mainwin_x = x;
1437 prefs_common.mainwin_y = y;
1439 debug_print("window position: x = %d, y = %d\n", x, y);
1442 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1448 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1449 folder = FOLDER(list->data);
1450 if (folder && folder->trash && folder->trash->total > 0)
1454 if (!has_trash) return;
1457 if (alertpanel(_("Empty trash"),
1458 _("Empty all messages in trash?"),
1459 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1461 manage_window_focus_in(mainwin->window, NULL, NULL);
1464 procmsg_empty_trash();
1466 for (list = folder_get_list(); list != NULL; list = list->next) {
1467 folder = list->data;
1468 if (folder && folder->trash) {
1469 folderview_update_item(folder->trash, TRUE);
1473 if (mainwin->summaryview->folder_item &&
1474 mainwin->summaryview->folder_item->stype == F_TRASH)
1475 gtk_widget_grab_focus(mainwin->folderview->ctree);
1478 void main_window_add_mailbox(MainWindow *mainwin)
1483 path = input_dialog(_("Add mailbox"),
1484 _("Input the location of mailbox.\n"
1485 "If the existing mailbox is specified, it will be\n"
1486 "scanned automatically."),
1489 if (folder_find_from_path(path)) {
1490 alertpanel_error(_("The mailbox `%s' already exists."), path);
1494 if (!strcmp(path, "Mail"))
1495 folder = folder_new(F_MH, _("Mailbox"), path);
1497 folder = folder_new(F_MH, g_basename(path), path);
1500 if (folder->create_tree(folder) < 0) {
1501 alertpanel_error(_("Creation of the mailbox failed.\n"
1502 "Maybe some files already exist, or you don't have the permission to write there."));
1503 folder_destroy(folder);
1508 folder_set_ui_func(folder, scan_tree_func, mainwin);
1509 folder_scan_tree(folder);
1510 folder_set_ui_func(folder, NULL, NULL);
1512 folderview_set(mainwin->folderview);
1515 void main_window_add_mbox(MainWindow *mainwin)
1521 path = input_dialog(_("Add mbox mailbox"),
1522 _("Input the location of mailbox."),
1527 if (folder_find_from_path(path)) {
1528 alertpanel_error(_("The mailbox `%s' already exists."), path);
1534 if (!strcmp(path, "Mail"))
1535 folder = folder_new(F_MBOX, _("Mailbox"), path);
1539 folder = folder_new(F_MBOX, g_basename(path), path);
1542 if (folder->create_tree(folder) < 0) {
1543 alertpanel_error(_("Creation of the mailbox failed."));
1544 folder_destroy(folder);
1550 item = folder_item_new(folder, folder->name, NULL);
1551 item->folder = folder;
1552 folder->node = g_node_new(item);
1554 folder_create_folder(item, "inbox");
1555 folder_create_folder(item, "outbox");
1556 folder_create_folder(item, "queue");
1557 folder_create_folder(item, "draft");
1558 folder_create_folder(item, "trash");
1560 folderview_set(mainwin->folderview);
1563 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1565 SensitiveCond state = 0;
1566 SummarySelection selection;
1567 FolderItem *item = mainwin->summaryview->folder_item;
1568 GList *account_list = account_get_list();
1570 selection = summary_get_selection_type(mainwin->summaryview);
1572 if (mainwin->lock_count == 0)
1573 state |= M_UNLOCKED;
1574 if (selection != SUMMARY_NONE)
1575 state |= M_MSG_EXIST;
1576 if (item && item->path && item->parent && !item->no_select) {
1578 /* if (item->folder->type != F_NEWS) */
1579 state |= M_ALLOW_DELETE;
1581 if (prefs_common.immediate_exec == 0
1582 && mainwin->lock_count == 0)
1583 state |= M_DELAY_EXEC;
1585 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1586 || selection != SUMMARY_NONE)
1587 state |= M_HIDE_READ_MSG;
1589 if (mainwin->summaryview->threaded)
1590 state |= M_THREADED;
1592 state |= M_UNTHREADED;
1593 if (selection == SUMMARY_SELECTED_SINGLE ||
1594 selection == SUMMARY_SELECTED_MULTIPLE)
1595 state |= M_TARGET_EXIST;
1596 if (selection == SUMMARY_SELECTED_SINGLE)
1597 state |= M_SINGLE_TARGET_EXIST;
1598 if (mainwin->summaryview->folder_item &&
1599 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1602 state |= M_NOT_NEWS;
1603 if (selection == SUMMARY_SELECTED_SINGLE &&
1605 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1606 item->stype == F_QUEUE)))
1607 state |= M_ALLOW_REEDIT;
1609 state |= M_HAVE_ACCOUNT;
1611 for ( ; account_list != NULL; account_list = account_list->next) {
1612 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1613 state |= M_HAVE_NEWS_ACCOUNT;
1618 if (inc_is_active())
1619 state |= M_INC_ACTIVE;
1626 void main_window_set_menu_sensitive(MainWindow *mainwin)
1628 GtkItemFactory *ifactory = mainwin->menu_factory;
1629 SensitiveCond state;
1631 GtkWidget *menuitem;
1632 SummaryView *summaryview;
1636 static const struct {
1640 {"/File/Add mailbox..." , M_UNLOCKED},
1641 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1642 {"/File/Check for new messages in all folders", M_UNLOCKED},
1643 {"/File/Folder" , M_UNLOCKED},
1644 {"/File/Import mbox file..." , M_UNLOCKED},
1645 {"/File/Export to mbox file..." , M_UNLOCKED},
1646 {"/File/Empty trash" , M_UNLOCKED},
1647 {"/File/Work offline" , M_UNLOCKED},
1649 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1650 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1651 /* {"/File/Close" , M_UNLOCKED}, */
1652 {"/File/Exit" , M_UNLOCKED},
1654 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1656 {"/View/Sort" , M_EXEC},
1657 {"/View/Thread view" , M_EXEC},
1658 {"/View/Expand all threads" , M_MSG_EXIST},
1659 {"/View/Collapse all threads" , M_MSG_EXIST},
1660 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1661 {"/View/Go to/Prev message" , M_MSG_EXIST},
1662 {"/View/Go to/Next message" , M_MSG_EXIST},
1663 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1664 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1665 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1666 {"/View/Go to/Next new message" , M_MSG_EXIST},
1667 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1668 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1669 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1670 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1671 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1672 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1673 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1675 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1676 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1677 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1678 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1679 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1680 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1681 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1682 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1683 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1684 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1685 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1686 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1687 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1688 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1689 {"/Message/Mark" , M_TARGET_EXIST},
1691 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1692 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1693 {"/Tools/Harvest addresses" , M_UNLOCKED},
1694 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1695 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1696 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1697 {"/Tools/Execute" , M_DELAY_EXEC},
1698 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1700 {"/Configuration", M_UNLOCKED},
1705 state = main_window_get_current_state(mainwin);
1707 for (i = 0; entry[i].entry != NULL; i++) {
1708 sensitive = ((entry[i].cond & state) == entry[i].cond);
1709 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1712 main_window_menu_callback_block(mainwin);
1714 #define SET_CHECK_MENU_ACTIVE(path, active) \
1716 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1717 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1720 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1721 messageview_is_visible(mainwin->messageview));
1723 summaryview = mainwin->summaryview;
1724 menu_path = "/View/Sort/Don't sort";
1726 switch (summaryview->sort_key) {
1727 case SORT_BY_NUMBER:
1728 menu_path = "/View/Sort/by number"; break;
1730 menu_path = "/View/Sort/by size"; break;
1732 menu_path = "/View/Sort/by date"; break;
1734 menu_path = "/View/Sort/by from"; break;
1735 case SORT_BY_SUBJECT:
1736 menu_path = "/View/Sort/by subject"; break;
1738 menu_path = "/View/Sort/by color label"; break;
1740 menu_path = "/View/Sort/by mark"; break;
1741 case SORT_BY_UNREAD:
1742 menu_path = "/View/Sort/by unread"; break;
1744 menu_path = "/View/Sort/by attachment"; break;
1746 menu_path = "/View/Sort/by score"; break;
1747 case SORT_BY_LOCKED:
1748 menu_path = "/View/Sort/by locked"; break;
1751 menu_path = "/View/Sort/Don't sort"; break;
1753 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1755 if (summaryview->sort_type == SORT_ASCENDING) {
1756 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1758 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1761 if (summaryview->sort_key != SORT_BY_NONE) {
1762 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1763 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1765 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1766 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1769 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1770 mainwin->messageview->textview->show_all_headers);
1771 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1773 #undef SET_CHECK_MENU_ACTIVE
1775 main_window_menu_callback_unblock(mainwin);
1778 void main_window_popup(MainWindow *mainwin)
1784 gdk_window_get_origin(mainwin->window->window, &x, &y);
1785 sx = gdk_screen_width();
1786 sy = gdk_screen_height();
1787 x %= sx; if (x < 0) x = 0;
1788 y %= sy; if (y < 0) y = 0;
1789 gdk_window_move(mainwin->window->window, x, y);
1790 gdk_window_raise(mainwin->window->window);
1791 gdk_window_show(mainwin->window->window);
1793 debug_print("window position: x = %d, y = %d\n", x, y);
1795 switch (mainwin->type) {
1796 case SEPARATE_FOLDER:
1797 widget = mainwin->win.sep_folder.folderwin;
1798 gdk_window_get_origin(widget->window, &x, &y);
1799 x %= sx; if (x < 0) x = 0;
1800 y %= sy; if (y < 0) y = 0;
1801 gdk_window_move(widget->window, x, y);
1802 gdk_window_raise(widget->window);
1804 case SEPARATE_MESSAGE:
1805 widget = mainwin->win.sep_message.messagewin;
1806 gdk_window_get_origin(widget->window, &x, &y);
1807 x %= sx; if (x < 0) x = 0;
1808 y %= sy; if (y < 0) y = 0;
1809 gdk_window_move(widget->window, x, y);
1810 gdk_window_raise(widget->window);
1813 widget = mainwin->win.sep_both.folderwin;
1814 gdk_window_get_origin(widget->window, &x, &y);
1815 x %= sx; if (x < 0) x = 0;
1816 y %= sy; if (y < 0) y = 0;
1817 gdk_window_move(widget->window, x, y);
1818 gdk_window_raise(widget->window);
1819 widget = mainwin->win.sep_both.messagewin;
1820 gdk_window_get_origin(widget->window, &x, &y);
1821 x %= sx; if (x < 0) x = 0;
1822 y %= sy; if (y < 0) y = 0;
1823 gdk_window_move(widget->window, x, y);
1824 gdk_window_raise(widget->window);
1831 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1833 GtkWidget *folderwin = NULL;
1834 GtkWidget *messagewin = NULL;
1837 GtkWidget *vbox_body = mainwin->vbox_body;
1838 GtkItemFactory *ifactory = mainwin->menu_factory;
1839 GtkWidget *menuitem;
1841 debug_print("Setting widgets...");
1843 /* create separated window(s) if needed */
1844 if (type & SEPARATE_FOLDER) {
1845 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1846 gtk_window_set_title(GTK_WINDOW(folderwin),
1847 _("Sylpheed - Folder View"));
1848 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1849 "folder_view", "Sylpheed");
1850 gtk_window_set_policy(GTK_WINDOW(folderwin),
1852 gtk_widget_set_usize(folderwin, -1,
1853 prefs_common.mainview_height);
1854 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1856 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1857 GTK_SIGNAL_FUNC(folder_window_close_cb),
1860 if (type & SEPARATE_MESSAGE) {
1861 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1862 gtk_window_set_title(GTK_WINDOW(messagewin),
1863 _("Sylpheed - Message View"));
1864 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1865 "message_view", "Sylpheed");
1866 gtk_window_set_policy(GTK_WINDOW(messagewin),
1868 gtk_widget_set_usize
1869 (messagewin, prefs_common.mainview_width,
1870 prefs_common.mainview_height
1871 - prefs_common.summaryview_height
1872 + DEFAULT_HEADERVIEW_HEIGHT);
1873 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1875 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1876 GTK_SIGNAL_FUNC(message_window_close_cb),
1882 hpaned = gtk_hpaned_new();
1883 gtk_widget_show(hpaned);
1884 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1885 gtk_paned_add1(GTK_PANED(hpaned),
1886 GTK_WIDGET_PTR(mainwin->folderview));
1888 vpaned = gtk_vpaned_new();
1889 if (messageview_is_visible(mainwin->messageview)) {
1890 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1891 gtk_paned_add1(GTK_PANED(vpaned),
1892 GTK_WIDGET_PTR(mainwin->summaryview));
1894 gtk_paned_add2(GTK_PANED(hpaned),
1895 GTK_WIDGET_PTR(mainwin->summaryview));
1896 gtk_widget_ref(vpaned);
1898 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1899 prefs_common.summaryview_width,
1900 prefs_common.summaryview_height);
1901 gtk_paned_add2(GTK_PANED(vpaned),
1902 GTK_WIDGET_PTR(mainwin->messageview));
1903 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1904 prefs_common.mainview_width, -1);
1905 gtk_widget_set_usize(mainwin->window,
1906 prefs_common.folderview_width +
1907 prefs_common.mainview_width,
1908 prefs_common.mainwin_height);
1909 gtk_widget_show_all(vpaned);
1911 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1912 * lose track of its visibility state */
1913 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1914 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1916 mainwin->win.sep_none.hpaned = hpaned;
1917 mainwin->win.sep_none.vpaned = vpaned;
1919 /* remove headerview if not in prefs */
1920 headerview_set_visibility(mainwin->messageview->headerview,
1921 prefs_common.display_header_pane);
1923 case SEPARATE_FOLDER:
1924 vpaned = gtk_vpaned_new();
1925 if (messageview_is_visible(mainwin->messageview)) {
1926 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1928 gtk_paned_add1(GTK_PANED(vpaned),
1929 GTK_WIDGET_PTR(mainwin->summaryview));
1931 gtk_box_pack_start(GTK_BOX(vbox_body),
1932 GTK_WIDGET_PTR(mainwin->summaryview),
1934 gtk_widget_ref(vpaned);
1936 gtk_paned_add2(GTK_PANED(vpaned),
1937 GTK_WIDGET_PTR(mainwin->messageview));
1938 gtk_widget_show_all(vpaned);
1939 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1940 prefs_common.summaryview_width,
1941 prefs_common.summaryview_height);
1942 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1943 prefs_common.mainview_width, -1);
1944 gtk_widget_set_usize(mainwin->window,
1945 prefs_common.mainview_width,
1946 prefs_common.mainview_height);
1948 gtk_container_add(GTK_CONTAINER(folderwin),
1949 GTK_WIDGET_PTR(mainwin->folderview));
1951 mainwin->win.sep_folder.folderwin = folderwin;
1952 mainwin->win.sep_folder.vpaned = vpaned;
1954 gtk_widget_show_all(folderwin);
1956 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1957 * lose track of its visibility state */
1958 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1959 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1961 /* remove headerview if not in prefs */
1962 headerview_set_visibility(mainwin->messageview->headerview,
1963 prefs_common.display_header_pane);
1966 case SEPARATE_MESSAGE:
1967 hpaned = gtk_hpaned_new();
1968 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1970 gtk_paned_add1(GTK_PANED(hpaned),
1971 GTK_WIDGET_PTR(mainwin->folderview));
1972 gtk_paned_add2(GTK_PANED(hpaned),
1973 GTK_WIDGET_PTR(mainwin->summaryview));
1974 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1975 prefs_common.summaryview_width,
1976 prefs_common.summaryview_height);
1977 gtk_widget_set_usize(mainwin->window,
1978 prefs_common.folderview_width +
1979 prefs_common.mainview_width,
1980 prefs_common.mainwin_height);
1981 gtk_widget_show_all(hpaned);
1982 gtk_container_add(GTK_CONTAINER(messagewin),
1983 GTK_WIDGET_PTR(mainwin->messageview));
1985 mainwin->win.sep_message.messagewin = messagewin;
1986 mainwin->win.sep_message.hpaned = hpaned;
1988 gtk_widget_show_all(messagewin);
1990 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1991 * lose track of its visibility state */
1992 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1993 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1996 gtk_box_pack_start(GTK_BOX(vbox_body),
1997 GTK_WIDGET_PTR(mainwin->summaryview),
1999 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
2000 prefs_common.summaryview_width,
2001 prefs_common.summaryview_height);
2002 gtk_widget_set_usize(mainwin->window,
2003 prefs_common.mainview_width,
2004 prefs_common.mainwin_height);
2005 gtk_container_add(GTK_CONTAINER(folderwin),
2006 GTK_WIDGET_PTR(mainwin->folderview));
2007 gtk_container_add(GTK_CONTAINER(messagewin),
2008 GTK_WIDGET_PTR(mainwin->messageview));
2010 mainwin->win.sep_both.folderwin = folderwin;
2011 mainwin->win.sep_both.messagewin = messagewin;
2013 gtk_widget_show_all(folderwin);
2014 gtk_widget_show_all(messagewin);
2016 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2017 * lose track of its visibility state */
2018 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2019 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2023 /* rehide quick search if necessary */
2024 if (!prefs_common.show_searchbar)
2025 gtk_widget_hide(mainwin->summaryview->hbox_search);
2027 mainwin->type = type;
2029 mainwin->messageview->visible = TRUE;
2031 /* toggle menu state */
2032 menuitem = gtk_item_factory_get_item
2033 (ifactory, "/View/Show or hide/Folder tree");
2034 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2035 menuitem = gtk_item_factory_get_item
2036 (ifactory, "/View/Show or hide/Message view");
2037 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2039 menuitem = gtk_item_factory_get_item
2040 (ifactory, "/View/Separate folder tree");
2041 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2042 ((type & SEPARATE_FOLDER) != 0));
2043 menuitem = gtk_item_factory_get_item
2044 (ifactory, "/View/Separate message view");
2045 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2046 ((type & SEPARATE_MESSAGE) != 0));
2048 debug_print("done.\n");
2051 void main_window_destroy_all(void)
2053 while (mainwin_list != NULL) {
2054 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2056 /* free toolbar stuff */
2057 toolbar_clear_list(TOOLBAR_MAIN);
2058 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->t_action_list);
2059 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->t_item_list);
2061 g_free(mainwin->toolbar);
2064 mainwin_list = g_list_remove(mainwin_list, mainwin);
2066 g_list_free(mainwin_list);
2070 static void toolbar_account_button_pressed(GtkWidget *widget,
2071 GdkEventButton *event,
2074 MainWindow *mainwin = (MainWindow *)data;
2077 if (event->button != 3) return;
2079 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2080 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2083 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2084 menu_button_position, widget,
2085 event->button, event->time);
2089 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2092 MainWindow *mainwin = (MainWindow *)data;
2096 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2097 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2100 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2101 menu_button_position, widget,
2102 event->button, event->time);
2105 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2107 MainWindow *mainwin = (MainWindow *)data;
2110 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2111 if (!button) return;
2112 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2113 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2114 manage_window_focus_in(mainwin->window, NULL, NULL);
2117 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2120 MainWindow *mainwin = (MainWindow *)data;
2122 if (mainwin->lock_count == 0)
2123 app_exit_cb(data, 0, widget);
2128 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2131 MainWindow *mainwin = (MainWindow *)data;
2132 GtkWidget *menuitem;
2134 menuitem = gtk_item_factory_get_item
2135 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2136 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2141 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2144 MainWindow *mainwin = (MainWindow *)data;
2145 GtkWidget *menuitem;
2147 menuitem = gtk_item_factory_get_item
2148 (mainwin->menu_factory, "/View/Show or hide/Message view");
2149 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2154 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2157 main_window_add_mailbox(mainwin);
2160 static void add_mbox_cb(MainWindow *mainwin, guint action,
2163 main_window_add_mbox(mainwin);
2166 static void update_folderview_cb(MainWindow *mainwin, guint action,
2169 summary_show(mainwin->summaryview, NULL);
2170 folderview_check_new_all();
2173 static void new_folder_cb(MainWindow *mainwin, guint action,
2176 folderview_new_folder(mainwin->folderview);
2179 static void rename_folder_cb(MainWindow *mainwin, guint action,
2182 folderview_rename_folder(mainwin->folderview);
2185 static void delete_folder_cb(MainWindow *mainwin, guint action,
2188 folderview_delete_folder(mainwin->folderview);
2191 static void import_mbox_cb(MainWindow *mainwin, guint action,
2194 import_mbox(mainwin->summaryview->folder_item);
2197 static void export_mbox_cb(MainWindow *mainwin, guint action,
2200 export_mbox(mainwin->summaryview->folder_item);
2203 static void empty_trash_cb(MainWindow *mainwin, guint action,
2206 main_window_empty_trash(mainwin, TRUE);
2209 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2211 summary_save_as(mainwin->summaryview);
2214 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2216 summary_print(mainwin->summaryview);
2219 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2221 if (prefs_common.confirm_on_exit) {
2222 if (alertpanel(_("Exit"), _("Exit this program?"),
2223 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2225 manage_window_focus_in(mainwin->window, NULL, NULL);
2228 app_will_exit(widget, mainwin);
2231 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2234 summary_search(mainwin->summaryview);
2236 message_search(mainwin->messageview);
2239 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2244 active = GTK_CHECK_MENU_ITEM(widget)->active;
2246 switch (mainwin->type) {
2248 case SEPARATE_MESSAGE:
2251 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2253 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2256 case SEPARATE_FOLDER:
2257 debug_print("separate folder\n");
2259 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2261 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2265 gtk_widget_show(mainwin->win.sep_both.folderwin);
2267 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2272 static void toggle_message_cb(MainWindow *mainwin, guint action,
2277 active = GTK_CHECK_MENU_ITEM(widget)->active;
2279 if (active != messageview_is_visible(mainwin->messageview))
2280 summary_toggle_view(mainwin->summaryview);
2283 /* Toolbar handling */
2284 static void toolbar_inc_cb(GtkWidget *widget,
2287 MainWindow *mainwin = (MainWindow *)data;
2289 inc_mail_cb(mainwin, 0, NULL);
2292 static void toolbar_inc_all_cb(GtkWidget *widget,
2295 MainWindow *mainwin = (MainWindow *)data;
2297 inc_all_account_mail_cb(mainwin, 0, NULL);
2300 static void toolbar_send_cb(GtkWidget *widget,
2303 MainWindow *mainwin = (MainWindow *)data;
2305 send_queue_cb(mainwin, 0, NULL);
2308 static void toolbar_compose_cb(GtkWidget *widget,
2311 MainWindow *mainwin = (MainWindow *)data;
2313 if (mainwin->toolbar->compose_btn_type == COMPOSEBUTTON_NEWS)
2314 compose_news_cb(mainwin, 0, NULL);
2316 compose_mail_cb(mainwin, 0, NULL);
2319 static void toolbar_reply_cb(GtkWidget *widget,
2322 MainWindow *mainwin = (MainWindow *)data;
2324 if (prefs_common.default_reply_list)
2326 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
2327 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
2331 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2332 : COMPOSE_REPLY_WITHOUT_QUOTE,
2336 static void toolbar_reply_to_all_cb(GtkWidget *widget,
2339 MainWindow *mainwin = (MainWindow *)data;
2342 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2343 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2347 static void toolbar_reply_to_list_cb(GtkWidget *widget,
2350 MainWindow *mainwin = (MainWindow *)data;
2353 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_LIST_WITH_QUOTE
2354 : COMPOSE_REPLY_TO_LIST_WITHOUT_QUOTE,
2358 static void toolbar_reply_to_sender_cb(GtkWidget *widget,
2361 MainWindow *mainwin = (MainWindow *)data;
2364 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2365 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2369 static void toolbar_forward_cb(GtkWidget *widget,
2372 MainWindow *mainwin = (MainWindow *)data;
2374 if (prefs_common.forward_as_attachment)
2375 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2377 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2380 static void toolbar_delete_cb(GtkWidget *widget,
2383 MainWindow *mainwin = (MainWindow *)data;
2385 summary_delete(mainwin->summaryview);
2388 static void toolbar_exec_cb(GtkWidget *widget,
2391 MainWindow *mainwin = (MainWindow *)data;
2393 summary_execute(mainwin->summaryview);
2396 static void toolbar_next_unread_cb(GtkWidget *widget,
2399 MainWindow *mainwin = (MainWindow *)data;
2401 next_unread_cb(mainwin, 0, NULL);
2404 /* popup callback functions */
2405 static void toolbar_reply_popup_cb(GtkWidget *widget,
2406 GdkEventButton *event,
2409 MainWindow *mainwindow = (MainWindow *) data;
2413 if (event->button == 3) {
2414 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2415 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->reply_popup), NULL, NULL,
2416 menu_button_position, widget,
2417 event->button, event->time);
2421 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2423 MainWindow *mainwin = (MainWindow *)data;
2425 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->reply_btn), GTK_RELIEF_NONE);
2426 manage_window_focus_in(mainwin->window, NULL, NULL);
2429 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2431 MainWindow *mainwindow = (MainWindow *) data;
2435 if (event->button == 3) {
2436 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2437 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replyall_popup), NULL, NULL,
2438 menu_button_position, widget,
2439 event->button, event->time);
2443 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2445 MainWindow *mainwin = (MainWindow *)data;
2447 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replyall_btn), GTK_RELIEF_NONE);
2448 manage_window_focus_in(mainwin->window, NULL, NULL);
2451 static void toolbar_reply_to_list_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2453 MainWindow *mainwindow = (MainWindow *) data;
2457 if (event->button == 3) {
2458 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2459 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replylist_popup), NULL, NULL,
2460 menu_button_position, widget,
2461 event->button, event->time);
2465 static void toolbar_reply_to_list_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2467 MainWindow *mainwin = (MainWindow *)data;
2469 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replylist_btn), GTK_RELIEF_NONE);
2470 manage_window_focus_in(mainwin->window, NULL, NULL);
2473 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2475 MainWindow *mainwindow = (MainWindow *) data;
2479 if (event->button == 3) {
2480 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2481 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->replysender_popup), NULL, NULL,
2482 menu_button_position, widget,
2483 event->button, event->time);
2487 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2489 MainWindow *mainwin = (MainWindow *)data;
2491 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->replysender_btn), GTK_RELIEF_NONE);
2492 manage_window_focus_in(mainwin->window, NULL, NULL);
2495 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2497 MainWindow *mainwindow = (MainWindow *) data;
2501 if (event->button == 3) {
2502 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2503 gtk_menu_popup(GTK_MENU(mainwindow->toolbar->fwd_popup), NULL, NULL,
2504 menu_button_position, widget,
2505 event->button, event->time);
2509 static void toolbar_forward_popup_closed_cb (GtkMenuShell *menu_shell,
2512 MainWindow *mainwin = (MainWindow *)data;
2514 gtk_button_set_relief(GTK_BUTTON(mainwin->toolbar->fwd_btn), GTK_RELIEF_NONE);
2515 manage_window_focus_in(mainwin->window, NULL, NULL);
2518 static void activate_compose_button (MainToolbar *toolbar,
2520 ComposeButtonType type)
2522 if ((!toolbar->compose_mail_btn) || (!toolbar->compose_news_btn))
2525 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? toolbar->compose_mail_btn
2526 : toolbar->compose_news_btn);
2527 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? toolbar->compose_news_btn
2528 : toolbar->compose_mail_btn);
2529 toolbar->compose_btn_type = type;
2532 void toolbar_set_compose_button(MainToolbar *toolbar,
2533 ComposeButtonType compose_btn_type)
2535 if (toolbar->compose_btn_type != compose_btn_type)
2536 activate_compose_button(toolbar,
2537 prefs_common.toolbar_style,
2541 static void toolbar_buttons_cb(GtkWidget *widget,
2542 ToolbarItem *t_item)
2546 void (*func)(GtkWidget *widget, gpointer data);
2547 } toolbar_action[] = {
2548 { A_RECEIVE_ALL, toolbar_inc_all_cb },
2549 { A_RECEIVE_CUR, toolbar_inc_cb },
2550 { A_SEND_QUEUED, toolbar_send_cb },
2551 { A_COMPOSE_EMAIL, toolbar_compose_cb },
2552 { A_REPLY_MESSAGE, toolbar_reply_cb },
2553 { A_REPLY_SENDER, toolbar_reply_to_sender_cb },
2554 { A_REPLY_ALL, toolbar_reply_to_all_cb },
2555 { A_REPLY_ML, toolbar_reply_to_list_cb },
2556 { A_FORWARD, toolbar_forward_cb },
2557 { A_DELETE, toolbar_delete_cb },
2558 { A_EXECUTE, toolbar_exec_cb },
2559 { A_GOTO_NEXT, toolbar_next_unread_cb },
2560 { A_SYL_ACTIONS, toolbar_actions_execute_cb },
2562 { A_COMPOSE_NEWS, toolbar_compose_cb },
2563 { A_SEPARATOR, NULL }};
2565 gint num_items = sizeof(toolbar_action)/sizeof(toolbar_action[0]);
2568 for (i = A_RECEIVE_ALL; i < num_items; i++) {
2570 if (toolbar_action[i].index == t_item->index) {
2571 MainWindow *mainwin = (MainWindow*)t_item->parent;
2572 toolbar_action[i].func(widget, mainwin);
2578 static void toolbar_actions_execute_cb(GtkWidget *widget,
2581 MainWindow *mainwin = (MainWindow*)data;
2583 toolbar_action_execute(widget, mainwin->toolbar->t_action_list, data, TOOLBAR_MAIN);
2586 void toolbar_set_sensitive(MainWindow *mainwin)
2588 SensitiveCond state;
2590 MainToolbar *toolbar = mainwin->toolbar;
2592 GSList *entry_list = NULL;
2594 typedef struct _Entry Entry;
2601 #define SET_WIDGET_COND(w, c) \
2603 Entry *e = g_new0(Entry, 1); \
2606 entry_list = g_slist_append(entry_list, e); \
2609 SET_WIDGET_COND(toolbar->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2610 SET_WIDGET_COND(toolbar->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
2611 SET_WIDGET_COND(toolbar->compose_news_btn, M_HAVE_ACCOUNT);
2612 SET_WIDGET_COND(toolbar->reply_btn,
2613 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2614 SET_WIDGET_COND(toolbar->replyall_btn,
2615 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2616 SET_WIDGET_COND(toolbar->replylist_btn,
2617 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2618 SET_WIDGET_COND(toolbar->replysender_btn,
2619 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
2620 SET_WIDGET_COND(toolbar->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
2622 SET_WIDGET_COND(toolbar->next_btn, M_MSG_EXIST);
2623 SET_WIDGET_COND(toolbar->delete_btn,
2624 M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
2625 SET_WIDGET_COND(toolbar->exec_btn, M_DELAY_EXEC);
2627 for (cur = toolbar->t_action_list; cur != NULL; cur = cur->next) {
2628 ToolbarSylpheedActions *act = (ToolbarSylpheedActions*)cur->data;
2630 SET_WIDGET_COND(act->widget, M_TARGET_EXIST|M_UNLOCKED);
2633 #undef SET_WIDGET_COND
2635 state = main_window_get_current_state(mainwin);
2637 for (cur = entry_list; cur != NULL; cur = cur->next) {
2638 Entry *e = (Entry*) cur->data;
2640 if (e->widget != NULL) {
2641 sensitive = ((e->cond & state) == e->cond);
2642 gtk_widget_set_sensitive(e->widget, sensitive);
2646 while (entry_list != NULL) {
2647 Entry *e = (Entry*) entry_list->data;
2651 entry_list = g_slist_remove(entry_list, e);
2654 g_slist_free(entry_list);
2656 activate_compose_button(toolbar,
2657 prefs_common.toolbar_style,
2658 toolbar->compose_btn_type);
2661 static void toolbar_update(MainWindow *mainwin)
2663 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox),
2664 GTK_WIDGET(mainwin->toolbar->toolbar));
2666 mainwin->toolbar->toolbar = NULL;
2667 mainwin->toolbar->get_btn = NULL;
2668 mainwin->toolbar->getall_btn = NULL;
2669 mainwin->toolbar->send_btn = NULL;
2670 mainwin->toolbar->compose_mail_btn = NULL;
2671 mainwin->toolbar->compose_news_btn = NULL;
2672 mainwin->toolbar->reply_btn = NULL;
2673 mainwin->toolbar->replyall_btn = NULL;
2674 mainwin->toolbar->replylist_btn = NULL;
2675 mainwin->toolbar->replysender_btn = NULL;
2676 mainwin->toolbar->fwd_btn = NULL;
2677 mainwin->toolbar->delete_btn = NULL;
2678 mainwin->toolbar->next_btn = NULL;
2679 mainwin->toolbar->exec_btn = NULL;
2681 toolbar_clear_list(TOOLBAR_MAIN);
2682 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->t_action_list);
2683 toolbar_create(mainwin, mainwin->handlebox);
2684 toolbar_set_sensitive(mainwin);
2688 static void toolbar_create(MainWindow *mainwin,
2689 GtkWidget *container)
2691 ToolbarItem *toolbar_item;
2694 GtkWidget *icon_wid = NULL;
2695 GtkWidget *icon_news = NULL;
2696 GtkWidget *item_news = NULL;
2698 GtkTooltips *toolbar_tips;
2699 ToolbarSylpheedActions *t_action_item;
2701 GSList *toolbar_list;
2703 guint n_menu_entries;
2704 GtkWidget *reply_popup;
2705 GtkWidget *replyall_popup;
2706 GtkWidget *replylist_popup;
2707 GtkWidget *replysender_popup;
2708 GtkWidget *fwd_popup;
2710 toolbar_tips = gtk_tooltips_new();
2712 if (mainwin->toolbar != NULL) {
2713 toolbar_clear_list(TOOLBAR_MAIN);
2714 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->t_action_list);
2715 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->t_item_list);
2716 g_free(mainwin->toolbar);
2719 toolbar_read_config_file(TOOLBAR_MAIN);
2720 toolbar_list = toolbar_get_list(TOOLBAR_MAIN);
2722 mainwin->toolbar = g_new0(MainToolbar, 1);
2724 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
2726 gtk_container_add(GTK_CONTAINER(container), toolbar);
2727 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
2728 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
2729 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
2730 GTK_TOOLBAR_SPACE_LINE);
2732 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
2734 if (g_strcasecmp(((ToolbarItem*)cur->data)->file, SEPARATOR) == 0) {
2735 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2739 toolbar_item = g_new0(ToolbarItem, 1);
2740 toolbar_item->file = g_strdup(((ToolbarItem*)cur->data)->file);
2741 toolbar_item->text = g_strdup(((ToolbarItem*)cur->data)->text);
2742 toolbar_item->index = ((ToolbarItem*)cur->data)->index;
2744 toolbar_item->parent = (gpointer)mainwin;
2746 /* collect toolbar items in list to keep track */
2747 mainwin->toolbar->t_item_list = g_slist_append(mainwin->toolbar->t_item_list,
2750 icon_wid = stock_pixmap_widget(container, stock_pixmap_get_icon(toolbar_item->file));
2751 item = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2755 icon_wid, toolbar_buttons_cb,
2758 switch (toolbar_item->index) {
2760 mainwin->toolbar->getall_btn = item;
2761 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2762 mainwin->toolbar->getall_btn,
2763 _("Receive Mail on all Accounts"), NULL);
2766 mainwin->toolbar->get_btn = item;
2767 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2768 mainwin->toolbar->get_btn,
2769 _("Receive Mail on current Account"), NULL);
2772 mainwin->toolbar->send_btn = item;
2773 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2774 mainwin->toolbar->send_btn,
2775 _("Send Queued Message(s)"), NULL);
2777 case A_COMPOSE_EMAIL:
2778 icon_news = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2779 item_news = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2783 icon_news, toolbar_buttons_cb,
2785 mainwin->toolbar->compose_mail_btn = item;
2786 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2787 mainwin->toolbar->compose_mail_btn,
2788 _("Compose Email"), NULL);
2789 mainwin->toolbar->compose_news_btn = item_news;
2790 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2791 mainwin->toolbar->compose_news_btn,
2792 _("Compose News"), NULL);
2794 case A_REPLY_MESSAGE:
2795 mainwin->toolbar->reply_btn = item;
2796 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2797 mainwin->toolbar->reply_btn,
2798 _("Reply to Message"), NULL);
2799 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->reply_btn),
2800 "button_press_event",
2801 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2803 n_menu_entries = sizeof(reply_popup_entries) /
2804 sizeof(reply_popup_entries[0]);
2805 reply_popup = popupmenu_create(mainwin->window, reply_popup_entries, n_menu_entries,
2806 "<ReplyPopup>", mainwin);
2807 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
2808 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
2809 mainwin->toolbar->reply_popup = reply_popup;
2811 case A_REPLY_SENDER:
2812 mainwin->toolbar->replysender_btn = item;
2813 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2814 mainwin->toolbar->replysender_btn,
2815 _("Reply to Sender"), NULL);
2816 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replysender_btn),
2817 "button_press_event",
2818 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2820 n_menu_entries = sizeof(replysender_popup_entries) /
2821 sizeof(replysender_popup_entries[0]);
2822 replysender_popup = popupmenu_create(mainwin->window,
2823 replysender_popup_entries, n_menu_entries,
2824 "<ReplySenderPopup>", mainwin);
2825 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
2826 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
2827 mainwin->toolbar->replysender_popup = replysender_popup;
2830 mainwin->toolbar->replyall_btn = item;
2831 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2832 mainwin->toolbar->replyall_btn,
2833 _("Reply to All"), NULL);
2834 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replyall_btn),
2835 "button_press_event",
2836 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2838 n_menu_entries = sizeof(replyall_popup_entries) /
2839 sizeof(replyall_popup_entries[0]);
2840 replyall_popup = popupmenu_create(mainwin->window,
2841 replyall_popup_entries, n_menu_entries,
2842 "<ReplyAllPopup>", mainwin);
2843 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
2844 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
2845 mainwin->toolbar->replyall_popup = replyall_popup;
2848 mainwin->toolbar->replylist_btn = item;
2849 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2850 mainwin->toolbar->replylist_btn,
2851 _("Reply to Mailing-list"), NULL);
2852 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->replylist_btn),
2853 "button_press_event",
2854 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_cb),
2856 n_menu_entries = sizeof(replylist_popup_entries) /
2857 sizeof(replylist_popup_entries[0]);
2858 replylist_popup = popupmenu_create(mainwin->window,
2859 replylist_popup_entries, n_menu_entries,
2860 "<ReplyMlPopup>", mainwin);
2861 gtk_signal_connect(GTK_OBJECT(replylist_popup), "selection_done",
2862 GTK_SIGNAL_FUNC(toolbar_reply_to_list_popup_closed_cb), mainwin);
2863 mainwin->toolbar->replylist_popup = replylist_popup;
2866 mainwin->toolbar->fwd_btn = item;
2867 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2868 mainwin->toolbar->fwd_btn,
2869 _("Forward Message"), NULL);
2870 gtk_signal_connect(GTK_OBJECT(mainwin->toolbar->fwd_btn),
2871 "button_press_event",
2872 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2874 n_menu_entries = sizeof(fwd_popup_entries) /
2875 sizeof(fwd_popup_entries[0]);
2876 fwd_popup = popupmenu_create(mainwin->window,
2877 fwd_popup_entries, n_menu_entries,
2878 "<ForwardPopup>", mainwin);
2879 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
2880 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
2881 mainwin->toolbar->fwd_popup = fwd_popup;
2884 mainwin->toolbar->delete_btn = item;
2885 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2886 mainwin->toolbar->delete_btn,
2887 _("Delete Message"), NULL);
2890 mainwin->toolbar->exec_btn = item;
2891 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2892 mainwin->toolbar->exec_btn,
2893 _("Execute"), NULL);
2896 mainwin->toolbar->next_btn = item;
2897 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2898 mainwin->toolbar->next_btn,
2899 _("Goto Next Message"), NULL);
2902 t_action_item = g_new0(ToolbarSylpheedActions, 1);
2903 t_action_item->widget = item;
2904 t_action_item->name = g_strdup(toolbar_item->text);
2906 mainwin->toolbar->t_action_list =
2907 g_slist_append(mainwin->toolbar->t_action_list,
2910 gtk_tooltips_set_tip(GTK_TOOLTIPS(toolbar_tips),
2912 t_action_item->name, NULL);
2914 gtk_widget_show(item);
2921 mainwin->toolbar->toolbar = toolbar;
2923 activate_compose_button(mainwin->toolbar,
2924 prefs_common.toolbar_style,
2925 mainwin->toolbar->compose_btn_type);
2927 gtk_widget_show_all(toolbar);
2930 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2933 switch ((ToolbarStyle)action) {
2935 gtk_widget_hide(mainwin->handlebox);
2937 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2941 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2945 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
2950 if (action != TOOLBAR_NONE) {
2951 gtk_widget_show(mainwin->handlebox);
2952 gtk_widget_queue_resize(mainwin->handlebox);
2955 mainwin->toolbar_style = (ToolbarStyle)action;
2956 prefs_common.toolbar_style = (ToolbarStyle)action;
2959 /* END Toolbar Stuff */
2961 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2964 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2965 gtk_widget_show(mainwin->hbox_stat);
2966 prefs_common.show_statusbar = TRUE;
2968 gtk_widget_hide(mainwin->hbox_stat);
2969 prefs_common.show_statusbar = FALSE;
2973 static void separate_widget_cb(MainWindow *mainwin, guint action,
2978 if (GTK_CHECK_MENU_ITEM(widget)->active)
2979 type = mainwin->type | action;
2981 type = mainwin->type & ~action;
2983 main_window_separation_change(mainwin, type);
2985 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2986 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2989 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline)
2992 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2994 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2997 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2999 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active);
3002 static void online_switch_clicked (GtkButton *btn, gpointer data)
3004 MainWindow *mainwin;
3005 GtkItemFactory *ifactory;
3006 GtkCheckMenuItem *menuitem;
3008 mainwin = (MainWindow *) data;
3010 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3011 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3013 g_return_if_fail(mainwin != NULL);
3014 g_return_if_fail(menuitem != NULL);
3016 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3018 gtk_widget_hide (mainwin->online_switch);
3019 gtk_widget_show (mainwin->offline_switch);
3020 menuitem->active = TRUE;
3021 prefs_common.work_offline = TRUE;
3022 inc_autocheck_timer_remove();
3025 gtk_widget_hide (mainwin->offline_switch);
3026 gtk_widget_show (mainwin->online_switch);
3027 menuitem->active = FALSE;
3028 prefs_common.work_offline = FALSE;
3029 inc_autocheck_timer_set();
3033 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3036 addressbook_open(NULL);
3039 static void log_window_show_cb(MainWindow *mainwin, guint action,
3042 log_window_show(mainwin->logwin);
3045 static void sel_download_cb(MainWindow *mainwin, guint action,
3048 selective_download(mainwin);
3051 static void prefs_toolbar_cb(MainWindow *mainwin, guint action,
3054 prefs_toolbar(action);
3058 void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3060 inc_mail(mainwin, prefs_common.newmail_notify_manu);
3063 void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
3066 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
3069 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3074 void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3078 if (prefs_common.work_offline)
3079 if (alertpanel(_("Offline warning"),
3080 _("You're working offline. Override?"),
3081 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
3084 for (list = folder_get_list(); list != NULL; list = list->next) {
3085 Folder *folder = list->data;
3087 if (folder->queue) {
3088 if (procmsg_send_queue
3089 (folder->queue, prefs_common.savemsg) < 0)
3090 alertpanel_error(_("Some errors occurred while sending queued messages."));
3091 statusbar_pop_all();
3092 folder_item_scan(folder->queue);
3093 folderview_update_item(folder->queue, TRUE);
3098 void compose_mail_cb(MainWindow *mainwin, guint action,
3101 PrefsAccount *ac = NULL;
3102 FolderItem *item = mainwin->summaryview->folder_item;
3107 ac = account_find_from_item(item);
3108 if (ac && ac->protocol != A_NNTP) {
3109 compose_new_with_folderitem(ac, item); /* CLAWS */
3115 * CLAWS - use current account
3117 if (cur_account && (cur_account->protocol != A_NNTP)) {
3118 compose_new_with_folderitem(cur_account, item);
3123 * CLAWS - just get the first one
3125 list = account_get_list();
3126 for (cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3127 ac = (PrefsAccount *) cur->data;
3128 if (ac->protocol != A_NNTP) {
3129 compose_new_with_folderitem(ac, item);
3135 void compose_news_cb(MainWindow *mainwin, guint action,
3138 PrefsAccount * ac = NULL;
3142 if (mainwin->summaryview->folder_item) {
3143 ac = mainwin->summaryview->folder_item->folder->account;
3144 if (ac && ac->protocol == A_NNTP) {
3146 mainwin->summaryview->folder_item->path,
3152 list = account_get_list();
3153 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
3154 ac = (PrefsAccount *) cur->data;
3155 if (ac->protocol == A_NNTP) {
3156 compose_new(ac, NULL, NULL);
3162 void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3164 summary_reply(mainwin->summaryview, (ComposeMode)action);
3167 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3169 summary_move_to(mainwin->summaryview);
3172 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3174 summary_copy_to(mainwin->summaryview);
3177 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3179 summary_delete(mainwin->summaryview);
3182 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3184 summary_cancel(mainwin->summaryview);
3187 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3189 summary_open_msg(mainwin->summaryview);
3192 static void view_source_cb(MainWindow *mainwin, guint action,
3195 summary_view_source(mainwin->summaryview);
3198 static void show_all_header_cb(MainWindow *mainwin, guint action,
3201 if (mainwin->menu_lock_count) return;
3202 summary_display_msg_selected(mainwin->summaryview,
3203 GTK_CHECK_MENU_ITEM(widget)->active);
3206 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3208 summary_reedit(mainwin->summaryview);
3211 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3213 summary_mark(mainwin->summaryview);
3216 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3218 summary_unmark(mainwin->summaryview);
3221 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3224 summary_mark_as_unread(mainwin->summaryview);
3227 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3230 summary_mark_as_read(mainwin->summaryview);
3233 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3236 summary_mark_all_read(mainwin->summaryview);
3239 static void add_address_cb(MainWindow *mainwin, guint action,
3242 summary_add_address(mainwin->summaryview);
3245 static void set_charset_cb(MainWindow *mainwin, guint action,
3250 str = conv_get_charset_str((CharSet)action);
3251 g_free(prefs_common.force_charset);
3252 prefs_common.force_charset = str ? g_strdup(str) : NULL;
3254 summary_redisplay_msg(mainwin->summaryview);
3256 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3259 static void hide_read_messages (MainWindow *mainwin, guint action,
3262 if (!mainwin->summaryview->folder_item
3263 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
3265 summary_toggle_show_read_messages(mainwin->summaryview);
3268 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3270 if (mainwin->menu_lock_count) return;
3271 if (!mainwin->summaryview->folder_item) return;
3273 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3274 summary_thread_build(mainwin->summaryview);
3275 /* mainwin->summaryview->folder_item->threaded = TRUE; */
3277 summary_unthread(mainwin->summaryview);
3278 /* mainwin->summaryview->folder_item->threaded = FALSE; */
3282 static void expand_threads_cb(MainWindow *mainwin, guint action,
3285 summary_expand_threads(mainwin->summaryview);
3288 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3291 summary_collapse_threads(mainwin->summaryview);
3294 static void set_display_item_cb(MainWindow *mainwin, guint action,
3297 prefs_summary_column_open();
3300 static void sort_summary_cb(MainWindow *mainwin, guint action,
3303 FolderItem *item = mainwin->summaryview->folder_item;
3304 GtkWidget *menuitem;
3306 if (mainwin->menu_lock_count) return;
3308 menuitem = gtk_item_factory_get_item
3309 (mainwin->menu_factory, "/View/Sort/Ascending");
3310 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3311 GTK_CHECK_MENU_ITEM(menuitem)->active
3312 ? SORT_ASCENDING : SORT_DESCENDING);
3316 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3319 FolderItem *item = mainwin->summaryview->folder_item;
3321 if (mainwin->menu_lock_count) return;
3323 summary_sort(mainwin->summaryview,
3324 item->sort_key, (FolderSortType)action);
3327 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3330 summary_attract_by_subject(mainwin->summaryview);
3333 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3336 summary_delete_duplicated(mainwin->summaryview);
3339 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3341 summary_filter(mainwin->summaryview);
3344 static void execute_summary_cb(MainWindow *mainwin, guint action,
3347 summary_execute(mainwin->summaryview);
3350 static void update_summary_cb(MainWindow *mainwin, guint action,
3354 FolderView *folderview = mainwin->folderview;
3356 if (!mainwin->summaryview->folder_item) return;
3357 if (!folderview->opened) return;
3359 folder_update_op_count();
3361 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3362 folderview->opened);
3365 folder_item_scan(fitem);
3366 summary_show(mainwin->summaryview, fitem);
3369 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3371 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3374 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3376 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3379 static void prev_unread_cb(MainWindow *mainwin, guint action,
3382 summary_select_prev_unread(mainwin->summaryview);
3385 void next_unread_cb(MainWindow *mainwin, guint action,
3388 summary_select_next_unread(mainwin->summaryview);
3391 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3393 summary_select_prev_new(mainwin->summaryview);
3396 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3398 summary_select_next_new(mainwin->summaryview);
3401 static void prev_marked_cb(MainWindow *mainwin, guint action,
3404 summary_select_prev_marked(mainwin->summaryview);
3407 static void next_marked_cb(MainWindow *mainwin, guint action,
3410 summary_select_next_marked(mainwin->summaryview);
3413 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3416 summary_select_prev_labeled(mainwin->summaryview);
3419 static void next_labeled_cb(MainWindow *mainwin, guint action,
3422 summary_select_next_labeled(mainwin->summaryview);
3425 static void goto_folder_cb(MainWindow *mainwin, guint action,
3428 FolderItem *to_folder;
3430 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3433 folderview_select(mainwin->folderview, to_folder);
3436 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3438 messageview_copy_clipboard(mainwin->messageview);
3441 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3443 MessageView *msgview = mainwin->messageview;
3445 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3446 summary_select_all(mainwin->summaryview);
3447 else if (messageview_is_visible(msgview) &&
3448 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
3449 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3450 messageview_select_all(mainwin->messageview);
3453 static void select_thread_cb(MainWindow *mainwin, guint action,
3456 summary_select_thread(mainwin->summaryview);
3459 static void create_filter_cb(MainWindow *mainwin, guint action,
3462 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3465 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3468 prefs_common_open();
3471 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3474 prefs_scoring_open(NULL);
3477 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3480 prefs_filtering_open(NULL, NULL, NULL);
3483 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3486 prefs_template_open();
3489 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3492 prefs_actions_open(mainwin);
3495 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3499 new_account_cb(mainwin, 0, widget);
3501 account_open(cur_account);
3505 static void new_account_cb(MainWindow *mainwin, guint action,
3508 account_edit_open();
3509 if (!compose_get_compose_list()) account_add();
3512 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3514 cur_account = (PrefsAccount *)data;
3515 main_window_reflect_prefs_all();
3518 static void manual_open_cb(MainWindow *mainwin, guint action,
3521 manual_open((ManualType)action);
3524 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3526 MainWindow *mainwin = (MainWindow *)data;
3530 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3531 LOCAL_FOLDER(folder)->rootpath,
3535 str = g_strdup_printf(_("Scanning folder %s ..."),
3536 LOCAL_FOLDER(folder)->rootpath);
3538 STATUSBAR_PUSH(mainwin, str);
3539 STATUSBAR_POP(mainwin);
3543 #define BREAK_ON_MODIFIER_KEY() \
3544 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3546 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3548 MainWindow *mainwin = (MainWindow*) data;
3550 if (!mainwin || !event) return;
3552 switch (event->keyval) {
3553 case GDK_Q: /* Quit */
3554 BREAK_ON_MODIFIER_KEY();
3556 app_exit_cb(mainwin, 0, NULL);
3559 if (mainwin->folderview && mainwin->summaryview
3560 && !mainwin->summaryview->displayed) {
3561 summary_lock(mainwin->summaryview);
3562 folderview_select_next_unread(mainwin->folderview);
3563 summary_unlock(mainwin->summaryview);
3571 #undef BREAK_ON_MODIFIER_KEY
3573 static void set_toolbar_style(MainWindow *mainwin)
3575 switch (prefs_common.toolbar_style) {
3577 gtk_widget_hide(mainwin->handlebox);
3580 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
3584 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
3588 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar->toolbar),
3593 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3594 gtk_widget_show(mainwin->handlebox);
3595 gtk_widget_queue_resize(mainwin->handlebox);
3600 * Harvest addresses for selected folder.
3602 static void addr_harvest_cb( MainWindow *mainwin,
3606 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3610 * Harvest addresses for selected messages in summary view.
3612 static void addr_harvest_msg_cb( MainWindow *mainwin,
3616 summary_harvest_address( mainwin->summaryview );