2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2001 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"
61 #include "prefs_common.h"
62 #include "prefs_filter.h"
63 #include "prefs_filtering.h"
64 #include "prefs_scoring.h"
65 #include "prefs_account.h"
66 #include "prefs_folder_item.h"
67 #include "prefs_summary_column.h"
68 #include "prefs_template.h"
70 #include "addressbook.h"
71 #include "headerwindow.h"
72 #include "logwindow.h"
73 #include "manage_window.h"
74 #include "alertpanel.h"
75 #include "statusbar.h"
76 #include "inputdialog.h"
84 #define AC_LABEL_WIDTH 240
86 #define STATUSBAR_PUSH(mainwin, str) \
88 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
89 mainwin->mainwin_cid, str); \
90 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
93 #define STATUSBAR_POP(mainwin) \
95 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
96 mainwin->mainwin_cid); \
99 /* list of all instantiated MainWindow */
100 static GList *mainwin_list = NULL;
102 static GdkCursor *watch_cursor;
104 static void main_window_show_cur_account (MainWindow *mainwin);
106 static void main_window_set_widgets (MainWindow *mainwin,
108 static void main_window_toolbar_create (MainWindow *mainwin,
109 GtkWidget *container);
111 /* callback functions */
112 static void toolbar_inc_cb (GtkWidget *widget,
114 static void toolbar_inc_all_cb (GtkWidget *widget,
116 static void toolbar_send_cb (GtkWidget *widget,
119 static void toolbar_compose_cb (GtkWidget *widget,
121 static void toolbar_compose_news_cb (GtkWidget *widget,
123 static void toolbar_compose_mail_cb (GtkWidget *widget,
125 static void toolbar_reply_cb (GtkWidget *widget,
127 static void toolbar_reply_popup_cb (GtkWidget *widget,
128 GdkEventButton *event,
130 static void toolbar_reply_to_all_cb (GtkWidget *widget,
132 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget,
133 GdkEventButton *event,
135 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
137 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
138 GdkEventButton *event,
140 static void toolbar_forward_cb (GtkWidget *widget,
142 static void toolbar_forward_popup_cb (GtkWidget *widget,
143 GdkEventButton *event,
146 static void toolbar_delete_cb (GtkWidget *widget,
148 static void toolbar_exec_cb (GtkWidget *widget,
151 static void toolbar_next_unread_cb (GtkWidget *widget,
154 static void toolbar_prefs_cb (GtkWidget *widget,
156 static void toolbar_account_cb (GtkWidget *widget,
159 static void toolbar_account_button_pressed (GtkWidget *widget,
160 GdkEventButton *event,
162 static void ac_label_button_pressed (GtkWidget *widget,
163 GdkEventButton *event,
165 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
168 static gint main_window_close_cb (GtkWidget *widget,
172 static void add_mailbox_cb (MainWindow *mainwin,
175 static void add_mbox_cb (MainWindow *mainwin,
178 static void update_folderview_cb (MainWindow *mainwin,
181 static void new_folder_cb (MainWindow *mainwin,
184 static void rename_folder_cb (MainWindow *mainwin,
187 static void delete_folder_cb (MainWindow *mainwin,
190 static void import_mbox_cb (MainWindow *mainwin,
193 static void export_mbox_cb (MainWindow *mainwin,
196 static void empty_trash_cb (MainWindow *mainwin,
200 static void save_as_cb (MainWindow *mainwin,
203 static void print_cb (MainWindow *mainwin,
206 static void app_exit_cb (MainWindow *mainwin,
210 static void search_cb (MainWindow *mainwin,
214 static void toggle_folder_cb (MainWindow *mainwin,
217 static void toggle_message_cb (MainWindow *mainwin,
220 static void toggle_toolbar_cb (MainWindow *mainwin,
223 static void toggle_statusbar_cb (MainWindow *mainwin,
226 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
230 static void addressbook_open_cb (MainWindow *mainwin,
233 static void log_window_show_cb (MainWindow *mainwin,
237 static void inc_mail_cb (MainWindow *mainwin,
240 static void inc_all_account_mail_cb (MainWindow *mainwin,
244 static void send_queue_cb (MainWindow *mainwin,
248 static void compose_cb (MainWindow *mainwin,
251 static void compose_mail_cb(MainWindow *mainwin, guint action,
253 static void compose_news_cb(MainWindow *mainwin, guint action,
255 static void reply_cb (MainWindow *mainwin,
259 static void open_msg_cb (MainWindow *mainwin,
263 static void view_source_cb (MainWindow *mainwin,
267 static void reedit_cb (MainWindow *mainwin,
271 static void move_to_cb (MainWindow *mainwin,
274 static void copy_to_cb (MainWindow *mainwin,
277 static void delete_cb (MainWindow *mainwin,
281 static void mark_cb (MainWindow *mainwin,
284 static void unmark_cb (MainWindow *mainwin,
288 static void mark_as_unread_cb (MainWindow *mainwin,
291 static void mark_as_read_cb (MainWindow *mainwin,
294 static void mark_all_read_cb (MainWindow *mainwin,
297 static void add_address_cb (MainWindow *mainwin,
301 static void set_charset_cb (MainWindow *mainwin,
305 static void hide_read_messages (MainWindow *mainwin,
309 static void thread_cb (MainWindow *mainwin,
312 static void set_display_item_cb (MainWindow *mainwin,
315 static void sort_summary_cb (MainWindow *mainwin,
318 static void attract_by_subject_cb(MainWindow *mainwin,
322 static void delete_duplicated_cb (MainWindow *mainwin,
325 static void filter_cb (MainWindow *mainwin,
328 static void execute_summary_cb (MainWindow *mainwin,
331 static void update_summary_cb (MainWindow *mainwin,
335 static void prev_cb (MainWindow *mainwin,
338 static void next_cb (MainWindow *mainwin,
342 static void prev_unread_cb (MainWindow *mainwin,
345 static void next_unread_cb (MainWindow *mainwin,
348 static void prev_marked_cb (MainWindow *mainwin,
351 static void next_marked_cb (MainWindow *mainwin,
354 static void prev_labeled_cb (MainWindow *mainwin,
357 static void next_labeled_cb (MainWindow *mainwin,
361 static void goto_folder_cb (MainWindow *mainwin,
365 static void copy_cb (MainWindow *mainwin,
368 static void allsel_cb (MainWindow *mainwin,
372 static void prefs_common_open_cb (MainWindow *mainwin,
375 static void prefs_filter_open_cb (MainWindow *mainwin,
378 static void prefs_scoring_open_cb (MainWindow *mainwin,
381 static void prefs_filtering_open_cb (MainWindow *mainwin,
384 static void prefs_account_open_cb(MainWindow *mainwin,
387 static void prefs_template_open_cb (MainWindow *mainwin,
390 static void new_account_cb (MainWindow *mainwin,
394 static void account_menu_cb (GtkMenuItem *menuitem,
397 static void manual_open_cb (MainWindow *mainwin,
401 static void scan_tree_func (Folder *folder,
405 static void activate_compose_button (MainWindow *mainwin,
407 ComposeButtonType type);
409 #define SEPARATE_ACTION 667
411 static GtkItemFactoryEntry mainwin_entries[] =
413 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
414 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
415 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
416 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
417 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
418 {N_("/_File/_Folder/Create _new folder..."),
419 NULL, new_folder_cb, 0, NULL},
420 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
421 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
422 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
423 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
424 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
425 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
426 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
427 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
428 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
429 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},*/
430 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
432 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
433 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
434 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
435 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
436 {N_("/_Edit/_Find in current message"), "<control>F", search_cb, 0, NULL},
437 {N_("/_Edit/_Search folder..."), "<control>S", search_cb, 1, NULL},
439 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
440 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
441 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
442 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
443 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
444 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
445 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
446 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
447 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
448 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
449 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
450 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
451 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
452 {N_("/_View/View _source"), "<control>U", view_source_cb, 0, NULL},
453 {N_("/_View/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
454 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
455 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
456 {N_("/_View/_Code set/_Auto detect"),
457 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
459 #define CODESET_SEPARATOR \
460 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
461 #define CODESET_ACTION(action) \
462 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
464 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
465 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
466 CODESET_ACTION(C_US_ASCII)},
469 {N_("/_View/_Code set/Unicode (_UTF-8)"),
470 CODESET_ACTION(C_UTF_8)},
473 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
474 CODESET_ACTION(C_ISO_8859_1)},
477 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
478 CODESET_ACTION(C_ISO_8859_2)},
480 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
481 CODESET_ACTION(C_ISO_8859_13)},
482 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
483 CODESET_ACTION(C_ISO_8859_4)},
485 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
486 CODESET_ACTION(C_ISO_8859_7)},
488 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
489 CODESET_ACTION(C_ISO_8859_9)},
491 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
492 CODESET_ACTION(C_ISO_8859_5)},
493 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
494 CODESET_ACTION(C_KOI8_R)},
495 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
496 CODESET_ACTION(C_CP1251)},
499 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
500 CODESET_ACTION(C_ISO_2022_JP)},
502 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
503 CODESET_ACTION(C_ISO_2022_JP_2)},
505 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
506 CODESET_ACTION(C_EUC_JP)},
507 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
508 CODESET_ACTION(C_SHIFT_JIS)},
511 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
512 CODESET_ACTION(C_GB2312)},
513 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
514 CODESET_ACTION(C_BIG5)},
515 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
516 CODESET_ACTION(C_EUC_TW)},
517 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
518 CODESET_ACTION(C_ISO_2022_CN)},
520 {N_("/_View/_Code set/Korean (EUC-_KR)"),
521 CODESET_ACTION(C_EUC_KR)},
522 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
523 CODESET_ACTION(C_ISO_2022_KR)},
525 {N_("/_View/_Code set/Thai (TIS-620)"),
526 CODESET_ACTION(C_TIS_620)},
527 {N_("/_View/_Code set/Thai (Windows-874)"),
528 CODESET_ACTION(C_WINDOWS_874)},
531 #undef CODESET_SEPARATOR
532 #undef CODESET_ACTION
534 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
535 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
536 {N_("/_Message/Get from _all accounts"),
537 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
538 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
539 {N_("/_Message/Send queued messa_ges"),
540 NULL, send_queue_cb, 0, NULL},
541 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
542 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
543 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
544 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
545 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
546 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
547 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
548 {N_("/_Message/_Forward"), "<shift><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
549 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
550 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
551 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
552 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
553 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
554 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
555 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
556 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
557 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
558 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
559 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
560 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
561 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
562 {N_("/_Message/_Mark/Mark as rea_d"),
563 NULL, mark_as_read_cb, 0, NULL},
564 {N_("/_Message/_Mark/Mark all read"), NULL, mark_all_read_cb, 0, NULL},
565 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
566 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
568 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
569 {N_("/_Summary/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
570 {N_("/_Summary/_Delete duplicated messages"),
571 NULL, delete_duplicated_cb, 0, NULL},
572 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
573 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
574 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
575 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
576 {N_("/_Summary/Go _to"), NULL, NULL, 0, "<Branch>"},
577 {N_("/_Summary/Go _to/_Prev message"), NULL, prev_cb, 0, NULL},
578 {N_("/_Summary/Go _to/_Next message"), NULL, next_cb, 0, NULL},
579 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
580 {N_("/_Summary/Go _to/P_rev unread message"),
581 NULL, prev_unread_cb, 0, NULL},
582 {N_("/_Summary/Go _to/N_ext unread message"),
583 NULL, next_unread_cb, 0, NULL},
584 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
585 {N_("/_Summary/Go _to/Prev _marked message"),
586 NULL, prev_marked_cb, 0, NULL},
587 {N_("/_Summary/Go _to/Next m_arked message"),
588 NULL, next_marked_cb, 0, NULL},
589 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
590 {N_("/_Summary/Go _to/Prev _labeled message"),
591 NULL, prev_labeled_cb, 0, NULL},
592 {N_("/_Summary/Go _to/Next la_beled message"),
593 NULL, next_labeled_cb, 0, NULL},
594 {N_("/_Summary/_Go to other folder..."),"<alt>G", goto_folder_cb, 0, NULL},
595 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
596 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
597 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
598 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
599 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
600 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
601 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
602 {N_("/_Summary/_Sort/Sort by _color label"),
603 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
604 {N_("/_Summary/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
605 {N_("/_Summary/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
606 {N_("/_Summary/_Sort/Sort by a_ttachment"),
607 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
608 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
609 {N_("/_Summary/_Sort/_Attract by subject"),
610 NULL, attract_by_subject_cb, 0, NULL},
611 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
612 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
613 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
615 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
616 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
617 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
619 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
620 {N_("/_Configuration/_Common preferences..."),
621 NULL, prefs_common_open_cb, 0, NULL},
622 {N_("/_Configuration/_Filter setting..."),
623 NULL, prefs_filter_open_cb, 0, NULL},
624 {N_("/_Configuration/_Scoring ..."),
625 NULL, prefs_scoring_open_cb, 0, NULL},
626 {N_("/_Configuration/_Filtering ..."),
627 NULL, prefs_filtering_open_cb, 0, NULL},
628 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
629 {N_("/_Configuration/_Preferences for current account..."),
630 NULL, prefs_account_open_cb, 0, NULL},
631 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
632 {N_("/_Configuration/Create _new account..."),
633 NULL, new_account_cb, 0, NULL},
634 {N_("/_Configuration/_Edit accounts..."),
635 NULL, account_edit_open, 0, NULL},
636 {N_("/_Configuration/C_hange current account"),
637 NULL, NULL, 0, "<Branch>"},
639 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
640 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
641 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
642 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
643 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
644 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
646 static GtkItemFactoryEntry reply_popup_entries[] =
648 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
649 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
651 static GtkItemFactoryEntry replyall_popup_entries[] =
653 {N_("/Reply to all with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
654 {N_("/_Reply to all without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
656 static GtkItemFactoryEntry replysender_popup_entries[] =
658 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
659 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
661 static GtkItemFactoryEntry fwd_popup_entries[] =
663 {N_("/_Forward message (inline style)"), NULL, reply_cb, COMPOSE_FORWARD_INLINE, NULL},
664 {N_("/Forward message as _attachment"), NULL, reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
668 MainWindow *main_window_create(SeparateType type)
674 GtkWidget *handlebox;
675 GtkWidget *vbox_body;
676 GtkWidget *hbox_stat;
677 GtkWidget *statusbar;
678 GtkWidget *progressbar;
679 GtkWidget *statuslabel;
680 GtkWidget *ac_button;
683 FolderView *folderview;
684 SummaryView *summaryview;
685 MessageView *messageview;
686 GdkColormap *colormap;
689 guint n_menu_entries;
690 GtkItemFactory *ifactory;
693 GtkWidget *compose_popup;
694 GtkWidget *reply_popup;
695 GtkWidget *replyall_popup;
696 GtkWidget *replysender_popup;
697 GtkWidget *fwd_popup;
700 debug_print(_("Creating main window...\n"));
701 mainwin = g_new0(MainWindow, 1);
704 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
705 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
706 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
707 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
708 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
709 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
710 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
711 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
712 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
714 gtk_widget_realize(window);
715 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
717 gtkut_widget_set_app_icon(window);
719 vbox = gtk_vbox_new(FALSE, 0);
720 gtk_widget_show(vbox);
721 gtk_container_add(GTK_CONTAINER(window), vbox);
724 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
725 menubar = menubar_create(window, mainwin_entries,
726 n_menu_entries, "<Main>", mainwin);
727 gtk_widget_show(menubar);
728 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
730 handlebox = gtk_handle_box_new();
731 gtk_widget_show(handlebox);
732 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
734 /* create the popup menus for the reply buttons specials */
735 n_menu_entries = sizeof(reply_popup_entries) /
736 sizeof(reply_popup_entries[0]);
737 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
738 "<ReplyPopup>", mainwin);
739 n_menu_entries = sizeof(replyall_popup_entries) /
740 sizeof(replyall_popup_entries[0]);
741 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
742 "<ReplyAllPopup>", mainwin);
743 n_menu_entries = sizeof(replysender_popup_entries) /
744 sizeof(replysender_popup_entries[0]);
745 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
746 "<ReplySenderPopup>", mainwin);
747 /* create the popup menu for the forward button */
748 n_menu_entries = sizeof(fwd_popup_entries) /
749 sizeof(fwd_popup_entries[0]);
750 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
751 "<ForwardPopup>", mainwin);
753 main_window_toolbar_create(mainwin, handlebox);
755 /* vbox that contains body */
756 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
757 gtk_widget_show(vbox_body);
758 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
759 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
761 hbox_stat = gtk_hbox_new(FALSE, 2);
762 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
764 statusbar = statusbar_create();
765 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
767 progressbar = gtk_progress_bar_new();
768 gtk_widget_set_usize(progressbar, 120, 1);
769 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
771 statuslabel = gtk_label_new("");
772 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
774 ac_button = gtk_button_new();
775 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
776 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
777 gtk_widget_set_usize(ac_button, -1, 1);
778 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
779 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
780 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
782 ac_label = gtk_label_new("");
783 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
785 gtk_widget_show_all(hbox_stat);
788 mainwin->folderview = folderview = folderview_create();
789 mainwin->summaryview = summaryview = summary_create();
790 mainwin->messageview = messageview = messageview_create();
791 mainwin->headerwin = header_window_create();
792 mainwin->logwin = log_window_create();
794 folderview->mainwin = mainwin;
795 folderview->summaryview = summaryview;
797 summaryview->mainwin = mainwin;
798 summaryview->folderview = folderview;
799 summaryview->messageview = messageview;
800 summaryview->headerwin = mainwin->headerwin;
801 summaryview->window = window;
803 messageview->mainwin = mainwin;
805 mainwin->window = window;
806 mainwin->vbox = vbox;
807 mainwin->menubar = menubar;
808 mainwin->handlebox = handlebox;
809 mainwin->vbox_body = vbox_body;
810 mainwin->hbox_stat = hbox_stat;
811 mainwin->statusbar = statusbar;
812 mainwin->progressbar = progressbar;
813 mainwin->statuslabel = statuslabel;
814 mainwin->ac_button = ac_button;
815 mainwin->ac_label = ac_label;
816 mainwin->reply_popup = reply_popup;
817 mainwin->replyall_popup = replyall_popup;
818 mainwin->replysender_popup = replysender_popup;
819 mainwin->fwd_popup = fwd_popup;
821 /* set context IDs for status bar */
822 mainwin->mainwin_cid = gtk_statusbar_get_context_id
823 (GTK_STATUSBAR(statusbar), "Main Window");
824 mainwin->folderview_cid = gtk_statusbar_get_context_id
825 (GTK_STATUSBAR(statusbar), "Folder View");
826 mainwin->summaryview_cid = gtk_statusbar_get_context_id
827 (GTK_STATUSBAR(statusbar), "Summary View");
829 /* allocate colors for summary view and folder view */
830 summaryview->color_marked.red = summaryview->color_marked.green = 0;
831 summaryview->color_marked.blue = (guint16)65535;
833 summaryview->color_dim.red = summaryview->color_dim.green =
834 summaryview->color_dim.blue = COLOR_DIM;
836 folderview->color_new.red = (guint16)55000;
837 folderview->color_new.green = folderview->color_new.blue = 15000;
839 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
840 &folderview->color_op);
842 summaryview->color_important.red = 0;
843 summaryview->color_marked.green = 0;
844 summaryview->color_important.blue = (guint16)65535;
846 color[0] = summaryview->color_marked;
847 color[1] = summaryview->color_dim;
848 color[2] = folderview->color_new;
849 color[3] = folderview->color_op;
851 colormap = gdk_window_get_colormap(window->window);
852 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
853 for (i = 0; i < 4; i++) {
854 if (success[i] == FALSE)
855 g_warning(_("MainWindow: color allocation %d failed\n"), i);
858 debug_print(_("done.\n"));
860 main_window_set_widgets(mainwin, type);
863 ifactory = gtk_item_factory_from_widget(menubar);
864 menuitem = gtk_item_factory_get_item
865 (ifactory, "/View/Code set/Auto detect");
866 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
868 switch (prefs_common.toolbar_style) {
870 menuitem = gtk_item_factory_get_item
871 (ifactory, "/View/Toolbar/None");
874 menuitem = gtk_item_factory_get_item
875 (ifactory, "/View/Toolbar/Icon");
878 menuitem = gtk_item_factory_get_item
879 (ifactory, "/View/Toolbar/Text");
882 menuitem = gtk_item_factory_get_item
883 (ifactory, "/View/Toolbar/Icon and text");
885 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
887 gtk_widget_hide(mainwin->hbox_stat);
888 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
889 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
890 prefs_common.show_statusbar);
892 /* Message view and Folder tree are always shown at startup
893 * make that in the menu visible */
894 menuitem = gtk_item_factory_get_item(ifactory, "/View/Message view");
895 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
896 menuitem = gtk_item_factory_get_item(ifactory, "/View/Folder tree");
897 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
899 /* set the check of the SEPARATE_xxx menu items. we also need the main window
900 * as a property and pass the action type to the callback */
901 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
903 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
904 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
905 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
906 GUINT_TO_POINTER(SEPARATE_FOLDER));
908 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
910 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
911 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
912 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
913 GUINT_TO_POINTER(SEPARATE_MESSAGE));
916 menu_set_sensitive(ifactory, "/Summary/Thread view",
917 prefs_common.enable_thread ? FALSE : TRUE);
918 menu_set_sensitive(ifactory, "/Summary/Unthread view",
919 prefs_common.enable_thread ? TRUE : FALSE);
921 /*main_window_set_thread_option(mainwin);*/
924 /* set account selection menu */
925 ac_menu = gtk_item_factory_get_widget
926 (ifactory, "/Configuration/Change current account");
927 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
928 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
929 mainwin->ac_menu = ac_menu;
931 main_window_set_toolbar_sensitive(mainwin);
933 /* show main window */
934 gtk_widget_set_uposition(mainwin->window,
935 prefs_common.mainwin_x,
936 prefs_common.mainwin_y);
937 gtk_widget_set_usize(window, prefs_common.mainwin_width,
938 prefs_common.mainwin_height);
940 gtk_widget_show(mainwin->window);
942 /* initialize views */
943 folderview_init(folderview);
944 summary_init(summaryview);
945 messageview_init(messageview);
946 header_window_init(mainwin->headerwin);
947 log_window_init(mainwin->logwin);
950 mainwin->lock_count = 0;
951 mainwin->cursor_count = 0;
954 watch_cursor = gdk_cursor_new(GDK_WATCH);
956 mainwin_list = g_list_append(mainwin_list, mainwin);
961 void main_window_cursor_wait(MainWindow *mainwin)
964 if (mainwin->cursor_count == 0)
965 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
967 mainwin->cursor_count++;
972 void main_window_cursor_normal(MainWindow *mainwin)
974 if (mainwin->cursor_count)
975 mainwin->cursor_count--;
977 if (mainwin->cursor_count == 0)
978 gdk_window_set_cursor(mainwin->window->window, NULL);
983 /* lock / unlock the user-interface */
984 void main_window_lock(MainWindow *mainwin)
986 if (mainwin->lock_count == 0)
987 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
989 mainwin->lock_count++;
991 main_window_set_menu_sensitive(mainwin);
992 main_window_set_toolbar_sensitive(mainwin);
995 void main_window_unlock(MainWindow *mainwin)
997 if (mainwin->lock_count)
998 mainwin->lock_count--;
1000 main_window_set_menu_sensitive(mainwin);
1001 main_window_set_toolbar_sensitive(mainwin);
1003 if (mainwin->lock_count == 0)
1004 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1007 void main_window_reflect_prefs_all(void)
1010 MainWindow *mainwin;
1012 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1013 mainwin = (MainWindow *)cur->data;
1015 main_window_show_cur_account(mainwin);
1016 main_window_set_menu_sensitive(mainwin);
1017 main_window_set_toolbar_sensitive(mainwin);
1019 if (prefs_common.immediate_exec)
1020 gtk_widget_hide(mainwin->exec_btn);
1022 gtk_widget_show(mainwin->exec_btn);
1024 summary_redisplay_msg(mainwin->summaryview);
1025 headerview_set_visibility(mainwin->messageview->headerview,
1026 prefs_common.display_header_pane);
1030 void main_window_set_summary_column(void)
1033 MainWindow *mainwin;
1035 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1036 mainwin = (MainWindow *)cur->data;
1037 summary_set_column_order(mainwin->summaryview);
1041 void main_window_set_account_menu(GList *account_list)
1043 GList *cur, *cur_ac, *cur_item;
1044 GtkWidget *menuitem;
1045 MainWindow *mainwin;
1046 PrefsAccount *ac_prefs;
1048 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1049 mainwin = (MainWindow *)cur->data;
1051 /* destroy all previous menu item */
1052 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1053 while (cur_item != NULL) {
1054 GList *next = cur_item->next;
1055 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1059 for (cur_ac = account_list; cur_ac != NULL;
1060 cur_ac = cur_ac->next) {
1061 ac_prefs = (PrefsAccount *)cur_ac->data;
1063 menuitem = gtk_menu_item_new_with_label
1064 (ac_prefs->account_name
1065 ? ac_prefs->account_name : _("Untitled"));
1066 gtk_widget_show(menuitem);
1067 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1068 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1069 GTK_SIGNAL_FUNC(account_menu_cb),
1075 static void main_window_show_cur_account(MainWindow *mainwin)
1080 ac_name = g_strdup(cur_account
1081 ? (cur_account->account_name
1082 ? cur_account->account_name : _("Untitled"))
1086 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1088 buf = g_strdup(PROG_VERSION);
1089 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1092 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1093 gtk_widget_queue_resize(mainwin->ac_button);
1098 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1100 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1101 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1102 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1104 if (mainwin->type == type) return;
1106 /* remove widgets from those containers */
1107 gtk_widget_ref(folder_wid);
1108 gtk_widget_ref(summary_wid);
1109 gtk_widget_ref(message_wid);
1110 gtkut_container_remove
1111 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1112 gtkut_container_remove
1113 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1114 gtkut_container_remove
1115 (GTK_CONTAINER(message_wid->parent), message_wid);
1117 /* clean containers */
1118 switch (mainwin->type) {
1120 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1122 case SEPARATE_FOLDER:
1123 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1124 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1126 case SEPARATE_MESSAGE:
1127 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1128 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1131 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1132 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1136 gtk_widget_hide(mainwin->window);
1137 main_window_set_widgets(mainwin, type);
1138 gtk_widget_show(mainwin->window);
1140 gtk_widget_unref(folder_wid);
1141 gtk_widget_unref(summary_wid);
1142 gtk_widget_unref(message_wid);
1145 void main_window_get_size(MainWindow *mainwin)
1147 GtkAllocation *allocation;
1149 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1151 prefs_common.summaryview_width = allocation->width;
1153 if (mainwin->summaryview->msg_is_toggled_on)
1154 prefs_common.summaryview_height = allocation->height;
1156 prefs_common.mainview_width = allocation->width;
1158 allocation = &mainwin->window->allocation;
1160 prefs_common.mainview_height = allocation->height;
1161 prefs_common.mainwin_width = allocation->width;
1162 prefs_common.mainwin_height = allocation->height;
1164 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1166 prefs_common.folderview_width = allocation->width;
1167 prefs_common.folderview_height = allocation->height;
1170 void main_window_get_position(MainWindow *mainwin)
1174 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1176 prefs_common.mainview_x = x;
1177 prefs_common.mainview_y = y;
1178 prefs_common.mainwin_x = x;
1179 prefs_common.mainwin_y = y;
1181 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1184 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1187 gboolean hasTrash = 0;
1189 for (list = folder_get_list(); list != NULL; list = list->next) {
1192 folder = list->data;
1193 if (folder->trash) {
1194 hasTrash = (folder->trash->total > 0);
1203 if (alertpanel(_("Empty trash"),
1204 _("Empty all messages in trash?"),
1205 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1207 manage_window_focus_in(mainwin->window, NULL, NULL);
1210 procmsg_empty_trash();
1212 for (list = folder_get_list(); list != NULL; list = list->next) {
1215 folder = list->data;
1216 if (folder->trash) {
1217 folder_item_scan(folder->trash);
1218 folderview_update_item(folder->trash, TRUE);
1222 if (mainwin->summaryview->folder_item &&
1223 mainwin->summaryview->folder_item->stype == F_TRASH)
1224 gtk_widget_grab_focus(mainwin->folderview->ctree);
1227 void main_window_add_mailbox(MainWindow *mainwin)
1232 path = input_dialog(_("Add mailbox"),
1233 _("Input the location of mailbox.\n"
1234 "If the existing mailbox is specified, it will be\n"
1235 "scanned automatically."),
1238 if (folder_find_from_path(path)) {
1239 alertpanel_error(_("The mailbox `%s' already exists."), path);
1243 if (!strcmp(path, "Mail"))
1244 folder = folder_new(F_MH, _("Mailbox"), path);
1246 folder = folder_new(F_MH, g_basename(path), path);
1249 if (folder->create_tree(folder) < 0) {
1250 alertpanel_error(_("Creation of the mailbox failed.\n"
1251 "Maybe some files already exist, or you don't have the permission to write there."));
1252 folder_destroy(folder);
1257 folder_set_ui_func(folder, scan_tree_func, mainwin);
1258 folder->scan_tree(folder);
1259 folder_set_ui_func(folder, NULL, NULL);
1261 folderview_set(mainwin->folderview);
1264 void main_window_add_mbox(MainWindow *mainwin)
1270 path = input_dialog(_("Add mbox mailbox"),
1271 _("Input the location of mailbox."),
1276 if (folder_find_from_path(path)) {
1277 alertpanel_error(_("The mailbox `%s' already exists."), path);
1283 if (!strcmp(path, "Mail"))
1284 folder = folder_new(F_MBOX, _("Mailbox"), path);
1288 folder = folder_new(F_MBOX, g_basename(path), path);
1291 if (folder->create_tree(folder) < 0) {
1292 alertpanel_error(_("Creation of the mailbox failed."));
1293 folder_destroy(folder);
1299 item = folder_item_new(folder->name, NULL);
1300 item->folder = folder;
1301 folder->node = g_node_new(item);
1303 folder->create_folder(folder, item, "inbox");
1304 folder->create_folder(folder, item, "outbox");
1305 folder->create_folder(folder, item, "queue");
1306 folder->create_folder(folder, item, "draft");
1307 folder->create_folder(folder, item, "trash");
1309 folderview_set(mainwin->folderview);
1314 M_UNLOCKED = 1 << 0,
1315 M_MSG_EXIST = 1 << 1,
1316 M_TARGET_EXIST = 1 << 2,
1317 M_SINGLE_TARGET_EXIST = 1 << 3,
1319 M_ALLOW_REEDIT = 1 << 5,
1320 M_HAVE_ACCOUNT = 1 << 6,
1321 M_THREADED = 1 << 7,
1322 M_UNTHREADED = 1 << 8,
1324 M_HAVE_NEWS_ACCOUNT = 1 << 10
1327 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1329 SensitiveCond state = 0;
1330 SummarySelection selection;
1331 FolderItem *item = mainwin->summaryview->folder_item;
1332 GList *account_list = account_get_list();
1334 selection = summary_get_selection_type(mainwin->summaryview);
1336 if (mainwin->lock_count == 0)
1337 state |= M_UNLOCKED;
1338 if (selection != SUMMARY_NONE)
1339 state |= M_MSG_EXIST;
1342 state |= M_THREADED;
1344 state |= M_UNTHREADED;
1346 if (selection == SUMMARY_SELECTED_SINGLE ||
1347 selection == SUMMARY_SELECTED_MULTIPLE)
1348 state |= M_TARGET_EXIST;
1349 if (selection == SUMMARY_SELECTED_SINGLE)
1350 state |= M_SINGLE_TARGET_EXIST;
1351 if (item && item->folder->type != F_NEWS)
1353 if (mainwin->summaryview->folder_item &&
1354 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1356 if (selection == SUMMARY_SELECTED_SINGLE &&
1358 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1359 item->stype == F_QUEUE)))
1360 state |= M_ALLOW_REEDIT;
1362 state |= M_HAVE_ACCOUNT;
1364 for ( ; account_list != NULL; account_list = account_list->next) {
1365 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1366 state |= M_HAVE_NEWS_ACCOUNT;
1374 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1376 SensitiveCond state;
1384 {mainwin->get_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1385 {mainwin->getall_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1386 {mainwin->compose_mail_btn, M_HAVE_ACCOUNT},
1387 {mainwin->compose_news_btn, M_HAVE_NEWS_ACCOUNT},
1388 {mainwin->reply_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1389 {mainwin->replyall_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1390 {mainwin->replysender_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1391 {mainwin->fwd_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1392 /* {mainwin->prefs_btn , M_UNLOCKED},
1393 {mainwin->account_btn , M_UNLOCKED}, */
1394 {mainwin->next_btn , M_MSG_EXIST},
1395 {mainwin->delete_btn , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1396 {mainwin->exec_btn , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1400 state = main_window_get_current_state(mainwin);
1402 for (i = 0; entry[i].widget != NULL; i++) {
1403 sensitive = ((entry[i].cond & state) == entry[i].cond);
1404 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1407 activate_compose_button(mainwin,
1408 prefs_common.toolbar_style,
1409 mainwin->compose_btn_type);
1412 void main_window_set_menu_sensitive(MainWindow *mainwin)
1414 GtkItemFactory *ifactory;
1415 SensitiveCond state;
1419 static const struct {
1423 {"/File/Add mailbox..." , M_UNLOCKED},
1424 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1425 {"/File/Rescan folder tree" , M_UNLOCKED},
1426 {"/File/Folder" , M_UNLOCKED},
1427 {"/File/Import mbox file..." , M_UNLOCKED},
1428 {"/File/Export to mbox file...", M_UNLOCKED},
1429 {"/File/Empty trash" , M_UNLOCKED},
1430 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1431 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1432 /* {"/File/Close", M_UNLOCKED},*/
1433 {"/File/Exit" , M_UNLOCKED},
1435 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1436 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1438 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1439 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1440 /* {"/Message/Compose new message" , M_HAVE_ACCOUNT}, */
1441 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1442 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1443 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1444 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1445 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1446 {"/Message/Forward" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1447 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1448 {"/Message/Open in new window" , M_SINGLE_TARGET_EXIST},
1449 {"/Message/Re-edit", M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1450 {"/Message/Move...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1451 {"/Message/Copy...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1452 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1453 {"/Message/Mark" , M_TARGET_EXIST},
1455 {"/Summary/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1456 {"/Summary/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1457 {"/Summary/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1458 {"/Summary/Go to" , M_MSG_EXIST},
1459 {"/Summary/Go to/Prev message" , M_MSG_EXIST},
1460 {"/Summary/Go to/Next message" , M_MSG_EXIST},
1461 {"/Summary/Go to/Next unread message" , M_MSG_EXIST},
1462 {"/Summary/Go to/Prev marked message" , M_MSG_EXIST},
1463 {"/Summary/Go to/Next marked message" , M_MSG_EXIST},
1464 {"/Summary/Go to/Prev labeled message", M_MSG_EXIST},
1465 {"/Summary/Go to/Next labeled message", M_MSG_EXIST},
1466 {"/Summary/Sort" , M_MSG_EXIST},
1467 {"/Summary/Thread view" , M_UNTHREADED},
1468 {"/Summary/Unthread view" , M_THREADED},
1470 {"/Configuration", M_UNLOCKED},
1475 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1476 state = main_window_get_current_state(mainwin);
1478 for (i = 0; entry[i].entry != NULL; i++) {
1479 sensitive = ((entry[i].cond & state) == entry[i].cond);
1480 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1484 void main_window_popup(MainWindow *mainwin)
1490 gdk_window_get_origin(mainwin->window->window, &x, &y);
1491 sx = gdk_screen_width();
1492 sy = gdk_screen_height();
1493 x %= sx; if (x < 0) x = 0;
1494 y %= sy; if (y < 0) y = 0;
1495 gdk_window_move(mainwin->window->window, x, y);
1496 gdk_window_raise(mainwin->window->window);
1497 gdk_window_show(mainwin->window->window);
1499 debug_print("window position: x = %d, y = %d\n", x, y);
1501 switch (mainwin->type) {
1502 case SEPARATE_FOLDER:
1503 widget = mainwin->win.sep_folder.folderwin;
1504 gdk_window_get_origin(widget->window, &x, &y);
1505 x %= sx; if (x < 0) x = 0;
1506 y %= sy; if (y < 0) y = 0;
1507 gdk_window_move(widget->window, x, y);
1508 gdk_window_raise(widget->window);
1510 case SEPARATE_MESSAGE:
1511 widget = mainwin->win.sep_message.messagewin;
1512 gdk_window_get_origin(widget->window, &x, &y);
1513 x %= sx; if (x < 0) x = 0;
1514 y %= sy; if (y < 0) y = 0;
1515 gdk_window_move(widget->window, x, y);
1516 gdk_window_raise(widget->window);
1519 widget = mainwin->win.sep_both.folderwin;
1520 gdk_window_get_origin(widget->window, &x, &y);
1521 x %= sx; if (x < 0) x = 0;
1522 y %= sy; if (y < 0) y = 0;
1523 gdk_window_move(widget->window, x, y);
1524 gdk_window_raise(widget->window);
1525 widget = mainwin->win.sep_both.messagewin;
1526 gdk_window_get_origin(widget->window, &x, &y);
1527 x %= sx; if (x < 0) x = 0;
1528 y %= sy; if (y < 0) y = 0;
1529 gdk_window_move(widget->window, x, y);
1530 gdk_window_raise(widget->window);
1537 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1539 GtkWidget *folderwin = NULL;
1540 GtkWidget *messagewin = NULL;
1543 GtkWidget *vbox_body = mainwin->vbox_body;
1544 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1546 debug_print(_("Setting widgets..."));
1548 /* create separated window(s) if needed */
1549 if (type & SEPARATE_FOLDER) {
1550 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1551 gtk_window_set_title(GTK_WINDOW(folderwin), _("Sylpheed - folder view"));
1552 gtk_window_set_wmclass(GTK_WINDOW(folderwin), "separate folderview", "Sylpheed");
1553 gtk_window_set_policy(GTK_WINDOW(folderwin),
1555 gtk_widget_set_usize(folderwin, -1,
1556 prefs_common.mainview_height);
1557 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1559 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1560 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1563 if (type & SEPARATE_MESSAGE) {
1564 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1565 gtk_window_set_title(GTK_WINDOW(messagewin), _("Sylpheed - message view"));
1566 gtk_window_set_wmclass(GTK_WINDOW(messagewin), "separate messageview", "Sylpheed");
1567 gtk_window_set_policy(GTK_WINDOW(messagewin),
1569 gtk_widget_set_usize
1570 (messagewin, prefs_common.mainview_width,
1571 prefs_common.mainview_height
1572 - prefs_common.summaryview_height
1573 + DEFAULT_HEADERVIEW_HEIGHT);
1574 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1576 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1577 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1583 hpaned = gtk_hpaned_new();
1584 gtk_widget_show(hpaned);
1585 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1586 gtk_paned_add1(GTK_PANED(hpaned),
1587 GTK_WIDGET_PTR(mainwin->folderview));
1589 vpaned = gtk_vpaned_new();
1590 if (mainwin->summaryview->msg_is_toggled_on) {
1591 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1592 gtk_paned_add1(GTK_PANED(vpaned),
1593 GTK_WIDGET_PTR(mainwin->summaryview));
1595 gtk_paned_add2(GTK_PANED(hpaned),
1596 GTK_WIDGET_PTR(mainwin->summaryview));
1597 gtk_widget_ref(vpaned);
1599 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1600 prefs_common.summaryview_width,
1601 prefs_common.summaryview_height);
1602 gtk_paned_add2(GTK_PANED(vpaned),
1603 GTK_WIDGET_PTR(mainwin->messageview));
1604 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1605 prefs_common.mainview_width, -1);
1606 gtk_widget_set_usize(mainwin->window,
1607 prefs_common.folderview_width +
1608 prefs_common.mainview_width,
1609 prefs_common.mainwin_height);
1610 gtk_widget_show_all(vpaned);
1612 menu_set_sensitive(ifactory, "/View/Message view", FALSE);
1613 menu_set_sensitive(ifactory, "/View/Folder tree", FALSE);
1615 mainwin->win.sep_none.hpaned = hpaned;
1616 mainwin->win.sep_none.vpaned = vpaned;
1618 case SEPARATE_FOLDER:
1619 vpaned = gtk_vpaned_new();
1620 if (mainwin->summaryview->msg_is_toggled_on) {
1621 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1623 gtk_paned_add1(GTK_PANED(vpaned),
1624 GTK_WIDGET_PTR(mainwin->summaryview));
1626 gtk_box_pack_start(GTK_BOX(vbox_body),
1627 GTK_WIDGET_PTR(mainwin->summaryview),
1629 gtk_widget_ref(vpaned);
1631 gtk_paned_add2(GTK_PANED(vpaned),
1632 GTK_WIDGET_PTR(mainwin->messageview));
1633 gtk_widget_show_all(vpaned);
1634 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1635 prefs_common.summaryview_width,
1636 prefs_common.summaryview_height);
1637 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1638 prefs_common.mainview_width, -1);
1639 gtk_widget_set_usize(mainwin->window,
1640 prefs_common.mainview_width,
1641 prefs_common.mainview_height);
1643 gtk_container_add(GTK_CONTAINER(folderwin),
1644 GTK_WIDGET_PTR(mainwin->folderview));
1646 menu_set_sensitive(ifactory, "/View/Message view", FALSE);
1647 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1649 mainwin->win.sep_folder.folderwin = folderwin;
1650 mainwin->win.sep_folder.vpaned = vpaned;
1652 gtk_widget_show_all(folderwin);
1654 case SEPARATE_MESSAGE:
1655 hpaned = gtk_hpaned_new();
1656 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1658 gtk_paned_add1(GTK_PANED(hpaned),
1659 GTK_WIDGET_PTR(mainwin->folderview));
1660 gtk_paned_add2(GTK_PANED(hpaned),
1661 GTK_WIDGET_PTR(mainwin->summaryview));
1662 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1663 prefs_common.summaryview_width,
1664 prefs_common.summaryview_height);
1665 gtk_widget_set_usize(mainwin->window,
1666 prefs_common.folderview_width +
1667 prefs_common.mainview_width,
1668 prefs_common.mainwin_height);
1669 gtk_widget_show_all(hpaned);
1670 gtk_container_add(GTK_CONTAINER(messagewin),
1671 GTK_WIDGET_PTR(mainwin->messageview));
1673 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1674 menu_set_sensitive(ifactory, "/View/Folder tree", FALSE);
1676 mainwin->win.sep_message.messagewin = messagewin;
1677 mainwin->win.sep_message.hpaned = hpaned;
1679 gtk_widget_show_all(messagewin);
1682 gtk_box_pack_start(GTK_BOX(vbox_body),
1683 GTK_WIDGET_PTR(mainwin->summaryview),
1685 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1686 prefs_common.summaryview_width,
1687 prefs_common.summaryview_height);
1688 gtk_widget_set_usize(mainwin->window,
1689 prefs_common.mainview_width,
1690 prefs_common.mainwin_height);
1691 gtk_container_add(GTK_CONTAINER(folderwin),
1692 GTK_WIDGET_PTR(mainwin->folderview));
1693 gtk_container_add(GTK_CONTAINER(messagewin),
1694 GTK_WIDGET_PTR(mainwin->messageview));
1696 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1697 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1699 mainwin->win.sep_both.folderwin = folderwin;
1700 mainwin->win.sep_both.messagewin = messagewin;
1702 gtk_widget_show_all(folderwin);
1703 gtk_widget_show_all(messagewin);
1707 mainwin->type = type;
1709 debug_print(_("done.\n"));
1712 #include "pixmaps/stock_mail_receive.xpm"
1713 #include "pixmaps/stock_mail_receive_all.xpm"
1714 #include "pixmaps/stock_mail_compose.xpm"
1715 #include "pixmaps/stock_news_compose.xpm"
1716 #include "pixmaps/stock_mail_reply.xpm"
1717 #include "pixmaps/stock_mail_reply_to_all.xpm"
1718 #include "pixmaps/stock_mail_reply_to_author.xpm"
1719 #include "pixmaps/stock_mail_forward.xpm"
1720 #include "pixmaps/stock_mail_send.xpm"
1721 #include "pixmaps/stock_preferences.xpm"
1722 #include "pixmaps/stock_properties.xpm"
1723 #include "pixmaps/stock_down_arrow.xpm"
1724 #include "pixmaps/stock_close.xpm"
1725 #include "pixmaps/stock_exec.xpm"
1727 #define CREATE_TOOLBAR_ICON(xpm_d) \
1729 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1730 &container->style->white, \
1732 icon_wid = gtk_pixmap_new(icon, mask); \
1735 static void main_window_toolbar_create(MainWindow *mainwin,
1736 GtkWidget *container)
1741 GtkWidget *icon_wid;
1743 GtkWidget *getall_btn;
1744 GtkWidget *compose_mail_btn;
1745 GtkWidget *compose_news_btn;
1746 GtkWidget *reply_btn;
1747 GtkWidget *replyall_btn;
1748 GtkWidget *replysender_btn;
1750 GtkWidget *send_btn;
1752 GtkWidget *prefs_btn;
1753 GtkWidget *account_btn;
1755 GtkWidget *next_btn;
1756 GtkWidget *delete_btn;
1757 GtkWidget *exec_btn;
1759 GtkTooltips *tooltips;
1761 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1763 gtk_container_add(GTK_CONTAINER(container), toolbar);
1764 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1765 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1766 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1767 GTK_TOOLBAR_SPACE_LINE);
1769 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1770 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1772 _("Get new mail from current account"),
1774 icon_wid, toolbar_inc_cb, mainwin);
1775 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1776 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1778 _("Get new mail from all accounts"),
1784 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1786 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1787 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1789 _("Send queued message(s)"),
1795 /* insert compose mail button widget */
1797 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1798 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1800 _("Compose an email message"),
1803 toolbar_compose_mail_cb,
1806 /* insert compose news button widget */
1808 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1809 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1811 _("Compose a news message"),
1814 toolbar_compose_news_cb,
1817 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1821 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1822 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1824 _("Reply to the message - Right button: more options"),
1830 /* replyall button */
1832 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1833 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1835 _("Reply to all - Right button: more options"),
1838 toolbar_reply_to_all_cb,
1841 /* reply to sender button */
1843 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1844 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1846 _("Reply to sender - Right button: more options"),
1849 toolbar_reply_to_sender_cb,
1852 /* forward button */
1854 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1855 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1857 _("Forward the message - Right button: more options"),
1863 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1865 CREATE_TOOLBAR_ICON(stock_close_xpm);
1866 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1868 _("Delete the message"),
1874 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1875 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1877 _("Execute marked process"),
1883 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1884 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1886 _("Next unread message"),
1889 toolbar_next_unread_cb,
1893 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1895 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1896 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1898 _("Common preference"),
1903 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1904 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1906 _("Account setting"),
1911 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1912 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1916 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
1917 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
1920 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
1921 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
1924 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
1925 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
1928 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
1929 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
1933 mainwin->toolbar = toolbar;
1934 mainwin->get_btn = get_btn;
1935 mainwin->getall_btn = getall_btn;
1936 mainwin->compose_mail_btn = compose_mail_btn;
1937 mainwin->compose_news_btn = compose_news_btn;
1938 mainwin->reply_btn = reply_btn;
1939 mainwin->replyall_btn = replyall_btn;
1940 mainwin->replysender_btn = replysender_btn;
1941 mainwin->fwd_btn = fwd_btn;
1942 mainwin->send_btn = send_btn;
1944 mainwin->prefs_btn = prefs_btn;
1945 mainwin->account_btn = account_btn;
1947 mainwin->next_btn = next_btn;
1948 mainwin->delete_btn = delete_btn;
1949 mainwin->exec_btn = exec_btn;
1951 gtk_widget_show_all(toolbar);
1954 /* callback functions */
1955 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1957 MainWindow *mainwindow = (MainWindow *) data;
1961 if (event->button == 3)
1962 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL, NULL, NULL, 1, 0);
1965 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1967 MainWindow *mainwindow = (MainWindow *) data;
1971 if (event->button == 3)
1972 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL, NULL, NULL, 1, 0);
1975 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1977 MainWindow *mainwindow = (MainWindow *) data;
1978 GtkWidget *replysender_menu, *replysender_item;
1982 if (event->button == 3)
1983 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL, NULL, NULL, 1, 0);
1986 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1988 MainWindow *mainwindow = (MainWindow *) data;
1992 if (event->button == 3)
1993 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL, NULL, NULL, 1, 0);
1996 static void toolbar_inc_cb (GtkWidget *widget,
1999 MainWindow *mainwin = (MainWindow *)data;
2001 inc_mail_cb(mainwin, 0, NULL);
2004 static void toolbar_inc_all_cb (GtkWidget *widget,
2007 MainWindow *mainwin = (MainWindow *)data;
2009 inc_all_account_mail_cb(mainwin, 0, NULL);
2012 static void toolbar_send_cb (GtkWidget *widget,
2015 MainWindow *mainwin = (MainWindow *)data;
2017 send_queue_cb(mainwin, 0, NULL);
2020 static void toolbar_compose_cb (GtkWidget *widget,
2023 MainWindow *mainwin = (MainWindow *)data;
2025 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2026 compose_cb(mainwin, 0, NULL);
2028 compose_news_cb(mainwin, 0, NULL);
2031 static void toolbar_compose_news_cb (GtkWidget *widget,
2034 MainWindow *mainwin = (MainWindow *)data;
2036 compose_news_cb(mainwin, 0, NULL);
2039 static void toolbar_compose_mail_cb (GtkWidget *widget,
2042 MainWindow *mainwin = (MainWindow *)data;
2044 compose_mail_cb(mainwin, 0, NULL);
2047 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2049 MainWindow *mainwin = (MainWindow *)data;
2052 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2053 : COMPOSE_REPLY_WITHOUT_QUOTE,
2057 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2059 MainWindow *mainwin = (MainWindow *)data;
2062 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2063 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2068 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2070 MainWindow *mainwin = (MainWindow *)data;
2073 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2074 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2078 static void toolbar_forward_cb (GtkWidget *widget,
2081 MainWindow *mainwin = (MainWindow *)data;
2083 if (prefs_common.forward_as_attachment)
2084 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2086 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2089 static void toolbar_delete_cb (GtkWidget *widget,
2092 MainWindow *mainwin = (MainWindow *)data;
2094 summary_delete(mainwin->summaryview);
2097 static void toolbar_exec_cb (GtkWidget *widget,
2100 MainWindow *mainwin = (MainWindow *)data;
2102 summary_execute(mainwin->summaryview);
2105 static void toolbar_next_unread_cb (GtkWidget *widget,
2108 MainWindow *mainwin = (MainWindow *)data;
2110 next_unread_cb(mainwin, 0, NULL);
2113 static void toolbar_prefs_cb (GtkWidget *widget,
2116 prefs_common_open();
2119 static void toolbar_account_cb (GtkWidget *widget,
2122 MainWindow *mainwin = (MainWindow *)data;
2124 prefs_account_open_cb(mainwin, 0, NULL);
2127 static void toolbar_account_button_pressed(GtkWidget *widget,
2128 GdkEventButton *event,
2131 MainWindow *mainwin = (MainWindow *)data;
2134 if (event->button != 3) return;
2136 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2137 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2140 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2141 menu_button_position, widget,
2142 event->button, event->time);
2145 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2148 MainWindow *mainwin = (MainWindow *)data;
2152 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2153 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2156 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2157 menu_button_position, widget,
2158 event->button, event->time);
2161 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2163 MainWindow *mainwin = (MainWindow *)data;
2166 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2167 if (!button) return;
2168 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2169 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2170 manage_window_focus_in(mainwin->window, NULL, NULL);
2173 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2176 MainWindow *mainwin = (MainWindow *)data;
2178 if (mainwin->lock_count == 0)
2179 app_exit_cb(data, 0, widget);
2184 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2187 main_window_add_mailbox(mainwin);
2190 static void add_mbox_cb(MainWindow *mainwin, guint action,
2193 main_window_add_mbox(mainwin);
2196 static void update_folderview_cb(MainWindow *mainwin, guint action,
2199 summary_show(mainwin->summaryview, NULL, FALSE);
2200 folderview_update_all();
2203 static void new_folder_cb(MainWindow *mainwin, guint action,
2206 folderview_new_folder(mainwin->folderview);
2209 static void rename_folder_cb(MainWindow *mainwin, guint action,
2212 folderview_rename_folder(mainwin->folderview);
2215 static void delete_folder_cb(MainWindow *mainwin, guint action,
2218 folderview_delete_folder(mainwin->folderview);
2221 static void import_mbox_cb(MainWindow *mainwin, guint action,
2224 import_mbox(mainwin->summaryview->folder_item);
2227 static void export_mbox_cb(MainWindow *mainwin, guint action,
2230 export_mbox(mainwin->summaryview->folder_item);
2233 static void empty_trash_cb(MainWindow *mainwin, guint action,
2236 main_window_empty_trash(mainwin, TRUE);
2239 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2241 summary_save_as(mainwin->summaryview);
2244 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2246 summary_print(mainwin->summaryview);
2249 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2251 if (prefs_common.confirm_on_exit) {
2252 if (alertpanel(_("Exit"), _("Exit this program?"),
2253 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2255 manage_window_focus_in(mainwin->window, NULL, NULL);
2258 app_will_exit(widget, mainwin);
2261 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2264 summary_search(mainwin->summaryview);
2266 message_search(mainwin->messageview);
2269 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2272 switch (mainwin->type) {
2274 case SEPARATE_MESSAGE:
2276 case SEPARATE_FOLDER:
2277 if (GTK_CHECK_MENU_ITEM(widget)->active)
2278 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2280 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2283 if (GTK_CHECK_MENU_ITEM(widget)->active)
2284 gtk_widget_show(mainwin->win.sep_both.folderwin);
2286 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2291 static void toggle_message_cb(MainWindow *mainwin, guint action,
2294 switch (mainwin->type) {
2296 case SEPARATE_FOLDER:
2298 case SEPARATE_MESSAGE:
2299 if (GTK_CHECK_MENU_ITEM(widget)->active)
2300 gtk_widget_show(mainwin->win.sep_message.messagewin);
2302 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2305 if (GTK_CHECK_MENU_ITEM(widget)->active)
2306 gtk_widget_show(mainwin->win.sep_both.messagewin);
2308 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2313 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2316 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2317 mainwin->compose_btn_type);
2318 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2319 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2320 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2321 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2323 switch ((ToolbarStyle)action) {
2325 gtk_widget_hide(mainwin->handlebox);
2327 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2331 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2335 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2340 if (action != TOOLBAR_NONE) {
2341 gtk_widget_show(mainwin->handlebox);
2342 gtk_widget_queue_resize(mainwin->handlebox);
2345 mainwin->toolbar_style = (ToolbarStyle)action;
2346 prefs_common.toolbar_style = (ToolbarStyle)action;
2349 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2352 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2353 gtk_widget_show(mainwin->hbox_stat);
2354 prefs_common.show_statusbar = TRUE;
2356 gtk_widget_hide(mainwin->hbox_stat);
2357 prefs_common.show_statusbar = FALSE;
2361 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2364 MainWindow *mainwin;
2367 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2368 g_return_if_fail(mainwin != NULL);
2370 type = mainwin->type ^ action;
2371 main_window_separation_change(mainwin, type);
2373 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2374 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2377 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2380 addressbook_open(NULL);
2383 static void log_window_show_cb(MainWindow *mainwin, guint action,
2386 log_window_show(mainwin->logwin);
2389 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2394 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2397 inc_all_account_mail(mainwin);
2400 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2404 if (procmsg_send_queue() < 0)
2405 alertpanel_error(_("Some errors occurred while sending queued messages."));
2407 statusbar_pop_all();
2409 for (list = folder_get_list(); list != NULL; list = list->next) {
2412 folder = list->data;
2413 if (folder->queue) {
2414 folder_item_scan(folder->queue);
2415 folderview_update_item(folder->queue, TRUE);
2420 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2422 if (mainwin->summaryview->folder_item) {
2423 if (mainwin->summaryview->folder_item->folder->account != NULL
2424 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2425 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2427 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2433 static void compose_mail_cb(MainWindow *mainwin, guint action,
2440 if (mainwin->summaryview->folder_item) {
2441 ac = mainwin->summaryview->folder_item->folder->account;
2442 if (ac && ac->protocol != A_NNTP) {
2443 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2448 if(cur_account && (cur_account->protocol != A_NNTP)) {
2449 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2453 list = account_get_list();
2454 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2455 ac = (PrefsAccount *) cur->data;
2456 if (ac->protocol != A_NNTP) {
2457 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2463 static void compose_news_cb(MainWindow *mainwin, guint action,
2466 PrefsAccount * ac = NULL;
2470 if (mainwin->summaryview->folder_item) {
2471 ac = mainwin->summaryview->folder_item->folder->account;
2472 if (ac && ac->protocol == A_NNTP) {
2473 compose_new_with_recipient
2474 (ac, mainwin->summaryview->folder_item->path);
2479 list = account_get_list();
2480 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2481 ac = (PrefsAccount *) cur->data;
2482 if (ac->protocol == A_NNTP) {
2489 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2491 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2494 msginfo = gtk_ctree_node_get_row_data
2495 (GTK_CTREE(mainwin->summaryview->ctree),
2496 mainwin->summaryview->selected);
2498 if (!msginfo) return;
2502 compose_reply(msginfo, prefs_common.reply_with_quote,
2505 case COMPOSE_REPLY_WITH_QUOTE:
2506 compose_reply(msginfo, TRUE, FALSE, FALSE);
2508 case COMPOSE_REPLY_WITHOUT_QUOTE:
2509 compose_reply(msginfo, FALSE, FALSE, FALSE);
2511 case COMPOSE_REPLY_TO_SENDER:
2512 compose_reply(msginfo, prefs_common.reply_with_quote,
2515 case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE:
2516 compose_reply(msginfo, TRUE, FALSE, TRUE);
2518 case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE:
2519 compose_reply(msginfo, FALSE, FALSE, TRUE);
2521 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2522 compose_followup_and_reply_to(msginfo,
2523 prefs_common.reply_with_quote,
2526 case COMPOSE_REPLY_TO_ALL:
2527 compose_reply(msginfo, prefs_common.reply_with_quote,
2530 case COMPOSE_REPLY_TO_ALL_WITH_QUOTE:
2531 compose_reply(msginfo, TRUE, TRUE, TRUE);
2533 case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE:
2534 compose_reply(msginfo, FALSE, TRUE, TRUE);
2536 case COMPOSE_FORWARD:
2537 if (prefs_common.forward_as_attachment) {
2538 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, widget);
2541 reply_cb(mainwin, COMPOSE_FORWARD_INLINE, widget);
2545 case COMPOSE_FORWARD_INLINE:
2547 compose_forward(NULL, msginfo, FALSE);
2550 /* if (sel->next) FALL_THROUGH */
2551 case COMPOSE_FORWARD_AS_ATTACH:
2553 GSList *msginfo_list = NULL;
2554 for ( ; sel != NULL; sel = sel->next)
2555 msginfo_list = g_slist_append(msginfo_list,
2556 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2557 GTK_CTREE_NODE(sel->data)));
2558 compose_forward_multiple(NULL, msginfo_list);
2559 g_slist_free(msginfo_list);
2562 case COMPOSE_BOUNCE:
2563 compose_bounce(NULL, msginfo);
2566 g_warning("reply_cb(): invalid action type: %d\n", action);
2569 summary_set_marks_selected(mainwin->summaryview);
2572 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2574 summary_move_to(mainwin->summaryview);
2577 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2579 summary_copy_to(mainwin->summaryview);
2582 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2584 summary_delete(mainwin->summaryview);
2587 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2589 summary_open_msg(mainwin->summaryview);
2592 static void view_source_cb(MainWindow *mainwin, guint action,
2595 summary_view_source(mainwin->summaryview);
2598 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2600 summary_reedit(mainwin->summaryview);
2603 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2605 summary_mark(mainwin->summaryview);
2608 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2610 summary_unmark(mainwin->summaryview);
2613 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2616 summary_mark_as_unread(mainwin->summaryview);
2619 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2622 summary_mark_as_read(mainwin->summaryview);
2625 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2628 summary_mark_all_read(mainwin->summaryview);
2631 static void add_address_cb(MainWindow *mainwin, guint action,
2634 summary_add_address(mainwin->summaryview);
2637 static void set_charset_cb(MainWindow *mainwin, guint action,
2642 str = conv_get_charset_str((CharSet)action);
2643 g_free(prefs_common.force_charset);
2644 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2646 summary_redisplay_msg(mainwin->summaryview);
2648 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2651 static void hide_read_messages (MainWindow *mainwin, guint action,
2654 if (!mainwin->summaryview->folder_item
2655 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2657 summary_toggle_show_read_messages(mainwin->summaryview);
2660 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2662 GtkItemFactory *ifactory;
2664 if (!mainwin->summaryview->folder_item) return;
2666 ifactory = gtk_item_factory_from_widget(widget);
2669 summary_thread_build(mainwin->summaryview);
2670 mainwin->summaryview->folder_item->threaded = TRUE;
2671 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2672 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2674 summary_unthread(mainwin->summaryview);
2675 mainwin->summaryview->folder_item->threaded = FALSE;
2676 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2677 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2681 static void set_display_item_cb(MainWindow *mainwin, guint action,
2684 prefs_summary_column_open();
2687 static void sort_summary_cb(MainWindow *mainwin, guint action,
2690 summary_sort(mainwin->summaryview, (SummarySortType)action);
2693 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2696 summary_attract_by_subject(mainwin->summaryview);
2699 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2702 summary_delete_duplicated(mainwin->summaryview);
2705 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2707 summary_filter(mainwin->summaryview);
2710 static void execute_summary_cb(MainWindow *mainwin, guint action,
2713 summary_execute(mainwin->summaryview);
2716 static void update_summary_cb(MainWindow *mainwin, guint action,
2720 FolderView *folderview = mainwin->folderview;
2722 if (!mainwin->summaryview->folder_item) return;
2723 if (!folderview->opened) return;
2725 folder_update_op_count();
2727 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2728 folderview->opened);
2731 summary_show(mainwin->summaryview, fitem, TRUE);
2734 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2736 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2739 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2741 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2744 static void prev_unread_cb(MainWindow *mainwin, guint action,
2747 summary_select_prev_unread(mainwin->summaryview);
2750 static void next_unread_cb(MainWindow *mainwin, guint action,
2753 summary_select_next_unread(mainwin->summaryview);
2756 static void prev_marked_cb(MainWindow *mainwin, guint action,
2759 summary_select_prev_marked(mainwin->summaryview);
2762 static void next_marked_cb(MainWindow *mainwin, guint action,
2765 summary_select_next_marked(mainwin->summaryview);
2768 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2771 summary_select_prev_labeled(mainwin->summaryview);
2774 static void next_labeled_cb(MainWindow *mainwin, guint action,
2777 summary_select_next_labeled(mainwin->summaryview);
2780 static void goto_folder_cb(MainWindow *mainwin, guint action,
2783 FolderItem *to_folder;
2785 to_folder = foldersel_folder_sel(NULL, NULL);
2788 folderview_select(mainwin->folderview, to_folder);
2791 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2793 messageview_copy_clipboard(mainwin->messageview);
2796 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2798 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2799 summary_select_all(mainwin->summaryview);
2800 else if (mainwin->summaryview->msg_is_toggled_on &&
2801 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2802 messageview_select_all(mainwin->messageview);
2805 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2808 prefs_common_open();
2811 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2814 prefs_filter_open();
2817 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2820 prefs_scoring_open(NULL);
2823 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2826 prefs_filtering_open(NULL);
2829 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2832 prefs_template_open();
2835 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2839 new_account_cb(mainwin, 0, widget);
2841 gboolean prev_default = cur_account->is_default;
2843 prefs_account_open(cur_account);
2844 if (!prev_default && cur_account->is_default)
2845 account_set_as_default(cur_account);
2846 account_save_config_all();
2848 main_window_reflect_prefs_all();
2852 static void new_account_cb(MainWindow *mainwin, guint action,
2855 account_edit_open();
2856 if (!compose_get_compose_list()) account_add();
2859 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2861 cur_account = (PrefsAccount *)data;
2862 main_window_reflect_prefs_all();
2865 static void manual_open_cb(MainWindow *mainwin, guint action,
2868 manual_open((ManualLang)action);
2871 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2873 MainWindow *mainwin = (MainWindow *)data;
2877 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2878 LOCAL_FOLDER(folder)->rootpath,
2882 str = g_strdup_printf(_("Scanning folder %s ..."),
2883 LOCAL_FOLDER(folder)->rootpath);
2885 STATUSBAR_PUSH(mainwin, str);
2886 STATUSBAR_POP(mainwin);
2890 static void activate_compose_button (MainWindow *mainwin,
2892 ComposeButtonType type)
2894 SensitiveCond state = main_window_get_current_state(mainwin);
2896 if (style == TOOLBAR_NONE)
2899 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2900 : mainwin->compose_news_btn);
2901 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2902 : mainwin->compose_mail_btn);
2903 mainwin->compose_btn_type = type;
2906 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2908 if (mainwin->compose_btn_type != compose_btn_type)
2909 activate_compose_button(mainwin,
2910 prefs_common.toolbar_style,