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"
55 #include "stock_pixmap.h"
62 #include "prefs_common.h"
63 #include "prefs_filter.h"
64 #include "prefs_filtering.h"
65 #include "prefs_scoring.h"
66 #include "prefs_account.h"
67 #include "prefs_folder_item.h"
68 #include "prefs_summary_column.h"
69 #include "prefs_template.h"
71 #include "addressbook.h"
72 #include "headerwindow.h"
73 #include "logwindow.h"
74 #include "manage_window.h"
75 #include "alertpanel.h"
76 #include "statusbar.h"
77 #include "inputdialog.h"
85 #define AC_LABEL_WIDTH 240
87 #define STATUSBAR_PUSH(mainwin, str) \
89 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
90 mainwin->mainwin_cid, str); \
91 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
94 #define STATUSBAR_POP(mainwin) \
96 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
97 mainwin->mainwin_cid); \
100 /* list of all instantiated MainWindow */
101 static GList *mainwin_list = NULL;
103 static GdkCursor *watch_cursor;
105 static void main_window_show_cur_account (MainWindow *mainwin);
107 static void main_window_set_widgets (MainWindow *mainwin,
109 static void main_window_toolbar_create (MainWindow *mainwin,
110 GtkWidget *container);
112 /* callback functions */
113 static void toolbar_inc_cb (GtkWidget *widget,
115 static void toolbar_inc_all_cb (GtkWidget *widget,
117 static void toolbar_send_cb (GtkWidget *widget,
120 static void toolbar_compose_cb (GtkWidget *widget,
122 static void toolbar_compose_news_cb (GtkWidget *widget,
124 static void toolbar_compose_mail_cb (GtkWidget *widget,
126 static void toolbar_reply_cb (GtkWidget *widget,
128 static void toolbar_reply_popup_cb (GtkWidget *widget,
129 GdkEventButton *event,
131 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell,
133 static void toolbar_reply_to_all_cb (GtkWidget *widget,
135 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget,
136 GdkEventButton *event,
138 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell,
140 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
142 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
143 GdkEventButton *event,
145 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell,
147 static void toolbar_forward_cb (GtkWidget *widget,
149 static void toolbar_forward_popup_cb (GtkWidget *widget,
150 GdkEventButton *event,
152 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell,
155 static void toolbar_delete_cb (GtkWidget *widget,
157 static void toolbar_exec_cb (GtkWidget *widget,
160 static void toolbar_next_unread_cb (GtkWidget *widget,
163 static void toolbar_prefs_cb (GtkWidget *widget,
165 static void toolbar_account_cb (GtkWidget *widget,
168 static void toolbar_account_button_pressed (GtkWidget *widget,
169 GdkEventButton *event,
171 static void ac_label_button_pressed (GtkWidget *widget,
172 GdkEventButton *event,
174 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
177 static gint main_window_close_cb (GtkWidget *widget,
181 static void add_mailbox_cb (MainWindow *mainwin,
184 static void add_mbox_cb (MainWindow *mainwin,
187 static void update_folderview_cb (MainWindow *mainwin,
190 static void new_folder_cb (MainWindow *mainwin,
193 static void rename_folder_cb (MainWindow *mainwin,
196 static void delete_folder_cb (MainWindow *mainwin,
199 static void import_mbox_cb (MainWindow *mainwin,
202 static void export_mbox_cb (MainWindow *mainwin,
205 static void empty_trash_cb (MainWindow *mainwin,
209 static void save_as_cb (MainWindow *mainwin,
212 static void print_cb (MainWindow *mainwin,
215 static void app_exit_cb (MainWindow *mainwin,
219 static void search_cb (MainWindow *mainwin,
223 static void toggle_folder_cb (MainWindow *mainwin,
226 static void toggle_message_cb (MainWindow *mainwin,
229 static void toggle_toolbar_cb (MainWindow *mainwin,
232 static void toggle_statusbar_cb (MainWindow *mainwin,
235 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
239 static void addressbook_open_cb (MainWindow *mainwin,
242 static void log_window_show_cb (MainWindow *mainwin,
246 static void inc_mail_cb (MainWindow *mainwin,
249 static void inc_all_account_mail_cb (MainWindow *mainwin,
253 static void send_queue_cb (MainWindow *mainwin,
257 static void compose_cb (MainWindow *mainwin,
260 static void compose_mail_cb(MainWindow *mainwin, guint action,
262 static void compose_news_cb(MainWindow *mainwin, guint action,
264 static void reply_cb (MainWindow *mainwin,
268 static void open_msg_cb (MainWindow *mainwin,
272 static void view_source_cb (MainWindow *mainwin,
276 static void reedit_cb (MainWindow *mainwin,
280 static void move_to_cb (MainWindow *mainwin,
283 static void copy_to_cb (MainWindow *mainwin,
286 static void delete_cb (MainWindow *mainwin,
290 static void mark_cb (MainWindow *mainwin,
293 static void unmark_cb (MainWindow *mainwin,
297 static void mark_as_unread_cb (MainWindow *mainwin,
300 static void mark_as_read_cb (MainWindow *mainwin,
303 static void mark_all_read_cb (MainWindow *mainwin,
306 static void add_address_cb (MainWindow *mainwin,
310 static void set_charset_cb (MainWindow *mainwin,
314 static void hide_read_messages (MainWindow *mainwin,
318 static void thread_cb (MainWindow *mainwin,
321 static void set_display_item_cb (MainWindow *mainwin,
324 static void sort_summary_cb (MainWindow *mainwin,
327 static void attract_by_subject_cb(MainWindow *mainwin,
331 static void delete_duplicated_cb (MainWindow *mainwin,
334 static void filter_cb (MainWindow *mainwin,
337 static void execute_summary_cb (MainWindow *mainwin,
340 static void update_summary_cb (MainWindow *mainwin,
344 static void prev_cb (MainWindow *mainwin,
347 static void next_cb (MainWindow *mainwin,
351 static void prev_unread_cb (MainWindow *mainwin,
354 static void next_unread_cb (MainWindow *mainwin,
357 static void prev_marked_cb (MainWindow *mainwin,
360 static void next_marked_cb (MainWindow *mainwin,
363 static void prev_labeled_cb (MainWindow *mainwin,
366 static void next_labeled_cb (MainWindow *mainwin,
370 static void goto_folder_cb (MainWindow *mainwin,
374 static void copy_cb (MainWindow *mainwin,
377 static void allsel_cb (MainWindow *mainwin,
381 static void prefs_common_open_cb (MainWindow *mainwin,
384 static void prefs_filter_open_cb (MainWindow *mainwin,
387 static void prefs_scoring_open_cb (MainWindow *mainwin,
390 static void prefs_filtering_open_cb (MainWindow *mainwin,
393 static void prefs_account_open_cb(MainWindow *mainwin,
396 static void prefs_template_open_cb (MainWindow *mainwin,
399 static void new_account_cb (MainWindow *mainwin,
403 static void account_menu_cb (GtkMenuItem *menuitem,
406 static void manual_open_cb (MainWindow *mainwin,
410 static void scan_tree_func (Folder *folder,
414 static void activate_compose_button (MainWindow *mainwin,
416 ComposeButtonType type);
418 #define SEPARATE_ACTION 667
420 static GtkItemFactoryEntry mainwin_entries[] =
422 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
423 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
424 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
425 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
426 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
427 {N_("/_File/_Folder/Create _new folder..."),
428 NULL, new_folder_cb, 0, NULL},
429 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
430 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
431 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
432 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
433 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
434 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
435 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
436 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
437 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
438 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},*/
439 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
441 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
442 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
443 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
444 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
445 {N_("/_Edit/_Find in current message"), "<control>F", search_cb, 0, NULL},
446 {N_("/_Edit/_Search folder..."), "<control>S", search_cb, 1, NULL},
448 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
449 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
450 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
451 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
452 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
453 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
454 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
455 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
456 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
457 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
458 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
459 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
460 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
461 {N_("/_View/View _source"), "<control>U", view_source_cb, 0, NULL},
462 {N_("/_View/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
463 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
464 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
465 {N_("/_View/_Code set/_Auto detect"),
466 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
468 #define CODESET_SEPARATOR \
469 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
470 #define CODESET_ACTION(action) \
471 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
473 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
474 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
475 CODESET_ACTION(C_US_ASCII)},
478 {N_("/_View/_Code set/Unicode (_UTF-8)"),
479 CODESET_ACTION(C_UTF_8)},
482 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
483 CODESET_ACTION(C_ISO_8859_1)},
486 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
487 CODESET_ACTION(C_ISO_8859_2)},
489 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
490 CODESET_ACTION(C_ISO_8859_13)},
491 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
492 CODESET_ACTION(C_ISO_8859_4)},
494 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
495 CODESET_ACTION(C_ISO_8859_7)},
497 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
498 CODESET_ACTION(C_ISO_8859_9)},
500 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
501 CODESET_ACTION(C_ISO_8859_5)},
502 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
503 CODESET_ACTION(C_KOI8_R)},
504 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
505 CODESET_ACTION(C_CP1251)},
508 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
509 CODESET_ACTION(C_ISO_2022_JP)},
511 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
512 CODESET_ACTION(C_ISO_2022_JP_2)},
514 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
515 CODESET_ACTION(C_EUC_JP)},
516 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
517 CODESET_ACTION(C_SHIFT_JIS)},
520 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
521 CODESET_ACTION(C_GB2312)},
522 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
523 CODESET_ACTION(C_BIG5)},
524 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
525 CODESET_ACTION(C_EUC_TW)},
526 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
527 CODESET_ACTION(C_ISO_2022_CN)},
529 {N_("/_View/_Code set/Korean (EUC-_KR)"),
530 CODESET_ACTION(C_EUC_KR)},
531 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
532 CODESET_ACTION(C_ISO_2022_KR)},
534 {N_("/_View/_Code set/Thai (TIS-620)"),
535 CODESET_ACTION(C_TIS_620)},
536 {N_("/_View/_Code set/Thai (Windows-874)"),
537 CODESET_ACTION(C_WINDOWS_874)},
540 #undef CODESET_SEPARATOR
541 #undef CODESET_ACTION
543 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
544 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
545 {N_("/_Message/Get from _all accounts"),
546 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
547 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
548 {N_("/_Message/Send queued messa_ges"),
549 NULL, send_queue_cb, 0, NULL},
550 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
551 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
552 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
553 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
554 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
555 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
556 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
557 {N_("/_Message/_Forward"), "<shift><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
558 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
559 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
560 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
561 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
562 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
563 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
564 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
565 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
566 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
567 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
568 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
569 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
570 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
571 {N_("/_Message/_Mark/Mark as rea_d"),
572 NULL, mark_as_read_cb, 0, NULL},
573 {N_("/_Message/_Mark/Mark all read"), NULL, mark_all_read_cb, 0, NULL},
574 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
575 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
577 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
578 {N_("/_Summary/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
579 {N_("/_Summary/_Delete duplicated messages"),
580 NULL, delete_duplicated_cb, 0, NULL},
581 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
582 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
583 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
584 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
585 {N_("/_Summary/Go _to"), NULL, NULL, 0, "<Branch>"},
586 {N_("/_Summary/Go _to/_Prev message"), NULL, prev_cb, 0, NULL},
587 {N_("/_Summary/Go _to/_Next message"), NULL, next_cb, 0, NULL},
588 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
589 {N_("/_Summary/Go _to/P_rev unread message"),
590 NULL, prev_unread_cb, 0, NULL},
591 {N_("/_Summary/Go _to/N_ext unread message"),
592 NULL, next_unread_cb, 0, NULL},
593 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
594 {N_("/_Summary/Go _to/Prev _marked message"),
595 NULL, prev_marked_cb, 0, NULL},
596 {N_("/_Summary/Go _to/Next m_arked message"),
597 NULL, next_marked_cb, 0, NULL},
598 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
599 {N_("/_Summary/Go _to/Prev _labeled message"),
600 NULL, prev_labeled_cb, 0, NULL},
601 {N_("/_Summary/Go _to/Next la_beled message"),
602 NULL, next_labeled_cb, 0, NULL},
603 {N_("/_Summary/_Go to other folder..."),"<alt>G", goto_folder_cb, 0, NULL},
604 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
605 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
606 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
607 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
608 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
609 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
610 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
611 {N_("/_Summary/_Sort/Sort by _color label"),
612 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
613 {N_("/_Summary/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
614 {N_("/_Summary/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
615 {N_("/_Summary/_Sort/Sort by a_ttachment"),
616 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
617 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
618 {N_("/_Summary/_Sort/_Attract by subject"),
619 NULL, attract_by_subject_cb, 0, NULL},
620 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
621 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
622 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
624 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
625 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
626 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
628 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
629 {N_("/_Configuration/_Common preferences..."),
630 NULL, prefs_common_open_cb, 0, NULL},
631 {N_("/_Configuration/_Filter setting..."),
632 NULL, prefs_filter_open_cb, 0, NULL},
633 {N_("/_Configuration/_Scoring ..."),
634 NULL, prefs_scoring_open_cb, 0, NULL},
635 {N_("/_Configuration/_Filtering ..."),
636 NULL, prefs_filtering_open_cb, 0, NULL},
637 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
638 {N_("/_Configuration/_Preferences for current account..."),
639 NULL, prefs_account_open_cb, 0, NULL},
640 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
641 {N_("/_Configuration/Create _new account..."),
642 NULL, new_account_cb, 0, NULL},
643 {N_("/_Configuration/_Edit accounts..."),
644 NULL, account_edit_open, 0, NULL},
645 {N_("/_Configuration/C_hange current account"),
646 NULL, NULL, 0, "<Branch>"},
648 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
649 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
650 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
651 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
652 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
653 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
655 static GtkItemFactoryEntry reply_popup_entries[] =
657 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
658 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
660 static GtkItemFactoryEntry replyall_popup_entries[] =
662 {N_("/Reply to all with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
663 {N_("/_Reply to all without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
665 static GtkItemFactoryEntry replysender_popup_entries[] =
667 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
668 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
670 static GtkItemFactoryEntry fwd_popup_entries[] =
672 {N_("/_Forward message (inline style)"), NULL, reply_cb, COMPOSE_FORWARD_INLINE, NULL},
673 {N_("/Forward message as _attachment"), NULL, reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
677 MainWindow *main_window_create(SeparateType type)
683 GtkWidget *handlebox;
684 GtkWidget *vbox_body;
685 GtkWidget *hbox_stat;
686 GtkWidget *statusbar;
687 GtkWidget *progressbar;
688 GtkWidget *statuslabel;
689 GtkWidget *ac_button;
692 FolderView *folderview;
693 SummaryView *summaryview;
694 MessageView *messageview;
695 GdkColormap *colormap;
698 guint n_menu_entries;
699 GtkItemFactory *ifactory;
702 GtkWidget *compose_popup;
703 GtkWidget *reply_popup;
704 GtkWidget *replyall_popup;
705 GtkWidget *replysender_popup;
706 GtkWidget *fwd_popup;
709 debug_print(_("Creating main window...\n"));
710 mainwin = g_new0(MainWindow, 1);
713 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
714 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
715 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
716 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
717 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
718 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
719 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
720 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
721 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
723 gtk_widget_realize(window);
724 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
726 gtkut_widget_set_app_icon(window);
728 vbox = gtk_vbox_new(FALSE, 0);
729 gtk_widget_show(vbox);
730 gtk_container_add(GTK_CONTAINER(window), vbox);
733 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
734 menubar = menubar_create(window, mainwin_entries,
735 n_menu_entries, "<Main>", mainwin);
736 gtk_widget_show(menubar);
737 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
739 handlebox = gtk_handle_box_new();
740 gtk_widget_show(handlebox);
741 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
743 /* create the popup menus for the reply buttons specials */
744 n_menu_entries = sizeof(reply_popup_entries) /
745 sizeof(reply_popup_entries[0]);
746 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
747 "<ReplyPopup>", mainwin);
748 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
749 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
750 n_menu_entries = sizeof(replyall_popup_entries) /
751 sizeof(replyall_popup_entries[0]);
752 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
753 "<ReplyAllPopup>", mainwin);
754 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
755 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
756 n_menu_entries = sizeof(replysender_popup_entries) /
757 sizeof(replysender_popup_entries[0]);
758 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
759 "<ReplySenderPopup>", mainwin);
760 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
761 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
762 /* create the popup menu for the forward button */
763 n_menu_entries = sizeof(fwd_popup_entries) /
764 sizeof(fwd_popup_entries[0]);
765 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
766 "<ForwardPopup>", mainwin);
767 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
768 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
770 main_window_toolbar_create(mainwin, handlebox);
772 /* vbox that contains body */
773 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
774 gtk_widget_show(vbox_body);
775 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
776 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
778 hbox_stat = gtk_hbox_new(FALSE, 2);
779 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
781 statusbar = statusbar_create();
782 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
784 progressbar = gtk_progress_bar_new();
785 gtk_widget_set_usize(progressbar, 120, 1);
786 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
788 statuslabel = gtk_label_new("");
789 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
791 ac_button = gtk_button_new();
792 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
793 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
794 gtk_widget_set_usize(ac_button, -1, 1);
795 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
796 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
797 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
799 ac_label = gtk_label_new("");
800 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
802 gtk_widget_show_all(hbox_stat);
805 mainwin->folderview = folderview = folderview_create();
806 mainwin->summaryview = summaryview = summary_create();
807 mainwin->messageview = messageview = messageview_create();
808 mainwin->headerwin = header_window_create();
809 mainwin->logwin = log_window_create();
811 folderview->mainwin = mainwin;
812 folderview->summaryview = summaryview;
814 summaryview->mainwin = mainwin;
815 summaryview->folderview = folderview;
816 summaryview->messageview = messageview;
817 summaryview->headerwin = mainwin->headerwin;
818 summaryview->window = window;
820 messageview->mainwin = mainwin;
822 mainwin->window = window;
823 mainwin->vbox = vbox;
824 mainwin->menubar = menubar;
825 mainwin->handlebox = handlebox;
826 mainwin->vbox_body = vbox_body;
827 mainwin->hbox_stat = hbox_stat;
828 mainwin->statusbar = statusbar;
829 mainwin->progressbar = progressbar;
830 mainwin->statuslabel = statuslabel;
831 mainwin->ac_button = ac_button;
832 mainwin->ac_label = ac_label;
833 mainwin->reply_popup = reply_popup;
834 mainwin->replyall_popup = replyall_popup;
835 mainwin->replysender_popup = replysender_popup;
836 mainwin->fwd_popup = fwd_popup;
838 /* set context IDs for status bar */
839 mainwin->mainwin_cid = gtk_statusbar_get_context_id
840 (GTK_STATUSBAR(statusbar), "Main Window");
841 mainwin->folderview_cid = gtk_statusbar_get_context_id
842 (GTK_STATUSBAR(statusbar), "Folder View");
843 mainwin->summaryview_cid = gtk_statusbar_get_context_id
844 (GTK_STATUSBAR(statusbar), "Summary View");
846 /* allocate colors for summary view and folder view */
847 summaryview->color_marked.red = summaryview->color_marked.green = 0;
848 summaryview->color_marked.blue = (guint16)65535;
850 summaryview->color_dim.red = summaryview->color_dim.green =
851 summaryview->color_dim.blue = COLOR_DIM;
853 folderview->color_new.red = (guint16)55000;
854 folderview->color_new.green = folderview->color_new.blue = 15000;
856 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
857 &folderview->color_op);
859 summaryview->color_important.red = 0;
860 summaryview->color_marked.green = 0;
861 summaryview->color_important.blue = (guint16)65535;
863 color[0] = summaryview->color_marked;
864 color[1] = summaryview->color_dim;
865 color[2] = folderview->color_new;
866 color[3] = folderview->color_op;
868 colormap = gdk_window_get_colormap(window->window);
869 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
870 for (i = 0; i < 4; i++) {
871 if (success[i] == FALSE)
872 g_warning(_("MainWindow: color allocation %d failed\n"), i);
875 debug_print(_("done.\n"));
877 main_window_set_widgets(mainwin, type);
880 ifactory = gtk_item_factory_from_widget(menubar);
881 menuitem = gtk_item_factory_get_item
882 (ifactory, "/View/Code set/Auto detect");
883 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
885 switch (prefs_common.toolbar_style) {
887 menuitem = gtk_item_factory_get_item
888 (ifactory, "/View/Toolbar/None");
891 menuitem = gtk_item_factory_get_item
892 (ifactory, "/View/Toolbar/Icon");
895 menuitem = gtk_item_factory_get_item
896 (ifactory, "/View/Toolbar/Text");
899 menuitem = gtk_item_factory_get_item
900 (ifactory, "/View/Toolbar/Icon and text");
902 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
904 gtk_widget_hide(mainwin->hbox_stat);
905 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
906 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
907 prefs_common.show_statusbar);
909 /* Message view and Folder tree are always shown at startup
910 * make that in the menu visible */
911 menuitem = gtk_item_factory_get_item(ifactory, "/View/Message view");
912 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
913 menuitem = gtk_item_factory_get_item(ifactory, "/View/Folder tree");
914 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
916 /* set the check of the SEPARATE_xxx menu items. we also need the main window
917 * as a property and pass the action type to the callback */
918 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
920 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
921 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
922 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
923 GUINT_TO_POINTER(SEPARATE_FOLDER));
925 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
927 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
928 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
929 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
930 GUINT_TO_POINTER(SEPARATE_MESSAGE));
933 menu_set_sensitive(ifactory, "/Summary/Thread view",
934 prefs_common.enable_thread ? FALSE : TRUE);
935 menu_set_sensitive(ifactory, "/Summary/Unthread view",
936 prefs_common.enable_thread ? TRUE : FALSE);
938 /*main_window_set_thread_option(mainwin);*/
941 /* set account selection menu */
942 ac_menu = gtk_item_factory_get_widget
943 (ifactory, "/Configuration/Change current account");
944 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
945 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
946 mainwin->ac_menu = ac_menu;
948 main_window_set_toolbar_sensitive(mainwin);
950 /* show main window */
951 gtk_widget_set_uposition(mainwin->window,
952 prefs_common.mainwin_x,
953 prefs_common.mainwin_y);
954 gtk_widget_set_usize(window, prefs_common.mainwin_width,
955 prefs_common.mainwin_height);
957 gtk_widget_show(mainwin->window);
959 /* initialize views */
960 folderview_init(folderview);
961 summary_init(summaryview);
962 messageview_init(messageview);
963 header_window_init(mainwin->headerwin);
964 log_window_init(mainwin->logwin);
967 mainwin->lock_count = 0;
968 mainwin->cursor_count = 0;
971 watch_cursor = gdk_cursor_new(GDK_WATCH);
973 mainwin_list = g_list_append(mainwin_list, mainwin);
978 void main_window_cursor_wait(MainWindow *mainwin)
981 if (mainwin->cursor_count == 0)
982 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
984 mainwin->cursor_count++;
989 void main_window_cursor_normal(MainWindow *mainwin)
991 if (mainwin->cursor_count)
992 mainwin->cursor_count--;
994 if (mainwin->cursor_count == 0)
995 gdk_window_set_cursor(mainwin->window->window, NULL);
1000 /* lock / unlock the user-interface */
1001 void main_window_lock(MainWindow *mainwin)
1003 if (mainwin->lock_count == 0)
1004 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1006 mainwin->lock_count++;
1008 main_window_set_menu_sensitive(mainwin);
1009 main_window_set_toolbar_sensitive(mainwin);
1012 void main_window_unlock(MainWindow *mainwin)
1014 if (mainwin->lock_count)
1015 mainwin->lock_count--;
1017 main_window_set_menu_sensitive(mainwin);
1018 main_window_set_toolbar_sensitive(mainwin);
1020 if (mainwin->lock_count == 0)
1021 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1024 void main_window_reflect_prefs_all(void)
1027 MainWindow *mainwin;
1029 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1030 mainwin = (MainWindow *)cur->data;
1032 main_window_show_cur_account(mainwin);
1033 main_window_set_menu_sensitive(mainwin);
1034 main_window_set_toolbar_sensitive(mainwin);
1036 if (prefs_common.immediate_exec)
1037 gtk_widget_hide(mainwin->exec_btn);
1039 gtk_widget_show(mainwin->exec_btn);
1041 summary_redisplay_msg(mainwin->summaryview);
1042 headerview_set_visibility(mainwin->messageview->headerview,
1043 prefs_common.display_header_pane);
1047 void main_window_set_summary_column(void)
1050 MainWindow *mainwin;
1052 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1053 mainwin = (MainWindow *)cur->data;
1054 summary_set_column_order(mainwin->summaryview);
1058 void main_window_set_account_menu(GList *account_list)
1060 GList *cur, *cur_ac, *cur_item;
1061 GtkWidget *menuitem;
1062 MainWindow *mainwin;
1063 PrefsAccount *ac_prefs;
1065 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1066 mainwin = (MainWindow *)cur->data;
1068 /* destroy all previous menu item */
1069 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1070 while (cur_item != NULL) {
1071 GList *next = cur_item->next;
1072 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1076 for (cur_ac = account_list; cur_ac != NULL;
1077 cur_ac = cur_ac->next) {
1078 ac_prefs = (PrefsAccount *)cur_ac->data;
1080 menuitem = gtk_menu_item_new_with_label
1081 (ac_prefs->account_name
1082 ? ac_prefs->account_name : _("Untitled"));
1083 gtk_widget_show(menuitem);
1084 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1085 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1086 GTK_SIGNAL_FUNC(account_menu_cb),
1092 static void main_window_show_cur_account(MainWindow *mainwin)
1097 ac_name = g_strdup(cur_account
1098 ? (cur_account->account_name
1099 ? cur_account->account_name : _("Untitled"))
1103 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1105 buf = g_strdup(PROG_VERSION);
1106 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1109 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1110 gtk_widget_queue_resize(mainwin->ac_button);
1115 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1117 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1118 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1119 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1121 if (mainwin->type == type) return;
1123 /* remove widgets from those containers */
1124 gtk_widget_ref(folder_wid);
1125 gtk_widget_ref(summary_wid);
1126 gtk_widget_ref(message_wid);
1127 gtkut_container_remove
1128 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1129 gtkut_container_remove
1130 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1131 gtkut_container_remove
1132 (GTK_CONTAINER(message_wid->parent), message_wid);
1134 /* clean containers */
1135 switch (mainwin->type) {
1137 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1139 case SEPARATE_FOLDER:
1140 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1141 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1143 case SEPARATE_MESSAGE:
1144 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1145 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1148 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1149 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1153 gtk_widget_hide(mainwin->window);
1154 main_window_set_widgets(mainwin, type);
1155 gtk_widget_show(mainwin->window);
1157 gtk_widget_unref(folder_wid);
1158 gtk_widget_unref(summary_wid);
1159 gtk_widget_unref(message_wid);
1162 void main_window_get_size(MainWindow *mainwin)
1164 GtkAllocation *allocation;
1166 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1168 prefs_common.summaryview_width = allocation->width;
1170 if (mainwin->summaryview->msg_is_toggled_on)
1171 prefs_common.summaryview_height = allocation->height;
1173 prefs_common.mainview_width = allocation->width;
1175 allocation = &mainwin->window->allocation;
1177 prefs_common.mainview_height = allocation->height;
1178 prefs_common.mainwin_width = allocation->width;
1179 prefs_common.mainwin_height = allocation->height;
1181 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1183 prefs_common.folderview_width = allocation->width;
1184 prefs_common.folderview_height = allocation->height;
1187 void main_window_get_position(MainWindow *mainwin)
1191 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1193 prefs_common.mainview_x = x;
1194 prefs_common.mainview_y = y;
1195 prefs_common.mainwin_x = x;
1196 prefs_common.mainwin_y = y;
1198 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1201 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1204 gboolean hasTrash = 0;
1206 for (list = folder_get_list(); list != NULL; list = list->next) {
1209 folder = list->data;
1210 if (folder->trash) {
1211 hasTrash = (folder->trash->total > 0);
1220 if (alertpanel(_("Empty trash"),
1221 _("Empty all messages in trash?"),
1222 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1224 manage_window_focus_in(mainwin->window, NULL, NULL);
1227 procmsg_empty_trash();
1229 for (list = folder_get_list(); list != NULL; list = list->next) {
1232 folder = list->data;
1233 if (folder->trash && folder->trash->total != 0) {
1234 folder_item_scan(folder->trash);
1235 folderview_update_item(folder->trash, TRUE);
1239 if (mainwin->summaryview->folder_item &&
1240 mainwin->summaryview->folder_item->stype == F_TRASH)
1241 gtk_widget_grab_focus(mainwin->folderview->ctree);
1244 void main_window_add_mailbox(MainWindow *mainwin)
1249 path = input_dialog(_("Add mailbox"),
1250 _("Input the location of mailbox.\n"
1251 "If the existing mailbox is specified, it will be\n"
1252 "scanned automatically."),
1255 if (folder_find_from_path(path)) {
1256 alertpanel_error(_("The mailbox `%s' already exists."), path);
1260 if (!strcmp(path, "Mail"))
1261 folder = folder_new(F_MH, _("Mailbox"), path);
1263 folder = folder_new(F_MH, g_basename(path), path);
1266 if (folder->create_tree(folder) < 0) {
1267 alertpanel_error(_("Creation of the mailbox failed.\n"
1268 "Maybe some files already exist, or you don't have the permission to write there."));
1269 folder_destroy(folder);
1274 folder_set_ui_func(folder, scan_tree_func, mainwin);
1275 folder->scan_tree(folder);
1276 folder_set_ui_func(folder, NULL, NULL);
1278 folderview_set(mainwin->folderview);
1281 void main_window_add_mbox(MainWindow *mainwin)
1287 path = input_dialog(_("Add mbox mailbox"),
1288 _("Input the location of mailbox."),
1293 if (folder_find_from_path(path)) {
1294 alertpanel_error(_("The mailbox `%s' already exists."), path);
1300 if (!strcmp(path, "Mail"))
1301 folder = folder_new(F_MBOX, _("Mailbox"), path);
1305 folder = folder_new(F_MBOX, g_basename(path), path);
1308 if (folder->create_tree(folder) < 0) {
1309 alertpanel_error(_("Creation of the mailbox failed."));
1310 folder_destroy(folder);
1316 item = folder_item_new(folder->name, NULL);
1317 item->folder = folder;
1318 folder->node = g_node_new(item);
1320 folder->create_folder(folder, item, "inbox");
1321 folder->create_folder(folder, item, "outbox");
1322 folder->create_folder(folder, item, "queue");
1323 folder->create_folder(folder, item, "draft");
1324 folder->create_folder(folder, item, "trash");
1326 folderview_set(mainwin->folderview);
1331 M_UNLOCKED = 1 << 0,
1332 M_MSG_EXIST = 1 << 1,
1333 M_TARGET_EXIST = 1 << 2,
1334 M_SINGLE_TARGET_EXIST = 1 << 3,
1336 M_ALLOW_REEDIT = 1 << 5,
1337 M_HAVE_ACCOUNT = 1 << 6,
1338 M_THREADED = 1 << 7,
1339 M_UNTHREADED = 1 << 8,
1341 M_HAVE_NEWS_ACCOUNT = 1 << 10
1344 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1346 SensitiveCond state = 0;
1347 SummarySelection selection;
1348 FolderItem *item = mainwin->summaryview->folder_item;
1349 GList *account_list = account_get_list();
1351 selection = summary_get_selection_type(mainwin->summaryview);
1353 if (mainwin->lock_count == 0)
1354 state |= M_UNLOCKED;
1355 if (selection != SUMMARY_NONE)
1356 state |= M_MSG_EXIST;
1359 state |= M_THREADED;
1361 state |= M_UNTHREADED;
1363 if (selection == SUMMARY_SELECTED_SINGLE ||
1364 selection == SUMMARY_SELECTED_MULTIPLE)
1365 state |= M_TARGET_EXIST;
1366 if (selection == SUMMARY_SELECTED_SINGLE)
1367 state |= M_SINGLE_TARGET_EXIST;
1368 if (item && item->folder->type != F_NEWS)
1370 if (mainwin->summaryview->folder_item &&
1371 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1373 if (selection == SUMMARY_SELECTED_SINGLE &&
1375 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1376 item->stype == F_QUEUE)))
1377 state |= M_ALLOW_REEDIT;
1379 state |= M_HAVE_ACCOUNT;
1381 for ( ; account_list != NULL; account_list = account_list->next) {
1382 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1383 state |= M_HAVE_NEWS_ACCOUNT;
1391 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1393 SensitiveCond state;
1401 {mainwin->get_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1402 {mainwin->getall_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1403 {mainwin->compose_mail_btn, M_HAVE_ACCOUNT},
1404 {mainwin->compose_news_btn, M_HAVE_NEWS_ACCOUNT},
1405 {mainwin->reply_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1406 {mainwin->replyall_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1407 {mainwin->replysender_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1408 {mainwin->fwd_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1409 /* {mainwin->prefs_btn , M_UNLOCKED},
1410 {mainwin->account_btn , M_UNLOCKED}, */
1411 {mainwin->next_btn , M_MSG_EXIST},
1412 {mainwin->delete_btn , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1413 {mainwin->exec_btn , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1417 state = main_window_get_current_state(mainwin);
1419 for (i = 0; entry[i].widget != NULL; i++) {
1420 sensitive = ((entry[i].cond & state) == entry[i].cond);
1421 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1424 activate_compose_button(mainwin,
1425 prefs_common.toolbar_style,
1426 mainwin->compose_btn_type);
1429 void main_window_set_menu_sensitive(MainWindow *mainwin)
1431 GtkItemFactory *ifactory;
1432 SensitiveCond state;
1436 static const struct {
1440 {"/File/Add mailbox..." , M_UNLOCKED},
1441 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1442 {"/File/Rescan folder tree" , M_UNLOCKED},
1443 {"/File/Folder" , M_UNLOCKED},
1444 {"/File/Import mbox file..." , M_UNLOCKED},
1445 {"/File/Export to mbox file...", M_UNLOCKED},
1446 {"/File/Empty trash" , M_UNLOCKED},
1447 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1448 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1449 /* {"/File/Close", M_UNLOCKED},*/
1450 {"/File/Exit" , M_UNLOCKED},
1452 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1453 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1455 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1456 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1457 /* {"/Message/Compose new message" , M_HAVE_ACCOUNT}, */
1458 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1459 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1460 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1461 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1462 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1463 {"/Message/Forward" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1464 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1465 {"/Message/Open in new window" , M_SINGLE_TARGET_EXIST},
1466 {"/Message/Re-edit", M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1467 {"/Message/Move...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1468 {"/Message/Copy...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1469 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1470 {"/Message/Mark" , M_TARGET_EXIST},
1472 {"/Summary/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1473 {"/Summary/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1474 {"/Summary/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1475 {"/Summary/Go to" , M_MSG_EXIST},
1476 {"/Summary/Go to/Prev message" , M_MSG_EXIST},
1477 {"/Summary/Go to/Next message" , M_MSG_EXIST},
1478 {"/Summary/Go to/Next unread message" , M_MSG_EXIST},
1479 {"/Summary/Go to/Prev marked message" , M_MSG_EXIST},
1480 {"/Summary/Go to/Next marked message" , M_MSG_EXIST},
1481 {"/Summary/Go to/Prev labeled message", M_MSG_EXIST},
1482 {"/Summary/Go to/Next labeled message", M_MSG_EXIST},
1483 {"/Summary/Sort" , M_MSG_EXIST},
1484 {"/Summary/Thread view" , M_UNTHREADED},
1485 {"/Summary/Unthread view" , M_THREADED},
1487 {"/Configuration", M_UNLOCKED},
1492 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1493 state = main_window_get_current_state(mainwin);
1495 for (i = 0; entry[i].entry != NULL; i++) {
1496 sensitive = ((entry[i].cond & state) == entry[i].cond);
1497 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1501 void main_window_popup(MainWindow *mainwin)
1507 gdk_window_get_origin(mainwin->window->window, &x, &y);
1508 sx = gdk_screen_width();
1509 sy = gdk_screen_height();
1510 x %= sx; if (x < 0) x = 0;
1511 y %= sy; if (y < 0) y = 0;
1512 gdk_window_move(mainwin->window->window, x, y);
1513 gdk_window_raise(mainwin->window->window);
1514 gdk_window_show(mainwin->window->window);
1516 debug_print("window position: x = %d, y = %d\n", x, y);
1518 switch (mainwin->type) {
1519 case SEPARATE_FOLDER:
1520 widget = mainwin->win.sep_folder.folderwin;
1521 gdk_window_get_origin(widget->window, &x, &y);
1522 x %= sx; if (x < 0) x = 0;
1523 y %= sy; if (y < 0) y = 0;
1524 gdk_window_move(widget->window, x, y);
1525 gdk_window_raise(widget->window);
1527 case SEPARATE_MESSAGE:
1528 widget = mainwin->win.sep_message.messagewin;
1529 gdk_window_get_origin(widget->window, &x, &y);
1530 x %= sx; if (x < 0) x = 0;
1531 y %= sy; if (y < 0) y = 0;
1532 gdk_window_move(widget->window, x, y);
1533 gdk_window_raise(widget->window);
1536 widget = mainwin->win.sep_both.folderwin;
1537 gdk_window_get_origin(widget->window, &x, &y);
1538 x %= sx; if (x < 0) x = 0;
1539 y %= sy; if (y < 0) y = 0;
1540 gdk_window_move(widget->window, x, y);
1541 gdk_window_raise(widget->window);
1542 widget = mainwin->win.sep_both.messagewin;
1543 gdk_window_get_origin(widget->window, &x, &y);
1544 x %= sx; if (x < 0) x = 0;
1545 y %= sy; if (y < 0) y = 0;
1546 gdk_window_move(widget->window, x, y);
1547 gdk_window_raise(widget->window);
1554 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1556 GtkWidget *folderwin = NULL;
1557 GtkWidget *messagewin = NULL;
1560 GtkWidget *vbox_body = mainwin->vbox_body;
1561 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1563 debug_print(_("Setting widgets..."));
1565 /* create separated window(s) if needed */
1566 if (type & SEPARATE_FOLDER) {
1567 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1568 gtk_window_set_title(GTK_WINDOW(folderwin), _("Sylpheed - folder view"));
1569 gtk_window_set_wmclass(GTK_WINDOW(folderwin), "separate folderview", "Sylpheed");
1570 gtk_window_set_policy(GTK_WINDOW(folderwin),
1572 gtk_widget_set_usize(folderwin, -1,
1573 prefs_common.mainview_height);
1574 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1576 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1577 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1580 if (type & SEPARATE_MESSAGE) {
1581 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1582 gtk_window_set_title(GTK_WINDOW(messagewin), _("Sylpheed - message view"));
1583 gtk_window_set_wmclass(GTK_WINDOW(messagewin), "separate messageview", "Sylpheed");
1584 gtk_window_set_policy(GTK_WINDOW(messagewin),
1586 gtk_widget_set_usize
1587 (messagewin, prefs_common.mainview_width,
1588 prefs_common.mainview_height
1589 - prefs_common.summaryview_height
1590 + DEFAULT_HEADERVIEW_HEIGHT);
1591 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1593 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1594 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1600 hpaned = gtk_hpaned_new();
1601 gtk_widget_show(hpaned);
1602 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1603 gtk_paned_add1(GTK_PANED(hpaned),
1604 GTK_WIDGET_PTR(mainwin->folderview));
1606 vpaned = gtk_vpaned_new();
1607 if (mainwin->summaryview->msg_is_toggled_on) {
1608 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1609 gtk_paned_add1(GTK_PANED(vpaned),
1610 GTK_WIDGET_PTR(mainwin->summaryview));
1612 gtk_paned_add2(GTK_PANED(hpaned),
1613 GTK_WIDGET_PTR(mainwin->summaryview));
1614 gtk_widget_ref(vpaned);
1616 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1617 prefs_common.summaryview_width,
1618 prefs_common.summaryview_height);
1619 gtk_paned_add2(GTK_PANED(vpaned),
1620 GTK_WIDGET_PTR(mainwin->messageview));
1621 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1622 prefs_common.mainview_width, -1);
1623 gtk_widget_set_usize(mainwin->window,
1624 prefs_common.folderview_width +
1625 prefs_common.mainview_width,
1626 prefs_common.mainwin_height);
1627 gtk_widget_show_all(vpaned);
1629 menu_set_sensitive(ifactory, "/View/Message view", FALSE);
1630 menu_set_sensitive(ifactory, "/View/Folder tree", FALSE);
1632 mainwin->win.sep_none.hpaned = hpaned;
1633 mainwin->win.sep_none.vpaned = vpaned;
1635 case SEPARATE_FOLDER:
1636 vpaned = gtk_vpaned_new();
1637 if (mainwin->summaryview->msg_is_toggled_on) {
1638 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1640 gtk_paned_add1(GTK_PANED(vpaned),
1641 GTK_WIDGET_PTR(mainwin->summaryview));
1643 gtk_box_pack_start(GTK_BOX(vbox_body),
1644 GTK_WIDGET_PTR(mainwin->summaryview),
1646 gtk_widget_ref(vpaned);
1648 gtk_paned_add2(GTK_PANED(vpaned),
1649 GTK_WIDGET_PTR(mainwin->messageview));
1650 gtk_widget_show_all(vpaned);
1651 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1652 prefs_common.summaryview_width,
1653 prefs_common.summaryview_height);
1654 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1655 prefs_common.mainview_width, -1);
1656 gtk_widget_set_usize(mainwin->window,
1657 prefs_common.mainview_width,
1658 prefs_common.mainview_height);
1660 gtk_container_add(GTK_CONTAINER(folderwin),
1661 GTK_WIDGET_PTR(mainwin->folderview));
1663 menu_set_sensitive(ifactory, "/View/Message view", FALSE);
1664 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1666 mainwin->win.sep_folder.folderwin = folderwin;
1667 mainwin->win.sep_folder.vpaned = vpaned;
1669 gtk_widget_show_all(folderwin);
1671 case SEPARATE_MESSAGE:
1672 hpaned = gtk_hpaned_new();
1673 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1675 gtk_paned_add1(GTK_PANED(hpaned),
1676 GTK_WIDGET_PTR(mainwin->folderview));
1677 gtk_paned_add2(GTK_PANED(hpaned),
1678 GTK_WIDGET_PTR(mainwin->summaryview));
1679 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1680 prefs_common.summaryview_width,
1681 prefs_common.summaryview_height);
1682 gtk_widget_set_usize(mainwin->window,
1683 prefs_common.folderview_width +
1684 prefs_common.mainview_width,
1685 prefs_common.mainwin_height);
1686 gtk_widget_show_all(hpaned);
1687 gtk_container_add(GTK_CONTAINER(messagewin),
1688 GTK_WIDGET_PTR(mainwin->messageview));
1690 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1691 menu_set_sensitive(ifactory, "/View/Folder tree", FALSE);
1693 mainwin->win.sep_message.messagewin = messagewin;
1694 mainwin->win.sep_message.hpaned = hpaned;
1696 gtk_widget_show_all(messagewin);
1699 gtk_box_pack_start(GTK_BOX(vbox_body),
1700 GTK_WIDGET_PTR(mainwin->summaryview),
1702 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1703 prefs_common.summaryview_width,
1704 prefs_common.summaryview_height);
1705 gtk_widget_set_usize(mainwin->window,
1706 prefs_common.mainview_width,
1707 prefs_common.mainwin_height);
1708 gtk_container_add(GTK_CONTAINER(folderwin),
1709 GTK_WIDGET_PTR(mainwin->folderview));
1710 gtk_container_add(GTK_CONTAINER(messagewin),
1711 GTK_WIDGET_PTR(mainwin->messageview));
1713 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1714 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1716 mainwin->win.sep_both.folderwin = folderwin;
1717 mainwin->win.sep_both.messagewin = messagewin;
1719 gtk_widget_show_all(folderwin);
1720 gtk_widget_show_all(messagewin);
1724 mainwin->type = type;
1726 debug_print(_("done.\n"));
1729 static void main_window_toolbar_create(MainWindow *mainwin,
1730 GtkWidget *container)
1733 GtkWidget *icon_wid;
1735 GtkWidget *getall_btn;
1736 GtkWidget *compose_mail_btn;
1737 GtkWidget *compose_news_btn;
1738 GtkWidget *reply_btn;
1739 GtkWidget *replyall_btn;
1740 GtkWidget *replysender_btn;
1742 GtkWidget *send_btn;
1744 GtkWidget *prefs_btn;
1745 GtkWidget *account_btn;
1747 GtkWidget *next_btn;
1748 GtkWidget *delete_btn;
1749 GtkWidget *exec_btn;
1751 GtkTooltips *tooltips;
1753 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1755 gtk_container_add(GTK_CONTAINER(container), toolbar);
1756 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1757 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1758 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1759 GTK_TOOLBAR_SPACE_LINE);
1761 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1762 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1764 _("Get new mail from current account"),
1766 icon_wid, toolbar_inc_cb, mainwin);
1767 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1768 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1770 _("Get new mail from all accounts"),
1776 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1778 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1779 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1781 _("Send queued message(s)"),
1787 /* insert compose mail button widget */
1788 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1789 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1791 _("Compose an email message"),
1794 toolbar_compose_mail_cb,
1797 /* insert compose news button widget */
1798 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1799 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1801 _("Compose a news message"),
1804 toolbar_compose_news_cb,
1807 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1811 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1812 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1814 _("Reply to the message - Right button: more options"),
1820 /* replyall button */
1822 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1823 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1825 _("Reply to all - Right button: more options"),
1828 toolbar_reply_to_all_cb,
1831 /* reply to sender button */
1832 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1833 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1835 _("Reply to sender - Right button: more options"),
1838 toolbar_reply_to_sender_cb,
1841 /* forward button */
1842 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1843 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1845 _("Forward the message - Right button: more options"),
1851 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1853 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1854 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1856 _("Delete the message"),
1862 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1863 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1865 _("Execute marked process"),
1871 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
1872 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1874 _("Next unread message"),
1877 toolbar_next_unread_cb,
1881 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1883 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
1884 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1886 _("Common preference"),
1891 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
1892 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1894 _("Account setting"),
1899 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1900 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1904 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
1905 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
1908 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
1909 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
1912 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
1913 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
1916 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
1917 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
1921 mainwin->toolbar = toolbar;
1922 mainwin->get_btn = get_btn;
1923 mainwin->getall_btn = getall_btn;
1924 mainwin->compose_mail_btn = compose_mail_btn;
1925 mainwin->compose_news_btn = compose_news_btn;
1926 mainwin->reply_btn = reply_btn;
1927 mainwin->replyall_btn = replyall_btn;
1928 mainwin->replysender_btn = replysender_btn;
1929 mainwin->fwd_btn = fwd_btn;
1930 mainwin->send_btn = send_btn;
1932 mainwin->prefs_btn = prefs_btn;
1933 mainwin->account_btn = account_btn;
1935 mainwin->next_btn = next_btn;
1936 mainwin->delete_btn = delete_btn;
1937 mainwin->exec_btn = exec_btn;
1939 gtk_widget_show_all(toolbar);
1942 /* callback functions */
1943 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1945 MainWindow *mainwindow = (MainWindow *) data;
1949 if (event->button == 3) {
1950 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1951 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
1952 menu_button_position, widget,
1953 event->button, event->time);
1957 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
1959 MainWindow *mainwin = (MainWindow *)data;
1961 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
1962 manage_window_focus_in(mainwin->window, NULL, NULL);
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_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1973 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
1974 menu_button_position, widget,
1975 event->button, event->time);
1979 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
1981 MainWindow *mainwin = (MainWindow *)data;
1983 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
1984 manage_window_focus_in(mainwin->window, NULL, NULL);
1987 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1989 MainWindow *mainwindow = (MainWindow *) data;
1990 GtkWidget *replysender_menu, *replysender_item;
1994 if (event->button == 3) {
1995 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1996 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
1997 menu_button_position, widget,
1998 event->button, event->time);
2002 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2004 MainWindow *mainwin = (MainWindow *)data;
2006 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2007 manage_window_focus_in(mainwin->window, NULL, NULL);
2010 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2012 MainWindow *mainwindow = (MainWindow *) data;
2016 if (event->button == 3) {
2017 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2018 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2019 menu_button_position, widget,
2020 event->button, event->time);
2024 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2026 MainWindow *mainwin = (MainWindow *)data;
2028 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2029 manage_window_focus_in(mainwin->window, NULL, NULL);
2032 static void toolbar_inc_cb (GtkWidget *widget,
2035 MainWindow *mainwin = (MainWindow *)data;
2037 inc_mail_cb(mainwin, 0, NULL);
2040 static void toolbar_inc_all_cb (GtkWidget *widget,
2043 MainWindow *mainwin = (MainWindow *)data;
2045 inc_all_account_mail_cb(mainwin, 0, NULL);
2048 static void toolbar_send_cb (GtkWidget *widget,
2051 MainWindow *mainwin = (MainWindow *)data;
2053 send_queue_cb(mainwin, 0, NULL);
2056 static void toolbar_compose_cb (GtkWidget *widget,
2059 MainWindow *mainwin = (MainWindow *)data;
2061 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2062 compose_cb(mainwin, 0, NULL);
2064 compose_news_cb(mainwin, 0, NULL);
2067 static void toolbar_compose_news_cb (GtkWidget *widget,
2070 MainWindow *mainwin = (MainWindow *)data;
2072 compose_news_cb(mainwin, 0, NULL);
2075 static void toolbar_compose_mail_cb (GtkWidget *widget,
2078 MainWindow *mainwin = (MainWindow *)data;
2080 compose_mail_cb(mainwin, 0, NULL);
2083 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2085 MainWindow *mainwin = (MainWindow *)data;
2088 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2089 : COMPOSE_REPLY_WITHOUT_QUOTE,
2093 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2095 MainWindow *mainwin = (MainWindow *)data;
2098 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2099 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2104 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2106 MainWindow *mainwin = (MainWindow *)data;
2109 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2110 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2114 static void toolbar_forward_cb (GtkWidget *widget,
2117 MainWindow *mainwin = (MainWindow *)data;
2119 if (prefs_common.forward_as_attachment)
2120 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2122 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2125 static void toolbar_delete_cb (GtkWidget *widget,
2128 MainWindow *mainwin = (MainWindow *)data;
2130 summary_delete(mainwin->summaryview);
2133 static void toolbar_exec_cb (GtkWidget *widget,
2136 MainWindow *mainwin = (MainWindow *)data;
2138 summary_execute(mainwin->summaryview);
2141 static void toolbar_next_unread_cb (GtkWidget *widget,
2144 MainWindow *mainwin = (MainWindow *)data;
2146 next_unread_cb(mainwin, 0, NULL);
2149 static void toolbar_prefs_cb (GtkWidget *widget,
2152 prefs_common_open();
2155 static void toolbar_account_cb (GtkWidget *widget,
2158 MainWindow *mainwin = (MainWindow *)data;
2160 prefs_account_open_cb(mainwin, 0, NULL);
2163 static void toolbar_account_button_pressed(GtkWidget *widget,
2164 GdkEventButton *event,
2167 MainWindow *mainwin = (MainWindow *)data;
2170 if (event->button != 3) return;
2172 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2173 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2176 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2177 menu_button_position, widget,
2178 event->button, event->time);
2181 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2184 MainWindow *mainwin = (MainWindow *)data;
2188 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2189 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2192 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2193 menu_button_position, widget,
2194 event->button, event->time);
2197 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2199 MainWindow *mainwin = (MainWindow *)data;
2202 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2203 if (!button) return;
2204 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2205 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2206 manage_window_focus_in(mainwin->window, NULL, NULL);
2209 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2212 MainWindow *mainwin = (MainWindow *)data;
2214 if (mainwin->lock_count == 0)
2215 app_exit_cb(data, 0, widget);
2220 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2223 main_window_add_mailbox(mainwin);
2226 static void add_mbox_cb(MainWindow *mainwin, guint action,
2229 main_window_add_mbox(mainwin);
2232 static void update_folderview_cb(MainWindow *mainwin, guint action,
2235 summary_show(mainwin->summaryview, NULL, FALSE);
2236 folderview_update_all();
2239 static void new_folder_cb(MainWindow *mainwin, guint action,
2242 folderview_new_folder(mainwin->folderview);
2245 static void rename_folder_cb(MainWindow *mainwin, guint action,
2248 folderview_rename_folder(mainwin->folderview);
2251 static void delete_folder_cb(MainWindow *mainwin, guint action,
2254 folderview_delete_folder(mainwin->folderview);
2257 static void import_mbox_cb(MainWindow *mainwin, guint action,
2260 import_mbox(mainwin->summaryview->folder_item);
2263 static void export_mbox_cb(MainWindow *mainwin, guint action,
2266 export_mbox(mainwin->summaryview->folder_item);
2269 static void empty_trash_cb(MainWindow *mainwin, guint action,
2272 main_window_empty_trash(mainwin, TRUE);
2275 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2277 summary_save_as(mainwin->summaryview);
2280 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2282 summary_print(mainwin->summaryview);
2285 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2287 if (prefs_common.confirm_on_exit) {
2288 if (alertpanel(_("Exit"), _("Exit this program?"),
2289 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2291 manage_window_focus_in(mainwin->window, NULL, NULL);
2294 app_will_exit(widget, mainwin);
2297 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2300 summary_search(mainwin->summaryview);
2302 message_search(mainwin->messageview);
2305 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2308 switch (mainwin->type) {
2310 case SEPARATE_MESSAGE:
2312 case SEPARATE_FOLDER:
2313 if (GTK_CHECK_MENU_ITEM(widget)->active)
2314 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2316 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2319 if (GTK_CHECK_MENU_ITEM(widget)->active)
2320 gtk_widget_show(mainwin->win.sep_both.folderwin);
2322 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2327 static void toggle_message_cb(MainWindow *mainwin, guint action,
2330 switch (mainwin->type) {
2332 case SEPARATE_FOLDER:
2334 case SEPARATE_MESSAGE:
2335 if (GTK_CHECK_MENU_ITEM(widget)->active)
2336 gtk_widget_show(mainwin->win.sep_message.messagewin);
2338 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2341 if (GTK_CHECK_MENU_ITEM(widget)->active)
2342 gtk_widget_show(mainwin->win.sep_both.messagewin);
2344 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2349 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2352 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2353 mainwin->compose_btn_type);
2354 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2355 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2356 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2357 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2359 switch ((ToolbarStyle)action) {
2361 gtk_widget_hide(mainwin->handlebox);
2363 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2367 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2371 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2376 if (action != TOOLBAR_NONE) {
2377 gtk_widget_show(mainwin->handlebox);
2378 gtk_widget_queue_resize(mainwin->handlebox);
2381 mainwin->toolbar_style = (ToolbarStyle)action;
2382 prefs_common.toolbar_style = (ToolbarStyle)action;
2385 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2388 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2389 gtk_widget_show(mainwin->hbox_stat);
2390 prefs_common.show_statusbar = TRUE;
2392 gtk_widget_hide(mainwin->hbox_stat);
2393 prefs_common.show_statusbar = FALSE;
2397 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2400 MainWindow *mainwin;
2403 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2404 g_return_if_fail(mainwin != NULL);
2406 type = mainwin->type ^ action;
2407 main_window_separation_change(mainwin, type);
2409 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2410 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2413 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2416 addressbook_open(NULL);
2419 static void log_window_show_cb(MainWindow *mainwin, guint action,
2422 log_window_show(mainwin->logwin);
2425 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2430 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2433 inc_all_account_mail(mainwin);
2436 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2440 if (procmsg_send_queue() < 0)
2441 alertpanel_error(_("Some errors occurred while sending queued messages."));
2443 statusbar_pop_all();
2445 for (list = folder_get_list(); list != NULL; list = list->next) {
2448 folder = list->data;
2449 if (folder->queue) {
2450 folder_item_scan(folder->queue);
2451 folderview_update_item(folder->queue, TRUE);
2456 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2458 if (mainwin->summaryview->folder_item) {
2459 if (mainwin->summaryview->folder_item->folder->account != NULL
2460 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2461 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2463 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2469 static void compose_mail_cb(MainWindow *mainwin, guint action,
2476 if (mainwin->summaryview->folder_item) {
2477 ac = mainwin->summaryview->folder_item->folder->account;
2478 if (ac && ac->protocol != A_NNTP) {
2479 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2484 if(cur_account && (cur_account->protocol != A_NNTP)) {
2485 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2489 list = account_get_list();
2490 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2491 ac = (PrefsAccount *) cur->data;
2492 if (ac->protocol != A_NNTP) {
2493 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2499 static void compose_news_cb(MainWindow *mainwin, guint action,
2502 PrefsAccount * ac = NULL;
2506 if (mainwin->summaryview->folder_item) {
2507 ac = mainwin->summaryview->folder_item->folder->account;
2508 if (ac && ac->protocol == A_NNTP) {
2509 compose_new_with_recipient
2510 (ac, mainwin->summaryview->folder_item->path);
2515 list = account_get_list();
2516 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2517 ac = (PrefsAccount *) cur->data;
2518 if (ac->protocol == A_NNTP) {
2525 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2527 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2530 msginfo = gtk_ctree_node_get_row_data
2531 (GTK_CTREE(mainwin->summaryview->ctree),
2532 mainwin->summaryview->selected);
2534 if (!msginfo) return;
2538 compose_reply(msginfo, prefs_common.reply_with_quote,
2541 case COMPOSE_REPLY_WITH_QUOTE:
2542 compose_reply(msginfo, TRUE, FALSE, FALSE);
2544 case COMPOSE_REPLY_WITHOUT_QUOTE:
2545 compose_reply(msginfo, FALSE, FALSE, FALSE);
2547 case COMPOSE_REPLY_TO_SENDER:
2548 compose_reply(msginfo, prefs_common.reply_with_quote,
2551 case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE:
2552 compose_reply(msginfo, TRUE, FALSE, TRUE);
2554 case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE:
2555 compose_reply(msginfo, FALSE, FALSE, TRUE);
2557 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2558 compose_followup_and_reply_to(msginfo,
2559 prefs_common.reply_with_quote,
2562 case COMPOSE_REPLY_TO_ALL:
2563 compose_reply(msginfo, prefs_common.reply_with_quote,
2566 case COMPOSE_REPLY_TO_ALL_WITH_QUOTE:
2567 compose_reply(msginfo, TRUE, TRUE, TRUE);
2569 case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE:
2570 compose_reply(msginfo, FALSE, TRUE, TRUE);
2572 case COMPOSE_FORWARD:
2573 if (prefs_common.forward_as_attachment) {
2574 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, widget);
2577 reply_cb(mainwin, COMPOSE_FORWARD_INLINE, widget);
2581 case COMPOSE_FORWARD_INLINE:
2583 compose_forward(NULL, msginfo, FALSE);
2586 /* if (sel->next) FALL_THROUGH */
2587 case COMPOSE_FORWARD_AS_ATTACH:
2589 GSList *msginfo_list = NULL;
2590 for ( ; sel != NULL; sel = sel->next)
2591 msginfo_list = g_slist_append(msginfo_list,
2592 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2593 GTK_CTREE_NODE(sel->data)));
2594 compose_forward_multiple(NULL, msginfo_list);
2595 g_slist_free(msginfo_list);
2598 case COMPOSE_BOUNCE:
2599 compose_bounce(NULL, msginfo);
2602 g_warning("reply_cb(): invalid action type: %d\n", action);
2605 summary_set_marks_selected(mainwin->summaryview);
2608 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2610 summary_move_to(mainwin->summaryview);
2613 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2615 summary_copy_to(mainwin->summaryview);
2618 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2620 summary_delete(mainwin->summaryview);
2623 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2625 summary_open_msg(mainwin->summaryview);
2628 static void view_source_cb(MainWindow *mainwin, guint action,
2631 summary_view_source(mainwin->summaryview);
2634 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2636 summary_reedit(mainwin->summaryview);
2639 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2641 summary_mark(mainwin->summaryview);
2644 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2646 summary_unmark(mainwin->summaryview);
2649 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2652 summary_mark_as_unread(mainwin->summaryview);
2655 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2658 summary_mark_as_read(mainwin->summaryview);
2661 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2664 summary_mark_all_read(mainwin->summaryview);
2667 static void add_address_cb(MainWindow *mainwin, guint action,
2670 summary_add_address(mainwin->summaryview);
2673 static void set_charset_cb(MainWindow *mainwin, guint action,
2678 str = conv_get_charset_str((CharSet)action);
2679 g_free(prefs_common.force_charset);
2680 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2682 summary_redisplay_msg(mainwin->summaryview);
2684 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2687 static void hide_read_messages (MainWindow *mainwin, guint action,
2690 if (!mainwin->summaryview->folder_item
2691 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2693 summary_toggle_show_read_messages(mainwin->summaryview);
2696 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2698 GtkItemFactory *ifactory;
2700 if (!mainwin->summaryview->folder_item) return;
2702 ifactory = gtk_item_factory_from_widget(widget);
2705 summary_thread_build(mainwin->summaryview);
2706 mainwin->summaryview->folder_item->threaded = TRUE;
2707 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2708 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2710 summary_unthread(mainwin->summaryview);
2711 mainwin->summaryview->folder_item->threaded = FALSE;
2712 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2713 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2717 static void set_display_item_cb(MainWindow *mainwin, guint action,
2720 prefs_summary_column_open();
2723 static void sort_summary_cb(MainWindow *mainwin, guint action,
2726 summary_sort(mainwin->summaryview, (SummarySortType)action);
2729 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2732 summary_attract_by_subject(mainwin->summaryview);
2735 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2738 summary_delete_duplicated(mainwin->summaryview);
2741 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2743 summary_filter(mainwin->summaryview);
2746 static void execute_summary_cb(MainWindow *mainwin, guint action,
2749 summary_execute(mainwin->summaryview);
2752 static void update_summary_cb(MainWindow *mainwin, guint action,
2756 FolderView *folderview = mainwin->folderview;
2758 if (!mainwin->summaryview->folder_item) return;
2759 if (!folderview->opened) return;
2761 folder_update_op_count();
2763 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2764 folderview->opened);
2767 summary_show(mainwin->summaryview, fitem, TRUE);
2770 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2772 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2775 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2777 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2780 static void prev_unread_cb(MainWindow *mainwin, guint action,
2783 summary_select_prev_unread(mainwin->summaryview);
2786 static void next_unread_cb(MainWindow *mainwin, guint action,
2789 summary_select_next_unread(mainwin->summaryview);
2792 static void prev_marked_cb(MainWindow *mainwin, guint action,
2795 summary_select_prev_marked(mainwin->summaryview);
2798 static void next_marked_cb(MainWindow *mainwin, guint action,
2801 summary_select_next_marked(mainwin->summaryview);
2804 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2807 summary_select_prev_labeled(mainwin->summaryview);
2810 static void next_labeled_cb(MainWindow *mainwin, guint action,
2813 summary_select_next_labeled(mainwin->summaryview);
2816 static void goto_folder_cb(MainWindow *mainwin, guint action,
2819 FolderItem *to_folder;
2821 to_folder = foldersel_folder_sel(NULL, NULL);
2824 folderview_select(mainwin->folderview, to_folder);
2827 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2829 messageview_copy_clipboard(mainwin->messageview);
2832 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2834 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2835 summary_select_all(mainwin->summaryview);
2836 else if (mainwin->summaryview->msg_is_toggled_on &&
2837 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2838 messageview_select_all(mainwin->messageview);
2841 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2844 prefs_common_open();
2847 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2850 prefs_filter_open();
2853 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2856 prefs_scoring_open(NULL);
2859 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2862 prefs_filtering_open(NULL);
2865 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2868 prefs_template_open();
2871 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2875 new_account_cb(mainwin, 0, widget);
2877 gboolean prev_default = cur_account->is_default;
2879 prefs_account_open(cur_account);
2880 if (!prev_default && cur_account->is_default)
2881 account_set_as_default(cur_account);
2882 account_save_config_all();
2884 main_window_reflect_prefs_all();
2888 static void new_account_cb(MainWindow *mainwin, guint action,
2891 account_edit_open();
2892 if (!compose_get_compose_list()) account_add();
2895 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2897 cur_account = (PrefsAccount *)data;
2898 main_window_reflect_prefs_all();
2901 static void manual_open_cb(MainWindow *mainwin, guint action,
2904 manual_open((ManualLang)action);
2907 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2909 MainWindow *mainwin = (MainWindow *)data;
2913 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2914 LOCAL_FOLDER(folder)->rootpath,
2918 str = g_strdup_printf(_("Scanning folder %s ..."),
2919 LOCAL_FOLDER(folder)->rootpath);
2921 STATUSBAR_PUSH(mainwin, str);
2922 STATUSBAR_POP(mainwin);
2926 static void activate_compose_button (MainWindow *mainwin,
2928 ComposeButtonType type)
2930 SensitiveCond state = main_window_get_current_state(mainwin);
2932 if (style == TOOLBAR_NONE)
2935 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2936 : mainwin->compose_news_btn);
2937 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2938 : mainwin->compose_mail_btn);
2939 mainwin->compose_btn_type = type;
2942 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2944 if (mainwin->compose_btn_type != compose_btn_type)
2945 activate_compose_button(mainwin,
2946 prefs_common.toolbar_style,