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 /* list of all instantiated MainWindow */
89 static GList *mainwin_list = NULL;
91 static GdkCursor *watch_cursor;
93 static void main_window_menu_callback_block (MainWindow *mainwin);
94 static void main_window_menu_callback_unblock (MainWindow *mainwin);
96 static void main_window_show_cur_account (MainWindow *mainwin);
98 static void main_window_set_widgets (MainWindow *mainwin,
100 static void main_window_toolbar_create (MainWindow *mainwin,
101 GtkWidget *container);
103 /* callback functions */
104 static void toolbar_inc_cb (GtkWidget *widget,
106 static void toolbar_inc_all_cb (GtkWidget *widget,
108 static void toolbar_send_cb (GtkWidget *widget,
111 static void toolbar_compose_news_cb (GtkWidget *widget,
113 static void toolbar_compose_mail_cb (GtkWidget *widget,
115 static void toolbar_reply_cb (GtkWidget *widget,
117 static void toolbar_reply_popup_cb (GtkWidget *widget,
118 GdkEventButton *event,
120 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell,
122 static void toolbar_reply_to_all_cb (GtkWidget *widget,
124 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget,
125 GdkEventButton *event,
127 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell,
129 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
131 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
132 GdkEventButton *event,
134 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell,
136 static void toolbar_forward_cb (GtkWidget *widget,
138 static void toolbar_forward_popup_cb (GtkWidget *widget,
139 GdkEventButton *event,
141 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell,
144 static void toolbar_delete_cb (GtkWidget *widget,
146 static void toolbar_exec_cb (GtkWidget *widget,
149 static void toolbar_next_unread_cb (GtkWidget *widget,
154 static void toolbar_account_button_pressed (GtkWidget *widget,
155 GdkEventButton *event,
158 static void ac_label_button_pressed (GtkWidget *widget,
159 GdkEventButton *event,
161 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
164 static gint main_window_close_cb (GtkWidget *widget,
167 static gint folder_window_close_cb (GtkWidget *widget,
170 static gint message_window_close_cb (GtkWidget *widget,
174 static void add_mailbox_cb (MainWindow *mainwin,
177 static void add_mbox_cb (MainWindow *mainwin,
180 static void update_folderview_cb (MainWindow *mainwin,
183 static void new_folder_cb (MainWindow *mainwin,
186 static void rename_folder_cb (MainWindow *mainwin,
189 static void delete_folder_cb (MainWindow *mainwin,
192 static void import_mbox_cb (MainWindow *mainwin,
195 static void export_mbox_cb (MainWindow *mainwin,
198 static void empty_trash_cb (MainWindow *mainwin,
202 static void save_as_cb (MainWindow *mainwin,
205 static void print_cb (MainWindow *mainwin,
208 static void app_exit_cb (MainWindow *mainwin,
212 static void search_cb (MainWindow *mainwin,
216 static void toggle_folder_cb (MainWindow *mainwin,
219 static void toggle_message_cb (MainWindow *mainwin,
222 static void toggle_toolbar_cb (MainWindow *mainwin,
225 static void toggle_statusbar_cb (MainWindow *mainwin,
228 static void separate_widget_cb (MainWindow *mainwin,
232 static void addressbook_open_cb (MainWindow *mainwin,
235 static void log_window_show_cb (MainWindow *mainwin,
238 static void sel_download_cb (MainWindow *mainwin,
242 static void inc_mail_cb (MainWindow *mainwin,
245 static void inc_all_account_mail_cb (MainWindow *mainwin,
248 static void inc_cancel_cb (MainWindow *mainwin,
252 static void send_queue_cb (MainWindow *mainwin,
256 static void compose_mail_cb(MainWindow *mainwin, guint action,
258 static void compose_news_cb(MainWindow *mainwin, guint action,
260 static void reply_cb (MainWindow *mainwin,
264 static void open_msg_cb (MainWindow *mainwin,
268 static void view_source_cb (MainWindow *mainwin,
272 static void show_all_header_cb (MainWindow *mainwin,
276 static void reedit_cb (MainWindow *mainwin,
280 static void move_to_cb (MainWindow *mainwin,
283 static void copy_to_cb (MainWindow *mainwin,
286 static void delete_cb (MainWindow *mainwin,
290 static void mark_cb (MainWindow *mainwin,
293 static void unmark_cb (MainWindow *mainwin,
297 static void mark_as_unread_cb (MainWindow *mainwin,
300 static void mark_as_read_cb (MainWindow *mainwin,
303 static void mark_all_read_cb (MainWindow *mainwin,
306 static void add_address_cb (MainWindow *mainwin,
310 static void set_charset_cb (MainWindow *mainwin,
314 static void hide_read_messages (MainWindow *mainwin,
318 static void thread_cb (MainWindow *mainwin,
321 static void expand_threads_cb (MainWindow *mainwin,
324 static void collapse_threads_cb (MainWindow *mainwin,
328 static void set_display_item_cb (MainWindow *mainwin,
331 static void sort_summary_cb (MainWindow *mainwin,
334 static void sort_summary_type_cb (MainWindow *mainwin,
337 static void attract_by_subject_cb(MainWindow *mainwin,
341 static void delete_duplicated_cb (MainWindow *mainwin,
344 static void filter_cb (MainWindow *mainwin,
347 static void execute_summary_cb (MainWindow *mainwin,
350 static void update_summary_cb (MainWindow *mainwin,
354 static void prev_cb (MainWindow *mainwin,
357 static void next_cb (MainWindow *mainwin,
361 static void prev_unread_cb (MainWindow *mainwin,
364 static void next_unread_cb (MainWindow *mainwin,
367 static void prev_new_cb (MainWindow *mainwin,
370 static void next_new_cb (MainWindow *mainwin,
373 static void prev_marked_cb (MainWindow *mainwin,
376 static void next_marked_cb (MainWindow *mainwin,
379 static void prev_labeled_cb (MainWindow *mainwin,
382 static void next_labeled_cb (MainWindow *mainwin,
386 static void goto_folder_cb (MainWindow *mainwin,
390 static void copy_cb (MainWindow *mainwin,
393 static void allsel_cb (MainWindow *mainwin,
396 static void selthread_cb (MainWindow *mainwin,
399 static void create_filter_cb (MainWindow *mainwin,
403 static void prefs_common_open_cb (MainWindow *mainwin,
406 static void prefs_filter_open_cb (MainWindow *mainwin,
409 static void prefs_template_open_cb (MainWindow *mainwin,
412 static void prefs_actions_open_cb (MainWindow *mainwin,
415 static void prefs_account_open_cb (MainWindow *mainwin,
418 static void prefs_scoring_open_cb (MainWindow *mainwin,
421 static void prefs_filtering_open_cb (MainWindow *mainwin,
425 static void new_account_cb (MainWindow *mainwin,
429 static void account_menu_cb (GtkMenuItem *menuitem,
432 static void online_switch_clicked(GtkButton *btn,
435 static void manual_open_cb (MainWindow *mainwin,
438 static void faq_open_cb (MainWindow *mainwin,
442 static void scan_tree_func (Folder *folder,
446 static void activate_compose_button (MainWindow *mainwin,
448 ComposeButtonType type);
450 static void key_pressed (GtkWidget *widget,
454 static void set_toolbar_style(MainWindow *mainwin);
456 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
458 static void addr_harvest_cb ( MainWindow *mainwin,
462 static void addr_harvest_msg_cb ( MainWindow *mainwin,
466 #define SEPARATE_ACTION 500
468 static GtkItemFactoryEntry mainwin_entries[] =
470 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
471 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
472 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
473 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
474 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
475 {N_("/_File/_Folder/Create _new folder..."),
476 NULL, new_folder_cb, 0, NULL},
477 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
478 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
479 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
480 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
481 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
482 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
483 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
484 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
485 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
486 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
487 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
488 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
490 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
491 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
492 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
493 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
494 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
495 {N_("/_Edit/_Find in current message..."),
496 "<control>F", search_cb, 0, NULL},
497 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
498 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
499 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
500 {N_("/_View/Show or hi_de/_Folder tree"),
501 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
502 {N_("/_View/Show or hi_de/_Message view"),
503 "V", toggle_message_cb, 0, "<ToggleItem>"},
504 {N_("/_View/Show or hi_de/_Toolbar"),
505 NULL, NULL, 0, "<Branch>"},
506 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
507 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
508 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
509 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
510 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
511 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
512 {N_("/_View/Show or hi_de/_Toolbar/_None"),
513 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
514 {N_("/_View/Show or hi_de/Status _bar"),
515 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
516 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
517 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
518 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
519 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
520 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
521 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
522 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
523 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
524 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
525 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
526 {N_("/_View/_Sort/by _color label"),
527 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
528 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
529 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
530 {N_("/_View/_Sort/by a_ttachment"),
531 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
532 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
533 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
534 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
535 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
536 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
537 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
538 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
539 {N_("/_View/_Sort/_Attract by subject"),
540 NULL, attract_by_subject_cb, 0, NULL},
541 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
542 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
543 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
544 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
545 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
547 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
548 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
549 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
550 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
551 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
552 {N_("/_View/_Go to/P_rev unread message"),
553 "<shift>P", prev_unread_cb, 0, NULL},
554 {N_("/_View/_Go to/N_ext unread message"),
555 "<shift>N", next_unread_cb, 0, NULL},
556 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
557 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
558 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
559 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
560 {N_("/_View/_Go to/Prev _marked message"),
561 NULL, prev_marked_cb, 0, NULL},
562 {N_("/_View/_Go to/Next m_arked message"),
563 NULL, next_marked_cb, 0, NULL},
564 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
565 {N_("/_View/_Go to/Prev _labeled message"),
566 NULL, prev_labeled_cb, 0, NULL},
567 {N_("/_View/_Go to/Next la_beled message"),
568 NULL, next_labeled_cb, 0, NULL},
569 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
570 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
571 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
573 #define CODESET_SEPARATOR \
574 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
575 #define CODESET_ACTION(action) \
576 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
578 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
579 {N_("/_View/_Code set/_Auto detect"),
580 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
581 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
582 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
583 CODESET_ACTION(C_US_ASCII)},
586 {N_("/_View/_Code set/Unicode (_UTF-8)"),
587 CODESET_ACTION(C_UTF_8)},
590 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
591 CODESET_ACTION(C_ISO_8859_1)},
592 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
593 CODESET_ACTION(C_ISO_8859_15)},
596 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
597 CODESET_ACTION(C_ISO_8859_2)},
599 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
600 CODESET_ACTION(C_ISO_8859_13)},
601 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
602 CODESET_ACTION(C_ISO_8859_4)},
604 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
605 CODESET_ACTION(C_ISO_8859_7)},
607 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
608 CODESET_ACTION(C_ISO_8859_9)},
610 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
611 CODESET_ACTION(C_ISO_8859_5)},
612 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
613 CODESET_ACTION(C_KOI8_R)},
614 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
615 CODESET_ACTION(C_WINDOWS_1251)},
618 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
619 CODESET_ACTION(C_ISO_2022_JP)},
621 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
622 CODESET_ACTION(C_ISO_2022_JP_2)},
624 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
625 CODESET_ACTION(C_EUC_JP)},
626 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
627 CODESET_ACTION(C_SHIFT_JIS)},
630 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
631 CODESET_ACTION(C_GB2312)},
632 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
633 CODESET_ACTION(C_BIG5)},
634 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
635 CODESET_ACTION(C_EUC_TW)},
636 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
637 CODESET_ACTION(C_ISO_2022_CN)},
639 {N_("/_View/_Code set/Korean (EUC-_KR)"),
640 CODESET_ACTION(C_EUC_KR)},
641 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
642 CODESET_ACTION(C_ISO_2022_KR)},
644 {N_("/_View/_Code set/Thai (TIS-620)"),
645 CODESET_ACTION(C_TIS_620)},
646 {N_("/_View/_Code set/Thai (Windows-874)"),
647 CODESET_ACTION(C_WINDOWS_874)},
650 #undef CODESET_SEPARATOR
651 #undef CODESET_ACTION
653 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
654 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
655 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
656 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
657 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
658 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
660 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
661 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
662 {N_("/_Message/Get from _all accounts"),
663 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
664 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
665 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
666 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
667 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
668 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
669 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
670 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
671 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
672 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
673 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
674 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
675 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
676 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
677 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
678 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
679 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
680 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
681 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
682 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
683 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
684 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
685 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
686 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
687 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
688 {N_("/_Message/_Mark/Mark as rea_d"),
689 NULL, mark_as_read_cb, 0, NULL},
690 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
692 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
693 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
694 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
695 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
696 {N_("/_Tools/Add sender to address boo_k"),
697 NULL, add_address_cb, 0, NULL},
698 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
699 {N_("/_Tools/_Harvest addresses/from _Folder..."),
700 NULL, addr_harvest_cb, 0, NULL},
701 {N_("/_Tools/_Harvest addresses/from _Messages..."),
702 NULL, addr_harvest_msg_cb, 0, NULL},
703 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
704 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
705 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
706 {N_("/_Tools/_Create filter rule/_Automatically"),
707 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
708 {N_("/_Tools/_Create filter rule/by _From"),
709 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
710 {N_("/_Tools/_Create filter rule/by _To"),
711 NULL, create_filter_cb, FILTER_BY_TO, NULL},
712 {N_("/_Tools/_Create filter rule/by _Subject"),
713 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
714 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
715 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
716 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
717 {N_("/_Tools/Delete du_plicated messages"),
718 NULL, delete_duplicated_cb, 0, NULL},
719 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
720 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
721 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
722 {N_("/_Tools/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
724 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
725 {N_("/_Configuration/_Common preferences..."),
726 NULL, prefs_common_open_cb, 0, NULL},
727 {N_("/_Configuration/_Filter setting..."),
728 NULL, prefs_filter_open_cb, 0, NULL},
729 {N_("/_Configuration/_Scoring..."),
730 NULL, prefs_scoring_open_cb, 0, NULL},
731 {N_("/_Configuration/_Filtering..."),
732 NULL, prefs_filtering_open_cb, 0, NULL},
733 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
734 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
735 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
736 {N_("/_Configuration/_Preferences for current account..."),
737 NULL, prefs_account_open_cb, 0, NULL},
738 {N_("/_Configuration/Create _new account..."),
739 NULL, new_account_cb, 0, NULL},
740 {N_("/_Configuration/_Edit accounts..."),
741 NULL, account_edit_open, 0, NULL},
742 {N_("/_Configuration/C_hange current account"),
743 NULL, NULL, 0, "<Branch>"},
745 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
746 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
747 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
748 {N_("/_Help/_Manual/_German"), NULL, manual_open_cb, MANUAL_LANG_DE, NULL},
749 {N_("/_Help/_Manual/_Spanish"), NULL, manual_open_cb, MANUAL_LANG_ES, NULL},
750 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
751 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
752 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
753 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
754 {N_("/_Help/_FAQ/_German"), NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
755 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
756 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
757 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
758 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
759 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
761 static GtkItemFactoryEntry reply_popup_entries[] =
763 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
764 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
766 static GtkItemFactoryEntry replyall_popup_entries[] =
768 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
769 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
771 static GtkItemFactoryEntry replysender_popup_entries[] =
773 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
774 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
776 static GtkItemFactoryEntry fwd_popup_entries[] =
778 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
779 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
782 MainWindow *main_window_create(SeparateType type)
788 GtkWidget *handlebox;
789 GtkWidget *vbox_body;
790 GtkWidget *hbox_stat;
791 GtkWidget *statusbar;
792 GtkWidget *progressbar;
793 GtkWidget *statuslabel;
794 GtkWidget *ac_button;
796 GtkWidget *online_status;
797 GtkWidget *offline_status;
798 GtkWidget *online_switch;
799 GtkWidget *offline_switch;
801 FolderView *folderview;
802 SummaryView *summaryview;
803 MessageView *messageview;
804 GdkColormap *colormap;
807 guint n_menu_entries;
808 GtkItemFactory *ifactory;
811 GtkWidget *reply_popup;
812 GtkWidget *replyall_popup;
813 GtkWidget *replysender_popup;
814 GtkWidget *fwd_popup;
817 static GdkGeometry geometry;
819 debug_print(_("Creating main window...\n"));
820 mainwin = g_new0(MainWindow, 1);
823 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
824 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
825 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
826 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
828 if (!geometry.min_height) {
829 geometry.min_width = 320;
830 geometry.min_height = 200;
832 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
835 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
836 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
837 MANAGE_WINDOW_SIGNALS_CONNECT(window);
838 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
839 GTK_SIGNAL_FUNC(key_pressed), mainwin);
841 gtk_widget_realize(window);
842 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
845 gtkut_widget_set_app_icon(window);
847 vbox = gtk_vbox_new(FALSE, 0);
848 gtk_widget_show(vbox);
849 gtk_container_add(GTK_CONTAINER(window), vbox);
852 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
853 menubar = menubar_create(window, mainwin_entries,
854 n_menu_entries, "<Main>", mainwin);
855 gtk_widget_show(menubar);
856 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
857 ifactory = gtk_item_factory_from_widget(menubar);
859 handlebox = gtk_handle_box_new();
860 gtk_widget_show(handlebox);
861 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
863 /* create the popup menus for the reply buttons specials */
864 n_menu_entries = sizeof(reply_popup_entries) /
865 sizeof(reply_popup_entries[0]);
866 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
867 "<ReplyPopup>", mainwin);
868 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
869 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
870 n_menu_entries = sizeof(replyall_popup_entries) /
871 sizeof(replyall_popup_entries[0]);
872 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
873 "<ReplyAllPopup>", mainwin);
874 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
875 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
876 n_menu_entries = sizeof(replysender_popup_entries) /
877 sizeof(replysender_popup_entries[0]);
878 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
879 "<ReplySenderPopup>", mainwin);
880 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
881 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
882 /* create the popup menu for the forward button */
883 n_menu_entries = sizeof(fwd_popup_entries) /
884 sizeof(fwd_popup_entries[0]);
885 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
886 "<ForwardPopup>", mainwin);
887 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
888 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
890 main_window_toolbar_create(mainwin, handlebox);
892 /* vbox that contains body */
893 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
894 gtk_widget_show(vbox_body);
895 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
896 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
898 hbox_stat = gtk_hbox_new(FALSE, 2);
899 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
901 statusbar = statusbar_create();
902 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
904 progressbar = gtk_progress_bar_new();
905 gtk_widget_set_usize(progressbar, 120, 1);
906 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
908 online_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
909 offline_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
910 online_switch = gtk_button_new ();
911 offline_switch = gtk_button_new ();
912 gtk_container_add (GTK_CONTAINER(online_switch), online_status);
913 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
914 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
915 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
916 gtk_container_add (GTK_CONTAINER(offline_switch), offline_status);
917 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
918 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
919 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
921 statuslabel = gtk_label_new("");
922 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
924 ac_button = gtk_button_new();
925 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
926 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
927 gtk_widget_set_usize(ac_button, -1, 1);
928 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
929 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
930 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
932 ac_label = gtk_label_new("");
933 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
935 gtk_widget_show_all(hbox_stat);
937 gtk_widget_hide(offline_switch);
939 mainwin->folderview = folderview = folderview_create();
940 mainwin->summaryview = summaryview = summary_create();
941 mainwin->messageview = messageview = messageview_create();
942 mainwin->logwin = log_window_create();
944 folderview->mainwin = mainwin;
945 folderview->summaryview = summaryview;
947 summaryview->mainwin = mainwin;
948 summaryview->folderview = folderview;
949 summaryview->messageview = messageview;
950 summaryview->window = window;
952 messageview->mainwin = mainwin;
954 mainwin->window = window;
955 mainwin->vbox = vbox;
956 mainwin->menubar = menubar;
957 mainwin->menu_factory = ifactory;
958 mainwin->handlebox = handlebox;
959 mainwin->vbox_body = vbox_body;
960 mainwin->hbox_stat = hbox_stat;
961 mainwin->statusbar = statusbar;
962 mainwin->progressbar = progressbar;
963 mainwin->statuslabel = statuslabel;
964 mainwin->ac_button = ac_button;
965 mainwin->ac_label = ac_label;
967 mainwin->reply_popup = reply_popup;
968 mainwin->replyall_popup = replyall_popup;
969 mainwin->replysender_popup = replysender_popup;
970 mainwin->fwd_popup = fwd_popup;
971 mainwin->online_switch = online_switch;
972 mainwin->offline_switch = offline_switch;
974 /* set context IDs for status bar */
975 mainwin->mainwin_cid = gtk_statusbar_get_context_id
976 (GTK_STATUSBAR(statusbar), "Main Window");
977 mainwin->folderview_cid = gtk_statusbar_get_context_id
978 (GTK_STATUSBAR(statusbar), "Folder View");
979 mainwin->summaryview_cid = gtk_statusbar_get_context_id
980 (GTK_STATUSBAR(statusbar), "Summary View");
982 /* allocate colors for summary view and folder view */
983 summaryview->color_marked.red = summaryview->color_marked.green = 0;
984 summaryview->color_marked.blue = (guint16)65535;
986 summaryview->color_dim.red = summaryview->color_dim.green =
987 summaryview->color_dim.blue = COLOR_DIM;
989 folderview->color_new.red = (guint16)55000;
990 folderview->color_new.green = folderview->color_new.blue = 15000;
992 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
993 &folderview->color_op);
995 summaryview->color_important.red = 0;
996 summaryview->color_important.green = 0;
997 summaryview->color_important.blue = (guint16)65535;
999 color[0] = summaryview->color_marked;
1000 color[1] = summaryview->color_dim;
1001 color[2] = folderview->color_new;
1002 color[3] = folderview->color_op;
1004 colormap = gdk_window_get_colormap(window->window);
1005 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1006 for (i = 0; i < 4; i++) {
1007 if (success[i] == FALSE)
1008 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1011 debug_print(_("done.\n"));
1013 messageview->visible = TRUE;
1015 main_window_set_widgets(mainwin, type);
1017 /* set menu items */
1018 menuitem = gtk_item_factory_get_item
1019 (ifactory, "/View/Code set/Auto detect");
1020 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1022 switch (prefs_common.toolbar_style) {
1024 menuitem = gtk_item_factory_get_item
1025 (ifactory, "/View/Show or hide/Toolbar/None");
1028 menuitem = gtk_item_factory_get_item
1029 (ifactory, "/View/Show or hide/Toolbar/Icon");
1032 menuitem = gtk_item_factory_get_item
1033 (ifactory, "/View/Show or hide/Toolbar/Text");
1036 menuitem = gtk_item_factory_get_item
1037 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1039 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1041 gtk_widget_hide(mainwin->hbox_stat);
1042 menuitem = gtk_item_factory_get_item
1043 (ifactory, "/View/Show or hide/Status bar");
1044 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1045 prefs_common.show_statusbar);
1047 /* set account selection menu */
1048 ac_menu = gtk_item_factory_get_widget
1049 (ifactory, "/Configuration/Change current account");
1050 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1051 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1052 mainwin->ac_menu = ac_menu;
1054 main_window_set_toolbar_sensitive(mainwin);
1056 /* create actions menu */
1057 update_mainwin_actions_menu(ifactory, mainwin);
1059 /* show main window */
1060 gtk_widget_set_uposition(mainwin->window,
1061 prefs_common.mainwin_x,
1062 prefs_common.mainwin_y);
1063 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1064 prefs_common.mainwin_height);
1065 gtk_widget_show(mainwin->window);
1067 /* initialize views */
1068 folderview_init(folderview);
1069 summary_init(summaryview);
1070 messageview_init(messageview);
1071 log_window_init(mainwin->logwin);
1073 mainwin->lock_count = 0;
1074 mainwin->menu_lock_count = 0;
1075 mainwin->cursor_count = 0;
1078 watch_cursor = gdk_cursor_new(GDK_WATCH);
1080 mainwin_list = g_list_append(mainwin_list, mainwin);
1082 /* init work_offline */
1083 if (prefs_common.work_offline)
1084 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1089 void main_window_cursor_wait(MainWindow *mainwin)
1092 if (mainwin->cursor_count == 0)
1093 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1095 mainwin->cursor_count++;
1100 void main_window_cursor_normal(MainWindow *mainwin)
1102 if (mainwin->cursor_count)
1103 mainwin->cursor_count--;
1105 if (mainwin->cursor_count == 0)
1106 gdk_window_set_cursor(mainwin->window->window, NULL);
1111 /* lock / unlock the user-interface */
1112 void main_window_lock(MainWindow *mainwin)
1114 if (mainwin->lock_count == 0)
1115 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1117 mainwin->lock_count++;
1119 main_window_set_menu_sensitive(mainwin);
1120 main_window_set_toolbar_sensitive(mainwin);
1123 void main_window_unlock(MainWindow *mainwin)
1125 if (mainwin->lock_count)
1126 mainwin->lock_count--;
1128 main_window_set_menu_sensitive(mainwin);
1129 main_window_set_toolbar_sensitive(mainwin);
1131 if (mainwin->lock_count == 0)
1132 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1135 static void main_window_menu_callback_block(MainWindow *mainwin)
1137 mainwin->menu_lock_count++;
1140 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1142 if (mainwin->menu_lock_count)
1143 mainwin->menu_lock_count--;
1146 void main_window_reflect_prefs_all(void)
1148 main_window_reflect_prefs_all_real(FALSE);
1151 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1154 MainWindow *mainwin;
1156 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1157 mainwin = (MainWindow *)cur->data;
1159 main_window_show_cur_account(mainwin);
1160 main_window_set_menu_sensitive(mainwin);
1161 main_window_set_toolbar_sensitive(mainwin);
1164 if (pixmap_theme_changed) {
1165 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1166 mainwin->toolbar = NULL;
1167 main_window_toolbar_create(mainwin, mainwin->handlebox);
1168 set_toolbar_style(mainwin);
1169 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1170 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1171 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1172 sd_reflect_prefs_pixmap_theme();
1175 if (prefs_common.immediate_exec)
1176 gtk_widget_hide(mainwin->exec_btn);
1178 gtk_widget_show(mainwin->exec_btn);
1180 summary_redisplay_msg(mainwin->summaryview);
1181 headerview_set_visibility(mainwin->messageview->headerview,
1182 prefs_common.display_header_pane);
1186 void main_window_set_summary_column(void)
1189 MainWindow *mainwin;
1191 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1192 mainwin = (MainWindow *)cur->data;
1193 summary_set_column_order(mainwin->summaryview);
1197 void main_window_set_account_menu(GList *account_list)
1199 GList *cur, *cur_ac, *cur_item;
1200 GtkWidget *menuitem;
1201 MainWindow *mainwin;
1202 PrefsAccount *ac_prefs;
1204 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1205 mainwin = (MainWindow *)cur->data;
1207 /* destroy all previous menu item */
1208 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1209 while (cur_item != NULL) {
1210 GList *next = cur_item->next;
1211 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1215 for (cur_ac = account_list; cur_ac != NULL;
1216 cur_ac = cur_ac->next) {
1217 ac_prefs = (PrefsAccount *)cur_ac->data;
1219 menuitem = gtk_menu_item_new_with_label
1220 (ac_prefs->account_name
1221 ? ac_prefs->account_name : _("Untitled"));
1222 gtk_widget_show(menuitem);
1223 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1224 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1225 GTK_SIGNAL_FUNC(account_menu_cb),
1231 static void main_window_show_cur_account(MainWindow *mainwin)
1236 ac_name = g_strdup(cur_account
1237 ? (cur_account->account_name
1238 ? cur_account->account_name : _("Untitled"))
1242 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1244 buf = g_strdup(PROG_VERSION);
1245 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1248 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1249 gtk_widget_queue_resize(mainwin->ac_button);
1254 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1256 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1257 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1258 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1260 debug_print(_("Changing window separation type from %d to %d\n"),
1261 mainwin->type, type);
1263 if (mainwin->type == type) return;
1265 /* remove widgets from those containers */
1266 gtk_widget_ref(folder_wid);
1267 gtk_widget_ref(summary_wid);
1268 gtk_widget_ref(message_wid);
1269 gtkut_container_remove
1270 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1271 gtkut_container_remove
1272 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1273 gtkut_container_remove
1274 (GTK_CONTAINER(message_wid->parent), message_wid);
1276 /* clean containers */
1277 switch (mainwin->type) {
1279 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1281 case SEPARATE_FOLDER:
1282 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1283 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1285 case SEPARATE_MESSAGE:
1286 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1287 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1290 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1291 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1295 gtk_widget_hide(mainwin->window);
1296 main_window_set_widgets(mainwin, type);
1297 gtk_widget_show(mainwin->window);
1299 gtk_widget_unref(folder_wid);
1300 gtk_widget_unref(summary_wid);
1301 gtk_widget_unref(message_wid);
1304 void main_window_toggle_message_view(MainWindow *mainwin)
1306 SummaryView *summaryview = mainwin->summaryview;
1307 union CompositeWin *cwin = &mainwin->win;
1308 GtkWidget *vpaned = NULL;
1309 GtkWidget *container = NULL;
1310 GtkWidget *msgwin = NULL;
1312 switch (mainwin->type) {
1314 vpaned = cwin->sep_none.vpaned;
1315 container = cwin->sep_none.hpaned;
1317 case SEPARATE_FOLDER:
1318 vpaned = cwin->sep_folder.vpaned;
1319 container = mainwin->vbox_body;
1321 case SEPARATE_MESSAGE:
1322 msgwin = mainwin->win.sep_message.messagewin;
1325 msgwin = mainwin->win.sep_both.messagewin;
1330 if (GTK_WIDGET_VISIBLE(msgwin)) {
1331 gtk_widget_hide(msgwin);
1332 mainwin->messageview->visible = FALSE;
1333 summaryview->displayed = NULL;
1335 gtk_widget_show(msgwin);
1336 mainwin->messageview->visible = TRUE;
1338 } else if (vpaned->parent != NULL) {
1339 mainwin->messageview->visible = FALSE;
1340 summaryview->displayed = NULL;
1341 gtk_widget_ref(vpaned);
1342 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1343 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1344 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1345 GTK_ARROW_UP, GTK_SHADOW_OUT);
1347 mainwin->messageview->visible = TRUE;
1348 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1349 gtk_container_add(GTK_CONTAINER(container), vpaned);
1350 gtk_widget_unref(vpaned);
1351 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1352 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1355 main_window_set_menu_sensitive(mainwin);
1357 gtk_widget_grab_focus(summaryview->ctree);
1360 void main_window_get_size(MainWindow *mainwin)
1362 GtkAllocation *allocation;
1364 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1366 prefs_common.summaryview_width = allocation->width;
1368 if ((mainwin->type == SEPARATE_NONE ||
1369 mainwin->type == SEPARATE_FOLDER) &&
1370 messageview_is_visible(mainwin->messageview))
1371 prefs_common.summaryview_height = allocation->height;
1373 prefs_common.mainview_width = allocation->width;
1375 allocation = &mainwin->window->allocation;
1377 prefs_common.mainview_height = allocation->height;
1378 prefs_common.mainwin_width = allocation->width;
1379 prefs_common.mainwin_height = allocation->height;
1381 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1383 prefs_common.folderview_width = allocation->width;
1384 prefs_common.folderview_height = allocation->height;
1387 void main_window_get_position(MainWindow *mainwin)
1391 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1393 prefs_common.mainview_x = x;
1394 prefs_common.mainview_y = y;
1395 prefs_common.mainwin_x = x;
1396 prefs_common.mainwin_y = y;
1398 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1401 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1407 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1408 folder = FOLDER(list->data);
1409 if (folder && folder->trash && folder->trash->total > 0)
1413 if (!has_trash) return;
1416 if (alertpanel(_("Empty trash"),
1417 _("Empty all messages in trash?"),
1418 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1420 manage_window_focus_in(mainwin->window, NULL, NULL);
1423 procmsg_empty_trash();
1425 for (list = folder_get_list(); list != NULL; list = list->next) {
1426 folder = list->data;
1427 if (folder && folder->trash) {
1428 folderview_update_item(folder->trash, TRUE);
1432 if (mainwin->summaryview->folder_item &&
1433 mainwin->summaryview->folder_item->stype == F_TRASH)
1434 gtk_widget_grab_focus(mainwin->folderview->ctree);
1437 void main_window_add_mailbox(MainWindow *mainwin)
1442 path = input_dialog(_("Add mailbox"),
1443 _("Input the location of mailbox.\n"
1444 "If the existing mailbox is specified, it will be\n"
1445 "scanned automatically."),
1448 if (folder_find_from_path(path)) {
1449 alertpanel_error(_("The mailbox `%s' already exists."), path);
1453 if (!strcmp(path, "Mail"))
1454 folder = folder_new(F_MH, _("Mailbox"), path);
1456 folder = folder_new(F_MH, g_basename(path), path);
1459 if (folder->create_tree(folder) < 0) {
1460 alertpanel_error(_("Creation of the mailbox failed.\n"
1461 "Maybe some files already exist, or you don't have the permission to write there."));
1462 folder_destroy(folder);
1467 folder_set_ui_func(folder, scan_tree_func, mainwin);
1468 folder_scan_tree(folder);
1469 folder_set_ui_func(folder, NULL, NULL);
1471 folderview_set(mainwin->folderview);
1474 void main_window_add_mbox(MainWindow *mainwin)
1480 path = input_dialog(_("Add mbox mailbox"),
1481 _("Input the location of mailbox."),
1486 if (folder_find_from_path(path)) {
1487 alertpanel_error(_("The mailbox `%s' already exists."), path);
1493 if (!strcmp(path, "Mail"))
1494 folder = folder_new(F_MBOX, _("Mailbox"), path);
1498 folder = folder_new(F_MBOX, g_basename(path), path);
1501 if (folder->create_tree(folder) < 0) {
1502 alertpanel_error(_("Creation of the mailbox failed."));
1503 folder_destroy(folder);
1509 item = folder_item_new(folder, folder->name, NULL);
1510 item->folder = folder;
1511 folder->node = g_node_new(item);
1513 folder->create_folder(folder, item, "inbox");
1514 folder->create_folder(folder, item, "outbox");
1515 folder->create_folder(folder, item, "queue");
1516 folder->create_folder(folder, item, "draft");
1517 folder->create_folder(folder, item, "trash");
1519 folderview_set(mainwin->folderview);
1524 M_UNLOCKED = 1 << 0,
1525 M_MSG_EXIST = 1 << 1,
1526 M_TARGET_EXIST = 1 << 2,
1527 M_SINGLE_TARGET_EXIST = 1 << 3,
1529 M_ALLOW_REEDIT = 1 << 5,
1530 M_HAVE_ACCOUNT = 1 << 6,
1531 M_THREADED = 1 << 7,
1532 M_UNTHREADED = 1 << 8,
1533 M_ALLOW_DELETE = 1 << 9,
1534 M_INC_ACTIVE = 1 << 10,
1536 M_HAVE_NEWS_ACCOUNT = 1 << 12,
1537 M_HIDE_READ_MSG = 1 << 13
1540 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1542 SensitiveCond state = 0;
1543 SummarySelection selection;
1544 FolderItem *item = mainwin->summaryview->folder_item;
1545 GList *account_list = account_get_list();
1547 selection = summary_get_selection_type(mainwin->summaryview);
1549 if (mainwin->lock_count == 0)
1550 state |= M_UNLOCKED;
1551 if (selection != SUMMARY_NONE)
1552 state |= M_MSG_EXIST;
1553 if (item && item->path && item->parent && !item->no_select) {
1556 state |= M_THREADED;
1558 state |= M_UNTHREADED;
1559 /* if (item->folder->type != F_NEWS) */
1560 state |= M_ALLOW_DELETE;
1562 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1563 || selection != SUMMARY_NONE)
1564 state |= M_HIDE_READ_MSG;
1566 if (selection == SUMMARY_SELECTED_SINGLE ||
1567 selection == SUMMARY_SELECTED_MULTIPLE)
1568 state |= M_TARGET_EXIST;
1569 if (selection == SUMMARY_SELECTED_SINGLE)
1570 state |= M_SINGLE_TARGET_EXIST;
1571 if (mainwin->summaryview->folder_item &&
1572 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1574 if (selection == SUMMARY_SELECTED_SINGLE &&
1576 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1577 item->stype == F_QUEUE)))
1578 state |= M_ALLOW_REEDIT;
1580 state |= M_HAVE_ACCOUNT;
1582 for ( ; account_list != NULL; account_list = account_list->next) {
1583 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1584 state |= M_HAVE_NEWS_ACCOUNT;
1589 if (inc_is_active())
1590 state |= M_INC_ACTIVE;
1595 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1597 SensitiveCond state;
1606 #define SET_WIDGET_COND(w, c) \
1608 entry[i].widget = w; \
1609 entry[i].cond = c; \
1613 SET_WIDGET_COND(mainwin->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1614 SET_WIDGET_COND(mainwin->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1615 SET_WIDGET_COND(mainwin->compose_news_btn, M_HAVE_ACCOUNT);
1616 SET_WIDGET_COND(mainwin->reply_btn,
1617 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1618 SET_WIDGET_COND(mainwin->replyall_btn,
1619 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1620 SET_WIDGET_COND(mainwin->replysender_btn,
1621 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1622 SET_WIDGET_COND(mainwin->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
1624 SET_WIDGET_COND(mainwin->prefs_btn, M_UNLOCKED);
1625 SET_WIDGET_COND(mainwin->account_btn, M_UNLOCKED);
1627 SET_WIDGET_COND(mainwin->next_btn, M_MSG_EXIST);
1628 SET_WIDGET_COND(mainwin->delete_btn,
1629 M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
1630 SET_WIDGET_COND(mainwin->exec_btn, M_MSG_EXIST|M_EXEC|M_UNLOCKED);
1631 SET_WIDGET_COND(NULL, 0);
1633 #undef SET_WIDGET_COND
1635 state = main_window_get_current_state(mainwin);
1637 for (i = 0; entry[i].widget != NULL; i++) {
1638 sensitive = ((entry[i].cond & state) == entry[i].cond);
1639 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1642 activate_compose_button(mainwin,
1643 prefs_common.toolbar_style,
1644 mainwin->compose_btn_type);
1647 void main_window_set_menu_sensitive(MainWindow *mainwin)
1649 GtkItemFactory *ifactory = mainwin->menu_factory;
1650 SensitiveCond state;
1652 GtkWidget *menuitem;
1657 static const struct {
1661 {"/File/Add mailbox..." , M_UNLOCKED},
1662 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1663 {"/File/Rescan folder tree" , M_UNLOCKED},
1664 {"/File/Folder" , M_UNLOCKED},
1665 {"/File/Import mbox file..." , M_UNLOCKED},
1666 {"/File/Export to mbox file...", M_UNLOCKED},
1667 {"/File/Empty trash" , M_UNLOCKED},
1668 {"/File/Work offline" , M_UNLOCKED},
1669 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1670 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1671 /* {"/File/Close", M_UNLOCKED}, */
1672 {"/File/Exit" , M_UNLOCKED},
1674 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1675 {"/View/Sort" , M_EXEC},
1676 {"/View/Thread view" , M_EXEC},
1677 {"/View/Expand all threads" , M_MSG_EXIST},
1678 {"/View/Collapse all threads" , M_MSG_EXIST},
1679 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1680 {"/View/Go to/Prev message" , M_MSG_EXIST},
1681 {"/View/Go to/Next message" , M_MSG_EXIST},
1682 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1683 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1684 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1685 {"/View/Go to/Next new message" , M_MSG_EXIST},
1686 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1687 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1688 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1689 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1690 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1691 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1692 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1694 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1695 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1696 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1697 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1698 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1699 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1700 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1701 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1702 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1703 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1704 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1705 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1706 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1707 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1708 {"/Message/Mark" , M_TARGET_EXIST},
1710 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1711 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1712 {"/Tools/Harvest addresses" , M_UNLOCKED},
1713 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1714 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1715 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1716 {"/Tools/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1717 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1719 {"/Configuration", M_UNLOCKED},
1724 state = main_window_get_current_state(mainwin);
1726 for (i = 0; entry[i].entry != NULL; i++) {
1727 sensitive = ((entry[i].cond & state) == entry[i].cond);
1728 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1731 main_window_menu_callback_block(mainwin);
1733 #define SET_CHECK_MENU_ACTIVE(path, active) \
1735 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1736 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1739 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1740 messageview_is_visible(mainwin->messageview));
1742 item = mainwin->summaryview->folder_item;
1743 menu_path = "/View/Sort/Don't sort";
1745 switch (item->sort_key) {
1746 case SORT_BY_NUMBER:
1747 menu_path = "/View/Sort/by number"; break;
1749 menu_path = "/View/Sort/by size"; break;
1751 menu_path = "/View/Sort/by date"; break;
1753 menu_path = "/View/Sort/by from"; break;
1754 case SORT_BY_SUBJECT:
1755 menu_path = "/View/Sort/by subject"; break;
1757 menu_path = "/View/Sort/by color label"; break;
1759 menu_path = "/View/Sort/by mark"; break;
1760 case SORT_BY_UNREAD:
1761 menu_path = "/View/Sort/by unread"; break;
1763 menu_path = "/View/Sort/by attachment"; break;
1765 menu_path = "/View/Sort/by score"; break;
1766 case SORT_BY_LOCKED:
1767 menu_path = "/View/Sort/by locked"; break;
1770 menu_path = "/View/Sort/Don't sort"; break;
1773 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1775 if (!item || item->sort_type == SORT_ASCENDING) {
1776 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1778 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1781 if (item && item->sort_key != SORT_BY_NONE) {
1782 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1783 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1785 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1786 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1789 SET_CHECK_MENU_ACTIVE("/View/Show all header",
1790 mainwin->messageview->textview->show_all_headers);
1791 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1793 #undef SET_CHECK_MENU_ACTIVE
1795 main_window_menu_callback_unblock(mainwin);
1798 void main_window_popup(MainWindow *mainwin)
1804 gdk_window_get_origin(mainwin->window->window, &x, &y);
1805 sx = gdk_screen_width();
1806 sy = gdk_screen_height();
1807 x %= sx; if (x < 0) x = 0;
1808 y %= sy; if (y < 0) y = 0;
1809 gdk_window_move(mainwin->window->window, x, y);
1810 gdk_window_raise(mainwin->window->window);
1811 gdk_window_show(mainwin->window->window);
1813 debug_print("window position: x = %d, y = %d\n", x, y);
1815 switch (mainwin->type) {
1816 case SEPARATE_FOLDER:
1817 widget = mainwin->win.sep_folder.folderwin;
1818 gdk_window_get_origin(widget->window, &x, &y);
1819 x %= sx; if (x < 0) x = 0;
1820 y %= sy; if (y < 0) y = 0;
1821 gdk_window_move(widget->window, x, y);
1822 gdk_window_raise(widget->window);
1824 case SEPARATE_MESSAGE:
1825 widget = mainwin->win.sep_message.messagewin;
1826 gdk_window_get_origin(widget->window, &x, &y);
1827 x %= sx; if (x < 0) x = 0;
1828 y %= sy; if (y < 0) y = 0;
1829 gdk_window_move(widget->window, x, y);
1830 gdk_window_raise(widget->window);
1833 widget = mainwin->win.sep_both.folderwin;
1834 gdk_window_get_origin(widget->window, &x, &y);
1835 x %= sx; if (x < 0) x = 0;
1836 y %= sy; if (y < 0) y = 0;
1837 gdk_window_move(widget->window, x, y);
1838 gdk_window_raise(widget->window);
1839 widget = mainwin->win.sep_both.messagewin;
1840 gdk_window_get_origin(widget->window, &x, &y);
1841 x %= sx; if (x < 0) x = 0;
1842 y %= sy; if (y < 0) y = 0;
1843 gdk_window_move(widget->window, x, y);
1844 gdk_window_raise(widget->window);
1851 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1853 GtkWidget *folderwin = NULL;
1854 GtkWidget *messagewin = NULL;
1857 GtkWidget *vbox_body = mainwin->vbox_body;
1858 GtkItemFactory *ifactory = mainwin->menu_factory;
1859 GtkWidget *menuitem;
1861 debug_print(_("Setting widgets..."));
1863 /* create separated window(s) if needed */
1864 if (type & SEPARATE_FOLDER) {
1865 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1866 gtk_window_set_title(GTK_WINDOW(folderwin),
1867 _("Sylpheed - Folder View"));
1868 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1869 "folder_view", "Sylpheed");
1870 gtk_window_set_policy(GTK_WINDOW(folderwin),
1872 gtk_widget_set_usize(folderwin, -1,
1873 prefs_common.mainview_height);
1874 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1876 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1877 GTK_SIGNAL_FUNC(folder_window_close_cb),
1880 if (type & SEPARATE_MESSAGE) {
1881 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1882 gtk_window_set_title(GTK_WINDOW(messagewin),
1883 _("Sylpheed - Message View"));
1884 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1885 "message_view", "Sylpheed");
1886 gtk_window_set_policy(GTK_WINDOW(messagewin),
1888 gtk_widget_set_usize
1889 (messagewin, prefs_common.mainview_width,
1890 prefs_common.mainview_height
1891 - prefs_common.summaryview_height
1892 + DEFAULT_HEADERVIEW_HEIGHT);
1893 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1895 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1896 GTK_SIGNAL_FUNC(message_window_close_cb),
1902 hpaned = gtk_hpaned_new();
1903 gtk_widget_show(hpaned);
1904 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1905 gtk_paned_add1(GTK_PANED(hpaned),
1906 GTK_WIDGET_PTR(mainwin->folderview));
1908 vpaned = gtk_vpaned_new();
1909 if (messageview_is_visible(mainwin->messageview)) {
1910 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1911 gtk_paned_add1(GTK_PANED(vpaned),
1912 GTK_WIDGET_PTR(mainwin->summaryview));
1914 gtk_paned_add2(GTK_PANED(hpaned),
1915 GTK_WIDGET_PTR(mainwin->summaryview));
1916 gtk_widget_ref(vpaned);
1918 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1919 prefs_common.summaryview_width,
1920 prefs_common.summaryview_height);
1921 gtk_paned_add2(GTK_PANED(vpaned),
1922 GTK_WIDGET_PTR(mainwin->messageview));
1923 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1924 prefs_common.mainview_width, -1);
1925 gtk_widget_set_usize(mainwin->window,
1926 prefs_common.folderview_width +
1927 prefs_common.mainview_width,
1928 prefs_common.mainwin_height);
1929 gtk_widget_show_all(vpaned);
1931 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1932 * lose track of its visibility state */
1933 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1934 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1936 mainwin->win.sep_none.hpaned = hpaned;
1937 mainwin->win.sep_none.vpaned = vpaned;
1939 case SEPARATE_FOLDER:
1940 vpaned = gtk_vpaned_new();
1941 if (messageview_is_visible(mainwin->messageview)) {
1942 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1944 gtk_paned_add1(GTK_PANED(vpaned),
1945 GTK_WIDGET_PTR(mainwin->summaryview));
1947 gtk_box_pack_start(GTK_BOX(vbox_body),
1948 GTK_WIDGET_PTR(mainwin->summaryview),
1950 gtk_widget_ref(vpaned);
1952 gtk_paned_add2(GTK_PANED(vpaned),
1953 GTK_WIDGET_PTR(mainwin->messageview));
1954 gtk_widget_show_all(vpaned);
1955 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1956 prefs_common.summaryview_width,
1957 prefs_common.summaryview_height);
1958 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1959 prefs_common.mainview_width, -1);
1960 gtk_widget_set_usize(mainwin->window,
1961 prefs_common.mainview_width,
1962 prefs_common.mainview_height);
1964 gtk_container_add(GTK_CONTAINER(folderwin),
1965 GTK_WIDGET_PTR(mainwin->folderview));
1967 mainwin->win.sep_folder.folderwin = folderwin;
1968 mainwin->win.sep_folder.vpaned = vpaned;
1970 gtk_widget_show_all(folderwin);
1972 case SEPARATE_MESSAGE:
1973 hpaned = gtk_hpaned_new();
1974 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1976 gtk_paned_add1(GTK_PANED(hpaned),
1977 GTK_WIDGET_PTR(mainwin->folderview));
1978 gtk_paned_add2(GTK_PANED(hpaned),
1979 GTK_WIDGET_PTR(mainwin->summaryview));
1980 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1981 prefs_common.summaryview_width,
1982 prefs_common.summaryview_height);
1983 gtk_widget_set_usize(mainwin->window,
1984 prefs_common.folderview_width +
1985 prefs_common.mainview_width,
1986 prefs_common.mainwin_height);
1987 gtk_widget_show_all(hpaned);
1988 gtk_container_add(GTK_CONTAINER(messagewin),
1989 GTK_WIDGET_PTR(mainwin->messageview));
1991 mainwin->win.sep_message.messagewin = messagewin;
1992 mainwin->win.sep_message.hpaned = hpaned;
1994 gtk_widget_show_all(messagewin);
1996 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1997 * lose track of its visibility state */
1998 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1999 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2002 gtk_box_pack_start(GTK_BOX(vbox_body),
2003 GTK_WIDGET_PTR(mainwin->summaryview),
2005 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
2006 prefs_common.summaryview_width,
2007 prefs_common.summaryview_height);
2008 gtk_widget_set_usize(mainwin->window,
2009 prefs_common.mainview_width,
2010 prefs_common.mainwin_height);
2011 gtk_container_add(GTK_CONTAINER(folderwin),
2012 GTK_WIDGET_PTR(mainwin->folderview));
2013 gtk_container_add(GTK_CONTAINER(messagewin),
2014 GTK_WIDGET_PTR(mainwin->messageview));
2016 mainwin->win.sep_both.folderwin = folderwin;
2017 mainwin->win.sep_both.messagewin = messagewin;
2019 gtk_widget_show_all(folderwin);
2020 gtk_widget_show_all(messagewin);
2022 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2023 * lose track of its visibility state */
2024 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2025 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2029 mainwin->type = type;
2031 mainwin->messageview->visible = TRUE;
2033 /* toggle menu state */
2034 menuitem = gtk_item_factory_get_item
2035 (ifactory, "/View/Show or hide/Folder tree");
2036 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2037 menuitem = gtk_item_factory_get_item
2038 (ifactory, "/View/Show or hide/Message view");
2039 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2041 menuitem = gtk_item_factory_get_item
2042 (ifactory, "/View/Separate folder tree");
2043 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2044 ((type & SEPARATE_FOLDER) != 0));
2045 menuitem = gtk_item_factory_get_item
2046 (ifactory, "/View/Separate message view");
2047 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2048 ((type & SEPARATE_MESSAGE) != 0));
2050 debug_print(_("done.\n"));
2053 static void main_window_toolbar_create(MainWindow *mainwin,
2054 GtkWidget *container)
2057 GtkWidget *icon_wid;
2059 GtkWidget *getall_btn;
2060 GtkWidget *compose_mail_btn;
2061 GtkWidget *compose_news_btn;
2062 GtkWidget *reply_btn;
2063 GtkWidget *replyall_btn;
2064 GtkWidget *replysender_btn;
2066 GtkWidget *send_btn;
2068 GtkWidget *prefs_btn;
2069 GtkWidget *account_btn;
2071 GtkWidget *next_btn;
2072 GtkWidget *delete_btn;
2073 GtkWidget *exec_btn;
2075 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
2077 gtk_container_add(GTK_CONTAINER(container), toolbar);
2078 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
2079 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
2080 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
2081 GTK_TOOLBAR_SPACE_LINE);
2083 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
2084 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2086 _("Get new mail from current account"),
2088 icon_wid, toolbar_inc_cb, mainwin);
2089 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
2090 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2092 _("Get new mail from all accounts"),
2098 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2100 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
2101 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2103 _("Send queued message(s)"),
2109 /* insert compose mail button widget */
2110 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
2111 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2113 _("Compose an email message"),
2116 toolbar_compose_mail_cb,
2119 /* insert compose news button widget */
2120 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2121 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2123 _("Compose a news message"),
2126 toolbar_compose_news_cb,
2129 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2133 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
2134 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2136 _("Reply to the message - Right button: more options"),
2142 /* replyall button */
2144 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
2145 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2147 _("Reply to all - Right button: more options"),
2150 toolbar_reply_to_all_cb,
2153 /* reply to sender button */
2154 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
2155 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2157 _("Reply to sender - Right button: more options"),
2160 toolbar_reply_to_sender_cb,
2163 /* forward button */
2164 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
2165 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2167 _("Forward the message - Right button: more options"),
2173 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2175 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
2176 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2178 _("Delete the message"),
2184 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
2185 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2187 _("Execute marked process"),
2193 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
2194 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2196 _("Next unread message"),
2199 toolbar_next_unread_cb,
2203 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2205 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2206 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2208 _("Common preferences"),
2213 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2214 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2216 _("Account setting"),
2221 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2222 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2226 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2227 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2230 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2231 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2234 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2235 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2238 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2239 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2243 mainwin->toolbar = toolbar;
2244 mainwin->get_btn = get_btn;
2245 mainwin->getall_btn = getall_btn;
2246 mainwin->compose_mail_btn = compose_mail_btn;
2247 mainwin->compose_news_btn = compose_news_btn;
2248 mainwin->reply_btn = reply_btn;
2249 mainwin->replyall_btn = replyall_btn;
2250 mainwin->replysender_btn = replysender_btn;
2251 mainwin->fwd_btn = fwd_btn;
2252 mainwin->send_btn = send_btn;
2254 mainwin->prefs_btn = prefs_btn;
2255 mainwin->account_btn = account_btn;
2257 mainwin->next_btn = next_btn;
2258 mainwin->delete_btn = delete_btn;
2259 mainwin->exec_btn = exec_btn;
2261 gtk_widget_show_all(toolbar);
2264 /* callback functions */
2265 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2267 MainWindow *mainwindow = (MainWindow *) data;
2271 if (event->button == 3) {
2272 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2273 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2274 menu_button_position, widget,
2275 event->button, event->time);
2279 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2281 MainWindow *mainwin = (MainWindow *)data;
2283 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2284 manage_window_focus_in(mainwin->window, NULL, NULL);
2287 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2289 MainWindow *mainwindow = (MainWindow *) data;
2293 if (event->button == 3) {
2294 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2295 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2296 menu_button_position, widget,
2297 event->button, event->time);
2301 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2303 MainWindow *mainwin = (MainWindow *)data;
2305 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2306 manage_window_focus_in(mainwin->window, NULL, NULL);
2309 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2311 MainWindow *mainwindow = (MainWindow *) data;
2315 if (event->button == 3) {
2316 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2317 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2318 menu_button_position, widget,
2319 event->button, event->time);
2323 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2325 MainWindow *mainwin = (MainWindow *)data;
2327 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2328 manage_window_focus_in(mainwin->window, NULL, NULL);
2331 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2333 MainWindow *mainwindow = (MainWindow *) data;
2337 if (event->button == 3) {
2338 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2339 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2340 menu_button_position, widget,
2341 event->button, event->time);
2345 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2347 MainWindow *mainwin = (MainWindow *)data;
2349 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2350 manage_window_focus_in(mainwin->window, NULL, NULL);
2353 static void toolbar_inc_cb (GtkWidget *widget,
2356 MainWindow *mainwin = (MainWindow *)data;
2358 inc_mail_cb(mainwin, 0, NULL);
2361 static void toolbar_inc_all_cb (GtkWidget *widget,
2364 MainWindow *mainwin = (MainWindow *)data;
2366 inc_all_account_mail_cb(mainwin, 0, NULL);
2369 static void toolbar_send_cb (GtkWidget *widget,
2372 MainWindow *mainwin = (MainWindow *)data;
2374 send_queue_cb(mainwin, 0, NULL);
2377 static void toolbar_compose_news_cb (GtkWidget *widget,
2380 MainWindow *mainwin = (MainWindow *)data;
2382 compose_news_cb(mainwin, 0, NULL);
2385 static void toolbar_compose_mail_cb (GtkWidget *widget,
2388 MainWindow *mainwin = (MainWindow *)data;
2390 compose_mail_cb(mainwin, 0, NULL);
2393 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2395 MainWindow *mainwin = (MainWindow *)data;
2398 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2399 : COMPOSE_REPLY_WITHOUT_QUOTE,
2403 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2405 MainWindow *mainwin = (MainWindow *)data;
2408 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2409 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2414 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2416 MainWindow *mainwin = (MainWindow *)data;
2419 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2420 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2424 static void toolbar_forward_cb (GtkWidget *widget,
2427 MainWindow *mainwin = (MainWindow *)data;
2429 if (prefs_common.forward_as_attachment)
2430 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2432 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2435 static void toolbar_delete_cb (GtkWidget *widget,
2438 MainWindow *mainwin = (MainWindow *)data;
2440 summary_delete(mainwin->summaryview);
2443 static void toolbar_exec_cb (GtkWidget *widget,
2446 MainWindow *mainwin = (MainWindow *)data;
2448 summary_execute(mainwin->summaryview);
2451 static void toolbar_next_unread_cb (GtkWidget *widget,
2454 MainWindow *mainwin = (MainWindow *)data;
2456 next_unread_cb(mainwin, 0, NULL);
2460 static void toolbar_account_button_pressed(GtkWidget *widget,
2461 GdkEventButton *event,
2464 MainWindow *mainwin = (MainWindow *)data;
2467 if (event->button != 3) return;
2469 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2470 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2473 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2474 menu_button_position, widget,
2475 event->button, event->time);
2479 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2482 MainWindow *mainwin = (MainWindow *)data;
2486 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2487 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2490 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2491 menu_button_position, widget,
2492 event->button, event->time);
2495 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2497 MainWindow *mainwin = (MainWindow *)data;
2500 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2501 if (!button) return;
2502 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2503 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2504 manage_window_focus_in(mainwin->window, NULL, NULL);
2507 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2510 MainWindow *mainwin = (MainWindow *)data;
2512 if (mainwin->lock_count == 0)
2513 app_exit_cb(data, 0, widget);
2518 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2521 MainWindow *mainwin = (MainWindow *)data;
2522 GtkWidget *menuitem;
2524 menuitem = gtk_item_factory_get_item
2525 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2526 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2531 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2534 MainWindow *mainwin = (MainWindow *)data;
2535 GtkWidget *menuitem;
2537 menuitem = gtk_item_factory_get_item
2538 (mainwin->menu_factory, "/View/Show or hide/Message view");
2539 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2544 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2547 main_window_add_mailbox(mainwin);
2550 static void add_mbox_cb(MainWindow *mainwin, guint action,
2553 main_window_add_mbox(mainwin);
2556 static void update_folderview_cb(MainWindow *mainwin, guint action,
2559 summary_show(mainwin->summaryview, NULL);
2560 folderview_rescan_all();
2563 static void new_folder_cb(MainWindow *mainwin, guint action,
2566 folderview_new_folder(mainwin->folderview);
2569 static void rename_folder_cb(MainWindow *mainwin, guint action,
2572 folderview_rename_folder(mainwin->folderview);
2575 static void delete_folder_cb(MainWindow *mainwin, guint action,
2578 folderview_delete_folder(mainwin->folderview);
2581 static void import_mbox_cb(MainWindow *mainwin, guint action,
2584 import_mbox(mainwin->summaryview->folder_item);
2587 static void export_mbox_cb(MainWindow *mainwin, guint action,
2590 export_mbox(mainwin->summaryview->folder_item);
2593 static void empty_trash_cb(MainWindow *mainwin, guint action,
2596 main_window_empty_trash(mainwin, TRUE);
2599 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2601 summary_save_as(mainwin->summaryview);
2604 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2606 summary_print(mainwin->summaryview);
2609 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2611 if (prefs_common.confirm_on_exit) {
2612 if (alertpanel(_("Exit"), _("Exit this program?"),
2613 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2615 manage_window_focus_in(mainwin->window, NULL, NULL);
2618 app_will_exit(widget, mainwin);
2621 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2624 summary_search(mainwin->summaryview);
2626 message_search(mainwin->messageview);
2629 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2634 active = GTK_CHECK_MENU_ITEM(widget)->active;
2636 switch (mainwin->type) {
2638 case SEPARATE_MESSAGE:
2641 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2643 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2646 case SEPARATE_FOLDER:
2647 debug_print("separate folder\n");
2649 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2651 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2655 gtk_widget_show(mainwin->win.sep_both.folderwin);
2657 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2662 static void toggle_message_cb(MainWindow *mainwin, guint action,
2667 active = GTK_CHECK_MENU_ITEM(widget)->active;
2669 if (active != messageview_is_visible(mainwin->messageview))
2670 summary_toggle_view(mainwin->summaryview);
2673 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2676 switch ((ToolbarStyle)action) {
2678 gtk_widget_hide(mainwin->handlebox);
2680 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2684 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2688 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2693 if (action != TOOLBAR_NONE) {
2694 gtk_widget_show(mainwin->handlebox);
2695 gtk_widget_queue_resize(mainwin->handlebox);
2698 mainwin->toolbar_style = (ToolbarStyle)action;
2699 prefs_common.toolbar_style = (ToolbarStyle)action;
2702 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2705 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2706 gtk_widget_show(mainwin->hbox_stat);
2707 prefs_common.show_statusbar = TRUE;
2709 gtk_widget_hide(mainwin->hbox_stat);
2710 prefs_common.show_statusbar = FALSE;
2714 static void separate_widget_cb(MainWindow *mainwin, guint action,
2719 if (GTK_CHECK_MENU_ITEM(widget)->active)
2720 type = mainwin->type | action;
2722 type = mainwin->type & ~action;
2724 main_window_separation_change(mainwin, type);
2726 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2727 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2730 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2732 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2733 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2735 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2739 static void online_switch_clicked (GtkButton *btn, gpointer data)
2741 MainWindow *mainwin;
2742 GtkItemFactory *ifactory;
2743 GtkCheckMenuItem *menuitem;
2745 mainwin = (MainWindow *) data;
2747 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2748 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2750 g_return_if_fail(mainwin != NULL);
2751 g_return_if_fail(menuitem != NULL);
2753 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2755 gtk_widget_hide (mainwin->online_switch);
2756 gtk_widget_show (mainwin->offline_switch);
2757 menuitem->active = TRUE;
2758 prefs_common.work_offline = TRUE;
2759 inc_autocheck_timer_remove();
2762 gtk_widget_hide (mainwin->offline_switch);
2763 gtk_widget_show (mainwin->online_switch);
2764 menuitem->active = FALSE;
2765 prefs_common.work_offline = FALSE;
2766 inc_autocheck_timer_set();
2770 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2773 addressbook_open(NULL);
2776 static void log_window_show_cb(MainWindow *mainwin, guint action,
2779 log_window_show(mainwin->logwin);
2782 static void sel_download_cb(MainWindow *mainwin, guint action,
2785 selective_download(mainwin);
2788 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2790 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2793 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2796 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2799 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2804 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2808 if (prefs_common.work_offline)
2809 if (alertpanel(_("Offline warning"),
2810 _("You're working offline. Override?"),
2811 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
2814 for (list = folder_get_list(); list != NULL; list = list->next) {
2815 Folder *folder = list->data;
2817 if (folder->queue) {
2818 if (procmsg_send_queue
2819 (folder->queue, prefs_common.savemsg) < 0)
2820 alertpanel_error(_("Some errors occurred while sending queued messages."));
2821 statusbar_pop_all();
2822 folder_item_scan(folder->queue);
2823 folderview_update_item(folder->queue, TRUE);
2828 static void compose_mail_cb(MainWindow *mainwin, guint action,
2835 if (mainwin->summaryview->folder_item) {
2836 ac = mainwin->summaryview->folder_item->folder->account;
2837 if (ac && ac->protocol != A_NNTP) {
2838 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2843 if(cur_account && (cur_account->protocol != A_NNTP)) {
2844 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2848 list = account_get_list();
2849 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2850 ac = (PrefsAccount *) cur->data;
2851 if (ac->protocol != A_NNTP) {
2852 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2858 static void compose_news_cb(MainWindow *mainwin, guint action,
2861 PrefsAccount * ac = NULL;
2865 if (mainwin->summaryview->folder_item) {
2866 ac = mainwin->summaryview->folder_item->folder->account;
2867 if (ac && ac->protocol == A_NNTP) {
2869 mainwin->summaryview->folder_item->path,
2875 list = account_get_list();
2876 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2877 ac = (PrefsAccount *) cur->data;
2878 if (ac->protocol == A_NNTP) {
2879 compose_new(ac, NULL, NULL);
2885 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2887 summary_reply(mainwin->summaryview, (ComposeMode)action);
2890 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2892 summary_move_to(mainwin->summaryview);
2895 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2897 summary_copy_to(mainwin->summaryview);
2900 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2902 summary_delete(mainwin->summaryview);
2905 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2907 summary_open_msg(mainwin->summaryview);
2910 static void view_source_cb(MainWindow *mainwin, guint action,
2913 summary_view_source(mainwin->summaryview);
2916 static void show_all_header_cb(MainWindow *mainwin, guint action,
2919 if (mainwin->menu_lock_count) return;
2920 summary_display_msg_selected(mainwin->summaryview,
2921 GTK_CHECK_MENU_ITEM(widget)->active);
2924 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2926 summary_reedit(mainwin->summaryview);
2929 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2931 summary_mark(mainwin->summaryview);
2934 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2936 summary_unmark(mainwin->summaryview);
2939 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2942 summary_mark_as_unread(mainwin->summaryview);
2945 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2948 summary_mark_as_read(mainwin->summaryview);
2951 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2954 summary_mark_all_read(mainwin->summaryview);
2957 static void add_address_cb(MainWindow *mainwin, guint action,
2960 summary_add_address(mainwin->summaryview);
2963 static void set_charset_cb(MainWindow *mainwin, guint action,
2968 str = conv_get_charset_str((CharSet)action);
2969 g_free(prefs_common.force_charset);
2970 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2972 summary_redisplay_msg(mainwin->summaryview);
2974 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2977 static void hide_read_messages (MainWindow *mainwin, guint action,
2980 if (!mainwin->summaryview->folder_item
2981 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2983 summary_toggle_show_read_messages(mainwin->summaryview);
2986 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2988 if (mainwin->menu_lock_count) return;
2989 if (!mainwin->summaryview->folder_item) return;
2991 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2992 summary_thread_build(mainwin->summaryview);
2993 mainwin->summaryview->folder_item->threaded = TRUE;
2995 summary_unthread(mainwin->summaryview);
2996 mainwin->summaryview->folder_item->threaded = FALSE;
3000 static void expand_threads_cb(MainWindow *mainwin, guint action,
3003 summary_expand_threads(mainwin->summaryview);
3006 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3009 summary_collapse_threads(mainwin->summaryview);
3012 static void set_display_item_cb(MainWindow *mainwin, guint action,
3015 prefs_summary_column_open();
3018 static void sort_summary_cb(MainWindow *mainwin, guint action,
3021 FolderItem *item = mainwin->summaryview->folder_item;
3022 GtkWidget *menuitem;
3024 if (mainwin->menu_lock_count) return;
3026 menuitem = gtk_item_factory_get_item
3027 (mainwin->menu_factory, "/View/Sort/Ascending");
3028 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3029 GTK_CHECK_MENU_ITEM(menuitem)->active
3030 ? SORT_ASCENDING : SORT_DESCENDING);
3034 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3037 FolderItem *item = mainwin->summaryview->folder_item;
3039 if (mainwin->menu_lock_count) return;
3041 summary_sort(mainwin->summaryview,
3042 item->sort_key, (FolderSortType)action);
3045 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3048 summary_attract_by_subject(mainwin->summaryview);
3051 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3054 summary_delete_duplicated(mainwin->summaryview);
3057 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3059 summary_filter(mainwin->summaryview);
3062 static void execute_summary_cb(MainWindow *mainwin, guint action,
3065 summary_execute(mainwin->summaryview);
3068 static void update_summary_cb(MainWindow *mainwin, guint action,
3072 FolderView *folderview = mainwin->folderview;
3074 if (!mainwin->summaryview->folder_item) return;
3075 if (!folderview->opened) return;
3077 folder_update_op_count();
3079 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3080 folderview->opened);
3083 folder_item_scan(fitem);
3084 summary_show(mainwin->summaryview, fitem);
3087 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3089 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3092 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3094 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3097 static void prev_unread_cb(MainWindow *mainwin, guint action,
3100 summary_select_prev_unread(mainwin->summaryview);
3103 static void next_unread_cb(MainWindow *mainwin, guint action,
3106 summary_select_next_unread(mainwin->summaryview);
3109 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3111 summary_select_prev_new(mainwin->summaryview);
3114 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3116 summary_select_next_new(mainwin->summaryview);
3119 static void prev_marked_cb(MainWindow *mainwin, guint action,
3122 summary_select_prev_marked(mainwin->summaryview);
3125 static void next_marked_cb(MainWindow *mainwin, guint action,
3128 summary_select_next_marked(mainwin->summaryview);
3131 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3134 summary_select_prev_labeled(mainwin->summaryview);
3137 static void next_labeled_cb(MainWindow *mainwin, guint action,
3140 summary_select_next_labeled(mainwin->summaryview);
3143 static void goto_folder_cb(MainWindow *mainwin, guint action,
3146 FolderItem *to_folder;
3148 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3151 folderview_select(mainwin->folderview, to_folder);
3154 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3156 messageview_copy_clipboard(mainwin->messageview);
3159 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3161 MessageView *msgview = mainwin->messageview;
3163 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3164 summary_select_all(mainwin->summaryview);
3165 else if (messageview_is_visible(msgview) &&
3166 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
3167 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3168 messageview_select_all(mainwin->messageview);
3171 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3173 if (messageview_is_visible(mainwin->summaryview->messageview))
3174 summary_select_thread(mainwin->summaryview);
3177 static void create_filter_cb(MainWindow *mainwin, guint action,
3180 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3183 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3186 prefs_common_open();
3189 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
3192 prefs_filter_open(NULL, NULL);
3195 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3198 prefs_scoring_open(NULL);
3201 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3204 prefs_filtering_open(NULL, NULL, NULL);
3207 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3210 prefs_template_open();
3213 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3216 prefs_actions_open(mainwin);
3219 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3223 new_account_cb(mainwin, 0, widget);
3225 gboolean prev_default = cur_account->is_default;
3227 prefs_account_open(cur_account);
3228 if (!prev_default && cur_account->is_default)
3229 account_set_as_default(cur_account);
3230 account_save_config_all();
3232 main_window_reflect_prefs_all();
3236 static void new_account_cb(MainWindow *mainwin, guint action,
3239 account_edit_open();
3240 if (!compose_get_compose_list()) account_add();
3243 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3245 cur_account = (PrefsAccount *)data;
3246 main_window_reflect_prefs_all();
3249 static void manual_open_cb(MainWindow *mainwin, guint action,
3252 manual_open((ManualLang)action);
3255 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3257 faq_open((ManualLang)action);
3260 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3262 MainWindow *mainwin = (MainWindow *)data;
3266 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3267 LOCAL_FOLDER(folder)->rootpath,
3271 str = g_strdup_printf(_("Scanning folder %s ..."),
3272 LOCAL_FOLDER(folder)->rootpath);
3274 STATUSBAR_PUSH(mainwin, str);
3275 STATUSBAR_POP(mainwin);
3279 static void activate_compose_button (MainWindow *mainwin,
3281 ComposeButtonType type)
3283 if (style == TOOLBAR_NONE)
3286 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
3287 : mainwin->compose_news_btn);
3288 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
3289 : mainwin->compose_mail_btn);
3290 mainwin->compose_btn_type = type;
3293 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
3295 if (mainwin->compose_btn_type != compose_btn_type)
3296 activate_compose_button(mainwin,
3297 prefs_common.toolbar_style,
3301 #define BREAK_ON_MODIFIER_KEY() \
3302 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3304 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3306 MainWindow *mainwin = (MainWindow*) data;
3308 if (!mainwin || !event) return;
3310 switch (event->keyval) {
3311 case GDK_Q: /* Quit */
3312 BREAK_ON_MODIFIER_KEY();
3314 app_exit_cb(mainwin, 0, NULL);
3321 #undef BREAK_ON_MODIFIER_KEY
3323 static void set_toolbar_style(MainWindow *mainwin)
3325 switch (prefs_common.toolbar_style) {
3327 gtk_widget_hide(mainwin->handlebox);
3330 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3334 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3338 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3343 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3344 gtk_widget_show(mainwin->handlebox);
3345 gtk_widget_queue_resize(mainwin->handlebox);
3350 * Harvest addresses for selected folder.
3352 static void addr_harvest_cb( MainWindow *mainwin,
3356 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3360 * Harvest addresses for selected messages in summary view.
3362 static void addr_harvest_msg_cb( MainWindow *mainwin,
3366 summary_harvest_address( mainwin->summaryview );