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_filter.h"
64 #include "prefs_actions.h"
65 #include "prefs_filtering.h"
66 #include "prefs_scoring.h"
67 #include "prefs_account.h"
68 #include "prefs_folder_item.h"
69 #include "prefs_summary_column.h"
70 #include "prefs_template.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"
86 #define AC_LABEL_WIDTH 240
88 #define STATUSBAR_PUSH(mainwin, str) \
90 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
91 mainwin->mainwin_cid, str); \
92 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
95 #define STATUSBAR_POP(mainwin) \
97 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
98 mainwin->mainwin_cid); \
101 /* list of all instantiated MainWindow */
102 static GList *mainwin_list = NULL;
104 static GdkCursor *watch_cursor;
106 static void main_window_menu_callback_block (MainWindow *mainwin);
107 static void main_window_menu_callback_unblock (MainWindow *mainwin);
109 static void main_window_show_cur_account (MainWindow *mainwin);
111 static void main_window_set_widgets (MainWindow *mainwin,
113 static void main_window_toolbar_create (MainWindow *mainwin,
114 GtkWidget *container);
116 /* callback functions */
117 static void toolbar_inc_cb (GtkWidget *widget,
119 static void toolbar_inc_all_cb (GtkWidget *widget,
121 static void toolbar_send_cb (GtkWidget *widget,
124 static void toolbar_compose_cb (GtkWidget *widget,
126 static void toolbar_compose_news_cb (GtkWidget *widget,
128 static void toolbar_compose_mail_cb (GtkWidget *widget,
130 static void toolbar_reply_cb (GtkWidget *widget,
132 static void toolbar_reply_popup_cb (GtkWidget *widget,
133 GdkEventButton *event,
135 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell,
137 static void toolbar_reply_to_all_cb (GtkWidget *widget,
139 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget,
140 GdkEventButton *event,
142 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell,
144 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
146 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
147 GdkEventButton *event,
149 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell,
151 static void toolbar_forward_cb (GtkWidget *widget,
153 static void toolbar_forward_popup_cb (GtkWidget *widget,
154 GdkEventButton *event,
156 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell,
159 static void toolbar_delete_cb (GtkWidget *widget,
161 static void toolbar_exec_cb (GtkWidget *widget,
164 static void toolbar_next_unread_cb (GtkWidget *widget,
167 static void toolbar_prefs_cb (GtkWidget *widget,
169 static void toolbar_account_cb (GtkWidget *widget,
172 static void toolbar_account_button_pressed (GtkWidget *widget,
173 GdkEventButton *event,
175 static void ac_label_button_pressed (GtkWidget *widget,
176 GdkEventButton *event,
178 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
181 static gint main_window_close_cb (GtkWidget *widget,
185 static void add_mailbox_cb (MainWindow *mainwin,
188 static void add_mbox_cb (MainWindow *mainwin,
191 static void update_folderview_cb (MainWindow *mainwin,
194 static void new_folder_cb (MainWindow *mainwin,
197 static void rename_folder_cb (MainWindow *mainwin,
200 static void delete_folder_cb (MainWindow *mainwin,
203 static void import_mbox_cb (MainWindow *mainwin,
206 static void export_mbox_cb (MainWindow *mainwin,
209 static void empty_trash_cb (MainWindow *mainwin,
213 static void save_as_cb (MainWindow *mainwin,
216 static void print_cb (MainWindow *mainwin,
219 static void app_exit_cb (MainWindow *mainwin,
223 static void search_cb (MainWindow *mainwin,
227 static void toggle_folder_cb (MainWindow *mainwin,
230 static void toggle_message_cb (MainWindow *mainwin,
233 static void toggle_toolbar_cb (MainWindow *mainwin,
236 static void toggle_statusbar_cb (MainWindow *mainwin,
239 static void toggle_expand_summaryview_cb (MainWindow *mainwin,
242 static void toggle_expand_messageview_cb (MainWindow *mainwin,
245 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
249 static void addressbook_open_cb (MainWindow *mainwin,
252 static void log_window_show_cb (MainWindow *mainwin,
255 static void sel_download_cb (MainWindow *mainwin,
259 static void inc_mail_cb (MainWindow *mainwin,
262 static void inc_all_account_mail_cb (MainWindow *mainwin,
265 static void inc_cancel_cb (MainWindow *mainwin,
269 static void send_queue_cb (MainWindow *mainwin,
273 static void compose_cb (MainWindow *mainwin,
276 static void compose_mail_cb(MainWindow *mainwin, guint action,
278 static void compose_news_cb(MainWindow *mainwin, guint action,
280 static void reply_cb (MainWindow *mainwin,
284 static void open_msg_cb (MainWindow *mainwin,
288 static void view_source_cb (MainWindow *mainwin,
292 static void show_all_header_cb (MainWindow *mainwin,
296 static void reedit_cb (MainWindow *mainwin,
300 static void move_to_cb (MainWindow *mainwin,
303 static void copy_to_cb (MainWindow *mainwin,
306 static void delete_cb (MainWindow *mainwin,
310 static void mark_cb (MainWindow *mainwin,
313 static void unmark_cb (MainWindow *mainwin,
317 static void mark_as_unread_cb (MainWindow *mainwin,
320 static void mark_as_read_cb (MainWindow *mainwin,
323 static void mark_all_read_cb (MainWindow *mainwin,
326 static void add_address_cb (MainWindow *mainwin,
330 static void set_charset_cb (MainWindow *mainwin,
334 static void hide_read_messages (MainWindow *mainwin,
338 static void thread_cb (MainWindow *mainwin,
341 static void set_display_item_cb (MainWindow *mainwin,
344 static void sort_summary_cb (MainWindow *mainwin,
347 static void attract_by_subject_cb(MainWindow *mainwin,
351 static void delete_duplicated_cb (MainWindow *mainwin,
354 static void filter_cb (MainWindow *mainwin,
357 static void execute_summary_cb (MainWindow *mainwin,
360 static void update_summary_cb (MainWindow *mainwin,
364 static void prev_cb (MainWindow *mainwin,
367 static void next_cb (MainWindow *mainwin,
371 static void prev_unread_cb (MainWindow *mainwin,
374 static void next_unread_cb (MainWindow *mainwin,
377 static void prev_marked_cb (MainWindow *mainwin,
380 static void next_marked_cb (MainWindow *mainwin,
383 static void prev_labeled_cb (MainWindow *mainwin,
386 static void next_labeled_cb (MainWindow *mainwin,
390 static void goto_folder_cb (MainWindow *mainwin,
394 static void copy_cb (MainWindow *mainwin,
397 static void allsel_cb (MainWindow *mainwin,
400 static void selthread_cb (MainWindow *mainwin,
403 static void create_filter_cb (MainWindow *mainwin,
407 static void prefs_common_open_cb (MainWindow *mainwin,
410 static void prefs_filter_open_cb (MainWindow *mainwin,
413 static void prefs_scoring_open_cb (MainWindow *mainwin,
416 static void prefs_filtering_open_cb (MainWindow *mainwin,
419 static void prefs_account_open_cb(MainWindow *mainwin,
422 static void prefs_template_open_cb (MainWindow *mainwin,
425 static void prefs_actions_open_cb (MainWindow *mainwin,
428 static void new_account_cb (MainWindow *mainwin,
432 static void account_menu_cb (GtkMenuItem *menuitem,
435 static void manual_open_cb (MainWindow *mainwin,
438 static void faq_open_cb (MainWindow *mainwin,
442 static void scan_tree_func (Folder *folder,
446 static void activate_compose_button (MainWindow *mainwin,
448 ComposeButtonType type);
450 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
454 static void key_pressed (GtkWidget *widget,
458 static void set_toolbar_style(MainWindow *mainwin);
460 static void addr_gather_cb ( MainWindow *mainwin,
464 #define SEPARATE_ACTION 667
466 static GtkItemFactoryEntry mainwin_entries[] =
468 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
469 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
470 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
471 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
472 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
473 {N_("/_File/_Folder/Create _new folder..."),
474 NULL, new_folder_cb, 0, NULL},
475 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
476 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
477 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
478 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
479 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
480 {N_("/_File/_Gather addresses..."), NULL, addr_gather_cb, 0, NULL},
481 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
482 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
483 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
484 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
485 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
487 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
488 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
489 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
490 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
491 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
492 {N_("/_Edit/_Find in current message..."),
493 "<control>F", search_cb, 0, NULL},
494 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
496 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
497 {N_("/_View/Separate _Folder Tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
498 {N_("/_View/Separate _Message View"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
499 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
500 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
501 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
502 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
503 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
504 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
505 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
506 {N_("/_View/Status _bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
507 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
508 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
509 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
510 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
511 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
512 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
513 {N_("/_View/_Sort/Sort by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
514 {N_("/_View/_Sort/Sort by _color label"),
515 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
516 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
517 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
518 {N_("/_View/_Sort/Sort by a_ttachment"),
519 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
520 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
521 {N_("/_View/_Sort/_Attract by subject"),
522 NULL, attract_by_subject_cb, 0, NULL},
523 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
524 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
525 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
526 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
528 #define CODESET_SEPARATOR \
529 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
530 #define CODESET_ACTION(action) \
531 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
533 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
534 {N_("/_View/_Code set/_Auto detect"),
535 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
536 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
537 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
538 CODESET_ACTION(C_US_ASCII)},
541 {N_("/_View/_Code set/Unicode (_UTF-8)"),
542 CODESET_ACTION(C_UTF_8)},
545 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
546 CODESET_ACTION(C_ISO_8859_1)},
547 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
548 CODESET_ACTION(C_ISO_8859_15)},
551 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
552 CODESET_ACTION(C_ISO_8859_2)},
554 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
555 CODESET_ACTION(C_ISO_8859_13)},
556 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
557 CODESET_ACTION(C_ISO_8859_4)},
559 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
560 CODESET_ACTION(C_ISO_8859_7)},
562 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
563 CODESET_ACTION(C_ISO_8859_9)},
565 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
566 CODESET_ACTION(C_ISO_8859_5)},
567 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
568 CODESET_ACTION(C_KOI8_R)},
569 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
570 CODESET_ACTION(C_CP1251)},
573 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
574 CODESET_ACTION(C_ISO_2022_JP)},
576 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
577 CODESET_ACTION(C_ISO_2022_JP_2)},
579 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
580 CODESET_ACTION(C_EUC_JP)},
581 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
582 CODESET_ACTION(C_SHIFT_JIS)},
585 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
586 CODESET_ACTION(C_GB2312)},
587 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
588 CODESET_ACTION(C_BIG5)},
589 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
590 CODESET_ACTION(C_EUC_TW)},
591 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
592 CODESET_ACTION(C_ISO_2022_CN)},
594 {N_("/_View/_Code set/Korean (EUC-_KR)"),
595 CODESET_ACTION(C_EUC_KR)},
596 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
597 CODESET_ACTION(C_ISO_2022_KR)},
599 {N_("/_View/_Code set/Thai (TIS-620)"),
600 CODESET_ACTION(C_TIS_620)},
601 {N_("/_View/_Code set/Thai (Windows-874)"),
602 CODESET_ACTION(C_WINDOWS_874)},
605 #undef CODESET_SEPARATOR
606 #undef CODESET_ACTION
608 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
609 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
610 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
611 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
612 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
613 {N_("/_View/_Go to/P_rev unread message"),
614 "<shift>P", prev_unread_cb, 0, NULL},
615 {N_("/_View/_Go to/N_ext unread message"),
616 "<shift>N", next_unread_cb, 0, NULL},
617 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
618 {N_("/_View/_Go to/Prev _marked message"),
619 NULL, prev_marked_cb, 0, NULL},
620 {N_("/_View/_Go to/Next m_arked message"),
621 NULL, next_marked_cb, 0, NULL},
622 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
623 {N_("/_View/_Go to/Prev _labeled message"),
624 NULL, prev_labeled_cb, 0, NULL},
625 {N_("/_View/_Go to/Next la_beled message"),
626 NULL, next_labeled_cb, 0, NULL},
627 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
628 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
629 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
630 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
631 {N_("/_View/_View source"), "<control>U", view_source_cb, 0, NULL},
632 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
633 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
634 {N_("/_View/_Update"), "<control><alt>U", update_summary_cb, 0, NULL},
636 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
637 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
638 {N_("/_Message/Get from _all accounts"),
639 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
640 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
641 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
642 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
643 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
644 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
645 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
646 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
647 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
648 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
649 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
650 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
651 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
652 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
653 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
654 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
655 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
656 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
657 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
658 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
659 {N_("/_Message/Delete du_plicated messages"),
660 NULL, delete_duplicated_cb, 0, NULL},
661 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
662 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
663 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
664 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
665 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
666 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
667 {N_("/_Message/_Mark/Mark as rea_d"),
668 NULL, mark_as_read_cb, 0, NULL},
669 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
671 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
672 {N_("/_Tool/_Address book"), "<shift><control>A", addressbook_open_cb, 0, NULL},
673 {N_("/_Tool/Add sender to address boo_k"),
674 NULL, add_address_cb, 0, NULL},
675 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
676 {N_("/_Tool/_Filter messages"), NULL, filter_cb, 0, NULL},
677 {N_("/_Tool/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
678 {N_("/_Tool/_Create filter rule/_Automatically"),
679 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
680 {N_("/_Tool/_Create filter rule/by _From"),
681 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
682 {N_("/_Tool/_Create filter rule/by _To"),
683 NULL, create_filter_cb, FILTER_BY_TO, NULL},
684 {N_("/_Tool/_Create filter rule/by _Subject"),
685 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
687 {N_("/_Tool/Actio_ns"), NULL, NULL, 0, "<Branch>"},
689 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
690 {N_("/_Tool/E_xecute"), "X", execute_summary_cb, 0, NULL},
691 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
692 {N_("/_Tool/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
693 {N_("/_Tool/_Selective Download"), "<alt>S", sel_download_cb, 0, NULL},
695 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
696 {N_("/_Configuration/_Common preferences..."),
697 NULL, prefs_common_open_cb, 0, NULL},
698 {N_("/_Configuration/_Filter setting..."),
699 NULL, prefs_filter_open_cb, 0, NULL},
700 {N_("/_Configuration/_Scoring ..."),
701 NULL, prefs_scoring_open_cb, 0, NULL},
702 {N_("/_Configuration/_Filtering ..."),
703 NULL, prefs_filtering_open_cb, 0, NULL},
704 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
705 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
706 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
707 {N_("/_Configuration/_Preferences for current account..."),
708 NULL, prefs_account_open_cb, 0, NULL},
709 {N_("/_Configuration/Create _new account..."),
710 NULL, new_account_cb, 0, NULL},
711 {N_("/_Configuration/_Edit accounts..."),
712 NULL, account_edit_open, 0, NULL},
713 {N_("/_Configuration/C_hange current account"),
714 NULL, NULL, 0, "<Branch>"},
716 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
717 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
718 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
719 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
720 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
721 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
722 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
723 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
724 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
725 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
726 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
727 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
729 static GtkItemFactoryEntry reply_popup_entries[] =
731 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
732 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
734 static GtkItemFactoryEntry replyall_popup_entries[] =
736 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
737 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
739 static GtkItemFactoryEntry replysender_popup_entries[] =
741 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
742 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
744 static GtkItemFactoryEntry fwd_popup_entries[] =
746 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
747 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
751 MainWindow *main_window_create(SeparateType type)
757 GtkWidget *handlebox;
758 GtkWidget *vbox_body;
759 GtkWidget *hbox_stat;
760 GtkWidget *statusbar;
761 GtkWidget *progressbar;
762 GtkWidget *statuslabel;
763 GtkWidget *ac_button;
766 FolderView *folderview;
767 SummaryView *summaryview;
768 MessageView *messageview;
769 GdkColormap *colormap;
772 guint n_menu_entries;
773 GtkItemFactory *ifactory;
776 GtkWidget *compose_popup;
777 GtkWidget *reply_popup;
778 GtkWidget *replyall_popup;
779 GtkWidget *replysender_popup;
780 GtkWidget *fwd_popup;
783 debug_print(_("Creating main window...\n"));
784 mainwin = g_new0(MainWindow, 1);
787 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
788 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
789 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
790 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
791 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
792 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
793 MANAGE_WINDOW_SIGNALS_CONNECT(window);
794 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
795 GTK_SIGNAL_FUNC(key_pressed), mainwin);
797 gtk_widget_realize(window);
798 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
801 gtkut_widget_set_app_icon(window);
803 vbox = gtk_vbox_new(FALSE, 0);
804 gtk_widget_show(vbox);
805 gtk_container_add(GTK_CONTAINER(window), vbox);
808 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
809 menubar = menubar_create(window, mainwin_entries,
810 n_menu_entries, "<Main>", mainwin);
811 gtk_widget_show(menubar);
812 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
814 handlebox = gtk_handle_box_new();
815 gtk_widget_show(handlebox);
816 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
818 /* create the popup menus for the reply buttons specials */
819 n_menu_entries = sizeof(reply_popup_entries) /
820 sizeof(reply_popup_entries[0]);
821 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
822 "<ReplyPopup>", mainwin);
823 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
824 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
825 n_menu_entries = sizeof(replyall_popup_entries) /
826 sizeof(replyall_popup_entries[0]);
827 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
828 "<ReplyAllPopup>", mainwin);
829 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
830 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
831 n_menu_entries = sizeof(replysender_popup_entries) /
832 sizeof(replysender_popup_entries[0]);
833 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
834 "<ReplySenderPopup>", mainwin);
835 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
836 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
837 /* create the popup menu for the forward button */
838 n_menu_entries = sizeof(fwd_popup_entries) /
839 sizeof(fwd_popup_entries[0]);
840 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
841 "<ForwardPopup>", mainwin);
842 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
843 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
845 main_window_toolbar_create(mainwin, handlebox);
847 /* vbox that contains body */
848 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
849 gtk_widget_show(vbox_body);
850 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
851 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
853 hbox_stat = gtk_hbox_new(FALSE, 2);
854 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
856 statusbar = statusbar_create();
857 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
859 progressbar = gtk_progress_bar_new();
860 gtk_widget_set_usize(progressbar, 120, 1);
861 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
863 statuslabel = gtk_label_new("");
864 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
866 ac_button = gtk_button_new();
867 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
868 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
869 gtk_widget_set_usize(ac_button, -1, 1);
870 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
871 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
872 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
874 ac_label = gtk_label_new("");
875 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
877 gtk_widget_show_all(hbox_stat);
880 mainwin->folderview = folderview = folderview_create();
881 mainwin->summaryview = summaryview = summary_create();
882 mainwin->messageview = messageview = messageview_create();
883 mainwin->logwin = log_window_create();
885 folderview->mainwin = mainwin;
886 folderview->summaryview = summaryview;
888 summaryview->mainwin = mainwin;
889 summaryview->folderview = folderview;
890 summaryview->messageview = messageview;
891 summaryview->window = window;
893 messageview->mainwin = mainwin;
895 mainwin->window = window;
896 mainwin->vbox = vbox;
897 mainwin->menubar = menubar;
898 mainwin->handlebox = handlebox;
899 mainwin->vbox_body = vbox_body;
900 mainwin->hbox_stat = hbox_stat;
901 mainwin->statusbar = statusbar;
902 mainwin->progressbar = progressbar;
903 mainwin->statuslabel = statuslabel;
904 mainwin->ac_button = ac_button;
905 mainwin->ac_label = ac_label;
906 mainwin->reply_popup = reply_popup;
907 mainwin->replyall_popup = replyall_popup;
908 mainwin->replysender_popup = replysender_popup;
909 mainwin->fwd_popup = fwd_popup;
911 /* set context IDs for status bar */
912 mainwin->mainwin_cid = gtk_statusbar_get_context_id
913 (GTK_STATUSBAR(statusbar), "Main Window");
914 mainwin->folderview_cid = gtk_statusbar_get_context_id
915 (GTK_STATUSBAR(statusbar), "Folder View");
916 mainwin->summaryview_cid = gtk_statusbar_get_context_id
917 (GTK_STATUSBAR(statusbar), "Summary View");
919 /* allocate colors for summary view and folder view */
920 summaryview->color_marked.red = summaryview->color_marked.green = 0;
921 summaryview->color_marked.blue = (guint16)65535;
923 summaryview->color_dim.red = summaryview->color_dim.green =
924 summaryview->color_dim.blue = COLOR_DIM;
926 folderview->color_new.red = (guint16)55000;
927 folderview->color_new.green = folderview->color_new.blue = 15000;
929 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
930 &folderview->color_op);
932 summaryview->color_important.red = 0;
933 summaryview->color_important.green = 0;
934 summaryview->color_important.blue = (guint16)65535;
936 color[0] = summaryview->color_marked;
937 color[1] = summaryview->color_dim;
938 color[2] = folderview->color_new;
939 color[3] = folderview->color_op;
941 colormap = gdk_window_get_colormap(window->window);
942 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
943 for (i = 0; i < 4; i++) {
944 if (success[i] == FALSE)
945 g_warning(_("MainWindow: color allocation %d failed\n"), i);
948 debug_print(_("done.\n"));
950 main_window_set_widgets(mainwin, type);
953 ifactory = gtk_item_factory_from_widget(menubar);
954 menuitem = gtk_item_factory_get_item
955 (ifactory, "/View/Code set/Auto detect");
956 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
958 switch (prefs_common.toolbar_style) {
960 menuitem = gtk_item_factory_get_item
961 (ifactory, "/View/Toolbar/None");
964 menuitem = gtk_item_factory_get_item
965 (ifactory, "/View/Toolbar/Icon");
968 menuitem = gtk_item_factory_get_item
969 (ifactory, "/View/Toolbar/Text");
972 menuitem = gtk_item_factory_get_item
973 (ifactory, "/View/Toolbar/Icon and text");
975 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
977 gtk_widget_hide(mainwin->hbox_stat);
978 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
979 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
980 prefs_common.show_statusbar);
981 #if 0 /* FIXED SEPARATE WINDOWS */
982 /* Message view and Folder tree are always shown at startup
983 * make that in the menu visible */
984 menuitem = gtk_item_factory_get_item(ifactory, "/View/Message view");
985 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
986 menuitem = gtk_item_factory_get_item(ifactory, "/View/Folder tree");
987 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
989 /* set the check of the SEPARATE_xxx menu items. we also need the main window
990 * as a property and pass the action type to the callback */
991 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
993 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
994 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
995 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
996 GUINT_TO_POINTER(SEPARATE_FOLDER));
998 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
1000 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
1001 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
1002 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
1003 GUINT_TO_POINTER(SEPARATE_MESSAGE));
1005 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
1006 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
1009 /* set account selection menu */
1010 ac_menu = gtk_item_factory_get_widget
1011 (ifactory, "/Configuration/Change current account");
1012 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1013 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1014 mainwin->ac_menu = ac_menu;
1016 main_window_set_toolbar_sensitive(mainwin);
1018 /* Create actions menu */
1019 update_mainwin_actions_menu(ifactory, mainwin);
1021 /* show main window */
1022 gtk_widget_set_uposition(mainwin->window,
1023 prefs_common.mainwin_x,
1024 prefs_common.mainwin_y);
1025 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1026 prefs_common.mainwin_height);
1027 gtk_widget_show(mainwin->window);
1029 /* initialize views */
1030 folderview_init(folderview);
1031 summary_init(summaryview);
1032 messageview_init(messageview);
1033 log_window_init(mainwin->logwin);
1035 mainwin->lock_count = 0;
1036 mainwin->menu_lock_count = 0;
1037 mainwin->cursor_count = 0;
1040 watch_cursor = gdk_cursor_new(GDK_WATCH);
1042 mainwin_list = g_list_append(mainwin_list, mainwin);
1047 void main_window_cursor_wait(MainWindow *mainwin)
1050 if (mainwin->cursor_count == 0)
1051 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1053 mainwin->cursor_count++;
1058 void main_window_cursor_normal(MainWindow *mainwin)
1060 if (mainwin->cursor_count)
1061 mainwin->cursor_count--;
1063 if (mainwin->cursor_count == 0)
1064 gdk_window_set_cursor(mainwin->window->window, NULL);
1069 /* lock / unlock the user-interface */
1070 void main_window_lock(MainWindow *mainwin)
1072 if (mainwin->lock_count == 0)
1073 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1075 mainwin->lock_count++;
1077 main_window_set_menu_sensitive(mainwin);
1078 main_window_set_toolbar_sensitive(mainwin);
1081 void main_window_unlock(MainWindow *mainwin)
1083 if (mainwin->lock_count)
1084 mainwin->lock_count--;
1086 main_window_set_menu_sensitive(mainwin);
1087 main_window_set_toolbar_sensitive(mainwin);
1089 if (mainwin->lock_count == 0)
1090 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1093 static void main_window_menu_callback_block(MainWindow *mainwin)
1095 mainwin->menu_lock_count++;
1098 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1100 if (mainwin->menu_lock_count)
1101 mainwin->menu_lock_count--;
1104 void main_window_reflect_prefs_all(void)
1106 main_window_reflect_prefs_all_real(FALSE);
1109 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1112 MainWindow *mainwin;
1114 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1115 mainwin = (MainWindow *)cur->data;
1117 main_window_show_cur_account(mainwin);
1118 main_window_set_menu_sensitive(mainwin);
1119 main_window_set_toolbar_sensitive(mainwin);
1122 if (pixmap_theme_changed)
1124 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1125 mainwin->toolbar = NULL;
1126 main_window_toolbar_create(mainwin, mainwin->handlebox);
1127 set_toolbar_style(mainwin);
1128 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1129 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1130 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1133 summary_redisplay_msg(mainwin->summaryview);
1134 headerview_set_visibility(mainwin->messageview->headerview,
1135 prefs_common.display_header_pane);
1139 void main_window_set_summary_column(void)
1142 MainWindow *mainwin;
1144 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1145 mainwin = (MainWindow *)cur->data;
1146 summary_set_column_order(mainwin->summaryview);
1150 void main_window_set_account_menu(GList *account_list)
1152 GList *cur, *cur_ac, *cur_item;
1153 GtkWidget *menuitem;
1154 MainWindow *mainwin;
1155 PrefsAccount *ac_prefs;
1157 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1158 mainwin = (MainWindow *)cur->data;
1160 /* destroy all previous menu item */
1161 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1162 while (cur_item != NULL) {
1163 GList *next = cur_item->next;
1164 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1168 for (cur_ac = account_list; cur_ac != NULL;
1169 cur_ac = cur_ac->next) {
1170 ac_prefs = (PrefsAccount *)cur_ac->data;
1172 menuitem = gtk_menu_item_new_with_label
1173 (ac_prefs->account_name
1174 ? ac_prefs->account_name : _("Untitled"));
1175 gtk_widget_show(menuitem);
1176 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1177 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1178 GTK_SIGNAL_FUNC(account_menu_cb),
1184 static void main_window_show_cur_account(MainWindow *mainwin)
1189 ac_name = g_strdup(cur_account
1190 ? (cur_account->account_name
1191 ? cur_account->account_name : _("Untitled"))
1195 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1197 buf = g_strdup(PROG_VERSION);
1198 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1201 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1202 gtk_widget_queue_resize(mainwin->ac_button);
1207 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1209 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1210 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1211 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1213 if (mainwin->type == type) return;
1215 /* remove widgets from those containers */
1216 gtk_widget_ref(folder_wid);
1217 gtk_widget_ref(summary_wid);
1218 gtk_widget_ref(message_wid);
1219 gtkut_container_remove
1220 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1221 gtkut_container_remove
1222 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1223 gtkut_container_remove
1224 (GTK_CONTAINER(message_wid->parent), message_wid);
1226 /* clean containers */
1227 switch (mainwin->type) {
1229 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1231 case SEPARATE_FOLDER:
1232 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1233 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1235 case SEPARATE_MESSAGE:
1236 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1237 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1240 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1241 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1245 gtk_widget_hide(mainwin->window);
1246 main_window_set_widgets(mainwin, type);
1247 gtk_widget_show(mainwin->window);
1249 gtk_widget_unref(folder_wid);
1250 gtk_widget_unref(summary_wid);
1251 gtk_widget_unref(message_wid);
1254 void main_window_get_size(MainWindow *mainwin)
1256 GtkAllocation *allocation;
1258 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1260 prefs_common.summaryview_width = allocation->width;
1262 if (mainwin->summaryview->msg_is_toggled_on)
1263 prefs_common.summaryview_height = allocation->height;
1265 prefs_common.mainview_width = allocation->width;
1267 allocation = &mainwin->window->allocation;
1269 prefs_common.mainview_height = allocation->height;
1270 prefs_common.mainwin_width = allocation->width;
1271 prefs_common.mainwin_height = allocation->height;
1273 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1275 prefs_common.folderview_width = allocation->width;
1276 prefs_common.folderview_height = allocation->height;
1279 void main_window_get_position(MainWindow *mainwin)
1283 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1285 prefs_common.mainview_x = x;
1286 prefs_common.mainview_y = y;
1287 prefs_common.mainwin_x = x;
1288 prefs_common.mainwin_y = y;
1290 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1293 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1299 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1300 folder = FOLDER(list->data);
1301 if (folder && folder->trash && folder->trash->total > 0)
1305 if (!has_trash) return;
1308 if (alertpanel(_("Empty trash"),
1309 _("Empty all messages in trash?"),
1310 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1312 manage_window_focus_in(mainwin->window, NULL, NULL);
1315 procmsg_empty_trash();
1317 for (list = folder_get_list(); list != NULL; list = list->next) {
1318 folder = list->data;
1319 if (folder && folder->trash && folder->trash->total != 0) {
1320 folder_item_scan(folder->trash);
1321 folderview_update_item(folder->trash, TRUE);
1325 if (mainwin->summaryview->folder_item &&
1326 mainwin->summaryview->folder_item->stype == F_TRASH)
1327 gtk_widget_grab_focus(mainwin->folderview->ctree);
1330 void main_window_add_mailbox(MainWindow *mainwin)
1335 path = input_dialog(_("Add mailbox"),
1336 _("Input the location of mailbox.\n"
1337 "If the existing mailbox is specified, it will be\n"
1338 "scanned automatically."),
1341 if (folder_find_from_path(path)) {
1342 alertpanel_error(_("The mailbox `%s' already exists."), path);
1346 if (!strcmp(path, "Mail"))
1347 folder = folder_new(F_MH, _("Mailbox"), path);
1349 folder = folder_new(F_MH, g_basename(path), path);
1352 if (folder->create_tree(folder) < 0) {
1353 alertpanel_error(_("Creation of the mailbox failed.\n"
1354 "Maybe some files already exist, or you don't have the permission to write there."));
1355 folder_destroy(folder);
1360 folder_set_ui_func(folder, scan_tree_func, mainwin);
1361 folder->scan_tree(folder);
1362 folder_set_ui_func(folder, NULL, NULL);
1364 folderview_set(mainwin->folderview);
1367 void main_window_add_mbox(MainWindow *mainwin)
1373 path = input_dialog(_("Add mbox mailbox"),
1374 _("Input the location of mailbox."),
1379 if (folder_find_from_path(path)) {
1380 alertpanel_error(_("The mailbox `%s' already exists."), path);
1386 if (!strcmp(path, "Mail"))
1387 folder = folder_new(F_MBOX, _("Mailbox"), path);
1391 folder = folder_new(F_MBOX, g_basename(path), path);
1394 if (folder->create_tree(folder) < 0) {
1395 alertpanel_error(_("Creation of the mailbox failed."));
1396 folder_destroy(folder);
1402 item = folder_item_new(folder->name, NULL);
1403 item->folder = folder;
1404 folder->node = g_node_new(item);
1406 folder->create_folder(folder, item, "inbox");
1407 folder->create_folder(folder, item, "outbox");
1408 folder->create_folder(folder, item, "queue");
1409 folder->create_folder(folder, item, "draft");
1410 folder->create_folder(folder, item, "trash");
1412 folderview_set(mainwin->folderview);
1417 M_UNLOCKED = 1 << 0,
1418 M_MSG_EXIST = 1 << 1,
1419 M_TARGET_EXIST = 1 << 2,
1420 M_SINGLE_TARGET_EXIST = 1 << 3,
1422 M_ALLOW_REEDIT = 1 << 5,
1423 M_HAVE_ACCOUNT = 1 << 6,
1424 M_THREADED = 1 << 7,
1425 M_UNTHREADED = 1 << 8,
1426 M_ALLOW_DELETE = 1 << 9,
1427 M_INC_ACTIVE = 1 << 10,
1429 M_HAVE_NEWS_ACCOUNT = 1 << 12,
1430 M_HIDE_READ_MSG = 1 << 13
1433 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1435 SensitiveCond state = 0;
1436 SummarySelection selection;
1437 FolderItem *item = mainwin->summaryview->folder_item;
1438 GList *account_list = account_get_list();
1440 selection = summary_get_selection_type(mainwin->summaryview);
1442 if (mainwin->lock_count == 0)
1443 state |= M_UNLOCKED;
1444 if (selection != SUMMARY_NONE)
1445 state |= M_MSG_EXIST;
1449 state |= M_THREADED;
1451 state |= M_UNTHREADED;
1452 /* if (item->folder->type != F_NEWS) */
1453 state |= M_ALLOW_DELETE;
1455 if (selection == SUMMARY_NONE && item->hide_read_msgs
1456 || selection != SUMMARY_NONE)
1457 state |= M_HIDE_READ_MSG;
1459 if (selection == SUMMARY_SELECTED_SINGLE ||
1460 selection == SUMMARY_SELECTED_MULTIPLE)
1461 state |= M_TARGET_EXIST;
1462 if (selection == SUMMARY_SELECTED_SINGLE)
1463 state |= M_SINGLE_TARGET_EXIST;
1464 if (mainwin->summaryview->folder_item &&
1465 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1467 if (selection == SUMMARY_SELECTED_SINGLE &&
1469 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1470 item->stype == F_QUEUE)))
1471 state |= M_ALLOW_REEDIT;
1473 state |= M_HAVE_ACCOUNT;
1475 for ( ; account_list != NULL; account_list = account_list->next) {
1476 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1477 state |= M_HAVE_NEWS_ACCOUNT;
1482 if (inc_is_active())
1483 state |= M_INC_ACTIVE;
1488 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1490 SensitiveCond state;
1499 entry[0].widget = mainwin->get_btn;
1500 entry[0].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1501 entry[1].widget = mainwin->getall_btn;
1502 entry[1].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1503 entry[2].widget = mainwin->compose_news_btn;
1504 entry[2].cond = M_HAVE_NEWS_ACCOUNT;
1505 entry[3].widget = mainwin->reply_btn;
1506 entry[3].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1507 entry[4].widget = mainwin->replyall_btn;
1508 entry[4].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1509 entry[5].widget = mainwin->replysender_btn;
1510 entry[5].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1511 entry[6].widget = mainwin->fwd_btn;
1512 entry[6].cond = M_HAVE_ACCOUNT|M_TARGET_EXIST;
1513 /* entry[6].widget = mainwin->prefs_btn;
1514 entry[6].cond = M_UNLOCKED;
1515 entry[7].widget = mainwin->account_btn;
1516 entry[7].cond = M_UNLOCKED; */
1517 entry[7].widget = mainwin->next_btn;
1518 entry[7].cond = M_MSG_EXIST;
1519 entry[8].widget = mainwin->delete_btn;
1520 entry[8].cond = M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED;
1521 entry[9].widget = mainwin->exec_btn;
1522 entry[9].cond = M_MSG_EXIST|M_EXEC|M_UNLOCKED;
1523 entry[10].widget = NULL;
1526 state = main_window_get_current_state(mainwin);
1528 for (i = 0; entry[i].widget != NULL; i++) {
1529 sensitive = ((entry[i].cond & state) == entry[i].cond);
1530 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1533 activate_compose_button(mainwin,
1534 prefs_common.toolbar_style,
1535 mainwin->compose_btn_type);
1538 void main_window_set_menu_sensitive(MainWindow *mainwin)
1540 GtkItemFactory *ifactory;
1541 SensitiveCond state;
1543 GtkWidget *menuitem;
1546 static const struct {
1550 {"/File/Add mailbox..." , M_UNLOCKED},
1551 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1552 {"/File/Rescan folder tree" , M_UNLOCKED},
1553 {"/File/Folder" , M_UNLOCKED},
1554 {"/File/Import mbox file..." , M_UNLOCKED},
1555 {"/File/Export to mbox file...", M_UNLOCKED},
1556 {"/File/Empty trash" , M_UNLOCKED},
1557 {"/File/Gather addresses...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1558 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1559 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1560 /* {"/File/Close", M_UNLOCKED}, */
1561 {"/File/Exit" , M_UNLOCKED},
1563 {"/Tool/Actions" , M_MSG_EXIST},
1564 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1565 {"/View/Sort" , M_MSG_EXIST},
1566 {"/View/Thread view" , M_EXEC},
1567 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1568 {"/View/Go to/Prev message" , M_MSG_EXIST},
1569 {"/View/Go to/Next message" , M_MSG_EXIST},
1570 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1571 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1572 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1573 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1574 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1575 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1576 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1577 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1578 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1580 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1581 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1582 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1583 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1584 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1585 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1586 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1587 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1588 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1589 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1590 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1591 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1592 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1593 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1594 {"/Message/Mark" , M_TARGET_EXIST},
1595 {"/Message/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1597 {"/Tool/Add sender to address book", M_SINGLE_TARGET_EXIST},
1598 {"/Tool/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1599 {"/Tool/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1600 {"/Tool/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1602 {"/Configuration", M_UNLOCKED},
1607 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1608 state = main_window_get_current_state(mainwin);
1610 for (i = 0; entry[i].entry != NULL; i++) {
1611 sensitive = ((entry[i].cond & state) == entry[i].cond);
1612 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1615 main_window_menu_callback_block(mainwin);
1616 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all header");
1617 gtk_check_menu_item_set_active
1618 (GTK_CHECK_MENU_ITEM(menuitem),
1619 mainwin->messageview->textview->show_all_headers);
1620 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1621 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1622 (state & M_THREADED) != 0);
1623 main_window_menu_callback_unblock(mainwin);
1626 void main_window_popup(MainWindow *mainwin)
1632 gdk_window_get_origin(mainwin->window->window, &x, &y);
1633 sx = gdk_screen_width();
1634 sy = gdk_screen_height();
1635 x %= sx; if (x < 0) x = 0;
1636 y %= sy; if (y < 0) y = 0;
1637 gdk_window_move(mainwin->window->window, x, y);
1638 gdk_window_raise(mainwin->window->window);
1639 gdk_window_show(mainwin->window->window);
1641 debug_print("window position: x = %d, y = %d\n", x, y);
1643 switch (mainwin->type) {
1644 case SEPARATE_FOLDER:
1645 widget = mainwin->win.sep_folder.folderwin;
1646 gdk_window_get_origin(widget->window, &x, &y);
1647 x %= sx; if (x < 0) x = 0;
1648 y %= sy; if (y < 0) y = 0;
1649 gdk_window_move(widget->window, x, y);
1650 gdk_window_raise(widget->window);
1652 case SEPARATE_MESSAGE:
1653 widget = mainwin->win.sep_message.messagewin;
1654 gdk_window_get_origin(widget->window, &x, &y);
1655 x %= sx; if (x < 0) x = 0;
1656 y %= sy; if (y < 0) y = 0;
1657 gdk_window_move(widget->window, x, y);
1658 gdk_window_raise(widget->window);
1661 widget = mainwin->win.sep_both.folderwin;
1662 gdk_window_get_origin(widget->window, &x, &y);
1663 x %= sx; if (x < 0) x = 0;
1664 y %= sy; if (y < 0) y = 0;
1665 gdk_window_move(widget->window, x, y);
1666 gdk_window_raise(widget->window);
1667 widget = mainwin->win.sep_both.messagewin;
1668 gdk_window_get_origin(widget->window, &x, &y);
1669 x %= sx; if (x < 0) x = 0;
1670 y %= sy; if (y < 0) y = 0;
1671 gdk_window_move(widget->window, x, y);
1672 gdk_window_raise(widget->window);
1679 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1681 GtkWidget *folderwin = NULL;
1682 GtkWidget *messagewin = NULL;
1685 GtkWidget *vbox_body = mainwin->vbox_body;
1686 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1687 GtkWidget *menuitem;
1689 debug_print(_("Setting widgets..."));
1691 /* create separated window(s) if needed */
1692 if (type & SEPARATE_FOLDER) {
1693 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1694 gtk_window_set_title(GTK_WINDOW(folderwin),
1695 _("Sylpheed - Folder View"));
1696 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1697 "folder_view", "Sylpheed");
1698 gtk_window_set_policy(GTK_WINDOW(folderwin),
1700 gtk_widget_set_usize(folderwin, -1,
1701 prefs_common.mainview_height);
1702 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1704 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1705 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1708 if (type & SEPARATE_MESSAGE) {
1709 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1710 gtk_window_set_title(GTK_WINDOW(messagewin),
1711 _("Sylpheed - Message View"));
1712 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1713 "message_view", "Sylpheed");
1714 gtk_window_set_policy(GTK_WINDOW(messagewin),
1716 gtk_widget_set_usize
1717 (messagewin, prefs_common.mainview_width,
1718 prefs_common.mainview_height
1719 - prefs_common.summaryview_height
1720 + DEFAULT_HEADERVIEW_HEIGHT);
1721 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1723 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1724 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1730 hpaned = gtk_hpaned_new();
1731 gtk_widget_show(hpaned);
1732 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1733 gtk_paned_add1(GTK_PANED(hpaned),
1734 GTK_WIDGET_PTR(mainwin->folderview));
1736 vpaned = gtk_vpaned_new();
1737 if (mainwin->summaryview->msg_is_toggled_on) {
1738 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1739 gtk_paned_add1(GTK_PANED(vpaned),
1740 GTK_WIDGET_PTR(mainwin->summaryview));
1742 gtk_paned_add2(GTK_PANED(hpaned),
1743 GTK_WIDGET_PTR(mainwin->summaryview));
1744 gtk_widget_ref(vpaned);
1746 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1747 prefs_common.summaryview_width,
1748 prefs_common.summaryview_height);
1749 gtk_paned_add2(GTK_PANED(vpaned),
1750 GTK_WIDGET_PTR(mainwin->messageview));
1751 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1752 prefs_common.mainview_width, -1);
1753 gtk_widget_set_usize(mainwin->window,
1754 prefs_common.folderview_width +
1755 prefs_common.mainview_width,
1756 prefs_common.mainwin_height);
1757 gtk_widget_show_all(vpaned);
1759 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1760 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1761 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1762 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1763 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1764 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1766 mainwin->win.sep_none.hpaned = hpaned;
1767 mainwin->win.sep_none.vpaned = vpaned;
1769 case SEPARATE_FOLDER:
1770 vpaned = gtk_vpaned_new();
1771 if (mainwin->summaryview->msg_is_toggled_on) {
1772 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1774 gtk_paned_add1(GTK_PANED(vpaned),
1775 GTK_WIDGET_PTR(mainwin->summaryview));
1777 gtk_box_pack_start(GTK_BOX(vbox_body),
1778 GTK_WIDGET_PTR(mainwin->summaryview),
1780 gtk_widget_ref(vpaned);
1782 gtk_paned_add2(GTK_PANED(vpaned),
1783 GTK_WIDGET_PTR(mainwin->messageview));
1784 gtk_widget_show_all(vpaned);
1785 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1786 prefs_common.summaryview_width,
1787 prefs_common.summaryview_height);
1788 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1789 prefs_common.mainview_width, -1);
1790 gtk_widget_set_usize(mainwin->window,
1791 prefs_common.mainview_width,
1792 prefs_common.mainview_height);
1794 gtk_container_add(GTK_CONTAINER(folderwin),
1795 GTK_WIDGET_PTR(mainwin->folderview));
1797 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1798 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1800 mainwin->win.sep_folder.folderwin = folderwin;
1801 mainwin->win.sep_folder.vpaned = vpaned;
1803 gtk_widget_show_all(folderwin);
1805 case SEPARATE_MESSAGE:
1806 hpaned = gtk_hpaned_new();
1807 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1809 gtk_paned_add1(GTK_PANED(hpaned),
1810 GTK_WIDGET_PTR(mainwin->folderview));
1811 gtk_paned_add2(GTK_PANED(hpaned),
1812 GTK_WIDGET_PTR(mainwin->summaryview));
1813 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1814 prefs_common.summaryview_width,
1815 prefs_common.summaryview_height);
1816 gtk_widget_set_usize(mainwin->window,
1817 prefs_common.folderview_width +
1818 prefs_common.mainview_width,
1819 prefs_common.mainwin_height);
1820 gtk_widget_show_all(hpaned);
1821 gtk_container_add(GTK_CONTAINER(messagewin),
1822 GTK_WIDGET_PTR(mainwin->messageview));
1824 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1825 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1826 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1827 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1829 mainwin->win.sep_message.messagewin = messagewin;
1830 mainwin->win.sep_message.hpaned = hpaned;
1832 gtk_widget_show_all(messagewin);
1835 gtk_box_pack_start(GTK_BOX(vbox_body),
1836 GTK_WIDGET_PTR(mainwin->summaryview),
1838 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1839 prefs_common.summaryview_width,
1840 prefs_common.summaryview_height);
1841 gtk_widget_set_usize(mainwin->window,
1842 prefs_common.mainview_width,
1843 prefs_common.mainwin_height);
1844 gtk_container_add(GTK_CONTAINER(folderwin),
1845 GTK_WIDGET_PTR(mainwin->folderview));
1846 gtk_container_add(GTK_CONTAINER(messagewin),
1847 GTK_WIDGET_PTR(mainwin->messageview));
1849 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1850 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1852 mainwin->win.sep_both.folderwin = folderwin;
1853 mainwin->win.sep_both.messagewin = messagewin;
1855 gtk_widget_show_all(folderwin);
1856 gtk_widget_show_all(messagewin);
1860 mainwin->type = type;
1862 debug_print(_("done.\n"));
1865 static void main_window_toolbar_create(MainWindow *mainwin,
1866 GtkWidget *container)
1869 GtkWidget *icon_wid;
1871 GtkWidget *getall_btn;
1872 GtkWidget *compose_mail_btn;
1873 GtkWidget *compose_news_btn;
1874 GtkWidget *reply_btn;
1875 GtkWidget *replyall_btn;
1876 GtkWidget *replysender_btn;
1878 GtkWidget *send_btn;
1880 GtkWidget *prefs_btn;
1881 GtkWidget *account_btn;
1883 GtkWidget *next_btn;
1884 GtkWidget *delete_btn;
1885 GtkWidget *exec_btn;
1887 GtkTooltips *tooltips;
1889 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1891 gtk_container_add(GTK_CONTAINER(container), toolbar);
1892 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1893 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1894 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1895 GTK_TOOLBAR_SPACE_LINE);
1897 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1898 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1900 _("Get new mail from current account"),
1902 icon_wid, toolbar_inc_cb, mainwin);
1903 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1904 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1906 _("Get new mail from all accounts"),
1912 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1914 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1915 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1917 _("Send queued message(s)"),
1923 /* insert compose mail button widget */
1924 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1925 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1927 _("Compose an email message"),
1930 toolbar_compose_mail_cb,
1933 /* insert compose news button widget */
1934 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1935 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1937 _("Compose a news message"),
1940 toolbar_compose_news_cb,
1943 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1947 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1948 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1950 _("Reply to the message - Right button: more options"),
1956 /* replyall button */
1958 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1959 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1961 _("Reply to all - Right button: more options"),
1964 toolbar_reply_to_all_cb,
1967 /* reply to sender button */
1968 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1969 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1971 _("Reply to sender - Right button: more options"),
1974 toolbar_reply_to_sender_cb,
1977 /* forward button */
1978 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1979 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1981 _("Forward the message - Right button: more options"),
1987 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1989 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1990 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1992 _("Delete the message"),
1998 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1999 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2001 _("Execute marked process"),
2007 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
2008 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2010 _("Next unread message"),
2013 toolbar_next_unread_cb,
2017 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2019 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2020 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2022 _("Common preference"),
2027 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2028 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2030 _("Account setting"),
2035 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2036 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2040 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2041 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2044 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2045 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2048 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2049 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2052 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2053 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2057 mainwin->toolbar = toolbar;
2058 mainwin->get_btn = get_btn;
2059 mainwin->getall_btn = getall_btn;
2060 mainwin->compose_mail_btn = compose_mail_btn;
2061 mainwin->compose_news_btn = compose_news_btn;
2062 mainwin->reply_btn = reply_btn;
2063 mainwin->replyall_btn = replyall_btn;
2064 mainwin->replysender_btn = replysender_btn;
2065 mainwin->fwd_btn = fwd_btn;
2066 mainwin->send_btn = send_btn;
2068 mainwin->prefs_btn = prefs_btn;
2069 mainwin->account_btn = account_btn;
2071 mainwin->next_btn = next_btn;
2072 mainwin->delete_btn = delete_btn;
2073 mainwin->exec_btn = exec_btn;
2075 gtk_widget_show_all(toolbar);
2078 /* callback functions */
2079 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2081 MainWindow *mainwindow = (MainWindow *) data;
2085 if (event->button == 3) {
2086 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2087 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2088 menu_button_position, widget,
2089 event->button, event->time);
2093 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2095 MainWindow *mainwin = (MainWindow *)data;
2097 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2098 manage_window_focus_in(mainwin->window, NULL, NULL);
2101 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2103 MainWindow *mainwindow = (MainWindow *) data;
2107 if (event->button == 3) {
2108 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2109 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2110 menu_button_position, widget,
2111 event->button, event->time);
2115 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2117 MainWindow *mainwin = (MainWindow *)data;
2119 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2120 manage_window_focus_in(mainwin->window, NULL, NULL);
2123 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2125 MainWindow *mainwindow = (MainWindow *) data;
2126 GtkWidget *replysender_menu, *replysender_item;
2130 if (event->button == 3) {
2131 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2132 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2133 menu_button_position, widget,
2134 event->button, event->time);
2138 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2140 MainWindow *mainwin = (MainWindow *)data;
2142 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2143 manage_window_focus_in(mainwin->window, NULL, NULL);
2146 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2148 MainWindow *mainwindow = (MainWindow *) data;
2152 if (event->button == 3) {
2153 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2154 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2155 menu_button_position, widget,
2156 event->button, event->time);
2160 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2162 MainWindow *mainwin = (MainWindow *)data;
2164 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2165 manage_window_focus_in(mainwin->window, NULL, NULL);
2168 static void toolbar_inc_cb (GtkWidget *widget,
2171 MainWindow *mainwin = (MainWindow *)data;
2173 inc_mail_cb(mainwin, 0, NULL);
2176 static void toolbar_inc_all_cb (GtkWidget *widget,
2179 MainWindow *mainwin = (MainWindow *)data;
2181 inc_all_account_mail_cb(mainwin, 0, NULL);
2184 static void toolbar_send_cb (GtkWidget *widget,
2187 MainWindow *mainwin = (MainWindow *)data;
2189 send_queue_cb(mainwin, 0, NULL);
2192 static void toolbar_compose_cb (GtkWidget *widget,
2195 MainWindow *mainwin = (MainWindow *)data;
2197 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2198 compose_cb(mainwin, 0, NULL);
2200 compose_news_cb(mainwin, 0, NULL);
2203 static void toolbar_compose_news_cb (GtkWidget *widget,
2206 MainWindow *mainwin = (MainWindow *)data;
2208 compose_news_cb(mainwin, 0, NULL);
2211 static void toolbar_compose_mail_cb (GtkWidget *widget,
2214 MainWindow *mainwin = (MainWindow *)data;
2216 compose_mail_cb(mainwin, 0, NULL);
2219 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2221 MainWindow *mainwin = (MainWindow *)data;
2224 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2225 : COMPOSE_REPLY_WITHOUT_QUOTE,
2229 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2231 MainWindow *mainwin = (MainWindow *)data;
2234 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2235 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2240 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2242 MainWindow *mainwin = (MainWindow *)data;
2245 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2246 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2250 static void toolbar_forward_cb (GtkWidget *widget,
2253 MainWindow *mainwin = (MainWindow *)data;
2255 if (prefs_common.forward_as_attachment)
2256 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2258 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2261 static void toolbar_delete_cb (GtkWidget *widget,
2264 MainWindow *mainwin = (MainWindow *)data;
2266 summary_delete(mainwin->summaryview);
2269 static void toolbar_exec_cb (GtkWidget *widget,
2272 MainWindow *mainwin = (MainWindow *)data;
2274 summary_execute(mainwin->summaryview);
2277 static void toolbar_next_unread_cb (GtkWidget *widget,
2280 MainWindow *mainwin = (MainWindow *)data;
2282 next_unread_cb(mainwin, 0, NULL);
2285 static void toolbar_prefs_cb (GtkWidget *widget,
2288 prefs_common_open();
2291 static void toolbar_account_cb (GtkWidget *widget,
2294 MainWindow *mainwin = (MainWindow *)data;
2296 prefs_account_open_cb(mainwin, 0, NULL);
2299 static void toolbar_account_button_pressed(GtkWidget *widget,
2300 GdkEventButton *event,
2303 MainWindow *mainwin = (MainWindow *)data;
2306 if (event->button != 3) return;
2308 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2309 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2312 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2313 menu_button_position, widget,
2314 event->button, event->time);
2317 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2320 MainWindow *mainwin = (MainWindow *)data;
2324 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2325 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2328 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2329 menu_button_position, widget,
2330 event->button, event->time);
2333 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2335 MainWindow *mainwin = (MainWindow *)data;
2338 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2339 if (!button) return;
2340 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2341 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2342 manage_window_focus_in(mainwin->window, NULL, NULL);
2345 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2348 MainWindow *mainwin = (MainWindow *)data;
2350 if (mainwin->lock_count == 0)
2351 app_exit_cb(data, 0, widget);
2356 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2359 main_window_add_mailbox(mainwin);
2362 static void add_mbox_cb(MainWindow *mainwin, guint action,
2365 main_window_add_mbox(mainwin);
2368 static void update_folderview_cb(MainWindow *mainwin, guint action,
2371 summary_show(mainwin->summaryview, NULL, FALSE);
2372 folderview_rescan_all();
2375 static void new_folder_cb(MainWindow *mainwin, guint action,
2378 folderview_new_folder(mainwin->folderview);
2381 static void rename_folder_cb(MainWindow *mainwin, guint action,
2384 folderview_rename_folder(mainwin->folderview);
2387 static void delete_folder_cb(MainWindow *mainwin, guint action,
2390 folderview_delete_folder(mainwin->folderview);
2393 static void import_mbox_cb(MainWindow *mainwin, guint action,
2396 import_mbox(mainwin->summaryview->folder_item);
2399 static void export_mbox_cb(MainWindow *mainwin, guint action,
2402 export_mbox(mainwin->summaryview->folder_item);
2405 static void empty_trash_cb(MainWindow *mainwin, guint action,
2408 main_window_empty_trash(mainwin, TRUE);
2411 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2413 summary_save_as(mainwin->summaryview);
2416 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2418 summary_print(mainwin->summaryview);
2421 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2423 if (prefs_common.confirm_on_exit) {
2424 if (alertpanel(_("Exit"), _("Exit this program?"),
2425 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2427 manage_window_focus_in(mainwin->window, NULL, NULL);
2430 app_will_exit(widget, mainwin);
2433 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2436 summary_search(mainwin->summaryview);
2438 message_search(mainwin->messageview);
2441 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2444 switch (mainwin->type) {
2446 case SEPARATE_MESSAGE:
2448 case SEPARATE_FOLDER:
2449 if (GTK_CHECK_MENU_ITEM(widget)->active)
2450 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2452 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2455 if (GTK_CHECK_MENU_ITEM(widget)->active)
2456 gtk_widget_show(mainwin->win.sep_both.folderwin);
2458 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2463 static void toggle_message_cb(MainWindow *mainwin, guint action,
2466 switch (mainwin->type) {
2468 case SEPARATE_FOLDER:
2470 case SEPARATE_MESSAGE:
2471 if (GTK_CHECK_MENU_ITEM(widget)->active)
2472 gtk_widget_show(mainwin->win.sep_message.messagewin);
2474 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2477 if (GTK_CHECK_MENU_ITEM(widget)->active)
2478 gtk_widget_show(mainwin->win.sep_both.messagewin);
2480 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2485 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2488 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2489 mainwin->compose_btn_type);
2490 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2491 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2492 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2493 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2495 mainwin->toolbar_style = (ToolbarStyle)action;
2496 prefs_common.toolbar_style = (ToolbarStyle)action;
2498 set_toolbar_style(mainwin);
2501 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2504 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2505 gtk_widget_show(mainwin->hbox_stat);
2506 prefs_common.show_statusbar = TRUE;
2508 gtk_widget_hide(mainwin->hbox_stat);
2509 prefs_common.show_statusbar = FALSE;
2513 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2515 summary_toggle_view_real(mainwin->summaryview);
2518 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2520 messageview_toggle_view_real(mainwin->messageview);
2523 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2526 MainWindow *mainwin;
2529 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2530 g_return_if_fail(mainwin != NULL);
2532 type = mainwin->type ^ action;
2533 main_window_separation_change(mainwin, type);
2535 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2536 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2539 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2542 addressbook_open(NULL);
2545 static void log_window_show_cb(MainWindow *mainwin, guint action,
2548 log_window_show(mainwin->logwin);
2551 static void sel_download_cb(MainWindow *mainwin, guint action,
2554 selective_download(mainwin);
2557 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2559 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2562 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2565 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2568 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2573 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2577 if (procmsg_send_queue() < 0)
2578 alertpanel_error(_("Some errors occurred while sending queued messages."));
2580 statusbar_pop_all();
2582 for (list = folder_get_list(); list != NULL; list = list->next) {
2585 folder = list->data;
2586 if (folder->queue) {
2587 folder_item_scan(folder->queue);
2588 folderview_update_item(folder->queue, TRUE);
2593 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2595 if (mainwin->summaryview->folder_item) {
2596 if (mainwin->summaryview->folder_item->folder->account != NULL
2597 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2598 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2600 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2606 static void compose_mail_cb(MainWindow *mainwin, guint action,
2613 if (mainwin->summaryview->folder_item) {
2614 ac = mainwin->summaryview->folder_item->folder->account;
2615 if (ac && ac->protocol != A_NNTP) {
2616 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2621 if(cur_account && (cur_account->protocol != A_NNTP)) {
2622 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2626 list = account_get_list();
2627 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2628 ac = (PrefsAccount *) cur->data;
2629 if (ac->protocol != A_NNTP) {
2630 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2636 static void compose_news_cb(MainWindow *mainwin, guint action,
2639 PrefsAccount * ac = NULL;
2643 if (mainwin->summaryview->folder_item) {
2644 ac = mainwin->summaryview->folder_item->folder->account;
2645 if (ac && ac->protocol == A_NNTP) {
2646 compose_new_with_recipient
2647 (ac, mainwin->summaryview->folder_item->path);
2652 list = account_get_list();
2653 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2654 ac = (PrefsAccount *) cur->data;
2655 if (ac->protocol == A_NNTP) {
2662 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2664 summary_reply(mainwin->summaryview, (ComposeMode)action);
2667 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2669 summary_move_to(mainwin->summaryview);
2672 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2674 summary_copy_to(mainwin->summaryview);
2677 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2679 summary_delete(mainwin->summaryview);
2682 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2684 summary_open_msg(mainwin->summaryview);
2687 static void view_source_cb(MainWindow *mainwin, guint action,
2690 summary_view_source(mainwin->summaryview);
2693 static void show_all_header_cb(MainWindow *mainwin, guint action,
2696 if (mainwin->menu_lock_count) return;
2697 summary_display_msg_selected(mainwin->summaryview,
2698 GTK_CHECK_MENU_ITEM(widget)->active);
2701 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2703 summary_reedit(mainwin->summaryview);
2706 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2708 summary_mark(mainwin->summaryview);
2711 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2713 summary_unmark(mainwin->summaryview);
2716 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2719 summary_mark_as_unread(mainwin->summaryview);
2722 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2725 summary_mark_as_read(mainwin->summaryview);
2728 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2731 summary_mark_all_read(mainwin->summaryview);
2734 static void add_address_cb(MainWindow *mainwin, guint action,
2737 summary_add_address(mainwin->summaryview);
2740 static void set_charset_cb(MainWindow *mainwin, guint action,
2745 str = conv_get_charset_str((CharSet)action);
2746 g_free(prefs_common.force_charset);
2747 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2749 summary_redisplay_msg(mainwin->summaryview);
2751 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2754 static void hide_read_messages (MainWindow *mainwin, guint action,
2757 if (!mainwin->summaryview->folder_item
2758 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2760 summary_toggle_show_read_messages(mainwin->summaryview);
2763 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2765 GtkItemFactory *ifactory;
2767 if (mainwin->menu_lock_count) return;
2768 if (!mainwin->summaryview->folder_item) return;
2770 ifactory = gtk_item_factory_from_widget(widget);
2772 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2773 summary_thread_build(mainwin->summaryview);
2774 mainwin->summaryview->folder_item->threaded = TRUE;
2776 summary_unthread(mainwin->summaryview);
2777 mainwin->summaryview->folder_item->threaded = FALSE;
2781 static void set_display_item_cb(MainWindow *mainwin, guint action,
2784 prefs_summary_column_open();
2787 static void sort_summary_cb(MainWindow *mainwin, guint action,
2790 summary_sort(mainwin->summaryview, (SummarySortType)action);
2793 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2796 summary_attract_by_subject(mainwin->summaryview);
2799 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2802 summary_delete_duplicated(mainwin->summaryview);
2805 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2807 summary_filter(mainwin->summaryview);
2810 static void execute_summary_cb(MainWindow *mainwin, guint action,
2813 summary_execute(mainwin->summaryview);
2816 static void update_summary_cb(MainWindow *mainwin, guint action,
2820 FolderView *folderview = mainwin->folderview;
2822 if (!mainwin->summaryview->folder_item) return;
2823 if (!folderview->opened) return;
2825 folder_update_op_count();
2827 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2828 folderview->opened);
2831 summary_show(mainwin->summaryview, fitem, TRUE);
2834 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2836 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2839 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2841 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2844 static void prev_unread_cb(MainWindow *mainwin, guint action,
2847 summary_select_prev_unread(mainwin->summaryview);
2850 static void next_unread_cb(MainWindow *mainwin, guint action,
2853 summary_select_next_unread(mainwin->summaryview);
2856 static void prev_marked_cb(MainWindow *mainwin, guint action,
2859 summary_select_prev_marked(mainwin->summaryview);
2862 static void next_marked_cb(MainWindow *mainwin, guint action,
2865 summary_select_next_marked(mainwin->summaryview);
2868 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2871 summary_select_prev_labeled(mainwin->summaryview);
2874 static void next_labeled_cb(MainWindow *mainwin, guint action,
2877 summary_select_next_labeled(mainwin->summaryview);
2880 static void goto_folder_cb(MainWindow *mainwin, guint action,
2883 FolderItem *to_folder;
2885 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2888 folderview_select(mainwin->folderview, to_folder);
2891 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2893 messageview_copy_clipboard(mainwin->messageview);
2896 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2898 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2899 summary_select_all(mainwin->summaryview);
2900 else if (mainwin->summaryview->msg_is_toggled_on &&
2901 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2902 messageview_select_all(mainwin->messageview);
2905 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2907 if (mainwin->summaryview->msg_is_toggled_on)
2908 summary_select_thread(mainwin->summaryview);
2911 static void create_filter_cb(MainWindow *mainwin, guint action,
2914 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2917 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2920 prefs_common_open();
2923 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2926 prefs_filter_open(NULL, NULL);
2929 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2932 prefs_scoring_open(NULL);
2935 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2938 prefs_filtering_open(NULL);
2941 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2944 prefs_template_open();
2947 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2950 prefs_actions_open(mainwin);
2953 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2957 new_account_cb(mainwin, 0, widget);
2959 gboolean prev_default = cur_account->is_default;
2961 prefs_account_open(cur_account);
2962 if (!prev_default && cur_account->is_default)
2963 account_set_as_default(cur_account);
2964 account_save_config_all();
2966 main_window_reflect_prefs_all();
2970 static void new_account_cb(MainWindow *mainwin, guint action,
2973 account_edit_open();
2974 if (!compose_get_compose_list()) account_add();
2977 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2979 cur_account = (PrefsAccount *)data;
2980 main_window_reflect_prefs_all();
2983 static void manual_open_cb(MainWindow *mainwin, guint action,
2986 manual_open((ManualLang)action);
2989 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2991 faq_open((ManualLang)action);
2994 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2996 MainWindow *mainwin = (MainWindow *)data;
3000 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3001 LOCAL_FOLDER(folder)->rootpath,
3005 str = g_strdup_printf(_("Scanning folder %s ..."),
3006 LOCAL_FOLDER(folder)->rootpath);
3008 STATUSBAR_PUSH(mainwin, str);
3009 STATUSBAR_POP(mainwin);
3013 static void activate_compose_button (MainWindow *mainwin,
3015 ComposeButtonType type)
3017 SensitiveCond state = main_window_get_current_state(mainwin);
3019 if (style == TOOLBAR_NONE)
3022 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
3023 : mainwin->compose_news_btn);
3024 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
3025 : mainwin->compose_mail_btn);
3026 mainwin->compose_btn_type = type;
3029 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
3031 if (mainwin->compose_btn_type != compose_btn_type)
3032 activate_compose_button(mainwin,
3033 prefs_common.toolbar_style,
3037 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
3039 MainWindow *mainwin = (MainWindow*) data;
3041 if (!mainwin) return;
3043 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
3046 #define BREAK_ON_MODIFIER_KEY() \
3047 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3049 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3051 MainWindow *mainwin = (MainWindow*) data;
3053 if (!mainwin || !event) return;
3055 switch (event->keyval) {
3056 case GDK_Q: /* Quit */
3057 BREAK_ON_MODIFIER_KEY();
3059 app_exit_cb(mainwin, 0, NULL);
3066 #undef BREAK_ON_MODIFIER_KEY
3068 static void set_toolbar_style(MainWindow *mainwin)
3070 switch (prefs_common.toolbar_style) {
3072 gtk_widget_hide(mainwin->handlebox);
3075 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3079 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3083 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3088 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3089 gtk_widget_show(mainwin->handlebox);
3090 gtk_widget_queue_resize(mainwin->handlebox);
3092 if (prefs_common.immediate_exec)
3093 gtk_widget_hide(mainwin->exec_btn);
3095 gtk_widget_show(mainwin->exec_btn);
3099 static void addr_gather_cb( MainWindow *mainwin,
3103 addressbook_gather( mainwin->summaryview->folder_item );