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,
397 static void selthread_cb (MainWindow *mainwin,
400 static void create_filter_cb (MainWindow *mainwin,
404 static void prefs_common_open_cb (MainWindow *mainwin,
407 static void prefs_filter_open_cb (MainWindow *mainwin,
410 static void prefs_scoring_open_cb (MainWindow *mainwin,
413 static void prefs_filtering_open_cb (MainWindow *mainwin,
416 static void prefs_account_open_cb(MainWindow *mainwin,
419 static void prefs_template_open_cb (MainWindow *mainwin,
422 static void prefs_actions_open_cb (MainWindow *mainwin,
425 static void new_account_cb (MainWindow *mainwin,
429 static void account_menu_cb (GtkMenuItem *menuitem,
432 static void manual_open_cb (MainWindow *mainwin,
436 static void scan_tree_func (Folder *folder,
440 static void activate_compose_button (MainWindow *mainwin,
442 ComposeButtonType type);
444 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
448 static void key_pressed (GtkWidget *widget,
452 static void set_toolbar_style(MainWindow *mainwin);
454 #define SEPARATE_ACTION 667
456 static GtkItemFactoryEntry mainwin_entries[] =
458 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
459 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
460 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
461 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
462 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
463 {N_("/_File/_Folder/Create _new folder..."),
464 NULL, new_folder_cb, 0, NULL},
465 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
466 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
467 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
468 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
469 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
470 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
471 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
472 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
473 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
474 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
476 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
477 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
478 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
479 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
480 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
481 {N_("/_Edit/_Find in current message..."),
482 "<control>F", search_cb, 0, NULL},
483 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
484 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
485 {N_("/_Edit/Actio_ns"), NULL, NULL, 0, "<Branch>"},
487 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
488 {N_("/_View/Separate _Folder Tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
489 {N_("/_View/Separate _Message View"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
490 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
491 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
492 {N_("/_View/_Toolbar"), NULL, NULL, 0, "<Branch>"},
493 {N_("/_View/_Toolbar/Icon _and text"), NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
494 {N_("/_View/_Toolbar/_Icon"), NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Toolbar/Icon and text"},
495 {N_("/_View/_Toolbar/_Text"), NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Toolbar/Icon and text"},
496 {N_("/_View/_Toolbar/_None"), NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Toolbar/Icon and text"},
497 {N_("/_View/Status _bar"), NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
498 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
499 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
500 {N_("/_View/_Sort/Sort by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, NULL},
501 {N_("/_View/_Sort/Sort by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, NULL},
502 {N_("/_View/_Sort/Sort by _date"), NULL, sort_summary_cb, SORT_BY_DATE, NULL},
503 {N_("/_View/_Sort/Sort by _from"), NULL, sort_summary_cb, SORT_BY_FROM, NULL},
504 {N_("/_View/_Sort/Sort by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, NULL},
505 {N_("/_View/_Sort/Sort by _color label"),
506 NULL, sort_summary_cb, SORT_BY_LABEL, NULL},
507 {N_("/_View/_Sort/Sort by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, NULL},
508 {N_("/_View/_Sort/Sort by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, NULL},
509 {N_("/_View/_Sort/Sort by a_ttachment"),
510 NULL, sort_summary_cb, SORT_BY_MIME, NULL},
511 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
512 {N_("/_View/_Sort/_Attract by subject"),
513 NULL, attract_by_subject_cb, 0, NULL},
514 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
515 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
516 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
517 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
519 #define CODESET_SEPARATOR \
520 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
521 #define CODESET_ACTION(action) \
522 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
524 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
525 {N_("/_View/_Code set/_Auto detect"),
526 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
527 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
528 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
529 CODESET_ACTION(C_US_ASCII)},
532 {N_("/_View/_Code set/Unicode (_UTF-8)"),
533 CODESET_ACTION(C_UTF_8)},
536 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
537 CODESET_ACTION(C_ISO_8859_1)},
538 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
539 CODESET_ACTION(C_ISO_8859_15)},
542 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
543 CODESET_ACTION(C_ISO_8859_2)},
545 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
546 CODESET_ACTION(C_ISO_8859_13)},
547 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
548 CODESET_ACTION(C_ISO_8859_4)},
550 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
551 CODESET_ACTION(C_ISO_8859_7)},
553 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
554 CODESET_ACTION(C_ISO_8859_9)},
556 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
557 CODESET_ACTION(C_ISO_8859_5)},
558 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
559 CODESET_ACTION(C_KOI8_R)},
560 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
561 CODESET_ACTION(C_CP1251)},
564 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
565 CODESET_ACTION(C_ISO_2022_JP)},
567 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
568 CODESET_ACTION(C_ISO_2022_JP_2)},
570 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
571 CODESET_ACTION(C_EUC_JP)},
572 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
573 CODESET_ACTION(C_SHIFT_JIS)},
576 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
577 CODESET_ACTION(C_GB2312)},
578 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
579 CODESET_ACTION(C_BIG5)},
580 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
581 CODESET_ACTION(C_EUC_TW)},
582 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
583 CODESET_ACTION(C_ISO_2022_CN)},
585 {N_("/_View/_Code set/Korean (EUC-_KR)"),
586 CODESET_ACTION(C_EUC_KR)},
587 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
588 CODESET_ACTION(C_ISO_2022_KR)},
590 {N_("/_View/_Code set/Thai (TIS-620)"),
591 CODESET_ACTION(C_TIS_620)},
592 {N_("/_View/_Code set/Thai (Windows-874)"),
593 CODESET_ACTION(C_WINDOWS_874)},
596 #undef CODESET_SEPARATOR
597 #undef CODESET_ACTION
599 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
600 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
601 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
602 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
603 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
604 {N_("/_View/_Go to/P_rev unread message"),
605 "<shift>P", prev_unread_cb, 0, NULL},
606 {N_("/_View/_Go to/N_ext unread message"),
607 "<shift>N", next_unread_cb, 0, NULL},
608 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
609 {N_("/_View/_Go to/Prev _marked message"),
610 NULL, prev_marked_cb, 0, NULL},
611 {N_("/_View/_Go to/Next m_arked message"),
612 NULL, next_marked_cb, 0, NULL},
613 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
614 {N_("/_View/_Go to/Prev _labeled message"),
615 NULL, prev_labeled_cb, 0, NULL},
616 {N_("/_View/_Go to/Next la_beled message"),
617 NULL, next_labeled_cb, 0, NULL},
618 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
619 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
620 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
621 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
622 {N_("/_View/_View source"), "<control>U", view_source_cb, 0, NULL},
623 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
624 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
625 {N_("/_View/_Update"), "<control><alt>U", update_summary_cb, 0, NULL},
627 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
628 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
629 {N_("/_Message/Get from _all accounts"),
630 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
631 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
632 {N_("/_Message/Send queued messa_ges"),
633 NULL, send_queue_cb, 0, NULL},
634 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
635 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
636 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
637 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
638 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
639 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
640 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
641 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
642 {N_("/_Message/Bounce"), NULL, reply_cb, COMPOSE_BOUNCE, NULL},
643 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
644 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
645 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
646 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
647 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
648 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
649 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
650 {N_("/_Message/Delete du_plicated messages"),
651 NULL, delete_duplicated_cb, 0, NULL},
652 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
653 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
654 {N_("/_Message/_Mark/_Mark"), NULL, mark_cb, 0, NULL},
655 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
656 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
657 {N_("/_Message/_Mark/Mark as unr_ead"), NULL, mark_as_unread_cb, 0, NULL},
658 {N_("/_Message/_Mark/Mark as rea_d"),
659 NULL, mark_as_read_cb, 0, NULL},
660 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
662 {N_("/_Tool"), NULL, NULL, 0, "<Branch>"},
663 {N_("/_Tool/_Address book"), "<shift><control>A", addressbook_open_cb, 0, NULL},
664 {N_("/_Tool/Add sender to address boo_k"),
665 NULL, add_address_cb, 0, NULL},
666 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
667 {N_("/_Tool/_Filter messages"), NULL, filter_cb, 0, NULL},
668 {N_("/_Tool/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
669 {N_("/_Tool/_Create filter rule/_Automatically"),
670 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
671 {N_("/_Tool/_Create filter rule/by _From"),
672 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
673 {N_("/_Tool/_Create filter rule/by _To"),
674 NULL, create_filter_cb, FILTER_BY_TO, NULL},
675 {N_("/_Tool/_Create filter rule/by _Subject"),
676 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
677 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
678 {N_("/_Tool/E_xecute"), "X", execute_summary_cb, 0, NULL},
679 {N_("/_Tool/---"), NULL, NULL, 0, "<Separator>"},
680 {N_("/_Tool/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
681 {N_("/_Tool/_Selective Download"), "<alt>S", sel_download_cb, 0, NULL},
683 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
684 {N_("/_Configuration/_Common preferences..."),
685 NULL, prefs_common_open_cb, 0, NULL},
686 {N_("/_Configuration/_Filter setting..."),
687 NULL, prefs_filter_open_cb, 0, NULL},
688 {N_("/_Configuration/_Scoring ..."),
689 NULL, prefs_scoring_open_cb, 0, NULL},
690 {N_("/_Configuration/_Filtering ..."),
691 NULL, prefs_filtering_open_cb, 0, NULL},
692 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
693 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
694 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
695 {N_("/_Configuration/_Preferences for current account..."),
696 NULL, prefs_account_open_cb, 0, NULL},
697 {N_("/_Configuration/Create _new account..."),
698 NULL, new_account_cb, 0, NULL},
699 {N_("/_Configuration/_Edit accounts..."),
700 NULL, account_edit_open, 0, NULL},
701 {N_("/_Configuration/C_hange current account"),
702 NULL, NULL, 0, "<Branch>"},
704 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
705 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
706 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
707 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
708 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
709 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
711 static GtkItemFactoryEntry reply_popup_entries[] =
713 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
714 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
716 static GtkItemFactoryEntry replyall_popup_entries[] =
718 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
719 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
721 static GtkItemFactoryEntry replysender_popup_entries[] =
723 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
724 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
726 static GtkItemFactoryEntry fwd_popup_entries[] =
728 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
729 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
733 MainWindow *main_window_create(SeparateType type)
739 GtkWidget *handlebox;
740 GtkWidget *vbox_body;
741 GtkWidget *hbox_stat;
742 GtkWidget *statusbar;
743 GtkWidget *progressbar;
744 GtkWidget *statuslabel;
745 GtkWidget *ac_button;
748 FolderView *folderview;
749 SummaryView *summaryview;
750 MessageView *messageview;
751 GdkColormap *colormap;
754 guint n_menu_entries;
755 GtkItemFactory *ifactory;
758 GtkWidget *compose_popup;
759 GtkWidget *reply_popup;
760 GtkWidget *replyall_popup;
761 GtkWidget *replysender_popup;
762 GtkWidget *fwd_popup;
765 debug_print(_("Creating main window...\n"));
766 mainwin = g_new0(MainWindow, 1);
769 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
770 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
771 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
772 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
773 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
774 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
775 MANAGE_WINDOW_SIGNALS_CONNECT(window);
776 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
777 GTK_SIGNAL_FUNC(key_pressed), mainwin);
779 gtk_widget_realize(window);
780 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
783 gtkut_widget_set_app_icon(window);
785 vbox = gtk_vbox_new(FALSE, 0);
786 gtk_widget_show(vbox);
787 gtk_container_add(GTK_CONTAINER(window), vbox);
790 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
791 menubar = menubar_create(window, mainwin_entries,
792 n_menu_entries, "<Main>", mainwin);
793 gtk_widget_show(menubar);
794 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
796 handlebox = gtk_handle_box_new();
797 gtk_widget_show(handlebox);
798 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
800 /* create the popup menus for the reply buttons specials */
801 n_menu_entries = sizeof(reply_popup_entries) /
802 sizeof(reply_popup_entries[0]);
803 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
804 "<ReplyPopup>", mainwin);
805 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
806 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
807 n_menu_entries = sizeof(replyall_popup_entries) /
808 sizeof(replyall_popup_entries[0]);
809 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
810 "<ReplyAllPopup>", mainwin);
811 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
812 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
813 n_menu_entries = sizeof(replysender_popup_entries) /
814 sizeof(replysender_popup_entries[0]);
815 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
816 "<ReplySenderPopup>", mainwin);
817 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
818 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
819 /* create the popup menu for the forward button */
820 n_menu_entries = sizeof(fwd_popup_entries) /
821 sizeof(fwd_popup_entries[0]);
822 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
823 "<ForwardPopup>", mainwin);
824 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
825 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
827 main_window_toolbar_create(mainwin, handlebox);
829 /* vbox that contains body */
830 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
831 gtk_widget_show(vbox_body);
832 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
833 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
835 hbox_stat = gtk_hbox_new(FALSE, 2);
836 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
838 statusbar = statusbar_create();
839 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
841 progressbar = gtk_progress_bar_new();
842 gtk_widget_set_usize(progressbar, 120, 1);
843 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
845 statuslabel = gtk_label_new("");
846 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
848 ac_button = gtk_button_new();
849 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
850 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
851 gtk_widget_set_usize(ac_button, -1, 1);
852 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
853 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
854 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
856 ac_label = gtk_label_new("");
857 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
859 gtk_widget_show_all(hbox_stat);
862 mainwin->folderview = folderview = folderview_create();
863 mainwin->summaryview = summaryview = summary_create();
864 mainwin->messageview = messageview = messageview_create();
865 mainwin->logwin = log_window_create();
867 folderview->mainwin = mainwin;
868 folderview->summaryview = summaryview;
870 summaryview->mainwin = mainwin;
871 summaryview->folderview = folderview;
872 summaryview->messageview = messageview;
873 summaryview->window = window;
875 messageview->mainwin = mainwin;
877 mainwin->window = window;
878 mainwin->vbox = vbox;
879 mainwin->menubar = menubar;
880 mainwin->handlebox = handlebox;
881 mainwin->vbox_body = vbox_body;
882 mainwin->hbox_stat = hbox_stat;
883 mainwin->statusbar = statusbar;
884 mainwin->progressbar = progressbar;
885 mainwin->statuslabel = statuslabel;
886 mainwin->ac_button = ac_button;
887 mainwin->ac_label = ac_label;
888 mainwin->reply_popup = reply_popup;
889 mainwin->replyall_popup = replyall_popup;
890 mainwin->replysender_popup = replysender_popup;
891 mainwin->fwd_popup = fwd_popup;
893 /* set context IDs for status bar */
894 mainwin->mainwin_cid = gtk_statusbar_get_context_id
895 (GTK_STATUSBAR(statusbar), "Main Window");
896 mainwin->folderview_cid = gtk_statusbar_get_context_id
897 (GTK_STATUSBAR(statusbar), "Folder View");
898 mainwin->summaryview_cid = gtk_statusbar_get_context_id
899 (GTK_STATUSBAR(statusbar), "Summary View");
901 /* allocate colors for summary view and folder view */
902 summaryview->color_marked.red = summaryview->color_marked.green = 0;
903 summaryview->color_marked.blue = (guint16)65535;
905 summaryview->color_dim.red = summaryview->color_dim.green =
906 summaryview->color_dim.blue = COLOR_DIM;
908 folderview->color_new.red = (guint16)55000;
909 folderview->color_new.green = folderview->color_new.blue = 15000;
911 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
912 &folderview->color_op);
914 summaryview->color_important.red = 0;
915 summaryview->color_marked.green = 0;
916 summaryview->color_important.blue = (guint16)65535;
918 color[0] = summaryview->color_marked;
919 color[1] = summaryview->color_dim;
920 color[2] = folderview->color_new;
921 color[3] = folderview->color_op;
923 colormap = gdk_window_get_colormap(window->window);
924 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
925 for (i = 0; i < 4; i++) {
926 if (success[i] == FALSE)
927 g_warning(_("MainWindow: color allocation %d failed\n"), i);
930 debug_print(_("done.\n"));
932 main_window_set_widgets(mainwin, type);
935 ifactory = gtk_item_factory_from_widget(menubar);
936 menuitem = gtk_item_factory_get_item
937 (ifactory, "/View/Code set/Auto detect");
938 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
940 switch (prefs_common.toolbar_style) {
942 menuitem = gtk_item_factory_get_item
943 (ifactory, "/View/Toolbar/None");
946 menuitem = gtk_item_factory_get_item
947 (ifactory, "/View/Toolbar/Icon");
950 menuitem = gtk_item_factory_get_item
951 (ifactory, "/View/Toolbar/Text");
954 menuitem = gtk_item_factory_get_item
955 (ifactory, "/View/Toolbar/Icon and text");
957 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
959 gtk_widget_hide(mainwin->hbox_stat);
960 menuitem = gtk_item_factory_get_item(ifactory, "/View/Status bar");
961 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
962 prefs_common.show_statusbar);
963 #if 0 /* FIXED SEPARATE WINDOWS */
964 /* Message view and Folder tree are always shown at startup
965 * make that in the menu visible */
966 menuitem = gtk_item_factory_get_item(ifactory, "/View/Message view");
967 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
968 menuitem = gtk_item_factory_get_item(ifactory, "/View/Folder tree");
969 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
971 /* set the check of the SEPARATE_xxx menu items. we also need the main window
972 * as a property and pass the action type to the callback */
973 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
975 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
976 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
977 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
978 GUINT_TO_POINTER(SEPARATE_FOLDER));
980 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
982 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
983 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
984 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
985 GUINT_TO_POINTER(SEPARATE_MESSAGE));
987 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
988 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
991 /* set account selection menu */
992 ac_menu = gtk_item_factory_get_widget
993 (ifactory, "/Configuration/Change current account");
994 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
995 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
996 mainwin->ac_menu = ac_menu;
998 main_window_set_toolbar_sensitive(mainwin);
1000 /* Create actions menu */
1001 update_mainwin_actions_menu(ifactory, mainwin);
1003 /* show main window */
1004 gtk_widget_set_uposition(mainwin->window,
1005 prefs_common.mainwin_x,
1006 prefs_common.mainwin_y);
1007 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1008 prefs_common.mainwin_height);
1009 gtk_widget_show(mainwin->window);
1011 /* initialize views */
1012 folderview_init(folderview);
1013 summary_init(summaryview);
1014 messageview_init(messageview);
1015 log_window_init(mainwin->logwin);
1017 mainwin->lock_count = 0;
1018 mainwin->menu_lock_count = 0;
1019 mainwin->cursor_count = 0;
1022 watch_cursor = gdk_cursor_new(GDK_WATCH);
1024 mainwin_list = g_list_append(mainwin_list, mainwin);
1029 void main_window_cursor_wait(MainWindow *mainwin)
1032 if (mainwin->cursor_count == 0)
1033 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1035 mainwin->cursor_count++;
1040 void main_window_cursor_normal(MainWindow *mainwin)
1042 if (mainwin->cursor_count)
1043 mainwin->cursor_count--;
1045 if (mainwin->cursor_count == 0)
1046 gdk_window_set_cursor(mainwin->window->window, NULL);
1051 /* lock / unlock the user-interface */
1052 void main_window_lock(MainWindow *mainwin)
1054 if (mainwin->lock_count == 0)
1055 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1057 mainwin->lock_count++;
1059 main_window_set_menu_sensitive(mainwin);
1060 main_window_set_toolbar_sensitive(mainwin);
1063 void main_window_unlock(MainWindow *mainwin)
1065 if (mainwin->lock_count)
1066 mainwin->lock_count--;
1068 main_window_set_menu_sensitive(mainwin);
1069 main_window_set_toolbar_sensitive(mainwin);
1071 if (mainwin->lock_count == 0)
1072 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1075 static void main_window_menu_callback_block(MainWindow *mainwin)
1077 mainwin->menu_lock_count++;
1080 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1082 if (mainwin->menu_lock_count)
1083 mainwin->menu_lock_count--;
1086 void main_window_reflect_prefs_all(void)
1088 main_window_reflect_prefs_all_real(FALSE);
1091 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1094 MainWindow *mainwin;
1096 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1097 mainwin = (MainWindow *)cur->data;
1099 main_window_show_cur_account(mainwin);
1100 main_window_set_menu_sensitive(mainwin);
1101 main_window_set_toolbar_sensitive(mainwin);
1104 if (pixmap_theme_changed)
1106 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1107 mainwin->toolbar = NULL;
1108 main_window_toolbar_create(mainwin, mainwin->handlebox);
1109 set_toolbar_style(mainwin);
1110 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1111 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1112 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1115 summary_redisplay_msg(mainwin->summaryview);
1116 headerview_set_visibility(mainwin->messageview->headerview,
1117 prefs_common.display_header_pane);
1121 void main_window_set_summary_column(void)
1124 MainWindow *mainwin;
1126 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1127 mainwin = (MainWindow *)cur->data;
1128 summary_set_column_order(mainwin->summaryview);
1132 void main_window_set_account_menu(GList *account_list)
1134 GList *cur, *cur_ac, *cur_item;
1135 GtkWidget *menuitem;
1136 MainWindow *mainwin;
1137 PrefsAccount *ac_prefs;
1139 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1140 mainwin = (MainWindow *)cur->data;
1142 /* destroy all previous menu item */
1143 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1144 while (cur_item != NULL) {
1145 GList *next = cur_item->next;
1146 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1150 for (cur_ac = account_list; cur_ac != NULL;
1151 cur_ac = cur_ac->next) {
1152 ac_prefs = (PrefsAccount *)cur_ac->data;
1154 menuitem = gtk_menu_item_new_with_label
1155 (ac_prefs->account_name
1156 ? ac_prefs->account_name : _("Untitled"));
1157 gtk_widget_show(menuitem);
1158 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1159 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1160 GTK_SIGNAL_FUNC(account_menu_cb),
1166 static void main_window_show_cur_account(MainWindow *mainwin)
1171 ac_name = g_strdup(cur_account
1172 ? (cur_account->account_name
1173 ? cur_account->account_name : _("Untitled"))
1177 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1179 buf = g_strdup(PROG_VERSION);
1180 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1183 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1184 gtk_widget_queue_resize(mainwin->ac_button);
1189 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1191 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1192 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1193 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1195 if (mainwin->type == type) return;
1197 /* remove widgets from those containers */
1198 gtk_widget_ref(folder_wid);
1199 gtk_widget_ref(summary_wid);
1200 gtk_widget_ref(message_wid);
1201 gtkut_container_remove
1202 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1203 gtkut_container_remove
1204 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1205 gtkut_container_remove
1206 (GTK_CONTAINER(message_wid->parent), message_wid);
1208 /* clean containers */
1209 switch (mainwin->type) {
1211 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1213 case SEPARATE_FOLDER:
1214 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1215 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1217 case SEPARATE_MESSAGE:
1218 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1219 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1222 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1223 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1227 gtk_widget_hide(mainwin->window);
1228 main_window_set_widgets(mainwin, type);
1229 gtk_widget_show(mainwin->window);
1231 gtk_widget_unref(folder_wid);
1232 gtk_widget_unref(summary_wid);
1233 gtk_widget_unref(message_wid);
1236 void main_window_get_size(MainWindow *mainwin)
1238 GtkAllocation *allocation;
1240 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1242 prefs_common.summaryview_width = allocation->width;
1244 if (mainwin->summaryview->msg_is_toggled_on)
1245 prefs_common.summaryview_height = allocation->height;
1247 prefs_common.mainview_width = allocation->width;
1249 allocation = &mainwin->window->allocation;
1251 prefs_common.mainview_height = allocation->height;
1252 prefs_common.mainwin_width = allocation->width;
1253 prefs_common.mainwin_height = allocation->height;
1255 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1257 prefs_common.folderview_width = allocation->width;
1258 prefs_common.folderview_height = allocation->height;
1261 void main_window_get_position(MainWindow *mainwin)
1265 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1267 prefs_common.mainview_x = x;
1268 prefs_common.mainview_y = y;
1269 prefs_common.mainwin_x = x;
1270 prefs_common.mainwin_y = y;
1272 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1275 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1281 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1282 folder = FOLDER(list->data);
1283 if (folder && folder->trash && folder->trash->total > 0)
1287 if (!has_trash) return;
1290 if (alertpanel(_("Empty trash"),
1291 _("Empty all messages in trash?"),
1292 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1294 manage_window_focus_in(mainwin->window, NULL, NULL);
1297 procmsg_empty_trash();
1299 for (list = folder_get_list(); list != NULL; list = list->next) {
1300 folder = list->data;
1301 if (folder && folder->trash && folder->trash->total != 0) {
1302 folder_item_scan(folder->trash);
1303 folderview_update_item(folder->trash, TRUE);
1307 if (mainwin->summaryview->folder_item &&
1308 mainwin->summaryview->folder_item->stype == F_TRASH)
1309 gtk_widget_grab_focus(mainwin->folderview->ctree);
1312 void main_window_add_mailbox(MainWindow *mainwin)
1317 path = input_dialog(_("Add mailbox"),
1318 _("Input the location of mailbox.\n"
1319 "If the existing mailbox is specified, it will be\n"
1320 "scanned automatically."),
1323 if (folder_find_from_path(path)) {
1324 alertpanel_error(_("The mailbox `%s' already exists."), path);
1328 if (!strcmp(path, "Mail"))
1329 folder = folder_new(F_MH, _("Mailbox"), path);
1331 folder = folder_new(F_MH, g_basename(path), path);
1334 if (folder->create_tree(folder) < 0) {
1335 alertpanel_error(_("Creation of the mailbox failed.\n"
1336 "Maybe some files already exist, or you don't have the permission to write there."));
1337 folder_destroy(folder);
1342 folder_set_ui_func(folder, scan_tree_func, mainwin);
1343 folder->scan_tree(folder);
1344 folder_set_ui_func(folder, NULL, NULL);
1346 folderview_set(mainwin->folderview);
1349 void main_window_add_mbox(MainWindow *mainwin)
1355 path = input_dialog(_("Add mbox mailbox"),
1356 _("Input the location of mailbox."),
1361 if (folder_find_from_path(path)) {
1362 alertpanel_error(_("The mailbox `%s' already exists."), path);
1368 if (!strcmp(path, "Mail"))
1369 folder = folder_new(F_MBOX, _("Mailbox"), path);
1373 folder = folder_new(F_MBOX, g_basename(path), path);
1376 if (folder->create_tree(folder) < 0) {
1377 alertpanel_error(_("Creation of the mailbox failed."));
1378 folder_destroy(folder);
1384 item = folder_item_new(folder->name, NULL);
1385 item->folder = folder;
1386 folder->node = g_node_new(item);
1388 folder->create_folder(folder, item, "inbox");
1389 folder->create_folder(folder, item, "outbox");
1390 folder->create_folder(folder, item, "queue");
1391 folder->create_folder(folder, item, "draft");
1392 folder->create_folder(folder, item, "trash");
1394 folderview_set(mainwin->folderview);
1399 M_UNLOCKED = 1 << 0,
1400 M_MSG_EXIST = 1 << 1,
1401 M_TARGET_EXIST = 1 << 2,
1402 M_SINGLE_TARGET_EXIST = 1 << 3,
1404 M_ALLOW_REEDIT = 1 << 5,
1405 M_HAVE_ACCOUNT = 1 << 6,
1406 M_THREADED = 1 << 7,
1407 M_UNTHREADED = 1 << 8,
1408 M_ALLOW_DELETE = 1 << 9,
1410 M_HAVE_NEWS_ACCOUNT = 1 << 11,
1411 M_HIDE_READ_MSG = 1 << 12
1414 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1416 SensitiveCond state = 0;
1417 SummarySelection selection;
1418 FolderItem *item = mainwin->summaryview->folder_item;
1419 GList *account_list = account_get_list();
1421 selection = summary_get_selection_type(mainwin->summaryview);
1423 if (mainwin->lock_count == 0)
1424 state |= M_UNLOCKED;
1425 if (selection != SUMMARY_NONE)
1426 state |= M_MSG_EXIST;
1430 state |= M_THREADED;
1432 state |= M_UNTHREADED;
1433 /* if (item->folder->type != F_NEWS) */
1434 state |= M_ALLOW_DELETE;
1436 if (selection == SUMMARY_NONE && item->hide_read_msgs
1437 || selection != SUMMARY_NONE)
1438 state |= M_HIDE_READ_MSG;
1440 if (selection == SUMMARY_SELECTED_SINGLE ||
1441 selection == SUMMARY_SELECTED_MULTIPLE)
1442 state |= M_TARGET_EXIST;
1443 if (selection == SUMMARY_SELECTED_SINGLE)
1444 state |= M_SINGLE_TARGET_EXIST;
1445 if (mainwin->summaryview->folder_item &&
1446 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1448 if (selection == SUMMARY_SELECTED_SINGLE &&
1450 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1451 item->stype == F_QUEUE)))
1452 state |= M_ALLOW_REEDIT;
1454 state |= M_HAVE_ACCOUNT;
1456 for ( ; account_list != NULL; account_list = account_list->next) {
1457 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1458 state |= M_HAVE_NEWS_ACCOUNT;
1466 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1468 SensitiveCond state;
1477 entry[0].widget = mainwin->get_btn;
1478 entry[0].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1479 entry[1].widget = mainwin->getall_btn;
1480 entry[1].cond = M_HAVE_ACCOUNT|M_UNLOCKED;
1481 entry[2].widget = mainwin->compose_news_btn;
1482 entry[2].cond = M_HAVE_NEWS_ACCOUNT;
1483 entry[3].widget = mainwin->reply_btn;
1484 entry[3].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1485 entry[4].widget = mainwin->replyall_btn;
1486 entry[4].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1487 entry[5].widget = mainwin->replysender_btn;
1488 entry[5].cond = M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST;
1489 entry[6].widget = mainwin->fwd_btn;
1490 entry[6].cond = M_HAVE_ACCOUNT|M_TARGET_EXIST;
1491 /* entry[6].widget = mainwin->prefs_btn;
1492 entry[6].cond = M_UNLOCKED;
1493 entry[7].widget = mainwin->account_btn;
1494 entry[7].cond = M_UNLOCKED; */
1495 entry[7].widget = mainwin->next_btn;
1496 entry[7].cond = M_MSG_EXIST;
1497 entry[8].widget = mainwin->delete_btn;
1498 entry[8].cond = M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED;
1499 entry[9].widget = mainwin->exec_btn;
1500 entry[9].cond = M_MSG_EXIST|M_EXEC|M_UNLOCKED;
1501 entry[10].widget = NULL;
1504 state = main_window_get_current_state(mainwin);
1506 for (i = 0; entry[i].widget != NULL; i++) {
1507 sensitive = ((entry[i].cond & state) == entry[i].cond);
1508 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1511 activate_compose_button(mainwin,
1512 prefs_common.toolbar_style,
1513 mainwin->compose_btn_type);
1516 void main_window_set_menu_sensitive(MainWindow *mainwin)
1518 GtkItemFactory *ifactory;
1519 SensitiveCond state;
1521 GtkWidget *menuitem;
1524 static const struct {
1528 {"/File/Add mailbox..." , M_UNLOCKED},
1529 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1530 {"/File/Rescan folder tree" , M_UNLOCKED},
1531 {"/File/Folder" , M_UNLOCKED},
1532 {"/File/Import mbox file..." , M_UNLOCKED},
1533 {"/File/Export to mbox file...", M_UNLOCKED},
1534 {"/File/Empty trash" , M_UNLOCKED},
1535 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1536 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1537 /* {"/File/Close", M_UNLOCKED}, */
1538 {"/File/Exit" , M_UNLOCKED},
1540 {"/Edit/Actions" , M_MSG_EXIST},
1541 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1542 {"/View/Sort" , M_MSG_EXIST},
1543 {"/View/Thread view" , M_EXEC},
1544 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1545 {"/View/Go to/Prev message" , M_MSG_EXIST},
1546 {"/View/Go to/Next message" , M_MSG_EXIST},
1547 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1548 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1549 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1550 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1551 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1552 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1553 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1554 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1555 {"/View/View source" , M_SINGLE_TARGET_EXIST},
1557 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1558 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1559 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1560 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1561 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1562 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1563 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1564 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1565 {"/Message/Bounce" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1566 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1567 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1568 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1569 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1570 {"/Message/Mark" , M_TARGET_EXIST},
1571 {"/Message/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1573 {"/Tool/Add sender to address book", M_SINGLE_TARGET_EXIST},
1574 {"/Tool/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1575 {"/Tool/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1576 {"/Tool/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1578 {"/Configuration", M_UNLOCKED},
1583 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1584 state = main_window_get_current_state(mainwin);
1586 for (i = 0; entry[i].entry != NULL; i++) {
1587 sensitive = ((entry[i].cond & state) == entry[i].cond);
1588 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1591 main_window_menu_callback_block(mainwin);
1592 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Show all header");
1593 gtk_check_menu_item_set_active
1594 (GTK_CHECK_MENU_ITEM(menuitem),
1595 mainwin->messageview->textview->show_all_headers);
1596 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Thread view");
1597 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1598 (state & M_THREADED) != 0);
1599 main_window_menu_callback_unblock(mainwin);
1602 void main_window_popup(MainWindow *mainwin)
1608 gdk_window_get_origin(mainwin->window->window, &x, &y);
1609 sx = gdk_screen_width();
1610 sy = gdk_screen_height();
1611 x %= sx; if (x < 0) x = 0;
1612 y %= sy; if (y < 0) y = 0;
1613 gdk_window_move(mainwin->window->window, x, y);
1614 gdk_window_raise(mainwin->window->window);
1615 gdk_window_show(mainwin->window->window);
1617 debug_print("window position: x = %d, y = %d\n", x, y);
1619 switch (mainwin->type) {
1620 case SEPARATE_FOLDER:
1621 widget = mainwin->win.sep_folder.folderwin;
1622 gdk_window_get_origin(widget->window, &x, &y);
1623 x %= sx; if (x < 0) x = 0;
1624 y %= sy; if (y < 0) y = 0;
1625 gdk_window_move(widget->window, x, y);
1626 gdk_window_raise(widget->window);
1628 case SEPARATE_MESSAGE:
1629 widget = mainwin->win.sep_message.messagewin;
1630 gdk_window_get_origin(widget->window, &x, &y);
1631 x %= sx; if (x < 0) x = 0;
1632 y %= sy; if (y < 0) y = 0;
1633 gdk_window_move(widget->window, x, y);
1634 gdk_window_raise(widget->window);
1637 widget = mainwin->win.sep_both.folderwin;
1638 gdk_window_get_origin(widget->window, &x, &y);
1639 x %= sx; if (x < 0) x = 0;
1640 y %= sy; if (y < 0) y = 0;
1641 gdk_window_move(widget->window, x, y);
1642 gdk_window_raise(widget->window);
1643 widget = mainwin->win.sep_both.messagewin;
1644 gdk_window_get_origin(widget->window, &x, &y);
1645 x %= sx; if (x < 0) x = 0;
1646 y %= sy; if (y < 0) y = 0;
1647 gdk_window_move(widget->window, x, y);
1648 gdk_window_raise(widget->window);
1655 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1657 GtkWidget *folderwin = NULL;
1658 GtkWidget *messagewin = NULL;
1661 GtkWidget *vbox_body = mainwin->vbox_body;
1662 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1663 GtkWidget *menuitem;
1665 debug_print(_("Setting widgets..."));
1667 /* create separated window(s) if needed */
1668 if (type & SEPARATE_FOLDER) {
1669 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1670 gtk_window_set_title(GTK_WINDOW(folderwin),
1671 _("Sylpheed - Folder View"));
1672 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1673 "folder_view", "Sylpheed");
1674 gtk_window_set_policy(GTK_WINDOW(folderwin),
1676 gtk_widget_set_usize(folderwin, -1,
1677 prefs_common.mainview_height);
1678 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1680 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1681 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1684 if (type & SEPARATE_MESSAGE) {
1685 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1686 gtk_window_set_title(GTK_WINDOW(messagewin),
1687 _("Sylpheed - Message View"));
1688 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1689 "message_view", "Sylpheed");
1690 gtk_window_set_policy(GTK_WINDOW(messagewin),
1692 gtk_widget_set_usize
1693 (messagewin, prefs_common.mainview_width,
1694 prefs_common.mainview_height
1695 - prefs_common.summaryview_height
1696 + DEFAULT_HEADERVIEW_HEIGHT);
1697 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1699 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1700 GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete),
1706 hpaned = gtk_hpaned_new();
1707 gtk_widget_show(hpaned);
1708 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1709 gtk_paned_add1(GTK_PANED(hpaned),
1710 GTK_WIDGET_PTR(mainwin->folderview));
1712 vpaned = gtk_vpaned_new();
1713 if (mainwin->summaryview->msg_is_toggled_on) {
1714 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1715 gtk_paned_add1(GTK_PANED(vpaned),
1716 GTK_WIDGET_PTR(mainwin->summaryview));
1718 gtk_paned_add2(GTK_PANED(hpaned),
1719 GTK_WIDGET_PTR(mainwin->summaryview));
1720 gtk_widget_ref(vpaned);
1722 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1723 prefs_common.summaryview_width,
1724 prefs_common.summaryview_height);
1725 gtk_paned_add2(GTK_PANED(vpaned),
1726 GTK_WIDGET_PTR(mainwin->messageview));
1727 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1728 prefs_common.mainview_width, -1);
1729 gtk_widget_set_usize(mainwin->window,
1730 prefs_common.folderview_width +
1731 prefs_common.mainview_width,
1732 prefs_common.mainwin_height);
1733 gtk_widget_show_all(vpaned);
1735 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1736 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1737 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1738 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1739 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1740 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1742 mainwin->win.sep_none.hpaned = hpaned;
1743 mainwin->win.sep_none.vpaned = vpaned;
1745 case SEPARATE_FOLDER:
1746 vpaned = gtk_vpaned_new();
1747 if (mainwin->summaryview->msg_is_toggled_on) {
1748 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1750 gtk_paned_add1(GTK_PANED(vpaned),
1751 GTK_WIDGET_PTR(mainwin->summaryview));
1753 gtk_box_pack_start(GTK_BOX(vbox_body),
1754 GTK_WIDGET_PTR(mainwin->summaryview),
1756 gtk_widget_ref(vpaned);
1758 gtk_paned_add2(GTK_PANED(vpaned),
1759 GTK_WIDGET_PTR(mainwin->messageview));
1760 gtk_widget_show_all(vpaned);
1761 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1762 prefs_common.summaryview_width,
1763 prefs_common.summaryview_height);
1764 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1765 prefs_common.mainview_width, -1);
1766 gtk_widget_set_usize(mainwin->window,
1767 prefs_common.mainview_width,
1768 prefs_common.mainview_height);
1770 gtk_container_add(GTK_CONTAINER(folderwin),
1771 GTK_WIDGET_PTR(mainwin->folderview));
1773 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1774 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1776 mainwin->win.sep_folder.folderwin = folderwin;
1777 mainwin->win.sep_folder.vpaned = vpaned;
1779 gtk_widget_show_all(folderwin);
1781 case SEPARATE_MESSAGE:
1782 hpaned = gtk_hpaned_new();
1783 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1785 gtk_paned_add1(GTK_PANED(hpaned),
1786 GTK_WIDGET_PTR(mainwin->folderview));
1787 gtk_paned_add2(GTK_PANED(hpaned),
1788 GTK_WIDGET_PTR(mainwin->summaryview));
1789 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1790 prefs_common.summaryview_width,
1791 prefs_common.summaryview_height);
1792 gtk_widget_set_usize(mainwin->window,
1793 prefs_common.folderview_width +
1794 prefs_common.mainview_width,
1795 prefs_common.mainwin_height);
1796 gtk_widget_show_all(hpaned);
1797 gtk_container_add(GTK_CONTAINER(messagewin),
1798 GTK_WIDGET_PTR(mainwin->messageview));
1800 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1801 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1802 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1803 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1805 mainwin->win.sep_message.messagewin = messagewin;
1806 mainwin->win.sep_message.hpaned = hpaned;
1808 gtk_widget_show_all(messagewin);
1811 gtk_box_pack_start(GTK_BOX(vbox_body),
1812 GTK_WIDGET_PTR(mainwin->summaryview),
1814 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1815 prefs_common.summaryview_width,
1816 prefs_common.summaryview_height);
1817 gtk_widget_set_usize(mainwin->window,
1818 prefs_common.mainview_width,
1819 prefs_common.mainwin_height);
1820 gtk_container_add(GTK_CONTAINER(folderwin),
1821 GTK_WIDGET_PTR(mainwin->folderview));
1822 gtk_container_add(GTK_CONTAINER(messagewin),
1823 GTK_WIDGET_PTR(mainwin->messageview));
1825 menu_set_sensitive(ifactory, "/View/Message view", TRUE);
1826 menu_set_sensitive(ifactory, "/View/Folder tree", TRUE);
1828 mainwin->win.sep_both.folderwin = folderwin;
1829 mainwin->win.sep_both.messagewin = messagewin;
1831 gtk_widget_show_all(folderwin);
1832 gtk_widget_show_all(messagewin);
1836 mainwin->type = type;
1838 debug_print(_("done.\n"));
1841 static void main_window_toolbar_create(MainWindow *mainwin,
1842 GtkWidget *container)
1845 GtkWidget *icon_wid;
1847 GtkWidget *getall_btn;
1848 GtkWidget *compose_mail_btn;
1849 GtkWidget *compose_news_btn;
1850 GtkWidget *reply_btn;
1851 GtkWidget *replyall_btn;
1852 GtkWidget *replysender_btn;
1854 GtkWidget *send_btn;
1856 GtkWidget *prefs_btn;
1857 GtkWidget *account_btn;
1859 GtkWidget *next_btn;
1860 GtkWidget *delete_btn;
1861 GtkWidget *exec_btn;
1863 GtkTooltips *tooltips;
1865 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
1867 gtk_container_add(GTK_CONTAINER(container), toolbar);
1868 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
1869 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
1870 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
1871 GTK_TOOLBAR_SPACE_LINE);
1873 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
1874 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1876 _("Get new mail from current account"),
1878 icon_wid, toolbar_inc_cb, mainwin);
1879 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
1880 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1882 _("Get new mail from all accounts"),
1888 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1890 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
1891 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1893 _("Send queued message(s)"),
1899 /* insert compose mail button widget */
1900 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
1901 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1903 _("Compose an email message"),
1906 toolbar_compose_mail_cb,
1909 /* insert compose news button widget */
1910 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
1911 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1913 _("Compose a news message"),
1916 toolbar_compose_news_cb,
1919 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1923 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
1924 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1926 _("Reply to the message - Right button: more options"),
1932 /* replyall button */
1934 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
1935 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1937 _("Reply to all - Right button: more options"),
1940 toolbar_reply_to_all_cb,
1943 /* reply to sender button */
1944 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
1945 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1947 _("Reply to sender - Right button: more options"),
1950 toolbar_reply_to_sender_cb,
1953 /* forward button */
1954 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
1955 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1957 _("Forward the message - Right button: more options"),
1963 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1965 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
1966 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1968 _("Delete the message"),
1974 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
1975 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1977 _("Execute marked process"),
1983 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
1984 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1986 _("Next unread message"),
1989 toolbar_next_unread_cb,
1993 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
1995 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
1996 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
1998 _("Common preference"),
2003 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2004 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2006 _("Account setting"),
2011 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2012 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2016 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2017 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2020 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2021 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2024 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2025 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2028 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2029 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2033 mainwin->toolbar = toolbar;
2034 mainwin->get_btn = get_btn;
2035 mainwin->getall_btn = getall_btn;
2036 mainwin->compose_mail_btn = compose_mail_btn;
2037 mainwin->compose_news_btn = compose_news_btn;
2038 mainwin->reply_btn = reply_btn;
2039 mainwin->replyall_btn = replyall_btn;
2040 mainwin->replysender_btn = replysender_btn;
2041 mainwin->fwd_btn = fwd_btn;
2042 mainwin->send_btn = send_btn;
2044 mainwin->prefs_btn = prefs_btn;
2045 mainwin->account_btn = account_btn;
2047 mainwin->next_btn = next_btn;
2048 mainwin->delete_btn = delete_btn;
2049 mainwin->exec_btn = exec_btn;
2051 gtk_widget_show_all(toolbar);
2054 /* callback functions */
2055 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2057 MainWindow *mainwindow = (MainWindow *) data;
2061 if (event->button == 3) {
2062 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2063 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2064 menu_button_position, widget,
2065 event->button, event->time);
2069 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2071 MainWindow *mainwin = (MainWindow *)data;
2073 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2074 manage_window_focus_in(mainwin->window, NULL, NULL);
2077 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2079 MainWindow *mainwindow = (MainWindow *) data;
2083 if (event->button == 3) {
2084 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2085 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2086 menu_button_position, widget,
2087 event->button, event->time);
2091 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2093 MainWindow *mainwin = (MainWindow *)data;
2095 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2096 manage_window_focus_in(mainwin->window, NULL, NULL);
2099 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2101 MainWindow *mainwindow = (MainWindow *) data;
2102 GtkWidget *replysender_menu, *replysender_item;
2106 if (event->button == 3) {
2107 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2108 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2109 menu_button_position, widget,
2110 event->button, event->time);
2114 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2116 MainWindow *mainwin = (MainWindow *)data;
2118 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2119 manage_window_focus_in(mainwin->window, NULL, NULL);
2122 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2124 MainWindow *mainwindow = (MainWindow *) data;
2128 if (event->button == 3) {
2129 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2130 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2131 menu_button_position, widget,
2132 event->button, event->time);
2136 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2138 MainWindow *mainwin = (MainWindow *)data;
2140 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2141 manage_window_focus_in(mainwin->window, NULL, NULL);
2144 static void toolbar_inc_cb (GtkWidget *widget,
2147 MainWindow *mainwin = (MainWindow *)data;
2149 inc_mail_cb(mainwin, 0, NULL);
2152 static void toolbar_inc_all_cb (GtkWidget *widget,
2155 MainWindow *mainwin = (MainWindow *)data;
2157 inc_all_account_mail_cb(mainwin, 0, NULL);
2160 static void toolbar_send_cb (GtkWidget *widget,
2163 MainWindow *mainwin = (MainWindow *)data;
2165 send_queue_cb(mainwin, 0, NULL);
2168 static void toolbar_compose_cb (GtkWidget *widget,
2171 MainWindow *mainwin = (MainWindow *)data;
2173 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2174 compose_cb(mainwin, 0, NULL);
2176 compose_news_cb(mainwin, 0, NULL);
2179 static void toolbar_compose_news_cb (GtkWidget *widget,
2182 MainWindow *mainwin = (MainWindow *)data;
2184 compose_news_cb(mainwin, 0, NULL);
2187 static void toolbar_compose_mail_cb (GtkWidget *widget,
2190 MainWindow *mainwin = (MainWindow *)data;
2192 compose_mail_cb(mainwin, 0, NULL);
2195 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2197 MainWindow *mainwin = (MainWindow *)data;
2200 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2201 : COMPOSE_REPLY_WITHOUT_QUOTE,
2205 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2207 MainWindow *mainwin = (MainWindow *)data;
2210 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2211 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2216 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2218 MainWindow *mainwin = (MainWindow *)data;
2221 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2222 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2226 static void toolbar_forward_cb (GtkWidget *widget,
2229 MainWindow *mainwin = (MainWindow *)data;
2231 if (prefs_common.forward_as_attachment)
2232 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2234 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2237 static void toolbar_delete_cb (GtkWidget *widget,
2240 MainWindow *mainwin = (MainWindow *)data;
2242 summary_delete(mainwin->summaryview);
2245 static void toolbar_exec_cb (GtkWidget *widget,
2248 MainWindow *mainwin = (MainWindow *)data;
2250 summary_execute(mainwin->summaryview);
2253 static void toolbar_next_unread_cb (GtkWidget *widget,
2256 MainWindow *mainwin = (MainWindow *)data;
2258 next_unread_cb(mainwin, 0, NULL);
2261 static void toolbar_prefs_cb (GtkWidget *widget,
2264 prefs_common_open();
2267 static void toolbar_account_cb (GtkWidget *widget,
2270 MainWindow *mainwin = (MainWindow *)data;
2272 prefs_account_open_cb(mainwin, 0, NULL);
2275 static void toolbar_account_button_pressed(GtkWidget *widget,
2276 GdkEventButton *event,
2279 MainWindow *mainwin = (MainWindow *)data;
2282 if (event->button != 3) return;
2284 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2285 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2288 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2289 menu_button_position, widget,
2290 event->button, event->time);
2293 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2296 MainWindow *mainwin = (MainWindow *)data;
2300 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2301 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2304 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2305 menu_button_position, widget,
2306 event->button, event->time);
2309 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2311 MainWindow *mainwin = (MainWindow *)data;
2314 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2315 if (!button) return;
2316 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2317 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2318 manage_window_focus_in(mainwin->window, NULL, NULL);
2321 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2324 MainWindow *mainwin = (MainWindow *)data;
2326 if (mainwin->lock_count == 0)
2327 app_exit_cb(data, 0, widget);
2332 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2335 main_window_add_mailbox(mainwin);
2338 static void add_mbox_cb(MainWindow *mainwin, guint action,
2341 main_window_add_mbox(mainwin);
2344 static void update_folderview_cb(MainWindow *mainwin, guint action,
2347 summary_show(mainwin->summaryview, NULL, FALSE);
2348 folderview_rescan_all();
2351 static void new_folder_cb(MainWindow *mainwin, guint action,
2354 folderview_new_folder(mainwin->folderview);
2357 static void rename_folder_cb(MainWindow *mainwin, guint action,
2360 folderview_rename_folder(mainwin->folderview);
2363 static void delete_folder_cb(MainWindow *mainwin, guint action,
2366 folderview_delete_folder(mainwin->folderview);
2369 static void import_mbox_cb(MainWindow *mainwin, guint action,
2372 import_mbox(mainwin->summaryview->folder_item);
2375 static void export_mbox_cb(MainWindow *mainwin, guint action,
2378 export_mbox(mainwin->summaryview->folder_item);
2381 static void empty_trash_cb(MainWindow *mainwin, guint action,
2384 main_window_empty_trash(mainwin, TRUE);
2387 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2389 summary_save_as(mainwin->summaryview);
2392 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2394 summary_print(mainwin->summaryview);
2397 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2399 if (prefs_common.confirm_on_exit) {
2400 if (alertpanel(_("Exit"), _("Exit this program?"),
2401 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2403 manage_window_focus_in(mainwin->window, NULL, NULL);
2406 app_will_exit(widget, mainwin);
2409 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2412 summary_search(mainwin->summaryview);
2414 message_search(mainwin->messageview);
2417 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2420 switch (mainwin->type) {
2422 case SEPARATE_MESSAGE:
2424 case SEPARATE_FOLDER:
2425 if (GTK_CHECK_MENU_ITEM(widget)->active)
2426 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2428 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2431 if (GTK_CHECK_MENU_ITEM(widget)->active)
2432 gtk_widget_show(mainwin->win.sep_both.folderwin);
2434 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2439 static void toggle_message_cb(MainWindow *mainwin, guint action,
2442 switch (mainwin->type) {
2444 case SEPARATE_FOLDER:
2446 case SEPARATE_MESSAGE:
2447 if (GTK_CHECK_MENU_ITEM(widget)->active)
2448 gtk_widget_show(mainwin->win.sep_message.messagewin);
2450 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2453 if (GTK_CHECK_MENU_ITEM(widget)->active)
2454 gtk_widget_show(mainwin->win.sep_both.messagewin);
2456 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2461 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2464 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2465 mainwin->compose_btn_type);
2466 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2467 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2468 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2469 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2471 mainwin->toolbar_style = (ToolbarStyle)action;
2472 prefs_common.toolbar_style = (ToolbarStyle)action;
2474 set_toolbar_style(mainwin);
2477 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2480 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2481 gtk_widget_show(mainwin->hbox_stat);
2482 prefs_common.show_statusbar = TRUE;
2484 gtk_widget_hide(mainwin->hbox_stat);
2485 prefs_common.show_statusbar = FALSE;
2489 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2491 summary_toggle_view_real(mainwin->summaryview);
2494 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2496 messageview_toggle_view_real(mainwin->messageview);
2499 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2502 MainWindow *mainwin;
2505 mainwin = (MainWindow *) gtk_object_get_data(GTK_OBJECT(checkitem), "mainwindow");
2506 g_return_if_fail(mainwin != NULL);
2508 type = mainwin->type ^ action;
2509 main_window_separation_change(mainwin, type);
2511 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2512 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2515 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2518 addressbook_open(NULL);
2521 static void log_window_show_cb(MainWindow *mainwin, guint action,
2524 log_window_show(mainwin->logwin);
2527 static void sel_download_cb(MainWindow *mainwin, guint action,
2530 selective_download(mainwin);
2533 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2535 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2538 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2541 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2544 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2548 if (procmsg_send_queue() < 0)
2549 alertpanel_error(_("Some errors occurred while sending queued messages."));
2551 statusbar_pop_all();
2553 for (list = folder_get_list(); list != NULL; list = list->next) {
2556 folder = list->data;
2557 if (folder->queue) {
2558 folder_item_scan(folder->queue);
2559 folderview_update_item(folder->queue, TRUE);
2564 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2566 if (mainwin->summaryview->folder_item) {
2567 if (mainwin->summaryview->folder_item->folder->account != NULL
2568 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2569 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2571 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2577 static void compose_mail_cb(MainWindow *mainwin, guint action,
2584 if (mainwin->summaryview->folder_item) {
2585 ac = mainwin->summaryview->folder_item->folder->account;
2586 if (ac && ac->protocol != A_NNTP) {
2587 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2592 if(cur_account && (cur_account->protocol != A_NNTP)) {
2593 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2597 list = account_get_list();
2598 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2599 ac = (PrefsAccount *) cur->data;
2600 if (ac->protocol != A_NNTP) {
2601 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2607 static void compose_news_cb(MainWindow *mainwin, guint action,
2610 PrefsAccount * ac = NULL;
2614 if (mainwin->summaryview->folder_item) {
2615 ac = mainwin->summaryview->folder_item->folder->account;
2616 if (ac && ac->protocol == A_NNTP) {
2617 compose_new_with_recipient
2618 (ac, mainwin->summaryview->folder_item->path);
2623 list = account_get_list();
2624 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2625 ac = (PrefsAccount *) cur->data;
2626 if (ac->protocol == A_NNTP) {
2633 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2635 summary_reply(mainwin->summaryview, (ComposeMode)action);
2638 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2640 summary_move_to(mainwin->summaryview);
2643 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2645 summary_copy_to(mainwin->summaryview);
2648 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2650 summary_delete(mainwin->summaryview);
2653 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2655 summary_open_msg(mainwin->summaryview);
2658 static void view_source_cb(MainWindow *mainwin, guint action,
2661 summary_view_source(mainwin->summaryview);
2664 static void show_all_header_cb(MainWindow *mainwin, guint action,
2667 if (mainwin->menu_lock_count) return;
2668 summary_display_msg_selected(mainwin->summaryview,
2669 GTK_CHECK_MENU_ITEM(widget)->active);
2672 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2674 summary_reedit(mainwin->summaryview);
2677 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2679 summary_mark(mainwin->summaryview);
2682 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2684 summary_unmark(mainwin->summaryview);
2687 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2690 summary_mark_as_unread(mainwin->summaryview);
2693 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2696 summary_mark_as_read(mainwin->summaryview);
2699 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2702 summary_mark_all_read(mainwin->summaryview);
2705 static void add_address_cb(MainWindow *mainwin, guint action,
2708 summary_add_address(mainwin->summaryview);
2711 static void set_charset_cb(MainWindow *mainwin, guint action,
2716 str = conv_get_charset_str((CharSet)action);
2717 g_free(prefs_common.force_charset);
2718 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2720 summary_redisplay_msg(mainwin->summaryview);
2722 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2725 static void hide_read_messages (MainWindow *mainwin, guint action,
2728 if (!mainwin->summaryview->folder_item
2729 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2731 summary_toggle_show_read_messages(mainwin->summaryview);
2734 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2736 GtkItemFactory *ifactory;
2738 if (mainwin->menu_lock_count) return;
2739 if (!mainwin->summaryview->folder_item) return;
2741 ifactory = gtk_item_factory_from_widget(widget);
2743 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2744 summary_thread_build(mainwin->summaryview);
2745 mainwin->summaryview->folder_item->threaded = TRUE;
2747 summary_unthread(mainwin->summaryview);
2748 mainwin->summaryview->folder_item->threaded = FALSE;
2752 static void set_display_item_cb(MainWindow *mainwin, guint action,
2755 prefs_summary_column_open();
2758 static void sort_summary_cb(MainWindow *mainwin, guint action,
2761 summary_sort(mainwin->summaryview, (SummarySortType)action);
2764 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2767 summary_attract_by_subject(mainwin->summaryview);
2770 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2773 summary_delete_duplicated(mainwin->summaryview);
2776 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2778 summary_filter(mainwin->summaryview);
2781 static void execute_summary_cb(MainWindow *mainwin, guint action,
2784 summary_execute(mainwin->summaryview);
2787 static void update_summary_cb(MainWindow *mainwin, guint action,
2791 FolderView *folderview = mainwin->folderview;
2793 if (!mainwin->summaryview->folder_item) return;
2794 if (!folderview->opened) return;
2796 folder_update_op_count();
2798 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2799 folderview->opened);
2802 summary_show(mainwin->summaryview, fitem, TRUE);
2805 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2807 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2810 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2812 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2815 static void prev_unread_cb(MainWindow *mainwin, guint action,
2818 summary_select_prev_unread(mainwin->summaryview);
2821 static void next_unread_cb(MainWindow *mainwin, guint action,
2824 summary_select_next_unread(mainwin->summaryview);
2827 static void prev_marked_cb(MainWindow *mainwin, guint action,
2830 summary_select_prev_marked(mainwin->summaryview);
2833 static void next_marked_cb(MainWindow *mainwin, guint action,
2836 summary_select_next_marked(mainwin->summaryview);
2839 static void prev_labeled_cb(MainWindow *mainwin, guint action,
2842 summary_select_prev_labeled(mainwin->summaryview);
2845 static void next_labeled_cb(MainWindow *mainwin, guint action,
2848 summary_select_next_labeled(mainwin->summaryview);
2851 static void goto_folder_cb(MainWindow *mainwin, guint action,
2854 FolderItem *to_folder;
2856 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
2859 folderview_select(mainwin->folderview, to_folder);
2862 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2864 messageview_copy_clipboard(mainwin->messageview);
2867 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2869 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
2870 summary_select_all(mainwin->summaryview);
2871 else if (mainwin->summaryview->msg_is_toggled_on &&
2872 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text))
2873 messageview_select_all(mainwin->messageview);
2876 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2878 if (mainwin->summaryview->msg_is_toggled_on)
2879 summary_select_thread(mainwin->summaryview);
2882 static void create_filter_cb(MainWindow *mainwin, guint action,
2885 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
2888 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
2891 prefs_common_open();
2894 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
2897 prefs_filter_open(NULL, NULL);
2900 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
2903 prefs_scoring_open(NULL);
2906 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
2909 prefs_filtering_open(NULL);
2912 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
2915 prefs_template_open();
2918 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
2921 prefs_actions_open(mainwin);
2924 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
2928 new_account_cb(mainwin, 0, widget);
2930 gboolean prev_default = cur_account->is_default;
2932 prefs_account_open(cur_account);
2933 if (!prev_default && cur_account->is_default)
2934 account_set_as_default(cur_account);
2935 account_save_config_all();
2937 main_window_reflect_prefs_all();
2941 static void new_account_cb(MainWindow *mainwin, guint action,
2944 account_edit_open();
2945 if (!compose_get_compose_list()) account_add();
2948 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
2950 cur_account = (PrefsAccount *)data;
2951 main_window_reflect_prefs_all();
2954 static void manual_open_cb(MainWindow *mainwin, guint action,
2957 manual_open((ManualLang)action);
2960 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
2962 MainWindow *mainwin = (MainWindow *)data;
2966 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
2967 LOCAL_FOLDER(folder)->rootpath,
2971 str = g_strdup_printf(_("Scanning folder %s ..."),
2972 LOCAL_FOLDER(folder)->rootpath);
2974 STATUSBAR_PUSH(mainwin, str);
2975 STATUSBAR_POP(mainwin);
2979 static void activate_compose_button (MainWindow *mainwin,
2981 ComposeButtonType type)
2983 SensitiveCond state = main_window_get_current_state(mainwin);
2985 if (style == TOOLBAR_NONE)
2988 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
2989 : mainwin->compose_news_btn);
2990 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
2991 : mainwin->compose_mail_btn);
2992 mainwin->compose_btn_type = type;
2995 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
2997 if (mainwin->compose_btn_type != compose_btn_type)
2998 activate_compose_button(mainwin,
2999 prefs_common.toolbar_style,
3003 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
3005 MainWindow *mainwin = (MainWindow*) data;
3007 if (!mainwin) return;
3009 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
3012 #define BREAK_ON_MODIFIER_KEY() \
3013 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3015 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3017 MainWindow *mainwin = (MainWindow*) data;
3019 if (!mainwin || !event) return;
3021 switch (event->keyval) {
3022 case GDK_Q: /* Quit */
3023 BREAK_ON_MODIFIER_KEY();
3025 app_exit_cb(mainwin, 0, NULL);
3032 #undef BREAK_ON_MODIFIER_KEY
3034 static void set_toolbar_style(MainWindow *mainwin)
3036 switch (prefs_common.toolbar_style) {
3038 gtk_widget_hide(mainwin->handlebox);
3041 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3045 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3049 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3054 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3055 gtk_widget_show(mainwin->handlebox);
3056 gtk_widget_queue_resize(mainwin->handlebox);
3058 if (prefs_common.immediate_exec)
3059 gtk_widget_hide(mainwin->exec_btn);
3061 gtk_widget_show(mainwin->exec_btn);