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_popup_closed_cb(GtkMenuShell *menu_shell,
132 static void toolbar_reply_to_all_cb (GtkWidget *widget,
134 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget,
135 GdkEventButton *event,
137 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell,
139 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
141 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
142 GdkEventButton *event,
144 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell,
146 static void toolbar_forward_cb (GtkWidget *widget,
148 static void toolbar_forward_popup_cb (GtkWidget *widget,
149 GdkEventButton *event,
151 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell,
154 static void toolbar_delete_cb (GtkWidget *widget,
156 static void toolbar_exec_cb (GtkWidget *widget,
159 static void toolbar_next_unread_cb (GtkWidget *widget,
162 static void toolbar_prefs_cb (GtkWidget *widget,
164 static void toolbar_account_cb (GtkWidget *widget,
167 static void toolbar_account_button_pressed (GtkWidget *widget,
168 GdkEventButton *event,
170 static void ac_label_button_pressed (GtkWidget *widget,
171 GdkEventButton *event,
173 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
176 static gint main_window_close_cb (GtkWidget *widget,
180 static void add_mailbox_cb (MainWindow *mainwin,
183 static void add_mbox_cb (MainWindow *mainwin,
186 static void update_folderview_cb (MainWindow *mainwin,
189 static void new_folder_cb (MainWindow *mainwin,
192 static void rename_folder_cb (MainWindow *mainwin,
195 static void delete_folder_cb (MainWindow *mainwin,
198 static void import_mbox_cb (MainWindow *mainwin,
201 static void export_mbox_cb (MainWindow *mainwin,
204 static void empty_trash_cb (MainWindow *mainwin,
208 static void save_as_cb (MainWindow *mainwin,
211 static void print_cb (MainWindow *mainwin,
214 static void app_exit_cb (MainWindow *mainwin,
218 static void search_cb (MainWindow *mainwin,
222 static void toggle_folder_cb (MainWindow *mainwin,
225 static void toggle_message_cb (MainWindow *mainwin,
228 static void toggle_toolbar_cb (MainWindow *mainwin,
231 static void toggle_statusbar_cb (MainWindow *mainwin,
234 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
238 static void addressbook_open_cb (MainWindow *mainwin,
241 static void log_window_show_cb (MainWindow *mainwin,
245 static void inc_mail_cb (MainWindow *mainwin,
248 static void inc_all_account_mail_cb (MainWindow *mainwin,
252 static void send_queue_cb (MainWindow *mainwin,
256 static void compose_cb (MainWindow *mainwin,
259 static void compose_mail_cb(MainWindow *mainwin, guint action,
261 static void compose_news_cb(MainWindow *mainwin, guint action,
263 static void reply_cb (MainWindow *mainwin,
267 static void open_msg_cb (MainWindow *mainwin,
271 static void view_source_cb (MainWindow *mainwin,
275 static void reedit_cb (MainWindow *mainwin,
279 static void move_to_cb (MainWindow *mainwin,
282 static void copy_to_cb (MainWindow *mainwin,
285 static void delete_cb (MainWindow *mainwin,
289 static void mark_cb (MainWindow *mainwin,
292 static void unmark_cb (MainWindow *mainwin,
296 static void mark_as_unread_cb (MainWindow *mainwin,
299 static void mark_as_read_cb (MainWindow *mainwin,
302 static void mark_all_read_cb (MainWindow *mainwin,
305 static void add_address_cb (MainWindow *mainwin,
309 static void set_charset_cb (MainWindow *mainwin,
313 static void hide_read_messages (MainWindow *mainwin,
317 static void thread_cb (MainWindow *mainwin,
320 static void set_display_item_cb (MainWindow *mainwin,
323 static void sort_summary_cb (MainWindow *mainwin,
326 static void attract_by_subject_cb(MainWindow *mainwin,
330 static void delete_duplicated_cb (MainWindow *mainwin,
333 static void filter_cb (MainWindow *mainwin,
336 static void execute_summary_cb (MainWindow *mainwin,
339 static void update_summary_cb (MainWindow *mainwin,
343 static void prev_cb (MainWindow *mainwin,
346 static void next_cb (MainWindow *mainwin,
350 static void prev_unread_cb (MainWindow *mainwin,
353 static void next_unread_cb (MainWindow *mainwin,
356 static void prev_marked_cb (MainWindow *mainwin,
359 static void next_marked_cb (MainWindow *mainwin,
362 static void prev_labeled_cb (MainWindow *mainwin,
365 static void next_labeled_cb (MainWindow *mainwin,
369 static void goto_folder_cb (MainWindow *mainwin,
373 static void copy_cb (MainWindow *mainwin,
376 static void allsel_cb (MainWindow *mainwin,
380 static void prefs_common_open_cb (MainWindow *mainwin,
383 static void prefs_filter_open_cb (MainWindow *mainwin,
386 static void prefs_scoring_open_cb (MainWindow *mainwin,
389 static void prefs_filtering_open_cb (MainWindow *mainwin,
392 static void prefs_account_open_cb(MainWindow *mainwin,
395 static void prefs_template_open_cb (MainWindow *mainwin,
398 static void new_account_cb (MainWindow *mainwin,
402 static void account_menu_cb (GtkMenuItem *menuitem,
405 static void manual_open_cb (MainWindow *mainwin,
409 static void scan_tree_func (Folder *folder,
413 static void activate_compose_button (MainWindow *mainwin,
415 ComposeButtonType type);
417 #define SEPARATE_ACTION 667
419 static GtkItemFactoryEntry mainwin_entries[] =
421 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
422 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
423 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
424 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
425 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
426 {N_("/_File/_Folder/Create _new folder..."),
427 NULL, new_folder_cb, 0, NULL},
428 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
429 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
430 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
431 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
432 {N_("/_File/Empty _trash"), NULL, empty_trash_cb, 0, NULL},
433 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
434 {N_("/_File/_Save as..."), NULL, save_as_cb, 0, NULL},
435 {N_("/_File/_Print..."), "<alt>P", print_cb, 0, NULL},
436 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
437 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL},*/
438 {N_("/_File/E_xit"), "<alt>Q", app_exit_cb, 0, NULL},
440 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
441 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
442 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
443 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
444 {N_("/_Edit/_Find in current message"), "<control>F", search_cb, 0, NULL},
445 {N_("/_Edit/_Search folder..."), "<control>S", search_cb, 1, NULL},
447 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
448 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
449 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
450 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
451 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
452 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
453 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
454 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
455 {N_("/_View/_Status bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
456 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
457 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
458 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
459 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
460 {N_("/_View/View _source"), "<control>U", view_source_cb, 0, NULL},
461 {N_("/_View/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
462 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
463 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
464 {N_("/_View/_Code set/_Auto detect"),
465 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
467 #define CODESET_SEPARATOR \
468 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
469 #define CODESET_ACTION(action) \
470 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
472 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
473 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
474 CODESET_ACTION(C_US_ASCII)},
477 {N_("/_View/_Code set/Unicode (_UTF-8)"),
478 CODESET_ACTION(C_UTF_8)},
481 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
482 CODESET_ACTION(C_ISO_8859_1)},
485 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
486 CODESET_ACTION(C_ISO_8859_2)},
488 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
489 CODESET_ACTION(C_ISO_8859_13)},
490 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
491 CODESET_ACTION(C_ISO_8859_4)},
493 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
494 CODESET_ACTION(C_ISO_8859_7)},
496 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
497 CODESET_ACTION(C_ISO_8859_9)},
499 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
500 CODESET_ACTION(C_ISO_8859_5)},
501 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
502 CODESET_ACTION(C_KOI8_R)},
503 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
504 CODESET_ACTION(C_CP1251)},
507 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
508 CODESET_ACTION(C_ISO_2022_JP)},
510 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
511 CODESET_ACTION(C_ISO_2022_JP_2)},
513 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
514 CODESET_ACTION(C_EUC_JP)},
515 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
516 CODESET_ACTION(C_SHIFT_JIS)},
519 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
520 CODESET_ACTION(C_GB2312)},
521 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
522 CODESET_ACTION(C_BIG5)},
523 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
524 CODESET_ACTION(C_EUC_TW)},
525 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
526 CODESET_ACTION(C_ISO_2022_CN)},
528 {N_("/_View/_Code set/Korean (EUC-_KR)"),
529 CODESET_ACTION(C_EUC_KR)},
530 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
531 CODESET_ACTION(C_ISO_2022_KR)},
533 {N_("/_View/_Code set/Thai (TIS-620)"),
534 CODESET_ACTION(C_TIS_620)},
535 {N_("/_View/_Code set/Thai (Windows-874)"),
536 CODESET_ACTION(C_WINDOWS_874)},
539 #undef CODESET_SEPARATOR
540 #undef CODESET_ACTION
542 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
543 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
544 {N_("/_Message/Get from _all accounts"),
545 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
546 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
547 {N_("/_Message/Send queued messa_ges"),
548 NULL, send_queue_cb, 0, NULL},
549 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
550 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
551 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
552 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
553 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
554 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
555 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
556 {N_("/_Message/_Forward"), "<shift><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
557 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
558 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
559 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
560 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
561 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
562 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
563 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
564 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
565 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
566 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
567 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
568 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
569 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
570 {N_("/_Message/_Mark/Mark as rea_d"),
571 NULL, mark_as_read_cb, 0, NULL},
572 {N_("/_Message/_Mark/Mark all read"), NULL, mark_all_read_cb, 0, NULL},
573 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
574 {N_("/_Message/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
576 {N_("/_Summary"), NULL, NULL, 0, "<Branch>"},
577 {N_("/_Summary/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
578 {N_("/_Summary/_Delete duplicated messages"),
579 NULL, delete_duplicated_cb, 0, NULL},
580 {N_("/_Summary/_Filter messages"), NULL, filter_cb, 0, NULL},
581 {N_("/_Summary/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
582 {N_("/_Summary/_Update"), "<alt>U", update_summary_cb, 0, NULL},
583 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
584 {N_("/_Summary/Go _to"), NULL, NULL, 0, "<Branch>"},
585 {N_("/_Summary/Go _to/_Prev message"), NULL, prev_cb, 0, NULL},
586 {N_("/_Summary/Go _to/_Next message"), NULL, next_cb, 0, NULL},
587 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
588 {N_("/_Summary/Go _to/P_rev unread message"),
589 NULL, prev_unread_cb, 0, NULL},
590 {N_("/_Summary/Go _to/N_ext unread message"),
591 NULL, next_unread_cb, 0, NULL},
592 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
593 {N_("/_Summary/Go _to/Prev _marked message"),
594 NULL, prev_marked_cb, 0, NULL},
595 {N_("/_Summary/Go _to/Next m_arked message"),
596 NULL, next_marked_cb, 0, NULL},
597 {N_("/_Summary/Go _to/---"), NULL, NULL, 0, "<Separator>"},
598 {N_("/_Summary/Go _to/Prev _labeled message"),
599 NULL, prev_labeled_cb, 0, NULL},
600 {N_("/_Summary/Go _to/Next la_beled message"),
601 NULL, next_labeled_cb, 0, NULL},
602 {N_("/_Summary/_Go to other folder..."),"<alt>G", goto_folder_cb, 0, NULL},
603 {N_("/_Summary/---"), NULL, NULL, 0, "<Separator>"},
604 {N_("/_Summary/_Sort"), NULL, NULL, 0, "<Branch>"},
605 {N_("/_Summary/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
606 {N_("/_Summary/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
607 {N_("/_Summary/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
608 {N_("/_Summary/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
609 {N_("/_Summary/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
610 {N_("/_Summary/_Sort/Sort by _color label"),
611 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
612 {N_("/_Summary/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
613 {N_("/_Summary/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
614 {N_("/_Summary/_Sort/Sort by a_ttachment"),
615 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
616 {N_("/_Summary/_Sort/---"), NULL, NULL, 0, "<Separator>"},
617 {N_("/_Summary/_Sort/_Attract by subject"),
618 NULL, attract_by_subject_cb, 0, NULL},
619 {N_("/_Summary/_Thread view"), "<control>T", thread_cb, 0, NULL},
620 {N_("/_Summary/Unt_hread view"), "<shift><control>T", thread_cb, 1, NULL},
621 {N_("/_Summary/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
623 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
624 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
625 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
627 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
628 {N_("/_Configuration/_Common preferences..."),
629 NULL, prefs_common_open_cb, 0, NULL},
630 {N_("/_Configuration/_Filter setting..."),
631 NULL, prefs_filter_open_cb, 0, NULL},
632 {N_("/_Configuration/_Scoring ..."),
633 NULL, prefs_scoring_open_cb, 0, NULL},
634 {N_("/_Configuration/_Filtering ..."),
635 NULL, prefs_filtering_open_cb, 0, NULL},
636 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
637 {N_("/_Configuration/_Preferences for current account..."),
638 NULL, prefs_account_open_cb, 0, NULL},
639 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
640 {N_("/_Configuration/Create _new account..."),
641 NULL, new_account_cb, 0, NULL},
642 {N_("/_Configuration/_Edit accounts..."),
643 NULL, account_edit_open, 0, NULL},
644 {N_("/_Configuration/C_hange current account"),
645 NULL, NULL, 0, "<Branch>"},
647 {N_("/_Help"), NULL, NULL, 0, "<LastBranch>"},
648 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
649 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
650 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
651 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
652 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
654 static GtkItemFactoryEntry reply_popup_entries[] =
656 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
657 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
659 static GtkItemFactoryEntry replyall_popup_entries[] =
661 {N_("/Reply to all with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
662 {N_("/_Reply to all without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
664 static GtkItemFactoryEntry replysender_popup_entries[] =
666 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
667 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
669 static GtkItemFactoryEntry fwd_popup_entries[] =
671 {N_("/_Forward message (inline style)"), NULL, reply_cb, COMPOSE_FORWARD_INLINE, NULL},
672 {N_("/Forward message as _attachment"), NULL, reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
676 MainWindow *main_window_create(SeparateType type)
682 GtkWidget *handlebox;
683 GtkWidget *vbox_body;
684 GtkWidget *hbox_stat;
685 GtkWidget *statusbar;
686 GtkWidget *progressbar;
687 GtkWidget *statuslabel;
688 GtkWidget *ac_button;
691 FolderView *folderview;
692 SummaryView *summaryview;
693 MessageView *messageview;
694 GdkColormap *colormap;
697 guint n_menu_entries;
698 GtkItemFactory *ifactory;
701 GtkWidget *compose_popup;
702 GtkWidget *reply_popup;
703 GtkWidget *replyall_popup;
704 GtkWidget *replysender_popup;
705 GtkWidget *fwd_popup;
708 debug_print(_("Creating main window...\n"));
709 mainwin = g_new0(MainWindow, 1);
712 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
713 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
714 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
715 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
716 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
717 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
718 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
719 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
720 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
722 gtk_widget_realize(window);
723 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
725 gtkut_widget_set_app_icon(window);
727 vbox = gtk_vbox_new(FALSE, 0);
728 gtk_widget_show(vbox);
729 gtk_container_add(GTK_CONTAINER(window), vbox);
732 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
733 menubar = menubar_create(window, mainwin_entries,
734 n_menu_entries, "<Main>", mainwin);
735 gtk_widget_show(menubar);
736 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
738 handlebox = gtk_handle_box_new();
739 gtk_widget_show(handlebox);
740 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
742 /* create the popup menus for the reply buttons specials */
743 n_menu_entries = sizeof(reply_popup_entries) /
744 sizeof(reply_popup_entries[0]);
745 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
746 "<ReplyPopup>", mainwin);
747 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
748 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
749 n_menu_entries = sizeof(replyall_popup_entries) /
750 sizeof(replyall_popup_entries[0]);
751 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
752 "<ReplyAllPopup>", mainwin);
753 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
754 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
755 n_menu_entries = sizeof(replysender_popup_entries) /
756 sizeof(replysender_popup_entries[0]);
757 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
758 "<ReplySenderPopup>", mainwin);
759 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
760 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
761 /* create the popup menu for the forward button */
762 n_menu_entries = sizeof(fwd_popup_entries) /
763 sizeof(fwd_popup_entries[0]);
764 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
765 "<ForwardPopup>", mainwin);
766 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
767 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
769 main_window_toolbar_create(mainwin, handlebox);
771 /* vbox that contains body */
772 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
773 gtk_widget_show(vbox_body);
774 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
775 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
777 hbox_stat = gtk_hbox_new(FALSE, 2);
778 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
780 statusbar = statusbar_create();
781 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
783 progressbar = gtk_progress_bar_new();
784 gtk_widget_set_usize(progressbar, 120, 1);
785 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
787 statuslabel = gtk_label_new("");
788 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
790 ac_button = gtk_button_new();
791 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
792 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
793 gtk_widget_set_usize(ac_button, -1, 1);
794 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
795 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
796 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
798 ac_label = gtk_label_new("");
799 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
801 gtk_widget_show_all(hbox_stat);
804 mainwin->folderview = folderview = folderview_create();
805 mainwin->summaryview = summaryview = summary_create();
806 mainwin->messageview = messageview = messageview_create();
807 mainwin->headerwin = header_window_create();
808 mainwin->logwin = log_window_create();
810 folderview->mainwin = mainwin;
811 folderview->summaryview = summaryview;
813 summaryview->mainwin = mainwin;
814 summaryview->folderview = folderview;
815 summaryview->messageview = messageview;
816 summaryview->headerwin = mainwin->headerwin;
817 summaryview->window = window;
819 messageview->mainwin = mainwin;
821 mainwin->window = window;
822 mainwin->vbox = vbox;
823 mainwin->menubar = menubar;
824 mainwin->handlebox = handlebox;
825 mainwin->vbox_body = vbox_body;
826 mainwin->hbox_stat = hbox_stat;
827 mainwin->statusbar = statusbar;
828 mainwin->progressbar = progressbar;
829 mainwin->statuslabel = statuslabel;
830 mainwin->ac_button = ac_button;
831 mainwin->ac_label = ac_label;
832 mainwin->reply_popup = reply_popup;
833 mainwin->replyall_popup = replyall_popup;
834 mainwin->replysender_popup = replysender_popup;
835 mainwin->fwd_popup = fwd_popup;
837 /* set context IDs for status bar */
838 mainwin->mainwin_cid = gtk_statusbar_get_context_id
839 (GTK_STATUSBAR(statusbar), "Main Window");
840 mainwin->folderview_cid = gtk_statusbar_get_context_id
841 (GTK_STATUSBAR(statusbar), "Folder View");
842 mainwin->summaryview_cid = gtk_statusbar_get_context_id
843 (GTK_STATUSBAR(statusbar), "Summary View");
845 /* allocate colors for summary view and folder view */
846 summaryview->color_marked.red = summaryview->color_marked.green = 0;
847 summaryview->color_marked.blue = (guint16)65535;
849 summaryview->color_dim.red = summaryview->color_dim.green =
850 summaryview->color_dim.blue = COLOR_DIM;
852 folderview->color_new.red = (guint16)55000;
853 folderview->color_new.green = folderview->color_new.blue = 15000;
855 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
856 &folderview->color_op);
858 summaryview->color_important.red = 0;
859 summaryview->color_marked.green = 0;
860 summaryview->color_important.blue = (guint16)65535;
862 color[0] = summaryview->color_marked;
863 color[1] = summaryview->color_dim;
864 color[2] = folderview->color_new;
865 color[3] = folderview->color_op;
867 colormap = gdk_window_get_colormap(window->window);
868 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
869 for (i = 0; i < 4; i++) {
870 if (success[i] == FALSE)
871 g_warning(_("MainWindow: color allocation %d failed\n"), i);
874 debug_print(_("done.\n"));
876 main_window_set_widgets(mainwin, type);
879 ifactory = gtk_item_factory_from_widget(menubar);
880 menuitem = gtk_item_factory_get_item
881 (ifactory, "/View/Code set/Auto detect");
882 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
884 switch (prefs_common.toolbar_style) {
886 menuitem = gtk_item_factory_get_item
887 (ifactory, "/View/Toolbar/None");
890 menuitem = gtk_item_factory_get_item
891 (ifactory, "/View/Toolbar/Icon");
894 menuitem = gtk_item_factory_get_item
895 (ifactory, "/View/Toolbar/Text");
898 menuitem = gtk_item_factory_get_item
899 (ifactory, "/View/Toolbar/Icon and text");
901 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
903 gtk_widget_hide(mainwin->hbox_stat);
904 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
905 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
906 prefs_common.show_statusbar);
908 /* Message view and Folder tree are always shown at startup
909 * make that in the menu visible */
910 menuitem = gtk_item_factory_get_item(ifactory, "/View/Message view");
911 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
912 menuitem = gtk_item_factory_get_item(ifactory, "/View/Folder tree");
913 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
915 /* set the check of the SEPARATE_xxx menu items. we also need the main window
916 * as a property and pass the action type to the callback */
917 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
919 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
920 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
921 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
922 GUINT_TO_POINTER(SEPARATE_FOLDER));
924 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
926 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
927 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
928 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
929 GUINT_TO_POINTER(SEPARATE_MESSAGE));
932 menu_set_sensitive(ifactory, "/Summary/Thread view",
933 prefs_common.enable_thread ? FALSE : TRUE);
934 menu_set_sensitive(ifactory, "/Summary/Unthread view",
935 prefs_common.enable_thread ? TRUE : FALSE);
937 /*main_window_set_thread_option(mainwin);*/
940 /* set account selection menu */
941 ac_menu = gtk_item_factory_get_widget
942 (ifactory, "/Configuration/Change current account");
943 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
944 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
945 mainwin->ac_menu = ac_menu;
947 main_window_set_toolbar_sensitive(mainwin);
949 /* show main window */
950 gtk_widget_set_uposition(mainwin->window,
951 prefs_common.mainwin_x,
952 prefs_common.mainwin_y);
953 gtk_widget_set_usize(window, prefs_common.mainwin_width,
954 prefs_common.mainwin_height);
956 gtk_widget_show(mainwin->window);
958 /* initialize views */
959 folderview_init(folderview);
960 summary_init(summaryview);
961 messageview_init(messageview);
962 header_window_init(mainwin->headerwin);
963 log_window_init(mainwin->logwin);
966 mainwin->lock_count = 0;
967 mainwin->cursor_count = 0;
970 watch_cursor = gdk_cursor_new(GDK_WATCH);
972 mainwin_list = g_list_append(mainwin_list, mainwin);
977 void main_window_cursor_wait(MainWindow *mainwin)
980 if (mainwin->cursor_count == 0)
981 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
983 mainwin->cursor_count++;
988 void main_window_cursor_normal(MainWindow *mainwin)
990 if (mainwin->cursor_count)
991 mainwin->cursor_count--;
993 if (mainwin->cursor_count == 0)
994 gdk_window_set_cursor(mainwin->window->window, NULL);
999 /* lock / unlock the user-interface */
1000 void main_window_lock(MainWindow *mainwin)
1002 if (mainwin->lock_count == 0)
1003 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1005 mainwin->lock_count++;
1007 main_window_set_menu_sensitive(mainwin);
1008 main_window_set_toolbar_sensitive(mainwin);
1011 void main_window_unlock(MainWindow *mainwin)
1013 if (mainwin->lock_count)
1014 mainwin->lock_count--;
1016 main_window_set_menu_sensitive(mainwin);
1017 main_window_set_toolbar_sensitive(mainwin);
1019 if (mainwin->lock_count == 0)
1020 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1023 void main_window_reflect_prefs_all(void)
1026 MainWindow *mainwin;
1028 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1029 mainwin = (MainWindow *)cur->data;
1031 main_window_show_cur_account(mainwin);
1032 main_window_set_menu_sensitive(mainwin);
1033 main_window_set_toolbar_sensitive(mainwin);
1035 if (prefs_common.immediate_exec)
1036 gtk_widget_hide(mainwin->exec_btn);
1038 gtk_widget_show(mainwin->exec_btn);
1040 summary_redisplay_msg(mainwin->summaryview);
1041 headerview_set_visibility(mainwin->messageview->headerview,
1042 prefs_common.display_header_pane);
1046 void main_window_set_summary_column(void)
1049 MainWindow *mainwin;
1051 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1052 mainwin = (MainWindow *)cur->data;
1053 summary_set_column_order(mainwin->summaryview);
1057 void main_window_set_account_menu(GList *account_list)
1059 GList *cur, *cur_ac, *cur_item;
1060 GtkWidget *menuitem;
1061 MainWindow *mainwin;
1062 PrefsAccount *ac_prefs;
1064 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1065 mainwin = (MainWindow *)cur->data;
1067 /* destroy all previous menu item */
1068 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1069 while (cur_item != NULL) {
1070 GList *next = cur_item->next;
1071 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1075 for (cur_ac = account_list; cur_ac != NULL;
1076 cur_ac = cur_ac->next) {
1077 ac_prefs = (PrefsAccount *)cur_ac->data;
1079 menuitem = gtk_menu_item_new_with_label
1080 (ac_prefs->account_name
1081 ? ac_prefs->account_name : _("Untitled"));
1082 gtk_widget_show(menuitem);
1083 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1084 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1085 GTK_SIGNAL_FUNC(account_menu_cb),
1091 static void main_window_show_cur_account(MainWindow *mainwin)
1096 ac_name = g_strdup(cur_account
1097 ? (cur_account->account_name
1098 ? cur_account->account_name : _("Untitled"))
1102 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1104 buf = g_strdup(PROG_VERSION);
1105 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1108 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1109 gtk_widget_queue_resize(mainwin->ac_button);
1114 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1116 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1117 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1118 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1120 if (mainwin->type == type) return;
1122 /* remove widgets from those containers */
1123 gtk_widget_ref(folder_wid);
1124 gtk_widget_ref(summary_wid);
1125 gtk_widget_ref(message_wid);
1126 gtkut_container_remove
1127 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1128 gtkut_container_remove
1129 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1130 gtkut_container_remove
1131 (GTK_CONTAINER(message_wid->parent), message_wid);
1133 /* clean containers */
1134 switch (mainwin->type) {
1136 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1138 case SEPARATE_FOLDER:
1139 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1140 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1142 case SEPARATE_MESSAGE:
1143 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1144 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1147 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1148 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1152 gtk_widget_hide(mainwin->window);
1153 main_window_set_widgets(mainwin, type);
1154 gtk_widget_show(mainwin->window);
1156 gtk_widget_unref(folder_wid);
1157 gtk_widget_unref(summary_wid);
1158 gtk_widget_unref(message_wid);
1161 void main_window_get_size(MainWindow *mainwin)
1163 GtkAllocation *allocation;
1165 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1167 prefs_common.summaryview_width = allocation->width;
1169 if (mainwin->summaryview->msg_is_toggled_on)
1170 prefs_common.summaryview_height = allocation->height;
1172 prefs_common.mainview_width = allocation->width;
1174 allocation = &mainwin->window->allocation;
1176 prefs_common.mainview_height = allocation->height;
1177 prefs_common.mainwin_width = allocation->width;
1178 prefs_common.mainwin_height = allocation->height;
1180 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1182 prefs_common.folderview_width = allocation->width;
1183 prefs_common.folderview_height = allocation->height;
1186 void main_window_get_position(MainWindow *mainwin)
1190 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1192 prefs_common.mainview_x = x;
1193 prefs_common.mainview_y = y;
1194 prefs_common.mainwin_x = x;
1195 prefs_common.mainwin_y = y;
1197 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1200 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1203 gboolean hasTrash = 0;
1205 for (list = folder_get_list(); list != NULL; list = list->next) {
1208 folder = list->data;
1209 if (folder->trash) {
1210 hasTrash = (folder->trash->total > 0);
1219 if (alertpanel(_("Empty trash"),
1220 _("Empty all messages in trash?"),
1221 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1223 manage_window_focus_in(mainwin->window, NULL, NULL);
1226 procmsg_empty_trash();
1228 for (list = folder_get_list(); list != NULL; list = list->next) {
1231 folder = list->data;
1232 if (folder->trash && folder->trash->total != 0) {
1233 folder_item_scan(folder->trash);
1234 folderview_update_item(folder->trash, TRUE);
1238 if (mainwin->summaryview->folder_item &&
1239 mainwin->summaryview->folder_item->stype == F_TRASH)
1240 gtk_widget_grab_focus(mainwin->folderview->ctree);
1243 void main_window_add_mailbox(MainWindow *mainwin)
1248 path = input_dialog(_("Add mailbox"),
1249 _("Input the location of mailbox.\n"
1250 "If the existing mailbox is specified, it will be\n"
1251 "scanned automatically."),
1254 if (folder_find_from_path(path)) {
1255 alertpanel_error(_("The mailbox `%s' already exists."), path);
1259 if (!strcmp(path, "Mail"))
1260 folder = folder_new(F_MH, _("Mailbox"), path);
1262 folder = folder_new(F_MH, g_basename(path), path);
1265 if (folder->create_tree(folder) < 0) {
1266 alertpanel_error(_("Creation of the mailbox failed.\n"
1267 "Maybe some files already exist, or you don't have the permission to write there."));
1268 folder_destroy(folder);
1273 folder_set_ui_func(folder, scan_tree_func, mainwin);
1274 folder->scan_tree(folder);
1275 folder_set_ui_func(folder, NULL, NULL);
1277 folderview_set(mainwin->folderview);
1280 void main_window_add_mbox(MainWindow *mainwin)
1286 path = input_dialog(_("Add mbox mailbox"),
1287 _("Input the location of mailbox."),
1292 if (folder_find_from_path(path)) {
1293 alertpanel_error(_("The mailbox `%s' already exists."), path);
1299 if (!strcmp(path, "Mail"))
1300 folder = folder_new(F_MBOX, _("Mailbox"), path);
1304 folder = folder_new(F_MBOX, g_basename(path), path);
1307 if (folder->create_tree(folder) < 0) {
1308 alertpanel_error(_("Creation of the mailbox failed."));
1309 folder_destroy(folder);
1315 item = folder_item_new(folder->name, NULL);
1316 item->folder = folder;
1317 folder->node = g_node_new(item);
1319 folder->create_folder(folder, item, "inbox");
1320 folder->create_folder(folder, item, "outbox");
1321 folder->create_folder(folder, item, "queue");
1322 folder->create_folder(folder, item, "draft");
1323 folder->create_folder(folder, item, "trash");
1325 folderview_set(mainwin->folderview);
1330 M_UNLOCKED = 1 << 0,
1331 M_MSG_EXIST = 1 << 1,
1332 M_TARGET_EXIST = 1 << 2,
1333 M_SINGLE_TARGET_EXIST = 1 << 3,
1335 M_ALLOW_REEDIT = 1 << 5,
1336 M_HAVE_ACCOUNT = 1 << 6,
1337 M_THREADED = 1 << 7,
1338 M_UNTHREADED = 1 << 8,
1340 M_HAVE_NEWS_ACCOUNT = 1 << 10
1343 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1345 SensitiveCond state = 0;
1346 SummarySelection selection;
1347 FolderItem *item = mainwin->summaryview->folder_item;
1348 GList *account_list = account_get_list();
1350 selection = summary_get_selection_type(mainwin->summaryview);
1352 if (mainwin->lock_count == 0)
1353 state |= M_UNLOCKED;
1354 if (selection != SUMMARY_NONE)
1355 state |= M_MSG_EXIST;
1358 state |= M_THREADED;
1360 state |= M_UNTHREADED;
1362 if (selection == SUMMARY_SELECTED_SINGLE ||
1363 selection == SUMMARY_SELECTED_MULTIPLE)
1364 state |= M_TARGET_EXIST;
1365 if (selection == SUMMARY_SELECTED_SINGLE)
1366 state |= M_SINGLE_TARGET_EXIST;
1367 if (item && item->folder->type != F_NEWS)
1369 if (mainwin->summaryview->folder_item &&
1370 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1372 if (selection == SUMMARY_SELECTED_SINGLE &&
1374 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1375 item->stype == F_QUEUE)))
1376 state |= M_ALLOW_REEDIT;
1378 state |= M_HAVE_ACCOUNT;
1380 for ( ; account_list != NULL; account_list = account_list->next) {
1381 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1382 state |= M_HAVE_NEWS_ACCOUNT;
1390 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1392 SensitiveCond state;
1400 {mainwin->get_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1401 {mainwin->getall_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1402 {mainwin->compose_mail_btn, M_HAVE_ACCOUNT},
1403 {mainwin->compose_news_btn, M_HAVE_NEWS_ACCOUNT},
1404 {mainwin->reply_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1405 {mainwin->replyall_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1406 {mainwin->replysender_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1407 {mainwin->fwd_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1408 /* {mainwin->prefs_btn , M_UNLOCKED},
1409 {mainwin->account_btn , M_UNLOCKED}, */
1410 {mainwin->next_btn , M_MSG_EXIST},
1411 {mainwin->delete_btn , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1412 {mainwin->exec_btn , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1416 state = main_window_get_current_state(mainwin);
1418 for (i = 0; entry[i].widget != NULL; i++) {
1419 sensitive = ((entry[i].cond & state) == entry[i].cond);
1420 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1423 activate_compose_button(mainwin,
1424 prefs_common.toolbar_style,
1425 mainwin->compose_btn_type);
1428 void main_window_set_menu_sensitive(MainWindow *mainwin)
1430 GtkItemFactory *ifactory;
1431 SensitiveCond state;
1435 static const struct {
1439 {"/File/Add mailbox..." , M_UNLOCKED},
1440 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1441 {"/File/Rescan folder tree" , M_UNLOCKED},
1442 {"/File/Folder" , M_UNLOCKED},
1443 {"/File/Import mbox file..." , M_UNLOCKED},
1444 {"/File/Export to mbox file...", M_UNLOCKED},
1445 {"/File/Empty trash" , M_UNLOCKED},
1446 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1447 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1448 /* {"/File/Close", M_UNLOCKED},*/
1449 {"/File/Exit" , M_UNLOCKED},
1451 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1452 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1454 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1455 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1456 /* {"/Message/Compose new message" , M_HAVE_ACCOUNT}, */
1457 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1458 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1459 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1460 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1461 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1462 {"/Message/Forward" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1463 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1464 {"/Message/Open in new window" , M_SINGLE_TARGET_EXIST},
1465 {"/Message/Re-edit", M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1466 {"/Message/Move...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1467 {"/Message/Copy...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1468 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1469 {"/Message/Mark" , M_TARGET_EXIST},
1471 {"/Summary/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1472 {"/Summary/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1473 {"/Summary/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1474 {"/Summary/Go to" , M_MSG_EXIST},
1475 {"/Summary/Go to/Prev message" , M_MSG_EXIST},
1476 {"/Summary/Go to/Next message" , M_MSG_EXIST},
1477 {"/Summary/Go to/Next unread message" , M_MSG_EXIST},
1478 {"/Summary/Go to/Prev marked message" , M_MSG_EXIST},
1479 {"/Summary/Go to/Next marked message" , M_MSG_EXIST},
1480 {"/Summary/Go to/Prev labeled message", M_MSG_EXIST},
1481 {"/Summary/Go to/Next labeled message", M_MSG_EXIST},
1482 {"/Summary/Sort" , M_MSG_EXIST},
1483 {"/Summary/Thread view" , M_UNTHREADED},
1484 {"/Summary/Unthread view" , M_THREADED},
1486 {"/Configuration", M_UNLOCKED},
1491 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1492 state = main_window_get_current_state(mainwin);
1494 for (i = 0; entry[i].entry != NULL; i++) {
1495 sensitive = ((entry[i].cond & state) == entry[i].cond);
1496 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1500 void main_window_popup(MainWindow *mainwin)
1506 gdk_window_get_origin(mainwin->window->window, &x, &y);
1507 sx = gdk_screen_width();
1508 sy = gdk_screen_height();
1509 x %= sx; if (x < 0) x = 0;
1510 y %= sy; if (y < 0) y = 0;
1511 gdk_window_move(mainwin->window->window, x, y);
1512 gdk_window_raise(mainwin->window->window);
1513 gdk_window_show(mainwin->window->window);
1515 debug_print("window position: x = %d, y = %d\n", x, y);
1517 switch (mainwin->type) {
1518 case SEPARATE_FOLDER:
1519 widget = mainwin->win.sep_folder.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);
1526 case SEPARATE_MESSAGE:
1527 widget = mainwin->win.sep_message.messagewin;
1528 gdk_window_get_origin(widget->window, &x, &y);
1529 x %= sx; if (x < 0) x = 0;
1530 y %= sy; if (y < 0) y = 0;
1531 gdk_window_move(widget->window, x, y);
1532 gdk_window_raise(widget->window);
1535 widget = mainwin->win.sep_both.folderwin;
1536 gdk_window_get_origin(widget->window, &x, &y);
1537 x %= sx; if (x < 0) x = 0;
1538 y %= sy; if (y < 0) y = 0;
1539 gdk_window_move(widget->window, x, y);
1540 gdk_window_raise(widget->window);
1541 widget = mainwin->win.sep_both.messagewin;
1542 gdk_window_get_origin(widget->window, &x, &y);
1543 x %= sx; if (x < 0) x = 0;
1544 y %= sy; if (y < 0) y = 0;
1545 gdk_window_move(widget->window, x, y);
1546 gdk_window_raise(widget->window);
1553 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1555 GtkWidget *folderwin = NULL;
1556 GtkWidget *messagewin = NULL;
1559 GtkWidget *vbox_body = mainwin->vbox_body;
1560 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1562 debug_print(_("Setting widgets..."));
1564 /* create separated window(s) if needed */
1565 if (type & SEPARATE_FOLDER) {
1566 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1567 gtk_window_set_title(GTK_WINDOW(folderwin), _("Sylpheed - folder view"));
1568 gtk_window_set_wmclass(GTK_WINDOW(folderwin), "separate folderview", "Sylpheed");
1569 gtk_window_set_policy(GTK_WINDOW(folderwin),
1571 gtk_widget_set_usize(folderwin, -1,
1572 prefs_common.mainview_height);
1573 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1575 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1576 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1579 if (type & SEPARATE_MESSAGE) {
1580 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1581 gtk_window_set_title(GTK_WINDOW(messagewin), _("Sylpheed - message view"));
1582 gtk_window_set_wmclass(GTK_WINDOW(messagewin), "separate messageview", "Sylpheed");
1583 gtk_window_set_policy(GTK_WINDOW(messagewin),
1585 gtk_widget_set_usize
1586 (messagewin, prefs_common.mainview_width,
1587 prefs_common.mainview_height
1588 - prefs_common.summaryview_height
1589 + DEFAULT_HEADERVIEW_HEIGHT);
1590 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1592 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1593 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1599 hpaned = gtk_hpaned_new();
1600 gtk_widget_show(hpaned);
1601 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1602 gtk_paned_add1(GTK_PANED(hpaned),
1603 GTK_WIDGET_PTR(mainwin->folderview));
1605 vpaned = gtk_vpaned_new();
1606 if (mainwin->summaryview->msg_is_toggled_on) {
1607 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1608 gtk_paned_add1(GTK_PANED(vpaned),
1609 GTK_WIDGET_PTR(mainwin->summaryview));
1611 gtk_paned_add2(GTK_PANED(hpaned),
1612 GTK_WIDGET_PTR(mainwin->summaryview));
1613 gtk_widget_ref(vpaned);
1615 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1616 prefs_common.summaryview_width,
1617 prefs_common.summaryview_height);
1618 gtk_paned_add2(GTK_PANED(vpaned),
1619 GTK_WIDGET_PTR(mainwin->messageview));
1620 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1621 prefs_common.mainview_width, -1);
1622 gtk_widget_set_usize(mainwin->window,
1623 prefs_common.folderview_width +
1624 prefs_common.mainview_width,
1625 prefs_common.mainwin_height);
1626 gtk_widget_show_all(vpaned);
1628 menu_set_sensitive(ifactory, "/View/Message view", FALSE);
1629 menu_set_sensitive(ifactory, "/View/Folder tree", FALSE);
1631 mainwin->win.sep_none.hpaned = hpaned;
1632 mainwin->win.sep_none.vpaned = vpaned;
1634 case SEPARATE_FOLDER:
1635 vpaned = gtk_vpaned_new();
1636 if (mainwin->summaryview->msg_is_toggled_on) {
1637 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1639 gtk_paned_add1(GTK_PANED(vpaned),
1640 GTK_WIDGET_PTR(mainwin->summaryview));
1642 gtk_box_pack_start(GTK_BOX(vbox_body),
1643 GTK_WIDGET_PTR(mainwin->summaryview),
1645 gtk_widget_ref(vpaned);
1647 gtk_paned_add2(GTK_PANED(vpaned),
1648 GTK_WIDGET_PTR(mainwin->messageview));
1649 gtk_widget_show_all(vpaned);
1650 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1651 prefs_common.summaryview_width,
1652 prefs_common.summaryview_height);
1653 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1654 prefs_common.mainview_width, -1);
1655 gtk_widget_set_usize(mainwin->window,
1656 prefs_common.mainview_width,
1657 prefs_common.mainview_height);
1659 gtk_container_add(GTK_CONTAINER(folderwin),
1660 GTK_WIDGET_PTR(mainwin->folderview));
1662 menu_set_sensitive(ifactory, "/View/Message view", FALSE);
1663 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1665 mainwin->win.sep_folder.folderwin = folderwin;
1666 mainwin->win.sep_folder.vpaned = vpaned;
1668 gtk_widget_show_all(folderwin);
1670 case SEPARATE_MESSAGE:
1671 hpaned = gtk_hpaned_new();
1672 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1674 gtk_paned_add1(GTK_PANED(hpaned),
1675 GTK_WIDGET_PTR(mainwin->folderview));
1676 gtk_paned_add2(GTK_PANED(hpaned),
1677 GTK_WIDGET_PTR(mainwin->summaryview));
1678 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1679 prefs_common.summaryview_width,
1680 prefs_common.summaryview_height);
1681 gtk_widget_set_usize(mainwin->window,
1682 prefs_common.folderview_width +
1683 prefs_common.mainview_width,
1684 prefs_common.mainwin_height);
1685 gtk_widget_show_all(hpaned);
1686 gtk_container_add(GTK_CONTAINER(messagewin),
1687 GTK_WIDGET_PTR(mainwin->messageview));
1689 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1690 menu_set_sensitive(ifactory, "/View/Folder tree", FALSE);
1692 mainwin->win.sep_message.messagewin = messagewin;
1693 mainwin->win.sep_message.hpaned = hpaned;
1695 gtk_widget_show_all(messagewin);
1698 gtk_box_pack_start(GTK_BOX(vbox_body),
1699 GTK_WIDGET_PTR(mainwin->summaryview),
1701 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1702 prefs_common.summaryview_width,
1703 prefs_common.summaryview_height);
1704 gtk_widget_set_usize(mainwin->window,
1705 prefs_common.mainview_width,
1706 prefs_common.mainwin_height);
1707 gtk_container_add(GTK_CONTAINER(folderwin),
1708 GTK_WIDGET_PTR(mainwin->folderview));
1709 gtk_container_add(GTK_CONTAINER(messagewin),
1710 GTK_WIDGET_PTR(mainwin->messageview));
1712 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1713 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1715 mainwin->win.sep_both.folderwin = folderwin;
1716 mainwin->win.sep_both.messagewin = messagewin;
1718 gtk_widget_show_all(folderwin);
1719 gtk_widget_show_all(messagewin);
1723 mainwin->type = type;
1725 debug_print(_("done.\n"));
1728 #include "pixmaps/stock_mail_receive.xpm"
1729 #include "pixmaps/stock_mail_receive_all.xpm"
1730 #include "pixmaps/stock_mail_compose.xpm"
1731 #include "pixmaps/stock_news_compose.xpm"
1732 #include "pixmaps/stock_mail_reply.xpm"
1733 #include "pixmaps/stock_mail_reply_to_all.xpm"
1734 #include "pixmaps/stock_mail_reply_to_author.xpm"
1735 #include "pixmaps/stock_mail_forward.xpm"
1736 #include "pixmaps/stock_mail_send.xpm"
1737 #include "pixmaps/stock_preferences.xpm"
1738 #include "pixmaps/stock_properties.xpm"
1739 #include "pixmaps/stock_down_arrow.xpm"
1740 #include "pixmaps/stock_close.xpm"
1741 #include "pixmaps/stock_exec.xpm"
1743 #define CREATE_TOOLBAR_ICON(xpm_d) \
1745 icon = gdk_pixmap_create_from_xpm_d(container->window, &mask, \
1746 &container->style->white, \
1748 icon_wid = gtk_pixmap_new(icon, mask); \
1751 static void main_window_toolbar_create(MainWindow *mainwin,
1752 GtkWidget *container)
1757 GtkWidget *icon_wid;
1759 GtkWidget *getall_btn;
1760 GtkWidget *compose_mail_btn;
1761 GtkWidget *compose_news_btn;
1762 GtkWidget *reply_btn;
1763 GtkWidget *replyall_btn;
1764 GtkWidget *replysender_btn;
1766 GtkWidget *send_btn;
1768 GtkWidget *prefs_btn;
1769 GtkWidget *account_btn;
1771 GtkWidget *next_btn;
1772 GtkWidget *delete_btn;
1773 GtkWidget *exec_btn;
1775 GtkTooltips *tooltips;
1777 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1779 gtk_container_add(GTK_CONTAINER(container), toolbar);
1780 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1781 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1782 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1783 GTK_TOOLBAR_SPACE_LINE);
1785 CREATE_TOOLBAR_ICON(stock_mail_receive_xpm);
1786 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1788 _("Get new mail from current account"),
1790 icon_wid, toolbar_inc_cb, mainwin);
1791 CREATE_TOOLBAR_ICON(stock_mail_receive_all_xpm);
1792 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1794 _("Get new mail from all accounts"),
1800 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1802 CREATE_TOOLBAR_ICON(stock_mail_send_xpm);
1803 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1805 _("Send queued message(s)"),
1811 /* insert compose mail button widget */
1813 CREATE_TOOLBAR_ICON(stock_mail_compose_xpm);
1814 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1816 _("Compose an email message"),
1819 toolbar_compose_mail_cb,
1822 /* insert compose news button widget */
1824 CREATE_TOOLBAR_ICON(stock_news_compose_xpm);
1825 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1827 _("Compose a news message"),
1830 toolbar_compose_news_cb,
1833 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1837 CREATE_TOOLBAR_ICON(stock_mail_reply_xpm);
1838 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1840 _("Reply to the message - Right button: more options"),
1846 /* replyall button */
1848 CREATE_TOOLBAR_ICON(stock_mail_reply_to_all_xpm);
1849 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1851 _("Reply to all - Right button: more options"),
1854 toolbar_reply_to_all_cb,
1857 /* reply to sender button */
1859 CREATE_TOOLBAR_ICON(stock_mail_reply_to_author_xpm);
1860 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1862 _("Reply to sender - Right button: more options"),
1865 toolbar_reply_to_sender_cb,
1868 /* forward button */
1870 CREATE_TOOLBAR_ICON(stock_mail_forward_xpm);
1871 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1873 _("Forward the message - Right button: more options"),
1879 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1881 CREATE_TOOLBAR_ICON(stock_close_xpm);
1882 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1884 _("Delete the message"),
1890 CREATE_TOOLBAR_ICON(stock_exec_xpm);
1891 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1893 _("Execute marked process"),
1899 CREATE_TOOLBAR_ICON(stock_down_arrow_xpm);
1900 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1902 _("Next unread message"),
1905 toolbar_next_unread_cb,
1909 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1911 CREATE_TOOLBAR_ICON(stock_preferences_xpm);
1912 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1914 _("Common preference"),
1919 CREATE_TOOLBAR_ICON(stock_properties_xpm);
1920 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1922 _("Account setting"),
1927 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1928 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1932 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
1933 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
1936 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
1937 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
1940 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
1941 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
1944 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
1945 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
1949 mainwin->toolbar = toolbar;
1950 mainwin->get_btn = get_btn;
1951 mainwin->getall_btn = getall_btn;
1952 mainwin->compose_mail_btn = compose_mail_btn;
1953 mainwin->compose_news_btn = compose_news_btn;
1954 mainwin->reply_btn = reply_btn;
1955 mainwin->replyall_btn = replyall_btn;
1956 mainwin->replysender_btn = replysender_btn;
1957 mainwin->fwd_btn = fwd_btn;
1958 mainwin->send_btn = send_btn;
1960 mainwin->prefs_btn = prefs_btn;
1961 mainwin->account_btn = account_btn;
1963 mainwin->next_btn = next_btn;
1964 mainwin->delete_btn = delete_btn;
1965 mainwin->exec_btn = exec_btn;
1967 gtk_widget_show_all(toolbar);
1970 /* callback functions */
1971 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1973 MainWindow *mainwindow = (MainWindow *) data;
1977 if (event->button == 3) {
1978 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1979 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
1980 menu_button_position, widget,
1981 event->button, event->time);
1985 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
1987 MainWindow *mainwin = (MainWindow *)data;
1989 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
1990 manage_window_focus_in(mainwin->window, NULL, NULL);
1993 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1995 MainWindow *mainwindow = (MainWindow *) data;
1999 if (event->button == 3) {
2000 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2001 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2002 menu_button_position, widget,
2003 event->button, event->time);
2007 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2009 MainWindow *mainwin = (MainWindow *)data;
2011 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2012 manage_window_focus_in(mainwin->window, NULL, NULL);
2015 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2017 MainWindow *mainwindow = (MainWindow *) data;
2018 GtkWidget *replysender_menu, *replysender_item;
2022 if (event->button == 3) {
2023 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2024 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2025 menu_button_position, widget,
2026 event->button, event->time);
2030 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2032 MainWindow *mainwin = (MainWindow *)data;
2034 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2035 manage_window_focus_in(mainwin->window, NULL, NULL);
2038 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2040 MainWindow *mainwindow = (MainWindow *) data;
2044 if (event->button == 3) {
2045 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2046 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2047 menu_button_position, widget,
2048 event->button, event->time);
2052 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2054 MainWindow *mainwin = (MainWindow *)data;
2056 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2057 manage_window_focus_in(mainwin->window, NULL, NULL);
2060 static void toolbar_inc_cb (GtkWidget *widget,
2063 MainWindow *mainwin = (MainWindow *)data;
2065 inc_mail_cb(mainwin, 0, NULL);
2068 static void toolbar_inc_all_cb (GtkWidget *widget,
2071 MainWindow *mainwin = (MainWindow *)data;
2073 inc_all_account_mail_cb(mainwin, 0, NULL);
2076 static void toolbar_send_cb (GtkWidget *widget,
2079 MainWindow *mainwin = (MainWindow *)data;
2081 send_queue_cb(mainwin, 0, NULL);
2084 static void toolbar_compose_cb (GtkWidget *widget,
2087 MainWindow *mainwin = (MainWindow *)data;
2089 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2090 compose_cb(mainwin, 0, NULL);
2092 compose_news_cb(mainwin, 0, NULL);
2095 static void toolbar_compose_news_cb (GtkWidget *widget,
2098 MainWindow *mainwin = (MainWindow *)data;
2100 compose_news_cb(mainwin, 0, NULL);
2103 static void toolbar_compose_mail_cb (GtkWidget *widget,
2106 MainWindow *mainwin = (MainWindow *)data;
2108 compose_mail_cb(mainwin, 0, NULL);
2111 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2113 MainWindow *mainwin = (MainWindow *)data;
2116 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2117 : COMPOSE_REPLY_WITHOUT_QUOTE,
2121 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2123 MainWindow *mainwin = (MainWindow *)data;
2126 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2127 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2132 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2134 MainWindow *mainwin = (MainWindow *)data;
2137 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2138 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2142 static void toolbar_forward_cb (GtkWidget *widget,
2145 MainWindow *mainwin = (MainWindow *)data;
2147 if (prefs_common.forward_as_attachment)
2148 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2150 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2153 static void toolbar_delete_cb (GtkWidget *widget,
2156 MainWindow *mainwin = (MainWindow *)data;
2158 summary_delete(mainwin->summaryview);
2161 static void toolbar_exec_cb (GtkWidget *widget,
2164 MainWindow *mainwin = (MainWindow *)data;
2166 summary_execute(mainwin->summaryview);
2169 static void toolbar_next_unread_cb (GtkWidget *widget,
2172 MainWindow *mainwin = (MainWindow *)data;
2174 next_unread_cb(mainwin, 0, NULL);
2177 static void toolbar_prefs_cb (GtkWidget *widget,
2180 prefs_common_open();
2183 static void toolbar_account_cb (GtkWidget *widget,
2186 MainWindow *mainwin = (MainWindow *)data;
2188 prefs_account_open_cb(mainwin, 0, NULL);
2191 static void toolbar_account_button_pressed(GtkWidget *widget,
2192 GdkEventButton *event,
2195 MainWindow *mainwin = (MainWindow *)data;
2198 if (event->button != 3) return;
2200 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2201 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2204 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2205 menu_button_position, widget,
2206 event->button, event->time);
2209 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2212 MainWindow *mainwin = (MainWindow *)data;
2216 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2217 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2220 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2221 menu_button_position, widget,
2222 event->button, event->time);
2225 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2227 MainWindow *mainwin = (MainWindow *)data;
2230 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2231 if (!button) return;
2232 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2233 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2234 manage_window_focus_in(mainwin->window, NULL, NULL);
2237 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2240 MainWindow *mainwin = (MainWindow *)data;
2242 if (mainwin->lock_count == 0)
2243 app_exit_cb(data, 0, widget);
2248 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2251 main_window_add_mailbox(mainwin);
2254 static void add_mbox_cb(MainWindow *mainwin, guint action,
2257 main_window_add_mbox(mainwin);
2260 static void update_folderview_cb(MainWindow *mainwin, guint action,
2263 summary_show(mainwin->summaryview, NULL, FALSE);
2264 folderview_update_all();
2267 static void new_folder_cb(MainWindow *mainwin, guint action,
2270 folderview_new_folder(mainwin->folderview);
2273 static void rename_folder_cb(MainWindow *mainwin, guint action,
2276 folderview_rename_folder(mainwin->folderview);
2279 static void delete_folder_cb(MainWindow *mainwin, guint action,
2282 folderview_delete_folder(mainwin->folderview);
2285 static void import_mbox_cb(MainWindow *mainwin, guint action,
2288 import_mbox(mainwin->summaryview->folder_item);
2291 static void export_mbox_cb(MainWindow *mainwin, guint action,
2294 export_mbox(mainwin->summaryview->folder_item);
2297 static void empty_trash_cb(MainWindow *mainwin, guint action,
2300 main_window_empty_trash(mainwin, TRUE);
2303 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2305 summary_save_as(mainwin->summaryview);
2308 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2310 summary_print(mainwin->summaryview);
2313 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2315 if (prefs_common.confirm_on_exit) {
2316 if (alertpanel(_("Exit"), _("Exit this program?"),
2317 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2319 manage_window_focus_in(mainwin->window, NULL, NULL);
2322 app_will_exit(widget, mainwin);
2325 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2328 summary_search(mainwin->summaryview);
2330 message_search(mainwin->messageview);
2333 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2336 switch (mainwin->type) {
2338 case SEPARATE_MESSAGE:
2340 case SEPARATE_FOLDER:
2341 if (GTK_CHECK_MENU_ITEM(widget)->active)
2342 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2344 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2347 if (GTK_CHECK_MENU_ITEM(widget)->active)
2348 gtk_widget_show(mainwin->win.sep_both.folderwin);
2350 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2355 static void toggle_message_cb(MainWindow *mainwin, guint action,
2358 switch (mainwin->type) {
2360 case SEPARATE_FOLDER:
2362 case SEPARATE_MESSAGE:
2363 if (GTK_CHECK_MENU_ITEM(widget)->active)
2364 gtk_widget_show(mainwin->win.sep_message.messagewin);
2366 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2369 if (GTK_CHECK_MENU_ITEM(widget)->active)
2370 gtk_widget_show(mainwin->win.sep_both.messagewin);
2372 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2377 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2380 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2381 mainwin->compose_btn_type);
2382 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2383 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2384 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2385 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2387 switch ((ToolbarStyle)action) {
2389 gtk_widget_hide(mainwin->handlebox);
2391 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2395 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2399 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2404 if (action != TOOLBAR_NONE) {
2405 gtk_widget_show(mainwin->handlebox);
2406 gtk_widget_queue_resize(mainwin->handlebox);
2409 mainwin->toolbar_style = (ToolbarStyle)action;
2410 prefs_common.toolbar_style = (ToolbarStyle)action;
2413 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2416 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2417 gtk_widget_show(mainwin->hbox_stat);
2418 prefs_common.show_statusbar = TRUE;
2420 gtk_widget_hide(mainwin->hbox_stat);
2421 prefs_common.show_statusbar = FALSE;
2425 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2428 MainWindow *mainwin;
2431 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2432 g_return_if_fail(mainwin != NULL);
2434 type = mainwin->type ^ action;
2435 main_window_separation_change(mainwin, type);
2437 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2438 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2441 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2444 addressbook_open(NULL);
2447 static void log_window_show_cb(MainWindow *mainwin, guint action,
2450 log_window_show(mainwin->logwin);
2453 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2458 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2461 inc_all_account_mail(mainwin);
2464 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2468 if (procmsg_send_queue() < 0)
2469 alertpanel_error(_("Some errors occurred while sending queued messages."));
2471 statusbar_pop_all();
2473 for (list = folder_get_list(); list != NULL; list = list->next) {
2476 folder = list->data;
2477 if (folder->queue) {
2478 folder_item_scan(folder->queue);
2479 folderview_update_item(folder->queue, TRUE);
2484 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2486 if (mainwin->summaryview->folder_item) {
2487 if (mainwin->summaryview->folder_item->folder->account != NULL
2488 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2489 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2491 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2497 static void compose_mail_cb(MainWindow *mainwin, guint action,
2504 if (mainwin->summaryview->folder_item) {
2505 ac = mainwin->summaryview->folder_item->folder->account;
2506 if (ac && ac->protocol != A_NNTP) {
2507 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2512 if(cur_account && (cur_account->protocol != A_NNTP)) {
2513 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2517 list = account_get_list();
2518 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2519 ac = (PrefsAccount *) cur->data;
2520 if (ac->protocol != A_NNTP) {
2521 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2527 static void compose_news_cb(MainWindow *mainwin, guint action,
2530 PrefsAccount * ac = NULL;
2534 if (mainwin->summaryview->folder_item) {
2535 ac = mainwin->summaryview->folder_item->folder->account;
2536 if (ac && ac->protocol == A_NNTP) {
2537 compose_new_with_recipient
2538 (ac, mainwin->summaryview->folder_item->path);
2543 list = account_get_list();
2544 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2545 ac = (PrefsAccount *) cur->data;
2546 if (ac->protocol == A_NNTP) {
2553 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2555 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2558 msginfo = gtk_ctree_node_get_row_data
2559 (GTK_CTREE(mainwin->summaryview->ctree),
2560 mainwin->summaryview->selected);
2562 if (!msginfo) return;
2566 compose_reply(msginfo, prefs_common.reply_with_quote,
2569 case COMPOSE_REPLY_WITH_QUOTE:
2570 compose_reply(msginfo, TRUE, FALSE, FALSE);
2572 case COMPOSE_REPLY_WITHOUT_QUOTE:
2573 compose_reply(msginfo, FALSE, FALSE, FALSE);
2575 case COMPOSE_REPLY_TO_SENDER:
2576 compose_reply(msginfo, prefs_common.reply_with_quote,
2579 case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE:
2580 compose_reply(msginfo, TRUE, FALSE, TRUE);
2582 case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE:
2583 compose_reply(msginfo, FALSE, FALSE, TRUE);
2585 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2586 compose_followup_and_reply_to(msginfo,
2587 prefs_common.reply_with_quote,
2590 case COMPOSE_REPLY_TO_ALL:
2591 compose_reply(msginfo, prefs_common.reply_with_quote,
2594 case COMPOSE_REPLY_TO_ALL_WITH_QUOTE:
2595 compose_reply(msginfo, TRUE, TRUE, TRUE);
2597 case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE:
2598 compose_reply(msginfo, FALSE, TRUE, TRUE);
2600 case COMPOSE_FORWARD:
2601 if (prefs_common.forward_as_attachment) {
2602 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, widget);
2605 reply_cb(mainwin, COMPOSE_FORWARD_INLINE, widget);
2609 case COMPOSE_FORWARD_INLINE:
2611 compose_forward(NULL, msginfo, FALSE);
2614 /* if (sel->next) FALL_THROUGH */
2615 case COMPOSE_FORWARD_AS_ATTACH:
2617 GSList *msginfo_list = NULL;
2618 for ( ; sel != NULL; sel = sel->next)
2619 msginfo_list = g_slist_append(msginfo_list,
2620 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2621 GTK_CTREE_NODE(sel->data)));
2622 compose_forward_multiple(NULL, msginfo_list);
2623 g_slist_free(msginfo_list);
2626 case COMPOSE_BOUNCE:
2627 compose_bounce(NULL, msginfo);
2630 g_warning("reply_cb(): invalid action type: %d\n", action);
2633 summary_set_marks_selected(mainwin->summaryview);
2636 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2638 summary_move_to(mainwin->summaryview);
2641 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2643 summary_copy_to(mainwin->summaryview);
2646 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2648 summary_delete(mainwin->summaryview);
2651 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2653 summary_open_msg(mainwin->summaryview);
2656 static void view_source_cb(MainWindow *mainwin, guint action,
2659 summary_view_source(mainwin->summaryview);
2662 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2664 summary_reedit(mainwin->summaryview);
2667 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2669 summary_mark(mainwin->summaryview);
2672 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2674 summary_unmark(mainwin->summaryview);
2677 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2680 summary_mark_as_unread(mainwin->summaryview);
2683 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2686 summary_mark_as_read(mainwin->summaryview);
2689 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2692 summary_mark_all_read(mainwin->summaryview);
2695 static void add_address_cb(MainWindow *mainwin, guint action,
2698 summary_add_address(mainwin->summaryview);
2701 static void set_charset_cb(MainWindow *mainwin, guint action,
2706 str = conv_get_charset_str((CharSet)action);
2707 g_free(prefs_common.force_charset);
2708 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2710 summary_redisplay_msg(mainwin->summaryview);
2712 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2715 static void hide_read_messages (MainWindow *mainwin, guint action,
2718 if (!mainwin->summaryview->folder_item
2719 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2721 summary_toggle_show_read_messages(mainwin->summaryview);
2724 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2726 GtkItemFactory *ifactory;
2728 if (!mainwin->summaryview->folder_item) return;
2730 ifactory = gtk_item_factory_from_widget(widget);
2733 summary_thread_build(mainwin->summaryview);
2734 mainwin->summaryview->folder_item->threaded = TRUE;
2735 menu_set_sensitive(ifactory, "/Summary/Thread view", FALSE);
2736 menu_set_sensitive(ifactory, "/Summary/Unthread view", TRUE);
2738 summary_unthread(mainwin->summaryview);
2739 mainwin->summaryview->folder_item->threaded = FALSE;
2740 menu_set_sensitive(ifactory, "/Summary/Thread view", TRUE);
2741 menu_set_sensitive(ifactory, "/Summary/Unthread view", FALSE);
2745 static void set_display_item_cb(MainWindow *mainwin, guint action,
2748 prefs_summary_column_open();
2751 static void sort_summary_cb(MainWindow *mainwin, guint action,
2754 summary_sort(mainwin->summaryview, (SummarySortType)action);
2757 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2760 summary_attract_by_subject(mainwin->summaryview);
2763 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2766 summary_delete_duplicated(mainwin->summaryview);
2769 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2771 summary_filter(mainwin->summaryview);
2774 static void execute_summary_cb(MainWindow *mainwin, guint action,
2777 summary_execute(mainwin->summaryview);
2780 static void update_summary_cb(MainWindow *mainwin, guint action,
2784 FolderView *folderview = mainwin->folderview;
2786 if (!mainwin->summaryview->folder_item) return;
2787 if (!folderview->opened) return;
2789 folder_update_op_count();
2791 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2792 folderview->opened);
2795 summary_show(mainwin->summaryview, fitem, TRUE);
2798 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2800 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2803 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2805 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2808 static void prev_unread_cb(MainWindow *mainwin, guint action,
2811 summary_select_prev_unread(mainwin->summaryview);
2814 static void next_unread_cb(MainWindow *mainwin, guint action,
2817 summary_select_next_unread(mainwin->summaryview);
2820 static void prev_marked_cb(MainWindow *mainwin, guint action,
2823 summary_select_prev_marked(mainwin->summaryview);
2826 static void next_marked_cb(MainWindow *mainwin, guint action,
2829 summary_select_next_marked(mainwin->summaryview);
2832 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2835 summary_select_prev_labeled(mainwin->summaryview);
2838 static void next_labeled_cb(MainWindow *mainwin, guint action,
2841 summary_select_next_labeled(mainwin->summaryview);
2844 static void goto_folder_cb(MainWindow *mainwin, guint action,
2847 FolderItem *to_folder;
2849 to_folder = foldersel_folder_sel(NULL, NULL);
2852 folderview_select(mainwin->folderview, to_folder);
2855 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2857 messageview_copy_clipboard(mainwin->messageview);
2860 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2862 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2863 summary_select_all(mainwin->summaryview);
2864 else if (mainwin->summaryview->msg_is_toggled_on &&
2865 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2866 messageview_select_all(mainwin->messageview);
2869 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2872 prefs_common_open();
2875 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2878 prefs_filter_open();
2881 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2884 prefs_scoring_open(NULL);
2887 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2890 prefs_filtering_open(NULL);
2893 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2896 prefs_template_open();
2899 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2903 new_account_cb(mainwin, 0, widget);
2905 gboolean prev_default = cur_account->is_default;
2907 prefs_account_open(cur_account);
2908 if (!prev_default && cur_account->is_default)
2909 account_set_as_default(cur_account);
2910 account_save_config_all();
2912 main_window_reflect_prefs_all();
2916 static void new_account_cb(MainWindow *mainwin, guint action,
2919 account_edit_open();
2920 if (!compose_get_compose_list()) account_add();
2923 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2925 cur_account = (PrefsAccount *)data;
2926 main_window_reflect_prefs_all();
2929 static void manual_open_cb(MainWindow *mainwin, guint action,
2932 manual_open((ManualLang)action);
2935 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2937 MainWindow *mainwin = (MainWindow *)data;
2941 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2942 LOCAL_FOLDER(folder)->rootpath,
2946 str = g_strdup_printf(_("Scanning folder %s ..."),
2947 LOCAL_FOLDER(folder)->rootpath);
2949 STATUSBAR_PUSH(mainwin, str);
2950 STATUSBAR_POP(mainwin);
2954 static void activate_compose_button (MainWindow *mainwin,
2956 ComposeButtonType type)
2958 SensitiveCond state = main_window_get_current_state(mainwin);
2960 if (style == TOOLBAR_NONE)
2963 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2964 : mainwin->compose_news_btn);
2965 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2966 : mainwin->compose_mail_btn);
2967 mainwin->compose_btn_type = type;
2970 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2972 if (mainwin->compose_btn_type != compose_btn_type)
2973 activate_compose_button(mainwin,
2974 prefs_common.toolbar_style,