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_harvest_cb ( MainWindow *mainwin,
464 static void addr_harvest_msg_cb ( MainWindow *mainwin,
468 #define SEPARATE_ACTION 667
470 static GtkItemFactoryEntry mainwin_entries[] =
472 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
473 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
474 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
475 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
476 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
477 {N_("/_File/_Folder/Create _new folder..."),
478 NULL, new_folder_cb, 0, NULL},
479 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
480 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
481 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
482 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
483 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
484 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
485 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
486 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
487 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
488 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
490 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
491 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
492 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
493 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
494 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
495 {N_("/_Edit/_Find in current message..."),
496 "<control>F", search_cb, 0, NULL},
497 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
498 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
499 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
500 {N_("/_View/Show or hi_de/_Toolbar"),
501 NULL, NULL, 0, "<Branch>"},
502 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
503 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
504 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
505 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
506 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
507 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
508 {N_("/_View/Show or hi_de/_Toolbar/_None"),
509 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
510 {N_("/_View/Show or hi_de/Status _bar"),
511 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
512 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
513 {N_("/_View/Separate _Folder Tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
514 {N_("/_View/Separate _Message View"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
515 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
516 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
517 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
518 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
519 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
520 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
521 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
522 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
523 {N_("/_View/_Sort/Sort by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
524 {N_("/_View/_Sort/Sort by _color label"),
525 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
526 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
527 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
528 {N_("/_View/_Sort/Sort by a_ttachment"),
529 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
530 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
531 {N_("/_View/_Sort/_Attract by subject"),
532 NULL, attract_by_subject_cb, 0, NULL},
533 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
534 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
535 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
537 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
538 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
539 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
540 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
541 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
542 {N_("/_View/_Go to/P_rev unread message"),
543 "<shift>P", prev_unread_cb, 0, NULL},
544 {N_("/_View/_Go to/N_ext unread message"),
545 "<shift>N", next_unread_cb, 0, NULL},
546 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
547 {N_("/_View/_Go to/Prev _marked message"),
548 NULL, prev_marked_cb, 0, NULL},
549 {N_("/_View/_Go to/Next m_arked message"),
550 NULL, next_marked_cb, 0, NULL},
551 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
552 {N_("/_View/_Go to/Prev _labeled message"),
553 NULL, prev_labeled_cb, 0, NULL},
554 {N_("/_View/_Go to/Next la_beled message"),
555 NULL, next_labeled_cb, 0, NULL},
556 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
557 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
558 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
560 #define CODESET_SEPARATOR \
561 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
562 #define CODESET_ACTION(action) \
563 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
565 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
566 {N_("/_View/_Code set/_Auto detect"),
567 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
568 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
569 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
570 CODESET_ACTION(C_US_ASCII)},
573 {N_("/_View/_Code set/Unicode (_UTF-8)"),
574 CODESET_ACTION(C_UTF_8)},
577 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
578 CODESET_ACTION(C_ISO_8859_1)},
579 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
580 CODESET_ACTION(C_ISO_8859_15)},
583 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
584 CODESET_ACTION(C_ISO_8859_2)},
586 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
587 CODESET_ACTION(C_ISO_8859_13)},
588 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
589 CODESET_ACTION(C_ISO_8859_4)},
591 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
592 CODESET_ACTION(C_ISO_8859_7)},
594 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
595 CODESET_ACTION(C_ISO_8859_9)},
597 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
598 CODESET_ACTION(C_ISO_8859_5)},
599 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
600 CODESET_ACTION(C_KOI8_R)},
601 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
602 CODESET_ACTION(C_CP1251)},
605 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
606 CODESET_ACTION(C_ISO_2022_JP)},
608 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
609 CODESET_ACTION(C_ISO_2022_JP_2)},
611 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
612 CODESET_ACTION(C_EUC_JP)},
613 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
614 CODESET_ACTION(C_SHIFT_JIS)},
617 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
618 CODESET_ACTION(C_GB2312)},
619 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
620 CODESET_ACTION(C_BIG5)},
621 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
622 CODESET_ACTION(C_EUC_TW)},
623 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
624 CODESET_ACTION(C_ISO_2022_CN)},
626 {N_("/_View/_Code set/Korean (EUC-_KR)"),
627 CODESET_ACTION(C_EUC_KR)},
628 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
629 CODESET_ACTION(C_ISO_2022_KR)},
631 {N_("/_View/_Code set/Thai (TIS-620)"),
632 CODESET_ACTION(C_TIS_620)},
633 {N_("/_View/_Code set/Thai (Windows-874)"),
634 CODESET_ACTION(C_WINDOWS_874)},
637 #undef CODESET_SEPARATOR
638 #undef CODESET_ACTION
640 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
641 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
642 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
643 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
644 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
645 {N_("/_View/_Update"), "<control><alt>U", update_summary_cb, 0, NULL},
647 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
648 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
649 {N_("/_Message/Get from _all accounts"),
650 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
651 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
652 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
653 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
654 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
655 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
656 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
657 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
658 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
659 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
660 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
661 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
662 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
663 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
664 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
665 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
666 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
667 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
668 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
669 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
670 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
671 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
672 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
673 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
674 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
675 {N_("/_Message/_Mark/Mark as rea_d"),
676 NULL, mark_as_read_cb, 0, NULL},
677 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
679 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
680 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
681 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
682 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
683 {N_("/_Tools/Add sender to address boo_k"),
684 NULL, add_address_cb, 0, NULL},
685 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
686 {N_("/_Tools/_Harvest addresses/from _Folder..."),
687 NULL, addr_harvest_cb, 0, NULL},
688 {N_("/_Tools/_Harvest addresses/from _Messages..."),
689 NULL, addr_harvest_msg_cb, 0, NULL},
690 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
691 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
692 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
693 {N_("/_Tools/_Create filter rule/_Automatically"),
694 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
695 {N_("/_Tools/_Create filter rule/by _From"),
696 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
697 {N_("/_Tools/_Create filter rule/by _To"),
698 NULL, create_filter_cb, FILTER_BY_TO, NULL},
699 {N_("/_Tools/_Create filter rule/by _Subject"),
700 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
701 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
702 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
703 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
704 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
705 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
706 {N_("/_Tools/Delete du_plicated messages"),
707 NULL, delete_duplicated_cb, 0, NULL},
708 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
709 {N_("/_Tools/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
711 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
712 {N_("/_Configuration/_Common preferences..."),
713 NULL, prefs_common_open_cb, 0, NULL},
714 {N_("/_Configuration/_Filter setting..."),
715 NULL, prefs_filter_open_cb, 0, NULL},
716 {N_("/_Configuration/_Scoring..."),
717 NULL, prefs_scoring_open_cb, 0, NULL},
718 {N_("/_Configuration/_Filtering..."),
719 NULL, prefs_filtering_open_cb, 0, NULL},
720 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
721 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
722 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
723 {N_("/_Configuration/_Preferences for current account..."),
724 NULL, prefs_account_open_cb, 0, NULL},
725 {N_("/_Configuration/Create _new account..."),
726 NULL, new_account_cb, 0, NULL},
727 {N_("/_Configuration/_Edit accounts..."),
728 NULL, account_edit_open, 0, NULL},
729 {N_("/_Configuration/C_hange current account"),
730 NULL, NULL, 0, "<Branch>"},
732 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
733 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
734 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
735 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
736 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
737 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
738 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
739 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
740 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
741 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
742 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
743 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
745 static GtkItemFactoryEntry reply_popup_entries[] =
747 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
748 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
750 static GtkItemFactoryEntry replyall_popup_entries[] =
752 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
753 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
755 static GtkItemFactoryEntry replysender_popup_entries[] =
757 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
758 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
760 static GtkItemFactoryEntry fwd_popup_entries[] =
762 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
763 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
767 MainWindow *main_window_create(SeparateType type)
773 GtkWidget *handlebox;
774 GtkWidget *vbox_body;
775 GtkWidget *hbox_stat;
776 GtkWidget *statusbar;
777 GtkWidget *progressbar;
778 GtkWidget *statuslabel;
779 GtkWidget *ac_button;
782 FolderView *folderview;
783 SummaryView *summaryview;
784 MessageView *messageview;
785 GdkColormap *colormap;
788 guint n_menu_entries;
789 GtkItemFactory *ifactory;
792 GtkWidget *compose_popup;
793 GtkWidget *reply_popup;
794 GtkWidget *replyall_popup;
795 GtkWidget *replysender_popup;
796 GtkWidget *fwd_popup;
799 static GdkGeometry geometry;
801 debug_print(_("Creating main window...\n"));
802 mainwin = g_new0(MainWindow, 1);
805 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
806 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
807 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
808 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
810 if (!geometry.min_height) {
811 geometry.min_width = 320;
812 geometry.min_height = 200;
814 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
817 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
818 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
819 MANAGE_WINDOW_SIGNALS_CONNECT(window);
820 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
821 GTK_SIGNAL_FUNC(key_pressed), mainwin);
823 gtk_widget_realize(window);
824 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
827 gtkut_widget_set_app_icon(window);
829 vbox = gtk_vbox_new(FALSE, 0);
830 gtk_widget_show(vbox);
831 gtk_container_add(GTK_CONTAINER(window), vbox);
834 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
835 menubar = menubar_create(window, mainwin_entries,
836 n_menu_entries, "<Main>", mainwin);
837 gtk_widget_show(menubar);
838 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
840 handlebox = gtk_handle_box_new();
841 gtk_widget_show(handlebox);
842 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
844 /* create the popup menus for the reply buttons specials */
845 n_menu_entries = sizeof(reply_popup_entries) /
846 sizeof(reply_popup_entries[0]);
847 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
848 "<ReplyPopup>", mainwin);
849 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
850 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
851 n_menu_entries = sizeof(replyall_popup_entries) /
852 sizeof(replyall_popup_entries[0]);
853 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
854 "<ReplyAllPopup>", mainwin);
855 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
856 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
857 n_menu_entries = sizeof(replysender_popup_entries) /
858 sizeof(replysender_popup_entries[0]);
859 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
860 "<ReplySenderPopup>", mainwin);
861 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
862 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
863 /* create the popup menu for the forward button */
864 n_menu_entries = sizeof(fwd_popup_entries) /
865 sizeof(fwd_popup_entries[0]);
866 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
867 "<ForwardPopup>", mainwin);
868 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
869 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
871 main_window_toolbar_create(mainwin, handlebox);
873 /* vbox that contains body */
874 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
875 gtk_widget_show(vbox_body);
876 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
877 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
879 hbox_stat = gtk_hbox_new(FALSE, 2);
880 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
882 statusbar = statusbar_create();
883 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
885 progressbar = gtk_progress_bar_new();
886 gtk_widget_set_usize(progressbar, 120, 1);
887 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
889 statuslabel = gtk_label_new("");
890 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
892 ac_button = gtk_button_new();
893 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
894 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
895 gtk_widget_set_usize(ac_button, -1, 1);
896 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
897 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
898 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
900 ac_label = gtk_label_new("");
901 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
903 gtk_widget_show_all(hbox_stat);
906 mainwin->folderview = folderview = folderview_create();
907 mainwin->summaryview = summaryview = summary_create();
908 mainwin->messageview = messageview = messageview_create();
909 mainwin->logwin = log_window_create();
911 folderview->mainwin = mainwin;
912 folderview->summaryview = summaryview;
914 summaryview->mainwin = mainwin;
915 summaryview->folderview = folderview;
916 summaryview->messageview = messageview;
917 summaryview->window = window;
919 messageview->mainwin = mainwin;
921 mainwin->window = window;
922 mainwin->vbox = vbox;
923 mainwin->menubar = menubar;
924 mainwin->handlebox = handlebox;
925 mainwin->vbox_body = vbox_body;
926 mainwin->hbox_stat = hbox_stat;
927 mainwin->statusbar = statusbar;
928 mainwin->progressbar = progressbar;
929 mainwin->statuslabel = statuslabel;
930 mainwin->ac_button = ac_button;
931 mainwin->ac_label = ac_label;
932 mainwin->reply_popup = reply_popup;
933 mainwin->replyall_popup = replyall_popup;
934 mainwin->replysender_popup = replysender_popup;
935 mainwin->fwd_popup = fwd_popup;
937 /* set context IDs for status bar */
938 mainwin->mainwin_cid = gtk_statusbar_get_context_id
939 (GTK_STATUSBAR(statusbar), "Main Window");
940 mainwin->folderview_cid = gtk_statusbar_get_context_id
941 (GTK_STATUSBAR(statusbar), "Folder View");
942 mainwin->summaryview_cid = gtk_statusbar_get_context_id
943 (GTK_STATUSBAR(statusbar), "Summary View");
945 /* allocate colors for summary view and folder view */
946 summaryview->color_marked.red = summaryview->color_marked.green = 0;
947 summaryview->color_marked.blue = (guint16)65535;
949 summaryview->color_dim.red = summaryview->color_dim.green =
950 summaryview->color_dim.blue = COLOR_DIM;
952 folderview->color_new.red = (guint16)55000;
953 folderview->color_new.green = folderview->color_new.blue = 15000;
955 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
956 &folderview->color_op);
958 summaryview->color_important.red = 0;
959 summaryview->color_important.green = 0;
960 summaryview->color_important.blue = (guint16)65535;
962 color[0] = summaryview->color_marked;
963 color[1] = summaryview->color_dim;
964 color[2] = folderview->color_new;
965 color[3] = folderview->color_op;
967 colormap = gdk_window_get_colormap(window->window);
968 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
969 for (i = 0; i < 4; i++) {
970 if (success[i] == FALSE)
971 g_warning(_("MainWindow: color allocation %d failed\n"), i);
974 debug_print(_("done.\n"));
976 main_window_set_widgets(mainwin, type);
979 ifactory = gtk_item_factory_from_widget(menubar);
980 menuitem = gtk_item_factory_get_item
981 (ifactory, "/View/Code set/Auto detect");
982 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
984 switch (prefs_common.toolbar_style) {
986 menuitem = gtk_item_factory_get_item
987 (ifactory, "/View/Show or hide/Toolbar/None");
990 menuitem = gtk_item_factory_get_item
991 (ifactory, "/View/Show or hide/Toolbar/Icon");
994 menuitem = gtk_item_factory_get_item
995 (ifactory, "/View/Show or hide/Toolbar/Text");
998 menuitem = gtk_item_factory_get_item
999 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1001 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1003 gtk_widget_hide(mainwin->hbox_stat);
1004 menuitem = gtk_item_factory_get_item
1005 (ifactory, "/View/Show or hide/Status bar");
1006 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1007 prefs_common.show_statusbar);
1008 #if 0 /* FIXED SEPARATE WINDOWS */
1009 /* Message view and Folder tree are always shown at startup
1010 * make that in the menu visible */
1011 menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Message View");
1012 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1013 menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Folder Tree");
1014 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1016 /* set the check of the SEPARATE_xxx menu items. we also need the main window
1017 * as a property and pass the action type to the callback */
1018 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
1020 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
1021 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
1022 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
1023 GUINT_TO_POINTER(SEPARATE_FOLDER));
1025 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
1027 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
1028 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
1029 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
1030 GUINT_TO_POINTER(SEPARATE_MESSAGE));
1032 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
1033 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
1036 /* set account selection menu */
1037 ac_menu = gtk_item_factory_get_widget
1038 (ifactory, "/Configuration/Change current account");
1039 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1040 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1041 mainwin->ac_menu = ac_menu;
1043 main_window_set_toolbar_sensitive(mainwin);
1045 /* Create actions menu */
1046 update_mainwin_actions_menu(ifactory, mainwin);
1048 /* show main window */
1049 gtk_widget_set_uposition(mainwin->window,
1050 prefs_common.mainwin_x,
1051 prefs_common.mainwin_y);
1052 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1053 prefs_common.mainwin_height);
1054 gtk_widget_show(mainwin->window);
1056 /* initialize views */
1057 folderview_init(folderview);
1058 summary_init(summaryview);
1059 messageview_init(messageview);
1060 log_window_init(mainwin->logwin);
1062 mainwin->lock_count = 0;
1063 mainwin->menu_lock_count = 0;
1064 mainwin->cursor_count = 0;
1067 watch_cursor = gdk_cursor_new(GDK_WATCH);
1069 mainwin_list = g_list_append(mainwin_list, mainwin);
1074 void main_window_cursor_wait(MainWindow *mainwin)
1077 if (mainwin->cursor_count == 0)
1078 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1080 mainwin->cursor_count++;
1085 void main_window_cursor_normal(MainWindow *mainwin)
1087 if (mainwin->cursor_count)
1088 mainwin->cursor_count--;
1090 if (mainwin->cursor_count == 0)
1091 gdk_window_set_cursor(mainwin->window->window, NULL);
1096 /* lock / unlock the user-interface */
1097 void main_window_lock(MainWindow *mainwin)
1099 if (mainwin->lock_count == 0)
1100 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1102 mainwin->lock_count++;
1104 main_window_set_menu_sensitive(mainwin);
1105 main_window_set_toolbar_sensitive(mainwin);
1108 void main_window_unlock(MainWindow *mainwin)
1110 if (mainwin->lock_count)
1111 mainwin->lock_count--;
1113 main_window_set_menu_sensitive(mainwin);
1114 main_window_set_toolbar_sensitive(mainwin);
1116 if (mainwin->lock_count == 0)
1117 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1120 static void main_window_menu_callback_block(MainWindow *mainwin)
1122 mainwin->menu_lock_count++;
1125 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1127 if (mainwin->menu_lock_count)
1128 mainwin->menu_lock_count--;
1131 void main_window_reflect_prefs_all(void)
1133 main_window_reflect_prefs_all_real(FALSE);
1136 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1139 MainWindow *mainwin;
1141 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1142 mainwin = (MainWindow *)cur->data;
1144 main_window_show_cur_account(mainwin);
1145 main_window_set_menu_sensitive(mainwin);
1146 main_window_set_toolbar_sensitive(mainwin);
1149 if (pixmap_theme_changed)
1151 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1152 mainwin->toolbar = NULL;
1153 main_window_toolbar_create(mainwin, mainwin->handlebox);
1154 set_toolbar_style(mainwin);
1155 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1156 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1157 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1160 summary_redisplay_msg(mainwin->summaryview);
1161 headerview_set_visibility(mainwin->messageview->headerview,
1162 prefs_common.display_header_pane);
1166 void main_window_set_summary_column(void)
1169 MainWindow *mainwin;
1171 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1172 mainwin = (MainWindow *)cur->data;
1173 summary_set_column_order(mainwin->summaryview);
1177 void main_window_set_account_menu(GList *account_list)
1179 GList *cur, *cur_ac, *cur_item;
1180 GtkWidget *menuitem;
1181 MainWindow *mainwin;
1182 PrefsAccount *ac_prefs;
1184 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1185 mainwin = (MainWindow *)cur->data;
1187 /* destroy all previous menu item */
1188 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1189 while (cur_item != NULL) {
1190 GList *next = cur_item->next;
1191 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1195 for (cur_ac = account_list; cur_ac != NULL;
1196 cur_ac = cur_ac->next) {
1197 ac_prefs = (PrefsAccount *)cur_ac->data;
1199 menuitem = gtk_menu_item_new_with_label
1200 (ac_prefs->account_name
1201 ? ac_prefs->account_name : _("Untitled"));
1202 gtk_widget_show(menuitem);
1203 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1204 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1205 GTK_SIGNAL_FUNC(account_menu_cb),
1211 static void main_window_show_cur_account(MainWindow *mainwin)
1216 ac_name = g_strdup(cur_account
1217 ? (cur_account->account_name
1218 ? cur_account->account_name : _("Untitled"))
1222 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1224 buf = g_strdup(PROG_VERSION);
1225 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1228 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1229 gtk_widget_queue_resize(mainwin->ac_button);
1234 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1236 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1237 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1238 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1240 if (mainwin->type == type) return;
1242 /* remove widgets from those containers */
1243 gtk_widget_ref(folder_wid);
1244 gtk_widget_ref(summary_wid);
1245 gtk_widget_ref(message_wid);
1246 gtkut_container_remove
1247 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1248 gtkut_container_remove
1249 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1250 gtkut_container_remove
1251 (GTK_CONTAINER(message_wid->parent), message_wid);
1253 /* clean containers */
1254 switch (mainwin->type) {
1256 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1258 case SEPARATE_FOLDER:
1259 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1260 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1262 case SEPARATE_MESSAGE:
1263 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1264 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1267 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1268 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1272 gtk_widget_hide(mainwin->window);
1273 main_window_set_widgets(mainwin, type);
1274 gtk_widget_show(mainwin->window);
1276 gtk_widget_unref(folder_wid);
1277 gtk_widget_unref(summary_wid);
1278 gtk_widget_unref(message_wid);
1281 void main_window_get_size(MainWindow *mainwin)
1283 GtkAllocation *allocation;
1285 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1287 prefs_common.summaryview_width = allocation->width;
1289 if (mainwin->summaryview->msg_is_toggled_on)
1290 prefs_common.summaryview_height = allocation->height;
1292 prefs_common.mainview_width = allocation->width;
1294 allocation = &mainwin->window->allocation;
1296 prefs_common.mainview_height = allocation->height;
1297 prefs_common.mainwin_width = allocation->width;
1298 prefs_common.mainwin_height = allocation->height;
1300 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1302 prefs_common.folderview_width = allocation->width;
1303 prefs_common.folderview_height = allocation->height;
1306 void main_window_get_position(MainWindow *mainwin)
1310 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1312 prefs_common.mainview_x = x;
1313 prefs_common.mainview_y = y;
1314 prefs_common.mainwin_x = x;
1315 prefs_common.mainwin_y = y;
1317 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1320 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1326 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1327 folder = FOLDER(list->data);
1328 if (folder && folder->trash && folder->trash->total > 0)
1332 if (!has_trash) return;
1335 if (alertpanel(_("Empty trash"),
1336 _("Empty all messages in trash?"),
1337 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1339 manage_window_focus_in(mainwin->window, NULL, NULL);
1342 procmsg_empty_trash();
1344 for (list = folder_get_list(); list != NULL; list = list->next) {
1345 folder = list->data;
1346 if (folder && folder->trash && folder->trash->total != 0) {
1347 folder_item_scan(folder->trash);
1348 folderview_update_item(folder->trash, TRUE);
1352 if (mainwin->summaryview->folder_item &&
1353 mainwin->summaryview->folder_item->stype == F_TRASH)
1354 gtk_widget_grab_focus(mainwin->folderview->ctree);
1357 void main_window_add_mailbox(MainWindow *mainwin)
1362 path = input_dialog(_("Add mailbox"),
1363 _("Input the location of mailbox.\n"
1364 "If the existing mailbox is specified, it will be\n"
1365 "scanned automatically."),
1368 if (folder_find_from_path(path)) {
1369 alertpanel_error(_("The mailbox `%s' already exists."), path);
1373 if (!strcmp(path, "Mail"))
1374 folder = folder_new(F_MH, _("Mailbox"), path);
1376 folder = folder_new(F_MH, g_basename(path), path);
1379 if (folder->create_tree(folder) < 0) {
1380 alertpanel_error(_("Creation of the mailbox failed.\n"
1381 "Maybe some files already exist, or you don't have the permission to write there."));
1382 folder_destroy(folder);
1387 folder_set_ui_func(folder, scan_tree_func, mainwin);
1388 folder->scan_tree(folder);
1389 folder_set_ui_func(folder, NULL, NULL);
1391 folderview_set(mainwin->folderview);
1394 void main_window_add_mbox(MainWindow *mainwin)
1400 path = input_dialog(_("Add mbox mailbox"),
1401 _("Input the location of mailbox."),
1406 if (folder_find_from_path(path)) {
1407 alertpanel_error(_("The mailbox `%s' already exists."), path);
1413 if (!strcmp(path, "Mail"))
1414 folder = folder_new(F_MBOX, _("Mailbox"), path);
1418 folder = folder_new(F_MBOX, g_basename(path), path);
1421 if (folder->create_tree(folder) < 0) {
1422 alertpanel_error(_("Creation of the mailbox failed."));
1423 folder_destroy(folder);
1429 item = folder_item_new(folder->name, NULL);
1430 item->folder = folder;
1431 folder->node = g_node_new(item);
1433 folder->create_folder(folder, item, "inbox");
1434 folder->create_folder(folder, item, "outbox");
1435 folder->create_folder(folder, item, "queue");
1436 folder->create_folder(folder, item, "draft");
1437 folder->create_folder(folder, item, "trash");
1439 folderview_set(mainwin->folderview);
1444 M_UNLOCKED = 1 << 0,
1445 M_MSG_EXIST = 1 << 1,
1446 M_TARGET_EXIST = 1 << 2,
1447 M_SINGLE_TARGET_EXIST = 1 << 3,
1449 M_ALLOW_REEDIT = 1 << 5,
1450 M_HAVE_ACCOUNT = 1 << 6,
1451 M_THREADED = 1 << 7,
1452 M_UNTHREADED = 1 << 8,
1453 M_ALLOW_DELETE = 1 << 9,
1454 M_INC_ACTIVE = 1 << 10,
1456 M_HAVE_NEWS_ACCOUNT = 1 << 12,
1457 M_HIDE_READ_MSG = 1 << 13
1460 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1462 SensitiveCond state = 0;
1463 SummarySelection selection;
1464 FolderItem *item = mainwin->summaryview->folder_item;
1465 GList *account_list = account_get_list();
1467 selection = summary_get_selection_type(mainwin->summaryview);
1469 if (mainwin->lock_count == 0)
1470 state |= M_UNLOCKED;
1471 if (selection != SUMMARY_NONE)
1472 state |= M_MSG_EXIST;
1476 state |= M_THREADED;
1478 state |= M_UNTHREADED;
1479 /* if (item->folder->type != F_NEWS) */
1480 state |= M_ALLOW_DELETE;
1482 if (selection == SUMMARY_NONE && item->hide_read_msgs
1483 || selection != SUMMARY_NONE)
1484 state |= M_HIDE_READ_MSG;
1486 if (selection == SUMMARY_SELECTED_SINGLE ||
1487 selection == SUMMARY_SELECTED_MULTIPLE)
1488 state |= M_TARGET_EXIST;
1489 if (selection == SUMMARY_SELECTED_SINGLE)
1490 state |= M_SINGLE_TARGET_EXIST;
1491 if (mainwin->summaryview->folder_item &&
1492 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1494 if (selection == SUMMARY_SELECTED_SINGLE &&
1496 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1497 item->stype == F_QUEUE)))
1498 state |= M_ALLOW_REEDIT;
1500 state |= M_HAVE_ACCOUNT;
1502 for ( ; account_list != NULL; account_list = account_list->next) {
1503 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1504 state |= M_HAVE_NEWS_ACCOUNT;
1509 if (inc_is_active())
1510 state |= M_INC_ACTIVE;
1515 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1517 SensitiveCond state;
1526 entry[0].widget = mainwin->get_btn;
1527 entry[0].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1528 entry[1].widget = mainwin->getall_btn;
1529 entry[1].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1530 entry[2].widget = mainwin->compose_news_btn;
1531 entry[2].cond = M_HAVE_NEWS_ACCOUNT;
1532 entry[3].widget = mainwin->reply_btn;
1533 entry[3].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1534 entry[4].widget = mainwin->replyall_btn;
1535 entry[4].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1536 entry[5].widget = mainwin->replysender_btn;
1537 entry[5].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1538 entry[6].widget = mainwin->fwd_btn;
1539 entry[6].cond = M_HAVE_ACCOUNT|M_TARGET_EXIST;
1540 /* entry[6].widget = mainwin->prefs_btn;
1541 entry[6].cond = M_UNLOCKED;
1542 entry[7].widget = mainwin->account_btn;
1543 entry[7].cond = M_UNLOCKED; */
1544 entry[7].widget = mainwin->next_btn;
1545 entry[7].cond = M_MSG_EXIST;
1546 entry[8].widget = mainwin->delete_btn;
1547 entry[8].cond = M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED;
1548 entry[9].widget = mainwin->exec_btn;
1549 entry[9].cond = M_MSG_EXIST|M_EXEC|M_UNLOCKED;
1550 entry[10].widget = NULL;
1553 state = main_window_get_current_state(mainwin);
1555 for (i = 0; entry[i].widget != NULL; i++) {
1556 sensitive = ((entry[i].cond & state) == entry[i].cond);
1557 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1560 activate_compose_button(mainwin,
1561 prefs_common.toolbar_style,
1562 mainwin->compose_btn_type);
1565 void main_window_set_menu_sensitive(MainWindow *mainwin)
1567 GtkItemFactory *ifactory;
1568 SensitiveCond state;
1570 GtkWidget *menuitem;
1573 static const struct {
1577 {"/File/Add mailbox..." , M_UNLOCKED},
1578 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1579 {"/File/Rescan folder tree" , M_UNLOCKED},
1580 {"/File/Folder" , M_UNLOCKED},
1581 {"/File/Import mbox file..." , M_UNLOCKED},
1582 {"/File/Export to mbox file...", M_UNLOCKED},
1583 {"/File/Empty trash" , M_UNLOCKED},
1584 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1585 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1586 /* {"/File/Close", M_UNLOCKED}, */
1587 {"/File/Exit" , M_UNLOCKED},
1589 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1590 {"/View/Sort" , M_MSG_EXIST},
1591 {"/View/Thread view" , M_EXEC},
1592 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1593 {"/View/Go to/Prev message" , M_MSG_EXIST},
1594 {"/View/Go to/Next message" , M_MSG_EXIST},
1595 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1596 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1597 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1598 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1599 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1600 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1601 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1602 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1603 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1605 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1606 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1607 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1608 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1609 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1610 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1611 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1612 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1613 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1614 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1615 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1616 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1617 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1618 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1619 {"/Message/Mark" , M_TARGET_EXIST},
1621 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1622 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1623 {"/Tools/Harvest addresses" , M_UNLOCKED},
1624 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1625 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1626 {"/Tools/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1627 {"/Tools/Actions" , M_MSG_EXIST},
1628 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1630 {"/Configuration", M_UNLOCKED},
1635 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1636 state = main_window_get_current_state(mainwin);
1638 for (i = 0; entry[i].entry != NULL; i++) {
1639 sensitive = ((entry[i].cond & state) == entry[i].cond);
1640 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1643 main_window_menu_callback_block(mainwin);
1644 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all header");
1645 gtk_check_menu_item_set_active
1646 (GTK_CHECK_MENU_ITEM(menuitem),
1647 mainwin->messageview->textview->show_all_headers);
1648 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1649 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1650 (state & M_THREADED) != 0);
1651 main_window_menu_callback_unblock(mainwin);
1654 void main_window_popup(MainWindow *mainwin)
1660 gdk_window_get_origin(mainwin->window->window, &x, &y);
1661 sx = gdk_screen_width();
1662 sy = gdk_screen_height();
1663 x %= sx; if (x < 0) x = 0;
1664 y %= sy; if (y < 0) y = 0;
1665 gdk_window_move(mainwin->window->window, x, y);
1666 gdk_window_raise(mainwin->window->window);
1667 gdk_window_show(mainwin->window->window);
1669 debug_print("window position: x = %d, y = %d\n", x, y);
1671 switch (mainwin->type) {
1672 case SEPARATE_FOLDER:
1673 widget = mainwin->win.sep_folder.folderwin;
1674 gdk_window_get_origin(widget->window, &x, &y);
1675 x %= sx; if (x < 0) x = 0;
1676 y %= sy; if (y < 0) y = 0;
1677 gdk_window_move(widget->window, x, y);
1678 gdk_window_raise(widget->window);
1680 case SEPARATE_MESSAGE:
1681 widget = mainwin->win.sep_message.messagewin;
1682 gdk_window_get_origin(widget->window, &x, &y);
1683 x %= sx; if (x < 0) x = 0;
1684 y %= sy; if (y < 0) y = 0;
1685 gdk_window_move(widget->window, x, y);
1686 gdk_window_raise(widget->window);
1689 widget = mainwin->win.sep_both.folderwin;
1690 gdk_window_get_origin(widget->window, &x, &y);
1691 x %= sx; if (x < 0) x = 0;
1692 y %= sy; if (y < 0) y = 0;
1693 gdk_window_move(widget->window, x, y);
1694 gdk_window_raise(widget->window);
1695 widget = mainwin->win.sep_both.messagewin;
1696 gdk_window_get_origin(widget->window, &x, &y);
1697 x %= sx; if (x < 0) x = 0;
1698 y %= sy; if (y < 0) y = 0;
1699 gdk_window_move(widget->window, x, y);
1700 gdk_window_raise(widget->window);
1707 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1709 GtkWidget *folderwin = NULL;
1710 GtkWidget *messagewin = NULL;
1713 GtkWidget *vbox_body = mainwin->vbox_body;
1714 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1715 GtkWidget *menuitem;
1717 debug_print(_("Setting widgets..."));
1719 /* create separated window(s) if needed */
1720 if (type & SEPARATE_FOLDER) {
1721 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1722 gtk_window_set_title(GTK_WINDOW(folderwin),
1723 _("Sylpheed - Folder View"));
1724 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1725 "folder_view", "Sylpheed");
1726 gtk_window_set_policy(GTK_WINDOW(folderwin),
1728 gtk_widget_set_usize(folderwin, -1,
1729 prefs_common.mainview_height);
1730 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1732 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1733 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1736 if (type & SEPARATE_MESSAGE) {
1737 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1738 gtk_window_set_title(GTK_WINDOW(messagewin),
1739 _("Sylpheed - Message View"));
1740 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1741 "message_view", "Sylpheed");
1742 gtk_window_set_policy(GTK_WINDOW(messagewin),
1744 gtk_widget_set_usize
1745 (messagewin, prefs_common.mainview_width,
1746 prefs_common.mainview_height
1747 - prefs_common.summaryview_height
1748 + DEFAULT_HEADERVIEW_HEIGHT);
1749 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1751 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1752 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1758 hpaned = gtk_hpaned_new();
1759 gtk_widget_show(hpaned);
1760 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1761 gtk_paned_add1(GTK_PANED(hpaned),
1762 GTK_WIDGET_PTR(mainwin->folderview));
1764 vpaned = gtk_vpaned_new();
1765 if (mainwin->summaryview->msg_is_toggled_on) {
1766 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1767 gtk_paned_add1(GTK_PANED(vpaned),
1768 GTK_WIDGET_PTR(mainwin->summaryview));
1770 gtk_paned_add2(GTK_PANED(hpaned),
1771 GTK_WIDGET_PTR(mainwin->summaryview));
1772 gtk_widget_ref(vpaned);
1774 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1775 prefs_common.summaryview_width,
1776 prefs_common.summaryview_height);
1777 gtk_paned_add2(GTK_PANED(vpaned),
1778 GTK_WIDGET_PTR(mainwin->messageview));
1779 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1780 prefs_common.mainview_width, -1);
1781 gtk_widget_set_usize(mainwin->window,
1782 prefs_common.folderview_width +
1783 prefs_common.mainview_width,
1784 prefs_common.mainwin_height);
1785 gtk_widget_show_all(vpaned);
1787 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1788 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1789 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1790 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1791 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1792 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1794 mainwin->win.sep_none.hpaned = hpaned;
1795 mainwin->win.sep_none.vpaned = vpaned;
1797 case SEPARATE_FOLDER:
1798 vpaned = gtk_vpaned_new();
1799 if (mainwin->summaryview->msg_is_toggled_on) {
1800 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1802 gtk_paned_add1(GTK_PANED(vpaned),
1803 GTK_WIDGET_PTR(mainwin->summaryview));
1805 gtk_box_pack_start(GTK_BOX(vbox_body),
1806 GTK_WIDGET_PTR(mainwin->summaryview),
1808 gtk_widget_ref(vpaned);
1810 gtk_paned_add2(GTK_PANED(vpaned),
1811 GTK_WIDGET_PTR(mainwin->messageview));
1812 gtk_widget_show_all(vpaned);
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(GTK_WIDGET_PTR(mainwin->messageview),
1817 prefs_common.mainview_width, -1);
1818 gtk_widget_set_usize(mainwin->window,
1819 prefs_common.mainview_width,
1820 prefs_common.mainview_height);
1822 gtk_container_add(GTK_CONTAINER(folderwin),
1823 GTK_WIDGET_PTR(mainwin->folderview));
1825 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1826 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1828 mainwin->win.sep_folder.folderwin = folderwin;
1829 mainwin->win.sep_folder.vpaned = vpaned;
1831 gtk_widget_show_all(folderwin);
1833 case SEPARATE_MESSAGE:
1834 hpaned = gtk_hpaned_new();
1835 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1837 gtk_paned_add1(GTK_PANED(hpaned),
1838 GTK_WIDGET_PTR(mainwin->folderview));
1839 gtk_paned_add2(GTK_PANED(hpaned),
1840 GTK_WIDGET_PTR(mainwin->summaryview));
1841 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1842 prefs_common.summaryview_width,
1843 prefs_common.summaryview_height);
1844 gtk_widget_set_usize(mainwin->window,
1845 prefs_common.folderview_width +
1846 prefs_common.mainview_width,
1847 prefs_common.mainwin_height);
1848 gtk_widget_show_all(hpaned);
1849 gtk_container_add(GTK_CONTAINER(messagewin),
1850 GTK_WIDGET_PTR(mainwin->messageview));
1852 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1853 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1854 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1855 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1857 mainwin->win.sep_message.messagewin = messagewin;
1858 mainwin->win.sep_message.hpaned = hpaned;
1860 gtk_widget_show_all(messagewin);
1863 gtk_box_pack_start(GTK_BOX(vbox_body),
1864 GTK_WIDGET_PTR(mainwin->summaryview),
1866 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1867 prefs_common.summaryview_width,
1868 prefs_common.summaryview_height);
1869 gtk_widget_set_usize(mainwin->window,
1870 prefs_common.mainview_width,
1871 prefs_common.mainwin_height);
1872 gtk_container_add(GTK_CONTAINER(folderwin),
1873 GTK_WIDGET_PTR(mainwin->folderview));
1874 gtk_container_add(GTK_CONTAINER(messagewin),
1875 GTK_WIDGET_PTR(mainwin->messageview));
1877 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1878 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1880 mainwin->win.sep_both.folderwin = folderwin;
1881 mainwin->win.sep_both.messagewin = messagewin;
1883 gtk_widget_show_all(folderwin);
1884 gtk_widget_show_all(messagewin);
1888 mainwin->type = type;
1890 debug_print(_("done.\n"));
1893 static void main_window_toolbar_create(MainWindow *mainwin,
1894 GtkWidget *container)
1897 GtkWidget *icon_wid;
1899 GtkWidget *getall_btn;
1900 GtkWidget *compose_mail_btn;
1901 GtkWidget *compose_news_btn;
1902 GtkWidget *reply_btn;
1903 GtkWidget *replyall_btn;
1904 GtkWidget *replysender_btn;
1906 GtkWidget *send_btn;
1908 GtkWidget *prefs_btn;
1909 GtkWidget *account_btn;
1911 GtkWidget *next_btn;
1912 GtkWidget *delete_btn;
1913 GtkWidget *exec_btn;
1915 GtkTooltips *tooltips;
1917 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1919 gtk_container_add(GTK_CONTAINER(container), toolbar);
1920 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1921 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1922 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1923 GTK_TOOLBAR_SPACE_LINE);
1925 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1926 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1928 _("Get new mail from current account"),
1930 icon_wid, toolbar_inc_cb, mainwin);
1931 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1932 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1934 _("Get new mail from all accounts"),
1940 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1942 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1943 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1945 _("Send queued message(s)"),
1951 /* insert compose mail button widget */
1952 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1953 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1955 _("Compose an email message"),
1958 toolbar_compose_mail_cb,
1961 /* insert compose news button widget */
1962 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1963 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1965 _("Compose a news message"),
1968 toolbar_compose_news_cb,
1971 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1975 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1976 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1978 _("Reply to the message - Right button: more options"),
1984 /* replyall button */
1986 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1987 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1989 _("Reply to all - Right button: more options"),
1992 toolbar_reply_to_all_cb,
1995 /* reply to sender button */
1996 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1997 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1999 _("Reply to sender - Right button: more options"),
2002 toolbar_reply_to_sender_cb,
2005 /* forward button */
2006 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
2007 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2009 _("Forward the message - Right button: more options"),
2015 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2017 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
2018 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2020 _("Delete the message"),
2026 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
2027 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2029 _("Execute marked process"),
2035 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
2036 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2038 _("Next unread message"),
2041 toolbar_next_unread_cb,
2045 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2047 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2048 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2050 _("Common preference"),
2055 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2056 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2058 _("Account setting"),
2063 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2064 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2068 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2069 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2072 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2073 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2076 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2077 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2080 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2081 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2085 mainwin->toolbar = toolbar;
2086 mainwin->get_btn = get_btn;
2087 mainwin->getall_btn = getall_btn;
2088 mainwin->compose_mail_btn = compose_mail_btn;
2089 mainwin->compose_news_btn = compose_news_btn;
2090 mainwin->reply_btn = reply_btn;
2091 mainwin->replyall_btn = replyall_btn;
2092 mainwin->replysender_btn = replysender_btn;
2093 mainwin->fwd_btn = fwd_btn;
2094 mainwin->send_btn = send_btn;
2096 mainwin->prefs_btn = prefs_btn;
2097 mainwin->account_btn = account_btn;
2099 mainwin->next_btn = next_btn;
2100 mainwin->delete_btn = delete_btn;
2101 mainwin->exec_btn = exec_btn;
2103 gtk_widget_show_all(toolbar);
2106 /* callback functions */
2107 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2109 MainWindow *mainwindow = (MainWindow *) data;
2113 if (event->button == 3) {
2114 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2115 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2116 menu_button_position, widget,
2117 event->button, event->time);
2121 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2123 MainWindow *mainwin = (MainWindow *)data;
2125 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2126 manage_window_focus_in(mainwin->window, NULL, NULL);
2129 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2131 MainWindow *mainwindow = (MainWindow *) data;
2135 if (event->button == 3) {
2136 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2137 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2138 menu_button_position, widget,
2139 event->button, event->time);
2143 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2145 MainWindow *mainwin = (MainWindow *)data;
2147 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2148 manage_window_focus_in(mainwin->window, NULL, NULL);
2151 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2153 MainWindow *mainwindow = (MainWindow *) data;
2154 GtkWidget *replysender_menu, *replysender_item;
2158 if (event->button == 3) {
2159 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2160 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2161 menu_button_position, widget,
2162 event->button, event->time);
2166 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2168 MainWindow *mainwin = (MainWindow *)data;
2170 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2171 manage_window_focus_in(mainwin->window, NULL, NULL);
2174 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2176 MainWindow *mainwindow = (MainWindow *) data;
2180 if (event->button == 3) {
2181 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2182 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2183 menu_button_position, widget,
2184 event->button, event->time);
2188 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2190 MainWindow *mainwin = (MainWindow *)data;
2192 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2193 manage_window_focus_in(mainwin->window, NULL, NULL);
2196 static void toolbar_inc_cb (GtkWidget *widget,
2199 MainWindow *mainwin = (MainWindow *)data;
2201 inc_mail_cb(mainwin, 0, NULL);
2204 static void toolbar_inc_all_cb (GtkWidget *widget,
2207 MainWindow *mainwin = (MainWindow *)data;
2209 inc_all_account_mail_cb(mainwin, 0, NULL);
2212 static void toolbar_send_cb (GtkWidget *widget,
2215 MainWindow *mainwin = (MainWindow *)data;
2217 send_queue_cb(mainwin, 0, NULL);
2220 static void toolbar_compose_cb (GtkWidget *widget,
2223 MainWindow *mainwin = (MainWindow *)data;
2225 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2226 compose_cb(mainwin, 0, NULL);
2228 compose_news_cb(mainwin, 0, NULL);
2231 static void toolbar_compose_news_cb (GtkWidget *widget,
2234 MainWindow *mainwin = (MainWindow *)data;
2236 compose_news_cb(mainwin, 0, NULL);
2239 static void toolbar_compose_mail_cb (GtkWidget *widget,
2242 MainWindow *mainwin = (MainWindow *)data;
2244 compose_mail_cb(mainwin, 0, NULL);
2247 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2249 MainWindow *mainwin = (MainWindow *)data;
2252 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2253 : COMPOSE_REPLY_WITHOUT_QUOTE,
2257 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2259 MainWindow *mainwin = (MainWindow *)data;
2262 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2263 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2268 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2270 MainWindow *mainwin = (MainWindow *)data;
2273 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2274 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2278 static void toolbar_forward_cb (GtkWidget *widget,
2281 MainWindow *mainwin = (MainWindow *)data;
2283 if (prefs_common.forward_as_attachment)
2284 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2286 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2289 static void toolbar_delete_cb (GtkWidget *widget,
2292 MainWindow *mainwin = (MainWindow *)data;
2294 summary_delete(mainwin->summaryview);
2297 static void toolbar_exec_cb (GtkWidget *widget,
2300 MainWindow *mainwin = (MainWindow *)data;
2302 summary_execute(mainwin->summaryview);
2305 static void toolbar_next_unread_cb (GtkWidget *widget,
2308 MainWindow *mainwin = (MainWindow *)data;
2310 next_unread_cb(mainwin, 0, NULL);
2313 static void toolbar_prefs_cb (GtkWidget *widget,
2316 prefs_common_open();
2319 static void toolbar_account_cb (GtkWidget *widget,
2322 MainWindow *mainwin = (MainWindow *)data;
2324 prefs_account_open_cb(mainwin, 0, NULL);
2327 static void toolbar_account_button_pressed(GtkWidget *widget,
2328 GdkEventButton *event,
2331 MainWindow *mainwin = (MainWindow *)data;
2334 if (event->button != 3) return;
2336 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2337 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2340 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2341 menu_button_position, widget,
2342 event->button, event->time);
2345 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2348 MainWindow *mainwin = (MainWindow *)data;
2352 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2353 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2356 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2357 menu_button_position, widget,
2358 event->button, event->time);
2361 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2363 MainWindow *mainwin = (MainWindow *)data;
2366 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2367 if (!button) return;
2368 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2369 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2370 manage_window_focus_in(mainwin->window, NULL, NULL);
2373 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2376 MainWindow *mainwin = (MainWindow *)data;
2378 if (mainwin->lock_count == 0)
2379 app_exit_cb(data, 0, widget);
2384 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2387 main_window_add_mailbox(mainwin);
2390 static void add_mbox_cb(MainWindow *mainwin, guint action,
2393 main_window_add_mbox(mainwin);
2396 static void update_folderview_cb(MainWindow *mainwin, guint action,
2399 summary_show(mainwin->summaryview, NULL, FALSE);
2400 folderview_rescan_all();
2403 static void new_folder_cb(MainWindow *mainwin, guint action,
2406 folderview_new_folder(mainwin->folderview);
2409 static void rename_folder_cb(MainWindow *mainwin, guint action,
2412 folderview_rename_folder(mainwin->folderview);
2415 static void delete_folder_cb(MainWindow *mainwin, guint action,
2418 folderview_delete_folder(mainwin->folderview);
2421 static void import_mbox_cb(MainWindow *mainwin, guint action,
2424 import_mbox(mainwin->summaryview->folder_item);
2427 static void export_mbox_cb(MainWindow *mainwin, guint action,
2430 export_mbox(mainwin->summaryview->folder_item);
2433 static void empty_trash_cb(MainWindow *mainwin, guint action,
2436 main_window_empty_trash(mainwin, TRUE);
2439 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2441 summary_save_as(mainwin->summaryview);
2444 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2446 summary_print(mainwin->summaryview);
2449 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2451 if (prefs_common.confirm_on_exit) {
2452 if (alertpanel(_("Exit"), _("Exit this program?"),
2453 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2455 manage_window_focus_in(mainwin->window, NULL, NULL);
2458 app_will_exit(widget, mainwin);
2461 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2464 summary_search(mainwin->summaryview);
2466 message_search(mainwin->messageview);
2469 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2472 switch (mainwin->type) {
2474 case SEPARATE_MESSAGE:
2476 case SEPARATE_FOLDER:
2477 if (GTK_CHECK_MENU_ITEM(widget)->active)
2478 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2480 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2483 if (GTK_CHECK_MENU_ITEM(widget)->active)
2484 gtk_widget_show(mainwin->win.sep_both.folderwin);
2486 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2491 static void toggle_message_cb(MainWindow *mainwin, guint action,
2494 switch (mainwin->type) {
2496 case SEPARATE_FOLDER:
2498 case SEPARATE_MESSAGE:
2499 if (GTK_CHECK_MENU_ITEM(widget)->active)
2500 gtk_widget_show(mainwin->win.sep_message.messagewin);
2502 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2505 if (GTK_CHECK_MENU_ITEM(widget)->active)
2506 gtk_widget_show(mainwin->win.sep_both.messagewin);
2508 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2513 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2516 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2517 mainwin->compose_btn_type);
2518 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2519 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2520 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2521 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2523 mainwin->toolbar_style = (ToolbarStyle)action;
2524 prefs_common.toolbar_style = (ToolbarStyle)action;
2526 set_toolbar_style(mainwin);
2529 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2532 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2533 gtk_widget_show(mainwin->hbox_stat);
2534 prefs_common.show_statusbar = TRUE;
2536 gtk_widget_hide(mainwin->hbox_stat);
2537 prefs_common.show_statusbar = FALSE;
2541 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2543 summary_toggle_view_real(mainwin->summaryview);
2546 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2548 messageview_toggle_view_real(mainwin->messageview);
2551 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2554 MainWindow *mainwin;
2557 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2558 g_return_if_fail(mainwin != NULL);
2560 type = mainwin->type ^ action;
2561 main_window_separation_change(mainwin, type);
2563 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2564 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2567 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2570 addressbook_open(NULL);
2573 static void log_window_show_cb(MainWindow *mainwin, guint action,
2576 log_window_show(mainwin->logwin);
2579 static void sel_download_cb(MainWindow *mainwin, guint action,
2582 selective_download(mainwin);
2585 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2587 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2590 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2593 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2596 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2601 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2605 for (list = folder_get_list(); list != NULL; list = list->next) {
2606 Folder *folder = list->data;
2608 if (folder->queue) {
2609 if (procmsg_send_queue
2610 (folder->queue, prefs_common.savemsg) < 0)
2611 alertpanel_error(_("Some errors occurred while sending queued messages."));
2612 statusbar_pop_all();
2613 folder_item_scan(folder->queue);
2614 folderview_update_item(folder->queue, TRUE);
2619 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2621 if (mainwin->summaryview->folder_item) {
2622 if (mainwin->summaryview->folder_item->folder->account != NULL
2623 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2624 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2626 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2632 static void compose_mail_cb(MainWindow *mainwin, guint action,
2639 if (mainwin->summaryview->folder_item) {
2640 ac = mainwin->summaryview->folder_item->folder->account;
2641 if (ac && ac->protocol != A_NNTP) {
2642 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2647 if(cur_account && (cur_account->protocol != A_NNTP)) {
2648 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
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) {
2656 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2662 static void compose_news_cb(MainWindow *mainwin, guint action,
2665 PrefsAccount * ac = NULL;
2669 if (mainwin->summaryview->folder_item) {
2670 ac = mainwin->summaryview->folder_item->folder->account;
2671 if (ac && ac->protocol == A_NNTP) {
2672 compose_new_with_recipient
2673 (ac, mainwin->summaryview->folder_item->path);
2678 list = account_get_list();
2679 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2680 ac = (PrefsAccount *) cur->data;
2681 if (ac->protocol == A_NNTP) {
2688 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2690 summary_reply(mainwin->summaryview, (ComposeMode)action);
2693 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2695 summary_move_to(mainwin->summaryview);
2698 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2700 summary_copy_to(mainwin->summaryview);
2703 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2705 summary_delete(mainwin->summaryview);
2708 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2710 summary_open_msg(mainwin->summaryview);
2713 static void view_source_cb(MainWindow *mainwin, guint action,
2716 summary_view_source(mainwin->summaryview);
2719 static void show_all_header_cb(MainWindow *mainwin, guint action,
2722 if (mainwin->menu_lock_count) return;
2723 summary_display_msg_selected(mainwin->summaryview,
2724 GTK_CHECK_MENU_ITEM(widget)->active);
2727 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2729 summary_reedit(mainwin->summaryview);
2732 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2734 summary_mark(mainwin->summaryview);
2737 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2739 summary_unmark(mainwin->summaryview);
2742 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2745 summary_mark_as_unread(mainwin->summaryview);
2748 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2751 summary_mark_as_read(mainwin->summaryview);
2754 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2757 summary_mark_all_read(mainwin->summaryview);
2760 static void add_address_cb(MainWindow *mainwin, guint action,
2763 summary_add_address(mainwin->summaryview);
2766 static void set_charset_cb(MainWindow *mainwin, guint action,
2771 str = conv_get_charset_str((CharSet)action);
2772 g_free(prefs_common.force_charset);
2773 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2775 summary_redisplay_msg(mainwin->summaryview);
2777 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2780 static void hide_read_messages (MainWindow *mainwin, guint action,
2783 if (!mainwin->summaryview->folder_item
2784 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2786 summary_toggle_show_read_messages(mainwin->summaryview);
2789 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2791 GtkItemFactory *ifactory;
2793 if (mainwin->menu_lock_count) return;
2794 if (!mainwin->summaryview->folder_item) return;
2796 ifactory = gtk_item_factory_from_widget(widget);
2798 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2799 summary_thread_build(mainwin->summaryview);
2800 mainwin->summaryview->folder_item->threaded = TRUE;
2802 summary_unthread(mainwin->summaryview);
2803 mainwin->summaryview->folder_item->threaded = FALSE;
2807 static void set_display_item_cb(MainWindow *mainwin, guint action,
2810 prefs_summary_column_open();
2813 static void sort_summary_cb(MainWindow *mainwin, guint action,
2816 summary_sort(mainwin->summaryview, (SummarySortType)action);
2819 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2822 summary_attract_by_subject(mainwin->summaryview);
2825 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2828 summary_delete_duplicated(mainwin->summaryview);
2831 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2833 summary_filter(mainwin->summaryview);
2836 static void execute_summary_cb(MainWindow *mainwin, guint action,
2839 summary_execute(mainwin->summaryview);
2842 static void update_summary_cb(MainWindow *mainwin, guint action,
2846 FolderView *folderview = mainwin->folderview;
2848 if (!mainwin->summaryview->folder_item) return;
2849 if (!folderview->opened) return;
2851 folder_update_op_count();
2853 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2854 folderview->opened);
2857 summary_show(mainwin->summaryview, fitem, TRUE);
2860 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2862 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2865 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2867 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2870 static void prev_unread_cb(MainWindow *mainwin, guint action,
2873 summary_select_prev_unread(mainwin->summaryview);
2876 static void next_unread_cb(MainWindow *mainwin, guint action,
2879 summary_select_next_unread(mainwin->summaryview);
2882 static void prev_marked_cb(MainWindow *mainwin, guint action,
2885 summary_select_prev_marked(mainwin->summaryview);
2888 static void next_marked_cb(MainWindow *mainwin, guint action,
2891 summary_select_next_marked(mainwin->summaryview);
2894 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2897 summary_select_prev_labeled(mainwin->summaryview);
2900 static void next_labeled_cb(MainWindow *mainwin, guint action,
2903 summary_select_next_labeled(mainwin->summaryview);
2906 static void goto_folder_cb(MainWindow *mainwin, guint action,
2909 FolderItem *to_folder;
2911 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2914 folderview_select(mainwin->folderview, to_folder);
2917 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2919 messageview_copy_clipboard(mainwin->messageview);
2922 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2924 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2925 summary_select_all(mainwin->summaryview);
2926 else if (mainwin->summaryview->msg_is_toggled_on &&
2927 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2928 messageview_select_all(mainwin->messageview);
2931 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2933 if (mainwin->summaryview->msg_is_toggled_on)
2934 summary_select_thread(mainwin->summaryview);
2937 static void create_filter_cb(MainWindow *mainwin, guint action,
2940 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2943 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2946 prefs_common_open();
2949 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2952 prefs_filter_open(NULL, NULL);
2955 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2958 prefs_scoring_open(NULL);
2961 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2964 prefs_filtering_open(NULL, NULL, NULL);
2967 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2970 prefs_template_open();
2973 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2976 prefs_actions_open(mainwin);
2979 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2983 new_account_cb(mainwin, 0, widget);
2985 gboolean prev_default = cur_account->is_default;
2987 prefs_account_open(cur_account);
2988 if (!prev_default && cur_account->is_default)
2989 account_set_as_default(cur_account);
2990 account_save_config_all();
2992 main_window_reflect_prefs_all();
2996 static void new_account_cb(MainWindow *mainwin, guint action,
2999 account_edit_open();
3000 if (!compose_get_compose_list()) account_add();
3003 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3005 cur_account = (PrefsAccount *)data;
3006 main_window_reflect_prefs_all();
3009 static void manual_open_cb(MainWindow *mainwin, guint action,
3012 manual_open((ManualLang)action);
3015 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3017 faq_open((ManualLang)action);
3020 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3022 MainWindow *mainwin = (MainWindow *)data;
3026 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3027 LOCAL_FOLDER(folder)->rootpath,
3031 str = g_strdup_printf(_("Scanning folder %s ..."),
3032 LOCAL_FOLDER(folder)->rootpath);
3034 STATUSBAR_PUSH(mainwin, str);
3035 STATUSBAR_POP(mainwin);
3039 static void activate_compose_button (MainWindow *mainwin,
3041 ComposeButtonType type)
3043 SensitiveCond state = main_window_get_current_state(mainwin);
3045 if (style == TOOLBAR_NONE)
3048 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
3049 : mainwin->compose_news_btn);
3050 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
3051 : mainwin->compose_mail_btn);
3052 mainwin->compose_btn_type = type;
3055 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
3057 if (mainwin->compose_btn_type != compose_btn_type)
3058 activate_compose_button(mainwin,
3059 prefs_common.toolbar_style,
3063 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
3065 MainWindow *mainwin = (MainWindow*) data;
3067 if (!mainwin) return;
3069 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
3072 #define BREAK_ON_MODIFIER_KEY() \
3073 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3075 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3077 MainWindow *mainwin = (MainWindow*) data;
3079 if (!mainwin || !event) return;
3081 switch (event->keyval) {
3082 case GDK_Q: /* Quit */
3083 BREAK_ON_MODIFIER_KEY();
3085 app_exit_cb(mainwin, 0, NULL);
3092 #undef BREAK_ON_MODIFIER_KEY
3094 static void set_toolbar_style(MainWindow *mainwin)
3096 switch (prefs_common.toolbar_style) {
3098 gtk_widget_hide(mainwin->handlebox);
3101 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3105 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3109 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3114 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3115 gtk_widget_show(mainwin->handlebox);
3116 gtk_widget_queue_resize(mainwin->handlebox);
3118 if (prefs_common.immediate_exec)
3119 gtk_widget_hide(mainwin->exec_btn);
3121 gtk_widget_show(mainwin->exec_btn);
3126 * Harvest addresses for selected folder.
3128 static void addr_harvest_cb( MainWindow *mainwin,
3132 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3136 * Harvest addresses for selected messages in summary view.
3138 static void addr_harvest_msg_cb( MainWindow *mainwin,
3142 summary_harvest_address( mainwin->summaryview );