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..."),
446 "<control>F", search_cb, 0, NULL},
447 {N_("/_Edit/_Search folder..."), "<control>S", search_cb, 1, NULL},
449 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
450 {N_("/_View/_Folder tree"), NULL, toggle_folder_cb, 0, "<ToggleItem>"},
451 {N_("/_View/_Message view"), NULL, toggle_message_cb, 0, "<ToggleItem>"},
452 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
453 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
454 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
455 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
456 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
457 {N_("/_View/Status _bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
458 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
459 {N_("/_View/Separate f_older tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
460 {N_("/_View/Separate m_essage view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
461 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
462 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
463 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
464 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
465 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
466 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
467 {N_("/_View/_Sort/Sort by _subject"),NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
468 {N_("/_View/_Sort/Sort by _color label"),
469 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
470 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
471 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
472 {N_("/_View/_Sort/Sort by a_ttachment"),
473 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
474 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
475 {N_("/_View/_Sort/_Attract by subject"),
476 NULL, attract_by_subject_cb, 0, NULL},
477 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, NULL},
478 {N_("/_View/U_nthread view"), "<shift><control>T", thread_cb, 1, NULL},
479 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
480 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
481 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
482 {N_("/_View/_Code set/_Auto detect"),
483 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
484 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
485 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
486 {N_("/_View/_Go to/_Prev message"), NULL, prev_cb, 0, NULL},
487 {N_("/_View/_Go to/_Next message"), NULL, next_cb, 0, NULL},
488 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
489 {N_("/_View/_Go to/P_rev unread message"),
490 NULL, prev_unread_cb, 0, NULL},
491 {N_("/_View/_Go to/N_ext unread message"),
492 NULL, next_unread_cb, 0, NULL},
493 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
494 {N_("/_View/_Go to/Prev _marked message"),
495 NULL, prev_marked_cb, 0, NULL},
496 {N_("/_View/_Go to/Next m_arked message"),
497 NULL, next_marked_cb, 0, NULL},
498 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
499 {N_("/_View/_Go to/Prev _labeled message"),
500 NULL, prev_labeled_cb, 0, NULL},
501 {N_("/_View/_Go to/Next la_beled message"),
502 NULL, next_labeled_cb, 0, NULL},
503 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
504 {N_("/_View/_Go to/Other _folder..."), "<alt>G", goto_folder_cb, 0, NULL},
505 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
506 {N_("/_View/Open in new _window"), "<shift><control>N", open_msg_cb, 0, NULL},
507 {N_("/_View/_View source"), "<control>U", view_source_cb, 0, NULL},
508 {N_("/_View/Show all _header"), "<control>H", header_window_show_cb, 0, NULL},
509 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
510 {N_("/_View/_Update"), "<alt>U", update_summary_cb, 0, NULL},
512 #define CODESET_SEPARATOR \
513 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
514 #define CODESET_ACTION(action) \
515 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
517 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
518 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
519 CODESET_ACTION(C_US_ASCII)},
522 {N_("/_View/_Code set/Unicode (_UTF-8)"),
523 CODESET_ACTION(C_UTF_8)},
526 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
527 CODESET_ACTION(C_ISO_8859_1)},
530 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
531 CODESET_ACTION(C_ISO_8859_2)},
533 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
534 CODESET_ACTION(C_ISO_8859_13)},
535 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
536 CODESET_ACTION(C_ISO_8859_4)},
538 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
539 CODESET_ACTION(C_ISO_8859_7)},
541 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
542 CODESET_ACTION(C_ISO_8859_9)},
544 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
545 CODESET_ACTION(C_ISO_8859_5)},
546 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
547 CODESET_ACTION(C_KOI8_R)},
548 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
549 CODESET_ACTION(C_CP1251)},
552 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
553 CODESET_ACTION(C_ISO_2022_JP)},
555 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
556 CODESET_ACTION(C_ISO_2022_JP_2)},
558 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
559 CODESET_ACTION(C_EUC_JP)},
560 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
561 CODESET_ACTION(C_SHIFT_JIS)},
564 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
565 CODESET_ACTION(C_GB2312)},
566 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
567 CODESET_ACTION(C_BIG5)},
568 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
569 CODESET_ACTION(C_EUC_TW)},
570 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
571 CODESET_ACTION(C_ISO_2022_CN)},
573 {N_("/_View/_Code set/Korean (EUC-_KR)"),
574 CODESET_ACTION(C_EUC_KR)},
575 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
576 CODESET_ACTION(C_ISO_2022_KR)},
578 {N_("/_View/_Code set/Thai (TIS-620)"),
579 CODESET_ACTION(C_TIS_620)},
580 {N_("/_View/_Code set/Thai (Windows-874)"),
581 CODESET_ACTION(C_WINDOWS_874)},
584 #undef CODESET_SEPARATOR
585 #undef CODESET_ACTION
587 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
588 {N_("/_Message/Get new ma_il"), "<alt>I", inc_mail_cb, 0, NULL},
589 {N_("/_Message/Get from _all accounts"),
590 "<shift><alt>I", inc_all_account_mail_cb, 0, NULL},
591 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
592 {N_("/_Message/Send queued messa_ges"),
593 NULL, send_queue_cb, 0, NULL},
594 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
595 {N_("/_Message/Compose a_n email message"), "<alt>N", compose_mail_cb, 0, NULL},
596 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
597 {N_("/_Message/_Reply"), "<alt>R", reply_cb, COMPOSE_REPLY, NULL},
598 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
599 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
600 {N_("/_Message/Reply to a_ll"), "<shift><alt>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
601 {N_("/_Message/_Forward"), "<shift><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
602 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
603 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
604 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
605 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
606 {N_("/_Message/M_ove..."), "<alt>O", move_to_cb, 0, NULL},
607 {N_("/_Message/_Copy..."), NULL, copy_to_cb, 0, NULL},
608 {N_("/_Message/_Delete"), "<alt>D", delete_cb, 0, NULL},
609 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
610 {N_("/_Message/Delete du_plicated messages"),
611 NULL, delete_duplicated_cb, 0, NULL},
612 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
613 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
614 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
615 {N_("/_Message/_Mark/_Unmark"), NULL, unmark_cb, 0, NULL},
616 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
617 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
618 {N_("/_Message/_Mark/Mark as rea_d"),
619 NULL, mark_as_read_cb, 0, NULL},
620 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
622 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
623 {N_("/_Tool/_Address book"), "<alt>A", addressbook_open_cb, 0, NULL},
624 {N_("/_Tool/Add sender to address boo_k"),
625 NULL, add_address_cb, 0, NULL},
626 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
627 {N_("/_Tool/_Filter messages"), NULL, filter_cb, 0, NULL},
628 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
629 {N_("/_Tool/E_xecute"), "<alt>X", execute_summary_cb, 0, NULL},
630 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
631 {N_("/_Tool/_Log window"), "<alt>L", log_window_show_cb, 0, NULL},
633 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
634 {N_("/_Configuration/_Common preferences..."),
635 NULL, prefs_common_open_cb, 0, NULL},
636 {N_("/_Configuration/_Filter setting..."),
637 NULL, prefs_filter_open_cb, 0, NULL},
638 {N_("/_Configuration/_Scoring ..."),
639 NULL, prefs_scoring_open_cb, 0, NULL},
640 {N_("/_Configuration/_Filtering ..."),
641 NULL, prefs_filtering_open_cb, 0, NULL},
642 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
643 {N_("/_Configuration/_Preferences for current account..."),
644 NULL, prefs_account_open_cb, 0, NULL},
645 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
646 {N_("/_Configuration/Create _new account..."),
647 NULL, new_account_cb, 0, NULL},
648 {N_("/_Configuration/_Edit accounts..."),
649 NULL, account_edit_open, 0, NULL},
650 {N_("/_Configuration/C_hange current account"),
651 NULL, NULL, 0, "<Branch>"},
653 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
654 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
655 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
656 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
657 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
658 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
660 static GtkItemFactoryEntry reply_popup_entries[] =
662 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
663 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
665 static GtkItemFactoryEntry replyall_popup_entries[] =
667 {N_("/Reply to all with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
668 {N_("/_Reply to all without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
670 static GtkItemFactoryEntry replysender_popup_entries[] =
672 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
673 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
675 static GtkItemFactoryEntry fwd_popup_entries[] =
677 {N_("/_Forward message (inline style)"), NULL, reply_cb, COMPOSE_FORWARD_INLINE, NULL},
678 {N_("/Forward message as _attachment"), NULL, reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
682 MainWindow *main_window_create(SeparateType type)
688 GtkWidget *handlebox;
689 GtkWidget *vbox_body;
690 GtkWidget *hbox_stat;
691 GtkWidget *statusbar;
692 GtkWidget *progressbar;
693 GtkWidget *statuslabel;
694 GtkWidget *ac_button;
697 FolderView *folderview;
698 SummaryView *summaryview;
699 MessageView *messageview;
700 GdkColormap *colormap;
703 guint n_menu_entries;
704 GtkItemFactory *ifactory;
707 GtkWidget *compose_popup;
708 GtkWidget *reply_popup;
709 GtkWidget *replyall_popup;
710 GtkWidget *replysender_popup;
711 GtkWidget *fwd_popup;
714 debug_print(_("Creating main window...\n"));
715 mainwin = g_new0(MainWindow, 1);
718 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
719 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
720 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
721 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
722 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
723 gtk_signal_connect(GTK_OBJECT(window), "focus_in_event",
724 GTK_SIGNAL_FUNC(manage_window_focus_in), NULL);
725 gtk_signal_connect(GTK_OBJECT(window), "focus_out_event",
726 GTK_SIGNAL_FUNC(manage_window_focus_out), NULL);
728 gtk_widget_realize(window);
729 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
731 gtkut_widget_set_app_icon(window);
733 vbox = gtk_vbox_new(FALSE, 0);
734 gtk_widget_show(vbox);
735 gtk_container_add(GTK_CONTAINER(window), vbox);
738 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
739 menubar = menubar_create(window, mainwin_entries,
740 n_menu_entries, "<Main>", mainwin);
741 gtk_widget_show(menubar);
742 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
744 handlebox = gtk_handle_box_new();
745 gtk_widget_show(handlebox);
746 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
748 /* create the popup menus for the reply buttons specials */
749 n_menu_entries = sizeof(reply_popup_entries) /
750 sizeof(reply_popup_entries[0]);
751 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
752 "<ReplyPopup>", mainwin);
753 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
754 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
755 n_menu_entries = sizeof(replyall_popup_entries) /
756 sizeof(replyall_popup_entries[0]);
757 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
758 "<ReplyAllPopup>", mainwin);
759 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
760 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
761 n_menu_entries = sizeof(replysender_popup_entries) /
762 sizeof(replysender_popup_entries[0]);
763 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
764 "<ReplySenderPopup>", mainwin);
765 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
766 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
767 /* create the popup menu for the forward button */
768 n_menu_entries = sizeof(fwd_popup_entries) /
769 sizeof(fwd_popup_entries[0]);
770 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
771 "<ForwardPopup>", mainwin);
772 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
773 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
775 main_window_toolbar_create(mainwin, handlebox);
777 /* vbox that contains body */
778 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
779 gtk_widget_show(vbox_body);
780 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
781 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
783 hbox_stat = gtk_hbox_new(FALSE, 2);
784 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
786 statusbar = statusbar_create();
787 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
789 progressbar = gtk_progress_bar_new();
790 gtk_widget_set_usize(progressbar, 120, 1);
791 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
793 statuslabel = gtk_label_new("");
794 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
796 ac_button = gtk_button_new();
797 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
798 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
799 gtk_widget_set_usize(ac_button, -1, 1);
800 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
801 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
802 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
804 ac_label = gtk_label_new("");
805 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
807 gtk_widget_show_all(hbox_stat);
810 mainwin->folderview = folderview = folderview_create();
811 mainwin->summaryview = summaryview = summary_create();
812 mainwin->messageview = messageview = messageview_create();
813 mainwin->headerwin = header_window_create();
814 mainwin->logwin = log_window_create();
816 folderview->mainwin = mainwin;
817 folderview->summaryview = summaryview;
819 summaryview->mainwin = mainwin;
820 summaryview->folderview = folderview;
821 summaryview->messageview = messageview;
822 summaryview->headerwin = mainwin->headerwin;
823 summaryview->window = window;
825 messageview->mainwin = mainwin;
827 mainwin->window = window;
828 mainwin->vbox = vbox;
829 mainwin->menubar = menubar;
830 mainwin->handlebox = handlebox;
831 mainwin->vbox_body = vbox_body;
832 mainwin->hbox_stat = hbox_stat;
833 mainwin->statusbar = statusbar;
834 mainwin->progressbar = progressbar;
835 mainwin->statuslabel = statuslabel;
836 mainwin->ac_button = ac_button;
837 mainwin->ac_label = ac_label;
838 mainwin->reply_popup = reply_popup;
839 mainwin->replyall_popup = replyall_popup;
840 mainwin->replysender_popup = replysender_popup;
841 mainwin->fwd_popup = fwd_popup;
843 /* set context IDs for status bar */
844 mainwin->mainwin_cid = gtk_statusbar_get_context_id
845 (GTK_STATUSBAR(statusbar), "Main Window");
846 mainwin->folderview_cid = gtk_statusbar_get_context_id
847 (GTK_STATUSBAR(statusbar), "Folder View");
848 mainwin->summaryview_cid = gtk_statusbar_get_context_id
849 (GTK_STATUSBAR(statusbar), "Summary View");
851 /* allocate colors for summary view and folder view */
852 summaryview->color_marked.red = summaryview->color_marked.green = 0;
853 summaryview->color_marked.blue = (guint16)65535;
855 summaryview->color_dim.red = summaryview->color_dim.green =
856 summaryview->color_dim.blue = COLOR_DIM;
858 folderview->color_new.red = (guint16)55000;
859 folderview->color_new.green = folderview->color_new.blue = 15000;
861 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
862 &folderview->color_op);
864 summaryview->color_important.red = 0;
865 summaryview->color_marked.green = 0;
866 summaryview->color_important.blue = (guint16)65535;
868 color[0] = summaryview->color_marked;
869 color[1] = summaryview->color_dim;
870 color[2] = folderview->color_new;
871 color[3] = folderview->color_op;
873 colormap = gdk_window_get_colormap(window->window);
874 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
875 for (i = 0; i < 4; i++) {
876 if (success[i] == FALSE)
877 g_warning(_("MainWindow: color allocation %d failed\n"), i);
880 debug_print(_("done.\n"));
882 main_window_set_widgets(mainwin, type);
885 ifactory = gtk_item_factory_from_widget(menubar);
886 menuitem = gtk_item_factory_get_item
887 (ifactory, "/View/Code set/Auto detect");
888 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
890 switch (prefs_common.toolbar_style) {
892 menuitem = gtk_item_factory_get_item
893 (ifactory, "/View/Toolbar/None");
896 menuitem = gtk_item_factory_get_item
897 (ifactory, "/View/Toolbar/Icon");
900 menuitem = gtk_item_factory_get_item
901 (ifactory, "/View/Toolbar/Text");
904 menuitem = gtk_item_factory_get_item
905 (ifactory, "/View/Toolbar/Icon and text");
907 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
909 gtk_widget_hide(mainwin->hbox_stat);
910 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
911 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
912 prefs_common.show_statusbar);
914 /* Message view and Folder tree are always shown at startup
915 * make that in the menu visible */
916 menuitem = gtk_item_factory_get_item(ifactory, "/View/Message view");
917 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
918 menuitem = gtk_item_factory_get_item(ifactory, "/View/Folder tree");
919 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
921 /* set the check of the SEPARATE_xxx menu items. we also need the main window
922 * as a property and pass the action type to the callback */
923 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
925 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
926 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
927 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
928 GUINT_TO_POINTER(SEPARATE_FOLDER));
930 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
932 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
933 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
934 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
935 GUINT_TO_POINTER(SEPARATE_MESSAGE));
938 menu_set_sensitive(ifactory, "/View/Thread view",
939 prefs_common.enable_thread ? FALSE : TRUE);
940 menu_set_sensitive(ifactory, "/View/Unthread view",
941 prefs_common.enable_thread ? TRUE : FALSE);
943 /* set account selection menu */
944 ac_menu = gtk_item_factory_get_widget
945 (ifactory, "/Configuration/Change current account");
946 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
947 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
948 mainwin->ac_menu = ac_menu;
950 main_window_set_toolbar_sensitive(mainwin);
952 /* show main window */
953 gtk_widget_set_uposition(mainwin->window,
954 prefs_common.mainwin_x,
955 prefs_common.mainwin_y);
956 gtk_widget_set_usize(window, prefs_common.mainwin_width,
957 prefs_common.mainwin_height);
958 gtk_widget_show(mainwin->window);
960 /* initialize views */
961 folderview_init(folderview);
962 summary_init(summaryview);
963 messageview_init(messageview);
964 header_window_init(mainwin->headerwin);
965 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)
1207 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1208 folder = FOLDER(list->data);
1209 if (folder && folder->trash && folder->trash->total > 0)
1213 if (!has_trash) return;
1216 if (alertpanel(_("Empty trash"),
1217 _("Empty all messages in trash?"),
1218 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1220 manage_window_focus_in(mainwin->window, NULL, NULL);
1223 procmsg_empty_trash();
1225 for (list = folder_get_list(); list != NULL; list = list->next) {
1226 folder = list->data;
1227 if (folder && folder->trash && folder->trash->total != 0) {
1228 folder_item_scan(folder->trash);
1229 folderview_update_item(folder->trash, TRUE);
1233 if (mainwin->summaryview->folder_item &&
1234 mainwin->summaryview->folder_item->stype == F_TRASH)
1235 gtk_widget_grab_focus(mainwin->folderview->ctree);
1238 void main_window_add_mailbox(MainWindow *mainwin)
1243 path = input_dialog(_("Add mailbox"),
1244 _("Input the location of mailbox.\n"
1245 "If the existing mailbox is specified, it will be\n"
1246 "scanned automatically."),
1249 if (folder_find_from_path(path)) {
1250 alertpanel_error(_("The mailbox `%s' already exists."), path);
1254 if (!strcmp(path, "Mail"))
1255 folder = folder_new(F_MH, _("Mailbox"), path);
1257 folder = folder_new(F_MH, g_basename(path), path);
1260 if (folder->create_tree(folder) < 0) {
1261 alertpanel_error(_("Creation of the mailbox failed.\n"
1262 "Maybe some files already exist, or you don't have the permission to write there."));
1263 folder_destroy(folder);
1268 folder_set_ui_func(folder, scan_tree_func, mainwin);
1269 folder->scan_tree(folder);
1270 folder_set_ui_func(folder, NULL, NULL);
1272 folderview_set(mainwin->folderview);
1275 void main_window_add_mbox(MainWindow *mainwin)
1281 path = input_dialog(_("Add mbox mailbox"),
1282 _("Input the location of mailbox."),
1287 if (folder_find_from_path(path)) {
1288 alertpanel_error(_("The mailbox `%s' already exists."), path);
1294 if (!strcmp(path, "Mail"))
1295 folder = folder_new(F_MBOX, _("Mailbox"), path);
1299 folder = folder_new(F_MBOX, g_basename(path), path);
1302 if (folder->create_tree(folder) < 0) {
1303 alertpanel_error(_("Creation of the mailbox failed."));
1304 folder_destroy(folder);
1310 item = folder_item_new(folder->name, NULL);
1311 item->folder = folder;
1312 folder->node = g_node_new(item);
1314 folder->create_folder(folder, item, "inbox");
1315 folder->create_folder(folder, item, "outbox");
1316 folder->create_folder(folder, item, "queue");
1317 folder->create_folder(folder, item, "draft");
1318 folder->create_folder(folder, item, "trash");
1320 folderview_set(mainwin->folderview);
1325 M_UNLOCKED = 1 << 0,
1326 M_MSG_EXIST = 1 << 1,
1327 M_TARGET_EXIST = 1 << 2,
1328 M_SINGLE_TARGET_EXIST = 1 << 3,
1330 M_ALLOW_REEDIT = 1 << 5,
1331 M_HAVE_ACCOUNT = 1 << 6,
1332 M_THREADED = 1 << 7,
1333 M_UNTHREADED = 1 << 8,
1335 M_HAVE_NEWS_ACCOUNT = 1 << 10
1338 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1340 SensitiveCond state = 0;
1341 SummarySelection selection;
1342 FolderItem *item = mainwin->summaryview->folder_item;
1343 GList *account_list = account_get_list();
1345 selection = summary_get_selection_type(mainwin->summaryview);
1347 if (mainwin->lock_count == 0)
1348 state |= M_UNLOCKED;
1349 if (selection != SUMMARY_NONE)
1350 state |= M_MSG_EXIST;
1353 state |= M_THREADED;
1355 state |= M_UNTHREADED;
1357 if (selection == SUMMARY_SELECTED_SINGLE ||
1358 selection == SUMMARY_SELECTED_MULTIPLE)
1359 state |= M_TARGET_EXIST;
1360 if (selection == SUMMARY_SELECTED_SINGLE)
1361 state |= M_SINGLE_TARGET_EXIST;
1362 if (item && item->folder->type != F_NEWS)
1364 if (mainwin->summaryview->folder_item &&
1365 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1367 if (selection == SUMMARY_SELECTED_SINGLE &&
1369 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1370 item->stype == F_QUEUE)))
1371 state |= M_ALLOW_REEDIT;
1373 state |= M_HAVE_ACCOUNT;
1375 for ( ; account_list != NULL; account_list = account_list->next) {
1376 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1377 state |= M_HAVE_NEWS_ACCOUNT;
1385 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1387 SensitiveCond state;
1395 {mainwin->get_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1396 {mainwin->getall_btn , M_HAVE_ACCOUNT|M_UNLOCKED},
1397 {mainwin->compose_mail_btn, M_HAVE_ACCOUNT},
1398 {mainwin->compose_news_btn, M_HAVE_NEWS_ACCOUNT},
1399 {mainwin->reply_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1400 {mainwin->replyall_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1401 {mainwin->replysender_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1402 {mainwin->fwd_btn , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1403 /* {mainwin->prefs_btn , M_UNLOCKED},
1404 {mainwin->account_btn , M_UNLOCKED}, */
1405 {mainwin->next_btn , M_MSG_EXIST},
1406 {mainwin->delete_btn , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1407 {mainwin->exec_btn , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1411 state = main_window_get_current_state(mainwin);
1413 for (i = 0; entry[i].widget != NULL; i++) {
1414 sensitive = ((entry[i].cond & state) == entry[i].cond);
1415 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1418 activate_compose_button(mainwin,
1419 prefs_common.toolbar_style,
1420 mainwin->compose_btn_type);
1423 void main_window_set_menu_sensitive(MainWindow *mainwin)
1425 GtkItemFactory *ifactory;
1426 SensitiveCond state;
1430 static const struct {
1434 {"/File/Add mailbox..." , M_UNLOCKED},
1435 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1436 {"/File/Rescan folder tree" , M_UNLOCKED},
1437 {"/File/Folder" , M_UNLOCKED},
1438 {"/File/Import mbox file..." , M_UNLOCKED},
1439 {"/File/Export to mbox file...", M_UNLOCKED},
1440 {"/File/Empty trash" , M_UNLOCKED},
1441 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1442 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1443 /* {"/File/Close", M_UNLOCKED}, */
1444 {"/File/Exit" , M_UNLOCKED},
1446 {"/View/Sort" , M_MSG_EXIST},
1447 {"/View/Thread view" , M_UNTHREADED},
1448 {"/View/Unthread view" , M_THREADED},
1449 {"/View/Go to" , M_MSG_EXIST},
1450 {"/View/Go to/Prev message" , M_MSG_EXIST},
1451 {"/View/Go to/Next message" , M_MSG_EXIST},
1452 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1453 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1454 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1455 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1456 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1457 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1458 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1459 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1461 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1462 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1463 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1464 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1465 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1466 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1467 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1468 {"/Message/Forward" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1469 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1470 {"/Message/Re-edit", M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1471 {"/Message/Move...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1472 {"/Message/Copy...", M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1473 {"/Message/Delete" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1474 {"/Message/Mark" , M_TARGET_EXIST},
1475 {"/Message/Delete duplicated messages", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1477 {"/Tool/Add sender to address book", M_SINGLE_TARGET_EXIST},
1478 {"/Tool/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1479 {"/Tool/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1481 {"/Configuration", M_UNLOCKED},
1486 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1487 state = main_window_get_current_state(mainwin);
1489 for (i = 0; entry[i].entry != NULL; i++) {
1490 sensitive = ((entry[i].cond & state) == entry[i].cond);
1491 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1495 void main_window_popup(MainWindow *mainwin)
1501 gdk_window_get_origin(mainwin->window->window, &x, &y);
1502 sx = gdk_screen_width();
1503 sy = gdk_screen_height();
1504 x %= sx; if (x < 0) x = 0;
1505 y %= sy; if (y < 0) y = 0;
1506 gdk_window_move(mainwin->window->window, x, y);
1507 gdk_window_raise(mainwin->window->window);
1508 gdk_window_show(mainwin->window->window);
1510 debug_print("window position: x = %d, y = %d\n", x, y);
1512 switch (mainwin->type) {
1513 case SEPARATE_FOLDER:
1514 widget = mainwin->win.sep_folder.folderwin;
1515 gdk_window_get_origin(widget->window, &x, &y);
1516 x %= sx; if (x < 0) x = 0;
1517 y %= sy; if (y < 0) y = 0;
1518 gdk_window_move(widget->window, x, y);
1519 gdk_window_raise(widget->window);
1521 case SEPARATE_MESSAGE:
1522 widget = mainwin->win.sep_message.messagewin;
1523 gdk_window_get_origin(widget->window, &x, &y);
1524 x %= sx; if (x < 0) x = 0;
1525 y %= sy; if (y < 0) y = 0;
1526 gdk_window_move(widget->window, x, y);
1527 gdk_window_raise(widget->window);
1530 widget = mainwin->win.sep_both.folderwin;
1531 gdk_window_get_origin(widget->window, &x, &y);
1532 x %= sx; if (x < 0) x = 0;
1533 y %= sy; if (y < 0) y = 0;
1534 gdk_window_move(widget->window, x, y);
1535 gdk_window_raise(widget->window);
1536 widget = mainwin->win.sep_both.messagewin;
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);
1548 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1550 GtkWidget *folderwin = NULL;
1551 GtkWidget *messagewin = NULL;
1554 GtkWidget *vbox_body = mainwin->vbox_body;
1555 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1557 debug_print(_("Setting widgets..."));
1559 /* create separated window(s) if needed */
1560 if (type & SEPARATE_FOLDER) {
1561 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1562 gtk_window_set_title(GTK_WINDOW(folderwin),
1563 _("Sylpheed - Folder View"));
1564 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1565 "folder_view", "Sylpheed");
1566 gtk_window_set_policy(GTK_WINDOW(folderwin),
1568 gtk_widget_set_usize(folderwin, -1,
1569 prefs_common.mainview_height);
1570 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1572 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1573 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1576 if (type & SEPARATE_MESSAGE) {
1577 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1578 gtk_window_set_title(GTK_WINDOW(messagewin),
1579 _("Sylpheed - Message View"));
1580 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1581 "message_view", "Sylpheed");
1582 gtk_window_set_policy(GTK_WINDOW(messagewin),
1584 gtk_widget_set_usize
1585 (messagewin, prefs_common.mainview_width,
1586 prefs_common.mainview_height
1587 - prefs_common.summaryview_height
1588 + DEFAULT_HEADERVIEW_HEIGHT);
1589 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1591 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1592 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1598 hpaned = gtk_hpaned_new();
1599 gtk_widget_show(hpaned);
1600 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1601 gtk_paned_add1(GTK_PANED(hpaned),
1602 GTK_WIDGET_PTR(mainwin->folderview));
1604 vpaned = gtk_vpaned_new();
1605 if (mainwin->summaryview->msg_is_toggled_on) {
1606 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1607 gtk_paned_add1(GTK_PANED(vpaned),
1608 GTK_WIDGET_PTR(mainwin->summaryview));
1610 gtk_paned_add2(GTK_PANED(hpaned),
1611 GTK_WIDGET_PTR(mainwin->summaryview));
1612 gtk_widget_ref(vpaned);
1614 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1615 prefs_common.summaryview_width,
1616 prefs_common.summaryview_height);
1617 gtk_paned_add2(GTK_PANED(vpaned),
1618 GTK_WIDGET_PTR(mainwin->messageview));
1619 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1620 prefs_common.mainview_width, -1);
1621 gtk_widget_set_usize(mainwin->window,
1622 prefs_common.folderview_width +
1623 prefs_common.mainview_width,
1624 prefs_common.mainwin_height);
1625 gtk_widget_show_all(vpaned);
1627 menu_set_sensitive(ifactory, "/View/Message view", FALSE);
1628 menu_set_sensitive(ifactory, "/View/Folder tree", FALSE);
1630 mainwin->win.sep_none.hpaned = hpaned;
1631 mainwin->win.sep_none.vpaned = vpaned;
1633 case SEPARATE_FOLDER:
1634 vpaned = gtk_vpaned_new();
1635 if (mainwin->summaryview->msg_is_toggled_on) {
1636 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1638 gtk_paned_add1(GTK_PANED(vpaned),
1639 GTK_WIDGET_PTR(mainwin->summaryview));
1641 gtk_box_pack_start(GTK_BOX(vbox_body),
1642 GTK_WIDGET_PTR(mainwin->summaryview),
1644 gtk_widget_ref(vpaned);
1646 gtk_paned_add2(GTK_PANED(vpaned),
1647 GTK_WIDGET_PTR(mainwin->messageview));
1648 gtk_widget_show_all(vpaned);
1649 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1650 prefs_common.summaryview_width,
1651 prefs_common.summaryview_height);
1652 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1653 prefs_common.mainview_width, -1);
1654 gtk_widget_set_usize(mainwin->window,
1655 prefs_common.mainview_width,
1656 prefs_common.mainview_height);
1658 gtk_container_add(GTK_CONTAINER(folderwin),
1659 GTK_WIDGET_PTR(mainwin->folderview));
1661 menu_set_sensitive(ifactory, "/View/Message view", FALSE);
1662 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1664 mainwin->win.sep_folder.folderwin = folderwin;
1665 mainwin->win.sep_folder.vpaned = vpaned;
1667 gtk_widget_show_all(folderwin);
1669 case SEPARATE_MESSAGE:
1670 hpaned = gtk_hpaned_new();
1671 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1673 gtk_paned_add1(GTK_PANED(hpaned),
1674 GTK_WIDGET_PTR(mainwin->folderview));
1675 gtk_paned_add2(GTK_PANED(hpaned),
1676 GTK_WIDGET_PTR(mainwin->summaryview));
1677 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1678 prefs_common.summaryview_width,
1679 prefs_common.summaryview_height);
1680 gtk_widget_set_usize(mainwin->window,
1681 prefs_common.folderview_width +
1682 prefs_common.mainview_width,
1683 prefs_common.mainwin_height);
1684 gtk_widget_show_all(hpaned);
1685 gtk_container_add(GTK_CONTAINER(messagewin),
1686 GTK_WIDGET_PTR(mainwin->messageview));
1688 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1689 menu_set_sensitive(ifactory, "/View/Folder tree", FALSE);
1691 mainwin->win.sep_message.messagewin = messagewin;
1692 mainwin->win.sep_message.hpaned = hpaned;
1694 gtk_widget_show_all(messagewin);
1697 gtk_box_pack_start(GTK_BOX(vbox_body),
1698 GTK_WIDGET_PTR(mainwin->summaryview),
1700 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1701 prefs_common.summaryview_width,
1702 prefs_common.summaryview_height);
1703 gtk_widget_set_usize(mainwin->window,
1704 prefs_common.mainview_width,
1705 prefs_common.mainwin_height);
1706 gtk_container_add(GTK_CONTAINER(folderwin),
1707 GTK_WIDGET_PTR(mainwin->folderview));
1708 gtk_container_add(GTK_CONTAINER(messagewin),
1709 GTK_WIDGET_PTR(mainwin->messageview));
1711 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1712 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1714 mainwin->win.sep_both.folderwin = folderwin;
1715 mainwin->win.sep_both.messagewin = messagewin;
1717 gtk_widget_show_all(folderwin);
1718 gtk_widget_show_all(messagewin);
1722 mainwin->type = type;
1724 debug_print(_("done.\n"));
1727 static void main_window_toolbar_create(MainWindow *mainwin,
1728 GtkWidget *container)
1731 GtkWidget *icon_wid;
1733 GtkWidget *getall_btn;
1734 GtkWidget *compose_mail_btn;
1735 GtkWidget *compose_news_btn;
1736 GtkWidget *reply_btn;
1737 GtkWidget *replyall_btn;
1738 GtkWidget *replysender_btn;
1740 GtkWidget *send_btn;
1742 GtkWidget *prefs_btn;
1743 GtkWidget *account_btn;
1745 GtkWidget *next_btn;
1746 GtkWidget *delete_btn;
1747 GtkWidget *exec_btn;
1749 GtkTooltips *tooltips;
1751 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1753 gtk_container_add(GTK_CONTAINER(container), toolbar);
1754 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1755 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1756 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1757 GTK_TOOLBAR_SPACE_LINE);
1759 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1760 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1762 _("Get new mail from current account"),
1764 icon_wid, toolbar_inc_cb, mainwin);
1765 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1766 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1768 _("Get new mail from all accounts"),
1774 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1776 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1777 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1779 _("Send queued message(s)"),
1785 /* insert compose mail button widget */
1786 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1787 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1789 _("Compose an email message"),
1792 toolbar_compose_mail_cb,
1795 /* insert compose news button widget */
1796 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1797 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1799 _("Compose a news message"),
1802 toolbar_compose_news_cb,
1805 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1809 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1810 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1812 _("Reply to the message - Right button: more options"),
1818 /* replyall button */
1820 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1821 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1823 _("Reply to all - Right button: more options"),
1826 toolbar_reply_to_all_cb,
1829 /* reply to sender button */
1830 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1831 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1833 _("Reply to sender - Right button: more options"),
1836 toolbar_reply_to_sender_cb,
1839 /* forward button */
1840 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1841 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1843 _("Forward the message - Right button: more options"),
1849 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1851 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1852 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1854 _("Delete the message"),
1860 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1861 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1863 _("Execute marked process"),
1869 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
1870 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1872 _("Next unread message"),
1875 toolbar_next_unread_cb,
1879 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1881 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
1882 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1884 _("Common preference"),
1889 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
1890 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1892 _("Account setting"),
1897 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
1898 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
1902 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
1903 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
1906 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
1907 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
1910 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
1911 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
1914 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
1915 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
1919 mainwin->toolbar = toolbar;
1920 mainwin->get_btn = get_btn;
1921 mainwin->getall_btn = getall_btn;
1922 mainwin->compose_mail_btn = compose_mail_btn;
1923 mainwin->compose_news_btn = compose_news_btn;
1924 mainwin->reply_btn = reply_btn;
1925 mainwin->replyall_btn = replyall_btn;
1926 mainwin->replysender_btn = replysender_btn;
1927 mainwin->fwd_btn = fwd_btn;
1928 mainwin->send_btn = send_btn;
1930 mainwin->prefs_btn = prefs_btn;
1931 mainwin->account_btn = account_btn;
1933 mainwin->next_btn = next_btn;
1934 mainwin->delete_btn = delete_btn;
1935 mainwin->exec_btn = exec_btn;
1937 gtk_widget_show_all(toolbar);
1940 /* callback functions */
1941 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1943 MainWindow *mainwindow = (MainWindow *) data;
1947 if (event->button == 3) {
1948 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1949 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
1950 menu_button_position, widget,
1951 event->button, event->time);
1955 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
1957 MainWindow *mainwin = (MainWindow *)data;
1959 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
1960 manage_window_focus_in(mainwin->window, NULL, NULL);
1963 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1965 MainWindow *mainwindow = (MainWindow *) data;
1969 if (event->button == 3) {
1970 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1971 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
1972 menu_button_position, widget,
1973 event->button, event->time);
1977 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
1979 MainWindow *mainwin = (MainWindow *)data;
1981 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
1982 manage_window_focus_in(mainwin->window, NULL, NULL);
1985 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
1987 MainWindow *mainwindow = (MainWindow *) data;
1988 GtkWidget *replysender_menu, *replysender_item;
1992 if (event->button == 3) {
1993 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
1994 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
1995 menu_button_position, widget,
1996 event->button, event->time);
2000 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2002 MainWindow *mainwin = (MainWindow *)data;
2004 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2005 manage_window_focus_in(mainwin->window, NULL, NULL);
2008 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2010 MainWindow *mainwindow = (MainWindow *) data;
2014 if (event->button == 3) {
2015 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2016 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2017 menu_button_position, widget,
2018 event->button, event->time);
2022 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2024 MainWindow *mainwin = (MainWindow *)data;
2026 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2027 manage_window_focus_in(mainwin->window, NULL, NULL);
2030 static void toolbar_inc_cb (GtkWidget *widget,
2033 MainWindow *mainwin = (MainWindow *)data;
2035 inc_mail_cb(mainwin, 0, NULL);
2038 static void toolbar_inc_all_cb (GtkWidget *widget,
2041 MainWindow *mainwin = (MainWindow *)data;
2043 inc_all_account_mail_cb(mainwin, 0, NULL);
2046 static void toolbar_send_cb (GtkWidget *widget,
2049 MainWindow *mainwin = (MainWindow *)data;
2051 send_queue_cb(mainwin, 0, NULL);
2054 static void toolbar_compose_cb (GtkWidget *widget,
2057 MainWindow *mainwin = (MainWindow *)data;
2059 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2060 compose_cb(mainwin, 0, NULL);
2062 compose_news_cb(mainwin, 0, NULL);
2065 static void toolbar_compose_news_cb (GtkWidget *widget,
2068 MainWindow *mainwin = (MainWindow *)data;
2070 compose_news_cb(mainwin, 0, NULL);
2073 static void toolbar_compose_mail_cb (GtkWidget *widget,
2076 MainWindow *mainwin = (MainWindow *)data;
2078 compose_mail_cb(mainwin, 0, NULL);
2081 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2083 MainWindow *mainwin = (MainWindow *)data;
2086 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2087 : COMPOSE_REPLY_WITHOUT_QUOTE,
2091 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2093 MainWindow *mainwin = (MainWindow *)data;
2096 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2097 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2102 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2104 MainWindow *mainwin = (MainWindow *)data;
2107 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2108 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2112 static void toolbar_forward_cb (GtkWidget *widget,
2115 MainWindow *mainwin = (MainWindow *)data;
2117 if (prefs_common.forward_as_attachment)
2118 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2120 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2123 static void toolbar_delete_cb (GtkWidget *widget,
2126 MainWindow *mainwin = (MainWindow *)data;
2128 summary_delete(mainwin->summaryview);
2131 static void toolbar_exec_cb (GtkWidget *widget,
2134 MainWindow *mainwin = (MainWindow *)data;
2136 summary_execute(mainwin->summaryview);
2139 static void toolbar_next_unread_cb (GtkWidget *widget,
2142 MainWindow *mainwin = (MainWindow *)data;
2144 next_unread_cb(mainwin, 0, NULL);
2147 static void toolbar_prefs_cb (GtkWidget *widget,
2150 prefs_common_open();
2153 static void toolbar_account_cb (GtkWidget *widget,
2156 MainWindow *mainwin = (MainWindow *)data;
2158 prefs_account_open_cb(mainwin, 0, NULL);
2161 static void toolbar_account_button_pressed(GtkWidget *widget,
2162 GdkEventButton *event,
2165 MainWindow *mainwin = (MainWindow *)data;
2168 if (event->button != 3) return;
2170 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2171 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2174 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2175 menu_button_position, widget,
2176 event->button, event->time);
2179 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2182 MainWindow *mainwin = (MainWindow *)data;
2186 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2187 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2190 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2191 menu_button_position, widget,
2192 event->button, event->time);
2195 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2197 MainWindow *mainwin = (MainWindow *)data;
2200 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2201 if (!button) return;
2202 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2203 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2204 manage_window_focus_in(mainwin->window, NULL, NULL);
2207 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2210 MainWindow *mainwin = (MainWindow *)data;
2212 if (mainwin->lock_count == 0)
2213 app_exit_cb(data, 0, widget);
2218 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2221 main_window_add_mailbox(mainwin);
2224 static void add_mbox_cb(MainWindow *mainwin, guint action,
2227 main_window_add_mbox(mainwin);
2230 static void update_folderview_cb(MainWindow *mainwin, guint action,
2233 summary_show(mainwin->summaryview, NULL, FALSE);
2234 folderview_update_all();
2237 static void new_folder_cb(MainWindow *mainwin, guint action,
2240 folderview_new_folder(mainwin->folderview);
2243 static void rename_folder_cb(MainWindow *mainwin, guint action,
2246 folderview_rename_folder(mainwin->folderview);
2249 static void delete_folder_cb(MainWindow *mainwin, guint action,
2252 folderview_delete_folder(mainwin->folderview);
2255 static void import_mbox_cb(MainWindow *mainwin, guint action,
2258 import_mbox(mainwin->summaryview->folder_item);
2261 static void export_mbox_cb(MainWindow *mainwin, guint action,
2264 export_mbox(mainwin->summaryview->folder_item);
2267 static void empty_trash_cb(MainWindow *mainwin, guint action,
2270 main_window_empty_trash(mainwin, TRUE);
2273 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2275 summary_save_as(mainwin->summaryview);
2278 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2280 summary_print(mainwin->summaryview);
2283 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2285 if (prefs_common.confirm_on_exit) {
2286 if (alertpanel(_("Exit"), _("Exit this program?"),
2287 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2289 manage_window_focus_in(mainwin->window, NULL, NULL);
2292 app_will_exit(widget, mainwin);
2295 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2298 summary_search(mainwin->summaryview);
2300 message_search(mainwin->messageview);
2303 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2306 switch (mainwin->type) {
2308 case SEPARATE_MESSAGE:
2310 case SEPARATE_FOLDER:
2311 if (GTK_CHECK_MENU_ITEM(widget)->active)
2312 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2314 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2317 if (GTK_CHECK_MENU_ITEM(widget)->active)
2318 gtk_widget_show(mainwin->win.sep_both.folderwin);
2320 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2325 static void toggle_message_cb(MainWindow *mainwin, guint action,
2328 switch (mainwin->type) {
2330 case SEPARATE_FOLDER:
2332 case SEPARATE_MESSAGE:
2333 if (GTK_CHECK_MENU_ITEM(widget)->active)
2334 gtk_widget_show(mainwin->win.sep_message.messagewin);
2336 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2339 if (GTK_CHECK_MENU_ITEM(widget)->active)
2340 gtk_widget_show(mainwin->win.sep_both.messagewin);
2342 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2347 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2350 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2351 mainwin->compose_btn_type);
2352 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2353 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2354 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2355 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2357 switch ((ToolbarStyle)action) {
2359 gtk_widget_hide(mainwin->handlebox);
2361 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2365 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2369 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2374 if (action != TOOLBAR_NONE) {
2375 gtk_widget_show(mainwin->handlebox);
2376 gtk_widget_queue_resize(mainwin->handlebox);
2379 mainwin->toolbar_style = (ToolbarStyle)action;
2380 prefs_common.toolbar_style = (ToolbarStyle)action;
2383 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2386 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2387 gtk_widget_show(mainwin->hbox_stat);
2388 prefs_common.show_statusbar = TRUE;
2390 gtk_widget_hide(mainwin->hbox_stat);
2391 prefs_common.show_statusbar = FALSE;
2395 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2398 MainWindow *mainwin;
2401 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2402 g_return_if_fail(mainwin != NULL);
2404 type = mainwin->type ^ action;
2405 main_window_separation_change(mainwin, type);
2407 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2408 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2411 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2414 addressbook_open(NULL);
2417 static void log_window_show_cb(MainWindow *mainwin, guint action,
2420 log_window_show(mainwin->logwin);
2423 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2428 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2431 inc_all_account_mail(mainwin);
2434 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2438 if (procmsg_send_queue() < 0)
2439 alertpanel_error(_("Some errors occurred while sending queued messages."));
2441 statusbar_pop_all();
2443 for (list = folder_get_list(); list != NULL; list = list->next) {
2446 folder = list->data;
2447 if (folder->queue) {
2448 folder_item_scan(folder->queue);
2449 folderview_update_item(folder->queue, TRUE);
2454 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2456 if (mainwin->summaryview->folder_item) {
2457 if (mainwin->summaryview->folder_item->folder->account != NULL
2458 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2459 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2461 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2467 static void compose_mail_cb(MainWindow *mainwin, guint action,
2474 if (mainwin->summaryview->folder_item) {
2475 ac = mainwin->summaryview->folder_item->folder->account;
2476 if (ac && ac->protocol != A_NNTP) {
2477 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2482 if(cur_account && (cur_account->protocol != A_NNTP)) {
2483 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2487 list = account_get_list();
2488 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2489 ac = (PrefsAccount *) cur->data;
2490 if (ac->protocol != A_NNTP) {
2491 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2497 static void compose_news_cb(MainWindow *mainwin, guint action,
2500 PrefsAccount * ac = NULL;
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_recipient
2508 (ac, mainwin->summaryview->folder_item->path);
2513 list = account_get_list();
2514 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2515 ac = (PrefsAccount *) cur->data;
2516 if (ac->protocol == A_NNTP) {
2523 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2525 GList *sel = GTK_CLIST(mainwin->summaryview->ctree)->selection;
2528 msginfo = gtk_ctree_node_get_row_data
2529 (GTK_CTREE(mainwin->summaryview->ctree),
2530 mainwin->summaryview->selected);
2532 if (!msginfo) return;
2536 compose_reply(msginfo, prefs_common.reply_with_quote,
2539 case COMPOSE_REPLY_WITH_QUOTE:
2540 compose_reply(msginfo, TRUE, FALSE, FALSE);
2542 case COMPOSE_REPLY_WITHOUT_QUOTE:
2543 compose_reply(msginfo, FALSE, FALSE, FALSE);
2545 case COMPOSE_REPLY_TO_SENDER:
2546 compose_reply(msginfo, prefs_common.reply_with_quote,
2549 case COMPOSE_REPLY_TO_SENDER_WITH_QUOTE:
2550 compose_reply(msginfo, TRUE, FALSE, TRUE);
2552 case COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE:
2553 compose_reply(msginfo, FALSE, FALSE, TRUE);
2555 case COMPOSE_FOLLOWUP_AND_REPLY_TO:
2556 compose_followup_and_reply_to(msginfo,
2557 prefs_common.reply_with_quote,
2560 case COMPOSE_REPLY_TO_ALL:
2561 compose_reply(msginfo, prefs_common.reply_with_quote,
2564 case COMPOSE_REPLY_TO_ALL_WITH_QUOTE:
2565 compose_reply(msginfo, TRUE, TRUE, TRUE);
2567 case COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE:
2568 compose_reply(msginfo, FALSE, TRUE, TRUE);
2570 case COMPOSE_FORWARD:
2571 if (prefs_common.forward_as_attachment) {
2572 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, widget);
2575 reply_cb(mainwin, COMPOSE_FORWARD_INLINE, widget);
2579 case COMPOSE_FORWARD_INLINE:
2581 compose_forward(NULL, msginfo, FALSE);
2584 /* if (sel->next) FALL_THROUGH */
2585 case COMPOSE_FORWARD_AS_ATTACH:
2587 GSList *msginfo_list = NULL;
2588 for ( ; sel != NULL; sel = sel->next)
2589 msginfo_list = g_slist_append(msginfo_list,
2590 gtk_ctree_node_get_row_data(GTK_CTREE(mainwin->summaryview->ctree),
2591 GTK_CTREE_NODE(sel->data)));
2592 compose_forward_multiple(NULL, msginfo_list);
2593 g_slist_free(msginfo_list);
2596 case COMPOSE_BOUNCE:
2597 compose_bounce(NULL, msginfo);
2600 g_warning("reply_cb(): invalid action type: %d\n", action);
2603 summary_set_marks_selected(mainwin->summaryview);
2606 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2608 summary_move_to(mainwin->summaryview);
2611 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2613 summary_copy_to(mainwin->summaryview);
2616 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2618 summary_delete(mainwin->summaryview);
2621 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2623 summary_open_msg(mainwin->summaryview);
2626 static void view_source_cb(MainWindow *mainwin, guint action,
2629 summary_view_source(mainwin->summaryview);
2632 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2634 summary_reedit(mainwin->summaryview);
2637 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2639 summary_mark(mainwin->summaryview);
2642 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2644 summary_unmark(mainwin->summaryview);
2647 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2650 summary_mark_as_unread(mainwin->summaryview);
2653 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2656 summary_mark_as_read(mainwin->summaryview);
2659 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2662 summary_mark_all_read(mainwin->summaryview);
2665 static void add_address_cb(MainWindow *mainwin, guint action,
2668 summary_add_address(mainwin->summaryview);
2671 static void set_charset_cb(MainWindow *mainwin, guint action,
2676 str = conv_get_charset_str((CharSet)action);
2677 g_free(prefs_common.force_charset);
2678 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2680 summary_redisplay_msg(mainwin->summaryview);
2682 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2685 static void hide_read_messages (MainWindow *mainwin, guint action,
2688 if (!mainwin->summaryview->folder_item
2689 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2691 summary_toggle_show_read_messages(mainwin->summaryview);
2694 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2696 GtkItemFactory *ifactory;
2698 if (!mainwin->summaryview->folder_item) return;
2700 ifactory = gtk_item_factory_from_widget(widget);
2703 summary_thread_build(mainwin->summaryview);
2704 mainwin->summaryview->folder_item->threaded = TRUE;
2705 menu_set_sensitive(ifactory, "/View/Thread view", FALSE);
2706 menu_set_sensitive(ifactory, "/View/Unthread view", TRUE);
2708 summary_unthread(mainwin->summaryview);
2709 mainwin->summaryview->folder_item->threaded = FALSE;
2710 menu_set_sensitive(ifactory, "/View/Thread view", TRUE);
2711 menu_set_sensitive(ifactory, "/View/Unthread view", FALSE);
2715 static void set_display_item_cb(MainWindow *mainwin, guint action,
2718 prefs_summary_column_open();
2721 static void sort_summary_cb(MainWindow *mainwin, guint action,
2724 summary_sort(mainwin->summaryview, (SummarySortType)action);
2727 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2730 summary_attract_by_subject(mainwin->summaryview);
2733 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2736 summary_delete_duplicated(mainwin->summaryview);
2739 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2741 summary_filter(mainwin->summaryview);
2744 static void execute_summary_cb(MainWindow *mainwin, guint action,
2747 summary_execute(mainwin->summaryview);
2750 static void update_summary_cb(MainWindow *mainwin, guint action,
2754 FolderView *folderview = mainwin->folderview;
2756 if (!mainwin->summaryview->folder_item) return;
2757 if (!folderview->opened) return;
2759 folder_update_op_count();
2761 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2762 folderview->opened);
2765 summary_show(mainwin->summaryview, fitem, TRUE);
2768 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2770 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2773 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2775 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2778 static void prev_unread_cb(MainWindow *mainwin, guint action,
2781 summary_select_prev_unread(mainwin->summaryview);
2784 static void next_unread_cb(MainWindow *mainwin, guint action,
2787 summary_select_next_unread(mainwin->summaryview);
2790 static void prev_marked_cb(MainWindow *mainwin, guint action,
2793 summary_select_prev_marked(mainwin->summaryview);
2796 static void next_marked_cb(MainWindow *mainwin, guint action,
2799 summary_select_next_marked(mainwin->summaryview);
2802 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2805 summary_select_prev_labeled(mainwin->summaryview);
2808 static void next_labeled_cb(MainWindow *mainwin, guint action,
2811 summary_select_next_labeled(mainwin->summaryview);
2814 static void goto_folder_cb(MainWindow *mainwin, guint action,
2817 FolderItem *to_folder;
2819 to_folder = foldersel_folder_sel(NULL, NULL);
2822 folderview_select(mainwin->folderview, to_folder);
2825 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2827 messageview_copy_clipboard(mainwin->messageview);
2830 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2832 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2833 summary_select_all(mainwin->summaryview);
2834 else if (mainwin->summaryview->msg_is_toggled_on &&
2835 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2836 messageview_select_all(mainwin->messageview);
2839 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2842 prefs_common_open();
2845 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2848 prefs_filter_open();
2851 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2854 prefs_scoring_open(NULL);
2857 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2860 prefs_filtering_open(NULL);
2863 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2866 prefs_template_open();
2869 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2873 new_account_cb(mainwin, 0, widget);
2875 gboolean prev_default = cur_account->is_default;
2877 prefs_account_open(cur_account);
2878 if (!prev_default && cur_account->is_default)
2879 account_set_as_default(cur_account);
2880 account_save_config_all();
2882 main_window_reflect_prefs_all();
2886 static void new_account_cb(MainWindow *mainwin, guint action,
2889 account_edit_open();
2890 if (!compose_get_compose_list()) account_add();
2893 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2895 cur_account = (PrefsAccount *)data;
2896 main_window_reflect_prefs_all();
2899 static void manual_open_cb(MainWindow *mainwin, guint action,
2902 manual_open((ManualLang)action);
2905 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2907 MainWindow *mainwin = (MainWindow *)data;
2911 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2912 LOCAL_FOLDER(folder)->rootpath,
2916 str = g_strdup_printf(_("Scanning folder %s ..."),
2917 LOCAL_FOLDER(folder)->rootpath);
2919 STATUSBAR_PUSH(mainwin, str);
2920 STATUSBAR_POP(mainwin);
2924 static void activate_compose_button (MainWindow *mainwin,
2926 ComposeButtonType type)
2928 SensitiveCond state = main_window_get_current_state(mainwin);
2930 if (style == TOOLBAR_NONE)
2933 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2934 : mainwin->compose_news_btn);
2935 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2936 : mainwin->compose_mail_btn);
2937 mainwin->compose_btn_type = type;
2940 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2942 if (mainwin->compose_btn_type != compose_btn_type)
2943 activate_compose_button(mainwin,
2944 prefs_common.toolbar_style,