2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2002 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
55 #include "stock_pixmap.h"
62 #include "prefs_common.h"
63 #include "prefs_filter.h"
64 #include "prefs_actions.h"
65 #include "prefs_filtering.h"
66 #include "prefs_scoring.h"
67 #include "prefs_account.h"
68 #include "prefs_folder_item.h"
69 #include "prefs_summary_column.h"
70 #include "prefs_template.h"
72 #include "addressbook.h"
73 #include "logwindow.h"
74 #include "manage_window.h"
75 #include "alertpanel.h"
76 #include "statusbar.h"
77 #include "inputdialog.h"
84 #include "selective_download.h"
86 #define AC_LABEL_WIDTH 240
88 #define STATUSBAR_PUSH(mainwin, str) \
90 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
91 mainwin->mainwin_cid, str); \
92 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
95 #define STATUSBAR_POP(mainwin) \
97 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
98 mainwin->mainwin_cid); \
101 /* list of all instantiated MainWindow */
102 static GList *mainwin_list = NULL;
104 static GdkCursor *watch_cursor;
106 static void main_window_menu_callback_block (MainWindow *mainwin);
107 static void main_window_menu_callback_unblock (MainWindow *mainwin);
109 static void main_window_show_cur_account (MainWindow *mainwin);
111 static void main_window_set_widgets (MainWindow *mainwin,
113 static void main_window_toolbar_create (MainWindow *mainwin,
114 GtkWidget *container);
116 /* callback functions */
117 static void toolbar_inc_cb (GtkWidget *widget,
119 static void toolbar_inc_all_cb (GtkWidget *widget,
121 static void toolbar_send_cb (GtkWidget *widget,
124 static void toolbar_compose_cb (GtkWidget *widget,
126 static void toolbar_compose_news_cb (GtkWidget *widget,
128 static void toolbar_compose_mail_cb (GtkWidget *widget,
130 static void toolbar_reply_cb (GtkWidget *widget,
132 static void toolbar_reply_popup_cb (GtkWidget *widget,
133 GdkEventButton *event,
135 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell,
137 static void toolbar_reply_to_all_cb (GtkWidget *widget,
139 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget,
140 GdkEventButton *event,
142 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell,
144 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
146 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
147 GdkEventButton *event,
149 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell,
151 static void toolbar_forward_cb (GtkWidget *widget,
153 static void toolbar_forward_popup_cb (GtkWidget *widget,
154 GdkEventButton *event,
156 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell,
159 static void toolbar_delete_cb (GtkWidget *widget,
161 static void toolbar_exec_cb (GtkWidget *widget,
164 static void toolbar_next_unread_cb (GtkWidget *widget,
167 static void toolbar_prefs_cb (GtkWidget *widget,
169 static void toolbar_account_cb (GtkWidget *widget,
172 static void toolbar_account_button_pressed (GtkWidget *widget,
173 GdkEventButton *event,
175 static void ac_label_button_pressed (GtkWidget *widget,
176 GdkEventButton *event,
178 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
181 static gint main_window_close_cb (GtkWidget *widget,
185 static void add_mailbox_cb (MainWindow *mainwin,
188 static void add_mbox_cb (MainWindow *mainwin,
191 static void update_folderview_cb (MainWindow *mainwin,
194 static void new_folder_cb (MainWindow *mainwin,
197 static void rename_folder_cb (MainWindow *mainwin,
200 static void delete_folder_cb (MainWindow *mainwin,
203 static void import_mbox_cb (MainWindow *mainwin,
206 static void export_mbox_cb (MainWindow *mainwin,
209 static void empty_trash_cb (MainWindow *mainwin,
213 static void save_as_cb (MainWindow *mainwin,
216 static void print_cb (MainWindow *mainwin,
219 static void app_exit_cb (MainWindow *mainwin,
223 static void search_cb (MainWindow *mainwin,
227 static void toggle_folder_cb (MainWindow *mainwin,
230 static void toggle_message_cb (MainWindow *mainwin,
233 static void toggle_toolbar_cb (MainWindow *mainwin,
236 static void toggle_statusbar_cb (MainWindow *mainwin,
239 static void toggle_expand_summaryview_cb (MainWindow *mainwin,
242 static void toggle_expand_messageview_cb (MainWindow *mainwin,
245 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
249 static void addressbook_open_cb (MainWindow *mainwin,
252 static void log_window_show_cb (MainWindow *mainwin,
255 static void sel_download_cb (MainWindow *mainwin,
259 static void inc_mail_cb (MainWindow *mainwin,
262 static void inc_all_account_mail_cb (MainWindow *mainwin,
266 static void send_queue_cb (MainWindow *mainwin,
270 static void compose_cb (MainWindow *mainwin,
273 static void compose_mail_cb(MainWindow *mainwin, guint action,
275 static void compose_news_cb(MainWindow *mainwin, guint action,
277 static void reply_cb (MainWindow *mainwin,
281 static void open_msg_cb (MainWindow *mainwin,
285 static void view_source_cb (MainWindow *mainwin,
289 static void show_all_header_cb (MainWindow *mainwin,
293 static void reedit_cb (MainWindow *mainwin,
297 static void move_to_cb (MainWindow *mainwin,
300 static void copy_to_cb (MainWindow *mainwin,
303 static void delete_cb (MainWindow *mainwin,
307 static void mark_cb (MainWindow *mainwin,
310 static void unmark_cb (MainWindow *mainwin,
314 static void mark_as_unread_cb (MainWindow *mainwin,
317 static void mark_as_read_cb (MainWindow *mainwin,
320 static void mark_all_read_cb (MainWindow *mainwin,
323 static void add_address_cb (MainWindow *mainwin,
327 static void set_charset_cb (MainWindow *mainwin,
331 static void hide_read_messages (MainWindow *mainwin,
335 static void thread_cb (MainWindow *mainwin,
338 static void set_display_item_cb (MainWindow *mainwin,
341 static void sort_summary_cb (MainWindow *mainwin,
344 static void attract_by_subject_cb(MainWindow *mainwin,
348 static void delete_duplicated_cb (MainWindow *mainwin,
351 static void filter_cb (MainWindow *mainwin,
354 static void execute_summary_cb (MainWindow *mainwin,
357 static void update_summary_cb (MainWindow *mainwin,
361 static void prev_cb (MainWindow *mainwin,
364 static void next_cb (MainWindow *mainwin,
368 static void prev_unread_cb (MainWindow *mainwin,
371 static void next_unread_cb (MainWindow *mainwin,
374 static void prev_marked_cb (MainWindow *mainwin,
377 static void next_marked_cb (MainWindow *mainwin,
380 static void prev_labeled_cb (MainWindow *mainwin,
383 static void next_labeled_cb (MainWindow *mainwin,
387 static void goto_folder_cb (MainWindow *mainwin,
391 static void copy_cb (MainWindow *mainwin,
394 static void allsel_cb (MainWindow *mainwin,
398 static void create_filter_cb (MainWindow *mainwin,
402 static void prefs_common_open_cb (MainWindow *mainwin,
405 static void prefs_filter_open_cb (MainWindow *mainwin,
408 static void prefs_scoring_open_cb (MainWindow *mainwin,
411 static void prefs_filtering_open_cb (MainWindow *mainwin,
414 static void prefs_account_open_cb(MainWindow *mainwin,
417 static void prefs_template_open_cb (MainWindow *mainwin,
420 static void prefs_actions_open_cb (MainWindow *mainwin,
423 static void new_account_cb (MainWindow *mainwin,
427 static void account_menu_cb (GtkMenuItem *menuitem,
430 static void manual_open_cb (MainWindow *mainwin,
434 static void scan_tree_func (Folder *folder,
438 static void activate_compose_button (MainWindow *mainwin,
440 ComposeButtonType type);
442 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
446 static void key_pressed (GtkWidget *widget,
450 static void set_toolbar_style(MainWindow *mainwin);
452 #define SEPARATE_ACTION 667
454 static GtkItemFactoryEntry mainwin_entries[] =
456 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
457 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
458 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
459 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
460 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
461 {N_("/_File/_Folder/Create _new folder..."),
462 NULL, new_folder_cb, 0, NULL},
463 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
464 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
465 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
466 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
467 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
468 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
469 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
470 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
471 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
472 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
474 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
475 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
476 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
477 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
478 {N_("/_Edit/_Find in current message..."),
479 "<control>F", search_cb, 0, NULL},
480 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
481 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
482 {N_("/_Edit/Actio_ns"), NULL, NULL, 0, "<Branch>"},
484 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
485 {N_("/_View/_Folder tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
486 {N_("/_View/_Message view"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
487 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
488 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
489 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
490 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
491 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
492 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
493 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
494 {N_("/_View/Status _bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
495 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
496 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
497 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
498 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
499 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
500 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
501 {N_("/_View/_Sort/Sort by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
502 {N_("/_View/_Sort/Sort by _color label"),
503 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
504 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
505 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
506 {N_("/_View/_Sort/Sort by a_ttachment"),
507 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
508 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
509 {N_("/_View/_Sort/_Attract by subject"),
510 NULL, attract_by_subject_cb, 0, NULL},
511 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
512 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
513 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
514 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
516 #define CODESET_SEPARATOR \
517 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
518 #define CODESET_ACTION(action) \
519 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
521 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
522 {N_("/_View/_Code set/_Auto detect"),
523 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
524 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
525 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
526 CODESET_ACTION(C_US_ASCII)},
529 {N_("/_View/_Code set/Unicode (_UTF-8)"),
530 CODESET_ACTION(C_UTF_8)},
533 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
534 CODESET_ACTION(C_ISO_8859_1)},
537 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
538 CODESET_ACTION(C_ISO_8859_2)},
540 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
541 CODESET_ACTION(C_ISO_8859_13)},
542 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
543 CODESET_ACTION(C_ISO_8859_4)},
545 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
546 CODESET_ACTION(C_ISO_8859_7)},
548 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
549 CODESET_ACTION(C_ISO_8859_9)},
551 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
552 CODESET_ACTION(C_ISO_8859_5)},
553 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
554 CODESET_ACTION(C_KOI8_R)},
555 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
556 CODESET_ACTION(C_CP1251)},
559 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
560 CODESET_ACTION(C_ISO_2022_JP)},
562 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
563 CODESET_ACTION(C_ISO_2022_JP_2)},
565 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
566 CODESET_ACTION(C_EUC_JP)},
567 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
568 CODESET_ACTION(C_SHIFT_JIS)},
571 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
572 CODESET_ACTION(C_GB2312)},
573 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
574 CODESET_ACTION(C_BIG5)},
575 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
576 CODESET_ACTION(C_EUC_TW)},
577 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
578 CODESET_ACTION(C_ISO_2022_CN)},
580 {N_("/_View/_Code set/Korean (EUC-_KR)"),
581 CODESET_ACTION(C_EUC_KR)},
582 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
583 CODESET_ACTION(C_ISO_2022_KR)},
585 {N_("/_View/_Code set/Thai (TIS-620)"),
586 CODESET_ACTION(C_TIS_620)},
587 {N_("/_View/_Code set/Thai (Windows-874)"),
588 CODESET_ACTION(C_WINDOWS_874)},
591 #undef CODESET_SEPARATOR
592 #undef CODESET_ACTION
594 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
595 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
596 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
597 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
598 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
599 {N_("/_View/_Go to/P_rev unread message"),
600 "<shift>P", prev_unread_cb, 0, NULL},
601 {N_("/_View/_Go to/N_ext unread message"),
602 "<shift>N", next_unread_cb, 0, NULL},
603 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
604 {N_("/_View/_Go to/Prev _marked message"),
605 NULL, prev_marked_cb, 0, NULL},
606 {N_("/_View/_Go to/Next m_arked message"),
607 NULL, next_marked_cb, 0, NULL},
608 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
609 {N_("/_View/_Go to/Prev _labeled message"),
610 NULL, prev_labeled_cb, 0, NULL},
611 {N_("/_View/_Go to/Next la_beled message"),
612 NULL, next_labeled_cb, 0, NULL},
613 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
614 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
615 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
616 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
617 {N_("/_View/_View source"), "<control>U", view_source_cb, 0, NULL},
618 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
619 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_View/_Update"), "<control><alt>U", update_summary_cb, 0, NULL},
622 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
623 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
624 {N_("/_Message/Get from _all accounts"),
625 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
626 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
627 {N_("/_Message/Send queued messa_ges"),
628 NULL, send_queue_cb, 0, NULL},
629 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
630 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
631 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
632 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
633 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
634 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
635 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
636 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
637 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
638 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
639 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
640 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
641 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
642 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
643 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
644 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
645 {N_("/_Message/Delete du_plicated messages"),
646 NULL, delete_duplicated_cb, 0, NULL},
647 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
648 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
649 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
650 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
651 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
652 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
653 {N_("/_Message/_Mark/Mark as rea_d"),
654 NULL, mark_as_read_cb, 0, NULL},
655 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
657 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
658 {N_("/_Tool/_Address book"), "<shift><control>A", addressbook_open_cb, 0, NULL},
659 {N_("/_Tool/Add sender to address boo_k"),
660 NULL, add_address_cb, 0, NULL},
661 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
662 {N_("/_Tool/_Filter messages"), NULL, filter_cb, 0, NULL},
663 {N_("/_Tool/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
664 {N_("/_Tool/_Create filter rule/_Automatically"),
665 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
666 {N_("/_Tool/_Create filter rule/by _From"),
667 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
668 {N_("/_Tool/_Create filter rule/by _To"),
669 NULL, create_filter_cb, FILTER_BY_TO, NULL},
670 {N_("/_Tool/_Create filter rule/by _Subject"),
671 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
672 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
673 {N_("/_Tool/E_xecute"), "X", execute_summary_cb, 0, NULL},
674 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
675 {N_("/_Tool/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
676 {N_("/_Tool/_Selective Download"), "<alt>S", sel_download_cb, 0, NULL},
678 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
679 {N_("/_Configuration/_Common preferences..."),
680 NULL, prefs_common_open_cb, 0, NULL},
681 {N_("/_Configuration/_Filter setting..."),
682 NULL, prefs_filter_open_cb, 0, NULL},
683 {N_("/_Configuration/_Scoring ..."),
684 NULL, prefs_scoring_open_cb, 0, NULL},
685 {N_("/_Configuration/_Filtering ..."),
686 NULL, prefs_filtering_open_cb, 0, NULL},
687 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
688 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
689 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
690 {N_("/_Configuration/_Preferences for current account..."),
691 NULL, prefs_account_open_cb, 0, NULL},
692 {N_("/_Configuration/Create _new account..."),
693 NULL, new_account_cb, 0, NULL},
694 {N_("/_Configuration/_Edit accounts..."),
695 NULL, account_edit_open, 0, NULL},
696 {N_("/_Configuration/C_hange current account"),
697 NULL, NULL, 0, "<Branch>"},
699 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
700 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
701 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
702 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
703 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
704 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
706 static GtkItemFactoryEntry reply_popup_entries[] =
708 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
709 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
711 static GtkItemFactoryEntry replyall_popup_entries[] =
713 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
714 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
716 static GtkItemFactoryEntry replysender_popup_entries[] =
718 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
719 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
721 static GtkItemFactoryEntry fwd_popup_entries[] =
723 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
724 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
728 MainWindow *main_window_create(SeparateType type)
734 GtkWidget *handlebox;
735 GtkWidget *vbox_body;
736 GtkWidget *hbox_stat;
737 GtkWidget *statusbar;
738 GtkWidget *progressbar;
739 GtkWidget *statuslabel;
740 GtkWidget *ac_button;
743 FolderView *folderview;
744 SummaryView *summaryview;
745 MessageView *messageview;
746 GdkColormap *colormap;
749 guint n_menu_entries;
750 GtkItemFactory *ifactory;
753 GtkWidget *compose_popup;
754 GtkWidget *reply_popup;
755 GtkWidget *replyall_popup;
756 GtkWidget *replysender_popup;
757 GtkWidget *fwd_popup;
760 debug_print(_("Creating main window...\n"));
761 mainwin = g_new0(MainWindow, 1);
764 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
765 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
766 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
767 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
768 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
769 MANAGE_WINDOW_SIGNALS_CONNECT(window);
770 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
771 GTK_SIGNAL_FUNC(key_pressed), mainwin);
773 gtk_widget_realize(window);
774 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
777 gtkut_widget_set_app_icon(window);
779 vbox = gtk_vbox_new(FALSE, 0);
780 gtk_widget_show(vbox);
781 gtk_container_add(GTK_CONTAINER(window), vbox);
784 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
785 menubar = menubar_create(window, mainwin_entries,
786 n_menu_entries, "<Main>", mainwin);
787 gtk_widget_show(menubar);
788 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
790 handlebox = gtk_handle_box_new();
791 gtk_widget_show(handlebox);
792 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
794 /* create the popup menus for the reply buttons specials */
795 n_menu_entries = sizeof(reply_popup_entries) /
796 sizeof(reply_popup_entries[0]);
797 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
798 "<ReplyPopup>", mainwin);
799 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
800 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
801 n_menu_entries = sizeof(replyall_popup_entries) /
802 sizeof(replyall_popup_entries[0]);
803 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
804 "<ReplyAllPopup>", mainwin);
805 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
806 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
807 n_menu_entries = sizeof(replysender_popup_entries) /
808 sizeof(replysender_popup_entries[0]);
809 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
810 "<ReplySenderPopup>", mainwin);
811 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
812 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
813 /* create the popup menu for the forward button */
814 n_menu_entries = sizeof(fwd_popup_entries) /
815 sizeof(fwd_popup_entries[0]);
816 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
817 "<ForwardPopup>", mainwin);
818 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
819 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
821 main_window_toolbar_create(mainwin, handlebox);
823 /* vbox that contains body */
824 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
825 gtk_widget_show(vbox_body);
826 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
827 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
829 hbox_stat = gtk_hbox_new(FALSE, 2);
830 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
832 statusbar = statusbar_create();
833 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
835 progressbar = gtk_progress_bar_new();
836 gtk_widget_set_usize(progressbar, 120, 1);
837 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
839 statuslabel = gtk_label_new("");
840 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
842 ac_button = gtk_button_new();
843 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
844 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
845 gtk_widget_set_usize(ac_button, -1, 1);
846 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
847 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
848 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
850 ac_label = gtk_label_new("");
851 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
853 gtk_widget_show_all(hbox_stat);
856 mainwin->folderview = folderview = folderview_create();
857 mainwin->summaryview = summaryview = summary_create();
858 mainwin->messageview = messageview = messageview_create();
859 mainwin->logwin = log_window_create();
861 folderview->mainwin = mainwin;
862 folderview->summaryview = summaryview;
864 summaryview->mainwin = mainwin;
865 summaryview->folderview = folderview;
866 summaryview->messageview = messageview;
867 summaryview->window = window;
869 messageview->mainwin = mainwin;
871 mainwin->window = window;
872 mainwin->vbox = vbox;
873 mainwin->menubar = menubar;
874 mainwin->handlebox = handlebox;
875 mainwin->vbox_body = vbox_body;
876 mainwin->hbox_stat = hbox_stat;
877 mainwin->statusbar = statusbar;
878 mainwin->progressbar = progressbar;
879 mainwin->statuslabel = statuslabel;
880 mainwin->ac_button = ac_button;
881 mainwin->ac_label = ac_label;
882 mainwin->reply_popup = reply_popup;
883 mainwin->replyall_popup = replyall_popup;
884 mainwin->replysender_popup = replysender_popup;
885 mainwin->fwd_popup = fwd_popup;
887 /* set context IDs for status bar */
888 mainwin->mainwin_cid = gtk_statusbar_get_context_id
889 (GTK_STATUSBAR(statusbar), "Main Window");
890 mainwin->folderview_cid = gtk_statusbar_get_context_id
891 (GTK_STATUSBAR(statusbar), "Folder View");
892 mainwin->summaryview_cid = gtk_statusbar_get_context_id
893 (GTK_STATUSBAR(statusbar), "Summary View");
895 /* allocate colors for summary view and folder view */
896 summaryview->color_marked.red = summaryview->color_marked.green = 0;
897 summaryview->color_marked.blue = (guint16)65535;
899 summaryview->color_dim.red = summaryview->color_dim.green =
900 summaryview->color_dim.blue = COLOR_DIM;
902 folderview->color_new.red = (guint16)55000;
903 folderview->color_new.green = folderview->color_new.blue = 15000;
905 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
906 &folderview->color_op);
908 summaryview->color_important.red = 0;
909 summaryview->color_marked.green = 0;
910 summaryview->color_important.blue = (guint16)65535;
912 color[0] = summaryview->color_marked;
913 color[1] = summaryview->color_dim;
914 color[2] = folderview->color_new;
915 color[3] = folderview->color_op;
917 colormap = gdk_window_get_colormap(window->window);
918 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
919 for (i = 0; i < 4; i++) {
920 if (success[i] == FALSE)
921 g_warning(_("MainWindow: color allocation %d failed\n"), i);
924 debug_print(_("done.\n"));
926 main_window_set_widgets(mainwin, type);
929 ifactory = gtk_item_factory_from_widget(menubar);
930 menuitem = gtk_item_factory_get_item
931 (ifactory, "/View/Code set/Auto detect");
932 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
934 switch (prefs_common.toolbar_style) {
936 menuitem = gtk_item_factory_get_item
937 (ifactory, "/View/Toolbar/None");
940 menuitem = gtk_item_factory_get_item
941 (ifactory, "/View/Toolbar/Icon");
944 menuitem = gtk_item_factory_get_item
945 (ifactory, "/View/Toolbar/Text");
948 menuitem = gtk_item_factory_get_item
949 (ifactory, "/View/Toolbar/Icon and text");
951 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
953 gtk_widget_hide(mainwin->hbox_stat);
954 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
955 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
956 prefs_common.show_statusbar);
957 #if 0 /* FIXED SEPARATE WINDOWS */
958 /* Message view and Folder tree are always shown at startup
959 * make that in the menu visible */
960 menuitem = gtk_item_factory_get_item(ifactory, "/View/Message view");
961 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
962 menuitem = gtk_item_factory_get_item(ifactory, "/View/Folder tree");
963 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
965 /* set the check of the SEPARATE_xxx menu items. we also need the main window
966 * as a property and pass the action type to the callback */
967 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
969 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
970 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
971 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
972 GUINT_TO_POINTER(SEPARATE_FOLDER));
974 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
976 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
977 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
978 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
979 GUINT_TO_POINTER(SEPARATE_MESSAGE));
981 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
982 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
985 /* set account selection menu */
986 ac_menu = gtk_item_factory_get_widget
987 (ifactory, "/Configuration/Change current account");
988 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
989 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
990 mainwin->ac_menu = ac_menu;
992 main_window_set_toolbar_sensitive(mainwin);
994 /* Create actions menu */
995 update_mainwin_actions_menu(ifactory, mainwin);
997 /* show main window */
998 gtk_widget_set_uposition(mainwin->window,
999 prefs_common.mainwin_x,
1000 prefs_common.mainwin_y);
1001 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1002 prefs_common.mainwin_height);
1003 gtk_widget_show(mainwin->window);
1005 /* initialize views */
1006 folderview_init(folderview);
1007 summary_init(summaryview);
1008 messageview_init(messageview);
1009 log_window_init(mainwin->logwin);
1011 mainwin->lock_count = 0;
1012 mainwin->menu_lock_count = 0;
1013 mainwin->cursor_count = 0;
1016 watch_cursor = gdk_cursor_new(GDK_WATCH);
1018 mainwin_list = g_list_append(mainwin_list, mainwin);
1023 void main_window_cursor_wait(MainWindow *mainwin)
1026 if (mainwin->cursor_count == 0)
1027 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1029 mainwin->cursor_count++;
1034 void main_window_cursor_normal(MainWindow *mainwin)
1036 if (mainwin->cursor_count)
1037 mainwin->cursor_count--;
1039 if (mainwin->cursor_count == 0)
1040 gdk_window_set_cursor(mainwin->window->window, NULL);
1045 /* lock / unlock the user-interface */
1046 void main_window_lock(MainWindow *mainwin)
1048 if (mainwin->lock_count == 0)
1049 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1051 mainwin->lock_count++;
1053 main_window_set_menu_sensitive(mainwin);
1054 main_window_set_toolbar_sensitive(mainwin);
1057 void main_window_unlock(MainWindow *mainwin)
1059 if (mainwin->lock_count)
1060 mainwin->lock_count--;
1062 main_window_set_menu_sensitive(mainwin);
1063 main_window_set_toolbar_sensitive(mainwin);
1065 if (mainwin->lock_count == 0)
1066 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1069 static void main_window_menu_callback_block(MainWindow *mainwin)
1071 mainwin->menu_lock_count++;
1074 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1076 if (mainwin->menu_lock_count)
1077 mainwin->menu_lock_count--;
1080 void main_window_reflect_prefs_all(void)
1082 main_window_reflect_prefs_all_real(FALSE);
1085 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1088 MainWindow *mainwin;
1090 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1091 mainwin = (MainWindow *)cur->data;
1093 main_window_show_cur_account(mainwin);
1094 main_window_set_menu_sensitive(mainwin);
1095 main_window_set_toolbar_sensitive(mainwin);
1098 if (pixmap_theme_changed)
1100 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1101 mainwin->toolbar = NULL;
1102 main_window_toolbar_create(mainwin, mainwin->handlebox);
1103 set_toolbar_style(mainwin);
1104 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1105 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1106 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1109 summary_redisplay_msg(mainwin->summaryview);
1110 headerview_set_visibility(mainwin->messageview->headerview,
1111 prefs_common.display_header_pane);
1115 void main_window_set_summary_column(void)
1118 MainWindow *mainwin;
1120 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1121 mainwin = (MainWindow *)cur->data;
1122 summary_set_column_order(mainwin->summaryview);
1126 void main_window_set_account_menu(GList *account_list)
1128 GList *cur, *cur_ac, *cur_item;
1129 GtkWidget *menuitem;
1130 MainWindow *mainwin;
1131 PrefsAccount *ac_prefs;
1133 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1134 mainwin = (MainWindow *)cur->data;
1136 /* destroy all previous menu item */
1137 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1138 while (cur_item != NULL) {
1139 GList *next = cur_item->next;
1140 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1144 for (cur_ac = account_list; cur_ac != NULL;
1145 cur_ac = cur_ac->next) {
1146 ac_prefs = (PrefsAccount *)cur_ac->data;
1148 menuitem = gtk_menu_item_new_with_label
1149 (ac_prefs->account_name
1150 ? ac_prefs->account_name : _("Untitled"));
1151 gtk_widget_show(menuitem);
1152 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1153 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1154 GTK_SIGNAL_FUNC(account_menu_cb),
1160 static void main_window_show_cur_account(MainWindow *mainwin)
1165 ac_name = g_strdup(cur_account
1166 ? (cur_account->account_name
1167 ? cur_account->account_name : _("Untitled"))
1171 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1173 buf = g_strdup(PROG_VERSION);
1174 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1177 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1178 gtk_widget_queue_resize(mainwin->ac_button);
1183 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1185 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1186 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1187 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1189 if (mainwin->type == type) return;
1191 /* remove widgets from those containers */
1192 gtk_widget_ref(folder_wid);
1193 gtk_widget_ref(summary_wid);
1194 gtk_widget_ref(message_wid);
1195 gtkut_container_remove
1196 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1197 gtkut_container_remove
1198 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1199 gtkut_container_remove
1200 (GTK_CONTAINER(message_wid->parent), message_wid);
1202 /* clean containers */
1203 switch (mainwin->type) {
1205 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1207 case SEPARATE_FOLDER:
1208 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1209 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1211 case SEPARATE_MESSAGE:
1212 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1213 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1216 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1217 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1221 gtk_widget_hide(mainwin->window);
1222 main_window_set_widgets(mainwin, type);
1223 gtk_widget_show(mainwin->window);
1225 gtk_widget_unref(folder_wid);
1226 gtk_widget_unref(summary_wid);
1227 gtk_widget_unref(message_wid);
1230 void main_window_get_size(MainWindow *mainwin)
1232 GtkAllocation *allocation;
1234 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1236 prefs_common.summaryview_width = allocation->width;
1238 if (mainwin->summaryview->msg_is_toggled_on)
1239 prefs_common.summaryview_height = allocation->height;
1241 prefs_common.mainview_width = allocation->width;
1243 allocation = &mainwin->window->allocation;
1245 prefs_common.mainview_height = allocation->height;
1246 prefs_common.mainwin_width = allocation->width;
1247 prefs_common.mainwin_height = allocation->height;
1249 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1251 prefs_common.folderview_width = allocation->width;
1252 prefs_common.folderview_height = allocation->height;
1255 void main_window_get_position(MainWindow *mainwin)
1259 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1261 prefs_common.mainview_x = x;
1262 prefs_common.mainview_y = y;
1263 prefs_common.mainwin_x = x;
1264 prefs_common.mainwin_y = y;
1266 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1269 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1275 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1276 folder = FOLDER(list->data);
1277 if (folder && folder->trash && folder->trash->total > 0)
1281 if (!has_trash) return;
1284 if (alertpanel(_("Empty trash"),
1285 _("Empty all messages in trash?"),
1286 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1288 manage_window_focus_in(mainwin->window, NULL, NULL);
1291 procmsg_empty_trash();
1293 for (list = folder_get_list(); list != NULL; list = list->next) {
1294 folder = list->data;
1295 if (folder && folder->trash && folder->trash->total != 0) {
1296 folder_item_scan(folder->trash);
1297 folderview_update_item(folder->trash, TRUE);
1301 if (mainwin->summaryview->folder_item &&
1302 mainwin->summaryview->folder_item->stype == F_TRASH)
1303 gtk_widget_grab_focus(mainwin->folderview->ctree);
1306 void main_window_add_mailbox(MainWindow *mainwin)
1311 path = input_dialog(_("Add mailbox"),
1312 _("Input the location of mailbox.\n"
1313 "If the existing mailbox is specified, it will be\n"
1314 "scanned automatically."),
1317 if (folder_find_from_path(path)) {
1318 alertpanel_error(_("The mailbox `%s' already exists."), path);
1322 if (!strcmp(path, "Mail"))
1323 folder = folder_new(F_MH, _("Mailbox"), path);
1325 folder = folder_new(F_MH, g_basename(path), path);
1328 if (folder->create_tree(folder) < 0) {
1329 alertpanel_error(_("Creation of the mailbox failed.\n"
1330 "Maybe some files already exist, or you don't have the permission to write there."));
1331 folder_destroy(folder);
1336 folder_set_ui_func(folder, scan_tree_func, mainwin);
1337 folder->scan_tree(folder);
1338 folder_set_ui_func(folder, NULL, NULL);
1340 folderview_set(mainwin->folderview);
1343 void main_window_add_mbox(MainWindow *mainwin)
1349 path = input_dialog(_("Add mbox mailbox"),
1350 _("Input the location of mailbox."),
1355 if (folder_find_from_path(path)) {
1356 alertpanel_error(_("The mailbox `%s' already exists."), path);
1362 if (!strcmp(path, "Mail"))
1363 folder = folder_new(F_MBOX, _("Mailbox"), path);
1367 folder = folder_new(F_MBOX, g_basename(path), path);
1370 if (folder->create_tree(folder) < 0) {
1371 alertpanel_error(_("Creation of the mailbox failed."));
1372 folder_destroy(folder);
1378 item = folder_item_new(folder->name, NULL);
1379 item->folder = folder;
1380 folder->node = g_node_new(item);
1382 folder->create_folder(folder, item, "inbox");
1383 folder->create_folder(folder, item, "outbox");
1384 folder->create_folder(folder, item, "queue");
1385 folder->create_folder(folder, item, "draft");
1386 folder->create_folder(folder, item, "trash");
1388 folderview_set(mainwin->folderview);
1393 M_UNLOCKED = 1 << 0,
1394 M_MSG_EXIST = 1 << 1,
1395 M_TARGET_EXIST = 1 << 2,
1396 M_SINGLE_TARGET_EXIST = 1 << 3,
1398 M_ALLOW_REEDIT = 1 << 5,
1399 M_HAVE_ACCOUNT = 1 << 6,
1400 M_THREADED = 1 << 7,
1401 M_UNTHREADED = 1 << 8,
1402 M_ALLOW_DELETE = 1 << 9,
1404 M_HAVE_NEWS_ACCOUNT = 1 << 11,
1405 M_HIDE_READ_MSG = 1 << 12
1408 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1410 SensitiveCond state = 0;
1411 SummarySelection selection;
1412 FolderItem *item = mainwin->summaryview->folder_item;
1413 GList *account_list = account_get_list();
1415 selection = summary_get_selection_type(mainwin->summaryview);
1417 if (mainwin->lock_count == 0)
1418 state |= M_UNLOCKED;
1419 if (selection != SUMMARY_NONE)
1420 state |= M_MSG_EXIST;
1424 state |= M_THREADED;
1426 state |= M_UNTHREADED;
1427 if (item->folder->type != F_NEWS)
1428 state |= M_ALLOW_DELETE;
1430 if (selection == SUMMARY_NONE && item->hide_read_msgs
1431 || selection != SUMMARY_NONE)
1432 state |= M_HIDE_READ_MSG;
1434 if (selection == SUMMARY_SELECTED_SINGLE ||
1435 selection == SUMMARY_SELECTED_MULTIPLE)
1436 state |= M_TARGET_EXIST;
1437 if (selection == SUMMARY_SELECTED_SINGLE)
1438 state |= M_SINGLE_TARGET_EXIST;
1439 if (mainwin->summaryview->folder_item &&
1440 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1442 if (selection == SUMMARY_SELECTED_SINGLE &&
1444 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1445 item->stype == F_QUEUE)))
1446 state |= M_ALLOW_REEDIT;
1448 state |= M_HAVE_ACCOUNT;
1450 for ( ; account_list != NULL; account_list = account_list->next) {
1451 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1452 state |= M_HAVE_NEWS_ACCOUNT;
1460 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1462 SensitiveCond state;
1471 entry[0].widget = mainwin->get_btn;
1472 entry[0].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1473 entry[1].widget = mainwin->getall_btn;
1474 entry[1].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1475 entry[2].widget = mainwin->compose_news_btn;
1476 entry[2].cond = M_HAVE_NEWS_ACCOUNT;
1477 entry[3].widget = mainwin->reply_btn;
1478 entry[3].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1479 entry[4].widget = mainwin->replyall_btn;
1480 entry[4].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1481 entry[5].widget = mainwin->replysender_btn;
1482 entry[5].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1483 entry[6].widget = mainwin->fwd_btn;
1484 entry[6].cond = M_HAVE_ACCOUNT|M_TARGET_EXIST;
1485 /* entry[6].widget = mainwin->prefs_btn;
1486 entry[6].cond = M_UNLOCKED;
1487 entry[7].widget = mainwin->account_btn;
1488 entry[7].cond = M_UNLOCKED; */
1489 entry[7].widget = mainwin->next_btn;
1490 entry[7].cond = M_MSG_EXIST;
1491 entry[8].widget = mainwin->delete_btn;
1492 entry[8].cond = M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED;
1493 entry[9].widget = mainwin->exec_btn;
1494 entry[9].cond = M_MSG_EXIST|M_EXEC|M_UNLOCKED;
1495 entry[10].widget = NULL;
1498 state = main_window_get_current_state(mainwin);
1500 for (i = 0; entry[i].widget != NULL; i++) {
1501 sensitive = ((entry[i].cond & state) == entry[i].cond);
1502 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1505 activate_compose_button(mainwin,
1506 prefs_common.toolbar_style,
1507 mainwin->compose_btn_type);
1510 void main_window_set_menu_sensitive(MainWindow *mainwin)
1512 GtkItemFactory *ifactory;
1513 SensitiveCond state;
1515 GtkWidget *menuitem;
1518 static const struct {
1522 {"/File/Add mailbox..." , M_UNLOCKED},
1523 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1524 {"/File/Rescan folder tree" , M_UNLOCKED},
1525 {"/File/Folder" , M_UNLOCKED},
1526 {"/File/Import mbox file..." , M_UNLOCKED},
1527 {"/File/Export to mbox file...", M_UNLOCKED},
1528 {"/File/Empty trash" , M_UNLOCKED},
1529 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1530 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1531 /* {"/File/Close", M_UNLOCKED}, */
1532 {"/File/Exit" , M_UNLOCKED},
1534 {"/Edit/Actions" , M_MSG_EXIST},
1535 {"/View/Sort" , M_MSG_EXIST},
1536 {"/View/Thread view" , M_EXEC},
1537 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1538 {"/View/Go to/Prev message" , M_MSG_EXIST},
1539 {"/View/Go to/Next message" , M_MSG_EXIST},
1540 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1541 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1542 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1543 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1544 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1545 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1546 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1547 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1548 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1550 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1551 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1552 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1553 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1554 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1555 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1556 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1557 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1558 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1559 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1560 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1561 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1562 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1563 {"/Message/Mark" , M_TARGET_EXIST},
1564 {"/Message/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1566 {"/Tool/Add sender to address book", M_SINGLE_TARGET_EXIST},
1567 {"/Tool/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1568 {"/Tool/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1569 {"/Tool/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1571 {"/Configuration", M_UNLOCKED},
1576 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1577 state = main_window_get_current_state(mainwin);
1579 for (i = 0; entry[i].entry != NULL; i++) {
1580 sensitive = ((entry[i].cond & state) == entry[i].cond);
1581 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1584 main_window_menu_callback_block(mainwin);
1585 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all header");
1586 gtk_check_menu_item_set_active
1587 (GTK_CHECK_MENU_ITEM(menuitem),
1588 mainwin->messageview->textview->show_all_headers);
1589 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1590 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1591 (state & M_THREADED) != 0);
1592 main_window_menu_callback_unblock(mainwin);
1595 void main_window_popup(MainWindow *mainwin)
1601 gdk_window_get_origin(mainwin->window->window, &x, &y);
1602 sx = gdk_screen_width();
1603 sy = gdk_screen_height();
1604 x %= sx; if (x < 0) x = 0;
1605 y %= sy; if (y < 0) y = 0;
1606 gdk_window_move(mainwin->window->window, x, y);
1607 gdk_window_raise(mainwin->window->window);
1608 gdk_window_show(mainwin->window->window);
1610 debug_print("window position: x = %d, y = %d\n", x, y);
1612 switch (mainwin->type) {
1613 case SEPARATE_FOLDER:
1614 widget = mainwin->win.sep_folder.folderwin;
1615 gdk_window_get_origin(widget->window, &x, &y);
1616 x %= sx; if (x < 0) x = 0;
1617 y %= sy; if (y < 0) y = 0;
1618 gdk_window_move(widget->window, x, y);
1619 gdk_window_raise(widget->window);
1621 case SEPARATE_MESSAGE:
1622 widget = mainwin->win.sep_message.messagewin;
1623 gdk_window_get_origin(widget->window, &x, &y);
1624 x %= sx; if (x < 0) x = 0;
1625 y %= sy; if (y < 0) y = 0;
1626 gdk_window_move(widget->window, x, y);
1627 gdk_window_raise(widget->window);
1630 widget = mainwin->win.sep_both.folderwin;
1631 gdk_window_get_origin(widget->window, &x, &y);
1632 x %= sx; if (x < 0) x = 0;
1633 y %= sy; if (y < 0) y = 0;
1634 gdk_window_move(widget->window, x, y);
1635 gdk_window_raise(widget->window);
1636 widget = mainwin->win.sep_both.messagewin;
1637 gdk_window_get_origin(widget->window, &x, &y);
1638 x %= sx; if (x < 0) x = 0;
1639 y %= sy; if (y < 0) y = 0;
1640 gdk_window_move(widget->window, x, y);
1641 gdk_window_raise(widget->window);
1648 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1650 GtkWidget *folderwin = NULL;
1651 GtkWidget *messagewin = NULL;
1654 GtkWidget *vbox_body = mainwin->vbox_body;
1655 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1656 GtkWidget *menuitem;
1658 debug_print(_("Setting widgets..."));
1660 /* create separated window(s) if needed */
1661 if (type & SEPARATE_FOLDER) {
1662 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1663 gtk_window_set_title(GTK_WINDOW(folderwin),
1664 _("Sylpheed - Folder View"));
1665 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1666 "folder_view", "Sylpheed");
1667 gtk_window_set_policy(GTK_WINDOW(folderwin),
1669 gtk_widget_set_usize(folderwin, -1,
1670 prefs_common.mainview_height);
1671 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1673 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1674 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1677 if (type & SEPARATE_MESSAGE) {
1678 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1679 gtk_window_set_title(GTK_WINDOW(messagewin),
1680 _("Sylpheed - Message View"));
1681 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1682 "message_view", "Sylpheed");
1683 gtk_window_set_policy(GTK_WINDOW(messagewin),
1685 gtk_widget_set_usize
1686 (messagewin, prefs_common.mainview_width,
1687 prefs_common.mainview_height
1688 - prefs_common.summaryview_height
1689 + DEFAULT_HEADERVIEW_HEIGHT);
1690 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1692 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1693 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1699 hpaned = gtk_hpaned_new();
1700 gtk_widget_show(hpaned);
1701 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1702 gtk_paned_add1(GTK_PANED(hpaned),
1703 GTK_WIDGET_PTR(mainwin->folderview));
1705 vpaned = gtk_vpaned_new();
1706 if (mainwin->summaryview->msg_is_toggled_on) {
1707 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1708 gtk_paned_add1(GTK_PANED(vpaned),
1709 GTK_WIDGET_PTR(mainwin->summaryview));
1711 gtk_paned_add2(GTK_PANED(hpaned),
1712 GTK_WIDGET_PTR(mainwin->summaryview));
1713 gtk_widget_ref(vpaned);
1715 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1716 prefs_common.summaryview_width,
1717 prefs_common.summaryview_height);
1718 gtk_paned_add2(GTK_PANED(vpaned),
1719 GTK_WIDGET_PTR(mainwin->messageview));
1720 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1721 prefs_common.mainview_width, -1);
1722 gtk_widget_set_usize(mainwin->window,
1723 prefs_common.folderview_width +
1724 prefs_common.mainview_width,
1725 prefs_common.mainwin_height);
1726 gtk_widget_show_all(vpaned);
1728 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1729 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1730 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1731 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1732 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1733 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1735 mainwin->win.sep_none.hpaned = hpaned;
1736 mainwin->win.sep_none.vpaned = vpaned;
1738 case SEPARATE_FOLDER:
1739 vpaned = gtk_vpaned_new();
1740 if (mainwin->summaryview->msg_is_toggled_on) {
1741 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1743 gtk_paned_add1(GTK_PANED(vpaned),
1744 GTK_WIDGET_PTR(mainwin->summaryview));
1746 gtk_box_pack_start(GTK_BOX(vbox_body),
1747 GTK_WIDGET_PTR(mainwin->summaryview),
1749 gtk_widget_ref(vpaned);
1751 gtk_paned_add2(GTK_PANED(vpaned),
1752 GTK_WIDGET_PTR(mainwin->messageview));
1753 gtk_widget_show_all(vpaned);
1754 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1755 prefs_common.summaryview_width,
1756 prefs_common.summaryview_height);
1757 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1758 prefs_common.mainview_width, -1);
1759 gtk_widget_set_usize(mainwin->window,
1760 prefs_common.mainview_width,
1761 prefs_common.mainview_height);
1763 gtk_container_add(GTK_CONTAINER(folderwin),
1764 GTK_WIDGET_PTR(mainwin->folderview));
1766 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1767 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1769 mainwin->win.sep_folder.folderwin = folderwin;
1770 mainwin->win.sep_folder.vpaned = vpaned;
1772 gtk_widget_show_all(folderwin);
1774 case SEPARATE_MESSAGE:
1775 hpaned = gtk_hpaned_new();
1776 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1778 gtk_paned_add1(GTK_PANED(hpaned),
1779 GTK_WIDGET_PTR(mainwin->folderview));
1780 gtk_paned_add2(GTK_PANED(hpaned),
1781 GTK_WIDGET_PTR(mainwin->summaryview));
1782 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1783 prefs_common.summaryview_width,
1784 prefs_common.summaryview_height);
1785 gtk_widget_set_usize(mainwin->window,
1786 prefs_common.folderview_width +
1787 prefs_common.mainview_width,
1788 prefs_common.mainwin_height);
1789 gtk_widget_show_all(hpaned);
1790 gtk_container_add(GTK_CONTAINER(messagewin),
1791 GTK_WIDGET_PTR(mainwin->messageview));
1793 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1794 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1795 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1796 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1798 mainwin->win.sep_message.messagewin = messagewin;
1799 mainwin->win.sep_message.hpaned = hpaned;
1801 gtk_widget_show_all(messagewin);
1804 gtk_box_pack_start(GTK_BOX(vbox_body),
1805 GTK_WIDGET_PTR(mainwin->summaryview),
1807 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1808 prefs_common.summaryview_width,
1809 prefs_common.summaryview_height);
1810 gtk_widget_set_usize(mainwin->window,
1811 prefs_common.mainview_width,
1812 prefs_common.mainwin_height);
1813 gtk_container_add(GTK_CONTAINER(folderwin),
1814 GTK_WIDGET_PTR(mainwin->folderview));
1815 gtk_container_add(GTK_CONTAINER(messagewin),
1816 GTK_WIDGET_PTR(mainwin->messageview));
1818 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1819 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1821 mainwin->win.sep_both.folderwin = folderwin;
1822 mainwin->win.sep_both.messagewin = messagewin;
1824 gtk_widget_show_all(folderwin);
1825 gtk_widget_show_all(messagewin);
1829 mainwin->type = type;
1831 debug_print(_("done.\n"));
1834 static void main_window_toolbar_create(MainWindow *mainwin,
1835 GtkWidget *container)
1838 GtkWidget *icon_wid;
1840 GtkWidget *getall_btn;
1841 GtkWidget *compose_mail_btn;
1842 GtkWidget *compose_news_btn;
1843 GtkWidget *reply_btn;
1844 GtkWidget *replyall_btn;
1845 GtkWidget *replysender_btn;
1847 GtkWidget *send_btn;
1849 GtkWidget *prefs_btn;
1850 GtkWidget *account_btn;
1852 GtkWidget *next_btn;
1853 GtkWidget *delete_btn;
1854 GtkWidget *exec_btn;
1856 GtkTooltips *tooltips;
1858 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1860 gtk_container_add(GTK_CONTAINER(container), toolbar);
1861 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1862 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1863 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1864 GTK_TOOLBAR_SPACE_LINE);
1866 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1867 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1869 _("Get new mail from current account"),
1871 icon_wid, toolbar_inc_cb, mainwin);
1872 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1873 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1875 _("Get new mail from all accounts"),
1881 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1883 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1884 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1886 _("Send queued message(s)"),
1892 /* insert compose mail button widget */
1893 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1894 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1896 _("Compose an email message"),
1899 toolbar_compose_mail_cb,
1902 /* insert compose news button widget */
1903 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1904 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1906 _("Compose a news message"),
1909 toolbar_compose_news_cb,
1912 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1916 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1917 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1919 _("Reply to the message - Right button: more options"),
1925 /* replyall button */
1927 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1928 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1930 _("Reply to all - Right button: more options"),
1933 toolbar_reply_to_all_cb,
1936 /* reply to sender button */
1937 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1938 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1940 _("Reply to sender - Right button: more options"),
1943 toolbar_reply_to_sender_cb,
1946 /* forward button */
1947 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1948 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1950 _("Forward the message - Right button: more options"),
1956 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1958 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1959 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1961 _("Delete the message"),
1967 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1968 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1970 _("Execute marked process"),
1976 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
1977 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1979 _("Next unread message"),
1982 toolbar_next_unread_cb,
1986 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1988 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
1989 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1991 _("Common preference"),
1996 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
1997 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1999 _("Account setting"),
2004 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2005 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2009 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2010 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2013 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2014 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2017 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2018 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2021 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2022 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2026 mainwin->toolbar = toolbar;
2027 mainwin->get_btn = get_btn;
2028 mainwin->getall_btn = getall_btn;
2029 mainwin->compose_mail_btn = compose_mail_btn;
2030 mainwin->compose_news_btn = compose_news_btn;
2031 mainwin->reply_btn = reply_btn;
2032 mainwin->replyall_btn = replyall_btn;
2033 mainwin->replysender_btn = replysender_btn;
2034 mainwin->fwd_btn = fwd_btn;
2035 mainwin->send_btn = send_btn;
2037 mainwin->prefs_btn = prefs_btn;
2038 mainwin->account_btn = account_btn;
2040 mainwin->next_btn = next_btn;
2041 mainwin->delete_btn = delete_btn;
2042 mainwin->exec_btn = exec_btn;
2044 gtk_widget_show_all(toolbar);
2047 /* callback functions */
2048 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2050 MainWindow *mainwindow = (MainWindow *) data;
2054 if (event->button == 3) {
2055 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2056 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2057 menu_button_position, widget,
2058 event->button, event->time);
2062 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2064 MainWindow *mainwin = (MainWindow *)data;
2066 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2067 manage_window_focus_in(mainwin->window, NULL, NULL);
2070 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2072 MainWindow *mainwindow = (MainWindow *) data;
2076 if (event->button == 3) {
2077 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2078 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2079 menu_button_position, widget,
2080 event->button, event->time);
2084 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2086 MainWindow *mainwin = (MainWindow *)data;
2088 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2089 manage_window_focus_in(mainwin->window, NULL, NULL);
2092 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2094 MainWindow *mainwindow = (MainWindow *) data;
2095 GtkWidget *replysender_menu, *replysender_item;
2099 if (event->button == 3) {
2100 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2101 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2102 menu_button_position, widget,
2103 event->button, event->time);
2107 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2109 MainWindow *mainwin = (MainWindow *)data;
2111 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2112 manage_window_focus_in(mainwin->window, NULL, NULL);
2115 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2117 MainWindow *mainwindow = (MainWindow *) data;
2121 if (event->button == 3) {
2122 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2123 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2124 menu_button_position, widget,
2125 event->button, event->time);
2129 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2131 MainWindow *mainwin = (MainWindow *)data;
2133 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2134 manage_window_focus_in(mainwin->window, NULL, NULL);
2137 static void toolbar_inc_cb (GtkWidget *widget,
2140 MainWindow *mainwin = (MainWindow *)data;
2142 inc_mail_cb(mainwin, 0, NULL);
2145 static void toolbar_inc_all_cb (GtkWidget *widget,
2148 MainWindow *mainwin = (MainWindow *)data;
2150 inc_all_account_mail_cb(mainwin, 0, NULL);
2153 static void toolbar_send_cb (GtkWidget *widget,
2156 MainWindow *mainwin = (MainWindow *)data;
2158 send_queue_cb(mainwin, 0, NULL);
2161 static void toolbar_compose_cb (GtkWidget *widget,
2164 MainWindow *mainwin = (MainWindow *)data;
2166 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2167 compose_cb(mainwin, 0, NULL);
2169 compose_news_cb(mainwin, 0, NULL);
2172 static void toolbar_compose_news_cb (GtkWidget *widget,
2175 MainWindow *mainwin = (MainWindow *)data;
2177 compose_news_cb(mainwin, 0, NULL);
2180 static void toolbar_compose_mail_cb (GtkWidget *widget,
2183 MainWindow *mainwin = (MainWindow *)data;
2185 compose_mail_cb(mainwin, 0, NULL);
2188 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2190 MainWindow *mainwin = (MainWindow *)data;
2193 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2194 : COMPOSE_REPLY_WITHOUT_QUOTE,
2198 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2200 MainWindow *mainwin = (MainWindow *)data;
2203 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2204 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2209 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2211 MainWindow *mainwin = (MainWindow *)data;
2214 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2215 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2219 static void toolbar_forward_cb (GtkWidget *widget,
2222 MainWindow *mainwin = (MainWindow *)data;
2224 if (prefs_common.forward_as_attachment)
2225 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2227 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2230 static void toolbar_delete_cb (GtkWidget *widget,
2233 MainWindow *mainwin = (MainWindow *)data;
2235 summary_delete(mainwin->summaryview);
2238 static void toolbar_exec_cb (GtkWidget *widget,
2241 MainWindow *mainwin = (MainWindow *)data;
2243 summary_execute(mainwin->summaryview);
2246 static void toolbar_next_unread_cb (GtkWidget *widget,
2249 MainWindow *mainwin = (MainWindow *)data;
2251 next_unread_cb(mainwin, 0, NULL);
2254 static void toolbar_prefs_cb (GtkWidget *widget,
2257 prefs_common_open();
2260 static void toolbar_account_cb (GtkWidget *widget,
2263 MainWindow *mainwin = (MainWindow *)data;
2265 prefs_account_open_cb(mainwin, 0, NULL);
2268 static void toolbar_account_button_pressed(GtkWidget *widget,
2269 GdkEventButton *event,
2272 MainWindow *mainwin = (MainWindow *)data;
2275 if (event->button != 3) return;
2277 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2278 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2281 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2282 menu_button_position, widget,
2283 event->button, event->time);
2286 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2289 MainWindow *mainwin = (MainWindow *)data;
2293 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2294 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2297 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2298 menu_button_position, widget,
2299 event->button, event->time);
2302 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2304 MainWindow *mainwin = (MainWindow *)data;
2307 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2308 if (!button) return;
2309 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2310 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2311 manage_window_focus_in(mainwin->window, NULL, NULL);
2314 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2317 MainWindow *mainwin = (MainWindow *)data;
2319 if (mainwin->lock_count == 0)
2320 app_exit_cb(data, 0, widget);
2325 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2328 main_window_add_mailbox(mainwin);
2331 static void add_mbox_cb(MainWindow *mainwin, guint action,
2334 main_window_add_mbox(mainwin);
2337 static void update_folderview_cb(MainWindow *mainwin, guint action,
2340 summary_show(mainwin->summaryview, NULL, FALSE);
2341 folderview_rescan_all();
2344 static void new_folder_cb(MainWindow *mainwin, guint action,
2347 folderview_new_folder(mainwin->folderview);
2350 static void rename_folder_cb(MainWindow *mainwin, guint action,
2353 folderview_rename_folder(mainwin->folderview);
2356 static void delete_folder_cb(MainWindow *mainwin, guint action,
2359 folderview_delete_folder(mainwin->folderview);
2362 static void import_mbox_cb(MainWindow *mainwin, guint action,
2365 import_mbox(mainwin->summaryview->folder_item);
2368 static void export_mbox_cb(MainWindow *mainwin, guint action,
2371 export_mbox(mainwin->summaryview->folder_item);
2374 static void empty_trash_cb(MainWindow *mainwin, guint action,
2377 main_window_empty_trash(mainwin, TRUE);
2380 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2382 summary_save_as(mainwin->summaryview);
2385 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2387 summary_print(mainwin->summaryview);
2390 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2392 if (prefs_common.confirm_on_exit) {
2393 if (alertpanel(_("Exit"), _("Exit this program?"),
2394 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2396 manage_window_focus_in(mainwin->window, NULL, NULL);
2399 app_will_exit(widget, mainwin);
2402 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2405 summary_search(mainwin->summaryview);
2407 message_search(mainwin->messageview);
2410 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2413 switch (mainwin->type) {
2415 case SEPARATE_MESSAGE:
2417 case SEPARATE_FOLDER:
2418 if (GTK_CHECK_MENU_ITEM(widget)->active)
2419 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2421 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2424 if (GTK_CHECK_MENU_ITEM(widget)->active)
2425 gtk_widget_show(mainwin->win.sep_both.folderwin);
2427 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2432 static void toggle_message_cb(MainWindow *mainwin, guint action,
2435 switch (mainwin->type) {
2437 case SEPARATE_FOLDER:
2439 case SEPARATE_MESSAGE:
2440 if (GTK_CHECK_MENU_ITEM(widget)->active)
2441 gtk_widget_show(mainwin->win.sep_message.messagewin);
2443 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2446 if (GTK_CHECK_MENU_ITEM(widget)->active)
2447 gtk_widget_show(mainwin->win.sep_both.messagewin);
2449 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2454 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2457 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2458 mainwin->compose_btn_type);
2459 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2460 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2461 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2462 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2464 mainwin->toolbar_style = (ToolbarStyle)action;
2465 prefs_common.toolbar_style = (ToolbarStyle)action;
2467 set_toolbar_style(mainwin);
2470 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2473 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2474 gtk_widget_show(mainwin->hbox_stat);
2475 prefs_common.show_statusbar = TRUE;
2477 gtk_widget_hide(mainwin->hbox_stat);
2478 prefs_common.show_statusbar = FALSE;
2482 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2484 summary_toggle_view_real(mainwin->summaryview);
2487 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2489 messageview_toggle_view_real(mainwin->messageview);
2492 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2495 MainWindow *mainwin;
2498 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2499 g_return_if_fail(mainwin != NULL);
2501 type = mainwin->type ^ action;
2502 main_window_separation_change(mainwin, type);
2504 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2505 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2508 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2511 addressbook_open(NULL);
2514 static void log_window_show_cb(MainWindow *mainwin, guint action,
2517 log_window_show(mainwin->logwin);
2520 static void sel_download_cb(MainWindow *mainwin, guint action,
2523 selective_download(mainwin);
2526 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2531 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2534 inc_all_account_mail(mainwin);
2537 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2541 if (procmsg_send_queue() < 0)
2542 alertpanel_error(_("Some errors occurred while sending queued messages."));
2544 statusbar_pop_all();
2546 for (list = folder_get_list(); list != NULL; list = list->next) {
2549 folder = list->data;
2550 if (folder->queue) {
2551 folder_item_scan(folder->queue);
2552 folderview_update_item(folder->queue, TRUE);
2557 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2559 if (mainwin->summaryview->folder_item) {
2560 if (mainwin->summaryview->folder_item->folder->account != NULL
2561 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2562 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2564 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2570 static void compose_mail_cb(MainWindow *mainwin, guint action,
2577 if (mainwin->summaryview->folder_item) {
2578 ac = mainwin->summaryview->folder_item->folder->account;
2579 if (ac && ac->protocol != A_NNTP) {
2580 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2585 if(cur_account && (cur_account->protocol != A_NNTP)) {
2586 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2590 list = account_get_list();
2591 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2592 ac = (PrefsAccount *) cur->data;
2593 if (ac->protocol != A_NNTP) {
2594 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2600 static void compose_news_cb(MainWindow *mainwin, guint action,
2603 PrefsAccount * ac = NULL;
2607 if (mainwin->summaryview->folder_item) {
2608 ac = mainwin->summaryview->folder_item->folder->account;
2609 if (ac && ac->protocol == A_NNTP) {
2610 compose_new_with_recipient
2611 (ac, mainwin->summaryview->folder_item->path);
2616 list = account_get_list();
2617 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2618 ac = (PrefsAccount *) cur->data;
2619 if (ac->protocol == A_NNTP) {
2626 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2628 summary_reply(mainwin->summaryview, (ComposeMode)action);
2631 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2633 summary_move_to(mainwin->summaryview);
2636 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2638 summary_copy_to(mainwin->summaryview);
2641 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2643 summary_delete(mainwin->summaryview);
2646 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2648 summary_open_msg(mainwin->summaryview);
2651 static void view_source_cb(MainWindow *mainwin, guint action,
2654 summary_view_source(mainwin->summaryview);
2657 static void show_all_header_cb(MainWindow *mainwin, guint action,
2660 if (mainwin->menu_lock_count) return;
2661 summary_display_msg_selected(mainwin->summaryview,
2662 GTK_CHECK_MENU_ITEM(widget)->active);
2665 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2667 summary_reedit(mainwin->summaryview);
2670 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2672 summary_mark(mainwin->summaryview);
2675 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2677 summary_unmark(mainwin->summaryview);
2680 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2683 summary_mark_as_unread(mainwin->summaryview);
2686 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2689 summary_mark_as_read(mainwin->summaryview);
2692 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2695 summary_mark_all_read(mainwin->summaryview);
2698 static void add_address_cb(MainWindow *mainwin, guint action,
2701 summary_add_address(mainwin->summaryview);
2704 static void set_charset_cb(MainWindow *mainwin, guint action,
2709 str = conv_get_charset_str((CharSet)action);
2710 g_free(prefs_common.force_charset);
2711 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2713 summary_redisplay_msg(mainwin->summaryview);
2715 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2718 static void hide_read_messages (MainWindow *mainwin, guint action,
2721 if (!mainwin->summaryview->folder_item
2722 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2724 summary_toggle_show_read_messages(mainwin->summaryview);
2727 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2729 GtkItemFactory *ifactory;
2731 if (mainwin->menu_lock_count) return;
2732 if (!mainwin->summaryview->folder_item) return;
2734 ifactory = gtk_item_factory_from_widget(widget);
2736 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2737 summary_thread_build(mainwin->summaryview);
2738 mainwin->summaryview->folder_item->threaded = TRUE;
2740 summary_unthread(mainwin->summaryview);
2741 mainwin->summaryview->folder_item->threaded = 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, FOLDER_SEL_ALL, 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 create_filter_cb(MainWindow *mainwin, guint action,
2872 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2875 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2878 prefs_common_open();
2881 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2884 prefs_filter_open(NULL, NULL);
2887 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2890 prefs_scoring_open(NULL);
2893 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2896 prefs_filtering_open(NULL);
2899 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2902 prefs_template_open();
2905 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2908 prefs_actions_open(mainwin);
2911 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2915 new_account_cb(mainwin, 0, widget);
2917 gboolean prev_default = cur_account->is_default;
2919 prefs_account_open(cur_account);
2920 if (!prev_default && cur_account->is_default)
2921 account_set_as_default(cur_account);
2922 account_save_config_all();
2924 main_window_reflect_prefs_all();
2928 static void new_account_cb(MainWindow *mainwin, guint action,
2931 account_edit_open();
2932 if (!compose_get_compose_list()) account_add();
2935 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2937 cur_account = (PrefsAccount *)data;
2938 main_window_reflect_prefs_all();
2941 static void manual_open_cb(MainWindow *mainwin, guint action,
2944 manual_open((ManualLang)action);
2947 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2949 MainWindow *mainwin = (MainWindow *)data;
2953 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2954 LOCAL_FOLDER(folder)->rootpath,
2958 str = g_strdup_printf(_("Scanning folder %s ..."),
2959 LOCAL_FOLDER(folder)->rootpath);
2961 STATUSBAR_PUSH(mainwin, str);
2962 STATUSBAR_POP(mainwin);
2966 static void activate_compose_button (MainWindow *mainwin,
2968 ComposeButtonType type)
2970 SensitiveCond state = main_window_get_current_state(mainwin);
2972 if (style == TOOLBAR_NONE)
2975 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2976 : mainwin->compose_news_btn);
2977 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2978 : mainwin->compose_mail_btn);
2979 mainwin->compose_btn_type = type;
2982 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2984 if (mainwin->compose_btn_type != compose_btn_type)
2985 activate_compose_button(mainwin,
2986 prefs_common.toolbar_style,
2990 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
2992 MainWindow *mainwin = (MainWindow*) data;
2994 if (!mainwin) return;
2996 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
2999 #define BREAK_ON_MODIFIER_KEY() \
3000 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3002 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3004 MainWindow *mainwin = (MainWindow*) data;
3006 if (!mainwin || !event) return;
3008 switch (event->keyval) {
3009 case GDK_Q: /* Quit */
3010 BREAK_ON_MODIFIER_KEY();
3012 app_exit_cb(mainwin, 0, NULL);
3019 #undef BREAK_ON_MODIFIER_KEY
3021 static void set_toolbar_style(MainWindow *mainwin)
3023 switch (prefs_common.toolbar_style) {
3025 gtk_widget_hide(mainwin->handlebox);
3028 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3032 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3036 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3041 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3042 gtk_widget_show(mainwin->handlebox);
3043 gtk_widget_queue_resize(mainwin->handlebox);
3045 if (prefs_common.immediate_exec)
3046 gtk_widget_hide(mainwin->exec_btn);
3048 gtk_widget_show(mainwin->exec_btn);