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/_Check for new mails in all folders"),
474 NULL, update_folderview_cb, 0, NULL},
475 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
476 {N_("/_File/_Folder/Create _new folder..."),
477 NULL, new_folder_cb, 0, NULL},
478 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
479 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
480 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
481 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
482 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
483 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
484 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
485 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
486 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
487 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
488 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
489 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
491 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
492 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
493 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
494 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
495 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
496 {N_("/_Edit/_Find in current message..."),
497 "<control>F", search_cb, 0, NULL},
498 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
499 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
500 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
501 {N_("/_View/Show or hi_de/_Folder tree"),
502 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
503 {N_("/_View/Show or hi_de/_Message view"),
504 "V", toggle_message_cb, 0, "<ToggleItem>"},
505 {N_("/_View/Show or hi_de/_Toolbar"),
506 NULL, NULL, 0, "<Branch>"},
507 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
508 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
509 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
510 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
511 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
512 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
513 {N_("/_View/Show or hi_de/_Toolbar/_None"),
514 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
515 {N_("/_View/Show or hi_de/Status _bar"),
516 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
517 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
518 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
519 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
520 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
521 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
522 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
523 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
524 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
525 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
526 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
527 {N_("/_View/_Sort/by _color label"),
528 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
529 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
530 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
531 {N_("/_View/_Sort/by a_ttachment"),
532 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
533 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
534 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
535 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
536 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
537 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
538 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
539 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
540 {N_("/_View/_Sort/_Attract by subject"),
541 NULL, attract_by_subject_cb, 0, NULL},
542 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
543 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
544 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
545 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
546 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
548 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
549 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
550 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
551 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
552 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
553 {N_("/_View/_Go to/P_rev unread message"),
554 "<shift>P", prev_unread_cb, 0, NULL},
555 {N_("/_View/_Go to/N_ext unread message"),
556 "<shift>N", next_unread_cb, 0, NULL},
557 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
558 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
559 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
560 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
561 {N_("/_View/_Go to/Prev _marked message"),
562 NULL, prev_marked_cb, 0, NULL},
563 {N_("/_View/_Go to/Next m_arked message"),
564 NULL, next_marked_cb, 0, NULL},
565 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
566 {N_("/_View/_Go to/Prev _labeled message"),
567 NULL, prev_labeled_cb, 0, NULL},
568 {N_("/_View/_Go to/Next la_beled message"),
569 NULL, next_labeled_cb, 0, NULL},
570 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
571 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
572 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
574 #define CODESET_SEPARATOR \
575 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
576 #define CODESET_ACTION(action) \
577 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
579 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
580 {N_("/_View/_Code set/_Auto detect"),
581 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
582 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
583 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
584 CODESET_ACTION(C_US_ASCII)},
587 {N_("/_View/_Code set/Unicode (_UTF-8)"),
588 CODESET_ACTION(C_UTF_8)},
591 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
592 CODESET_ACTION(C_ISO_8859_1)},
593 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
594 CODESET_ACTION(C_ISO_8859_15)},
597 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
598 CODESET_ACTION(C_ISO_8859_2)},
600 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
601 CODESET_ACTION(C_ISO_8859_13)},
602 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
603 CODESET_ACTION(C_ISO_8859_4)},
605 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
606 CODESET_ACTION(C_ISO_8859_7)},
608 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
609 CODESET_ACTION(C_ISO_8859_9)},
611 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
612 CODESET_ACTION(C_ISO_8859_5)},
613 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
614 CODESET_ACTION(C_KOI8_R)},
615 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
616 CODESET_ACTION(C_WINDOWS_1251)},
619 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
620 CODESET_ACTION(C_ISO_2022_JP)},
622 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
623 CODESET_ACTION(C_ISO_2022_JP_2)},
625 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
626 CODESET_ACTION(C_EUC_JP)},
627 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
628 CODESET_ACTION(C_SHIFT_JIS)},
631 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
632 CODESET_ACTION(C_GB2312)},
633 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
634 CODESET_ACTION(C_BIG5)},
635 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
636 CODESET_ACTION(C_EUC_TW)},
637 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
638 CODESET_ACTION(C_ISO_2022_CN)},
640 {N_("/_View/_Code set/Korean (EUC-_KR)"),
641 CODESET_ACTION(C_EUC_KR)},
642 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
643 CODESET_ACTION(C_ISO_2022_KR)},
645 {N_("/_View/_Code set/Thai (TIS-620)"),
646 CODESET_ACTION(C_TIS_620)},
647 {N_("/_View/_Code set/Thai (Windows-874)"),
648 CODESET_ACTION(C_WINDOWS_874)},
651 #undef CODESET_SEPARATOR
652 #undef CODESET_ACTION
654 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
655 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
656 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
657 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
658 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
659 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
661 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
662 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
663 {N_("/_Message/Get from _all accounts"),
664 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
665 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
666 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
667 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
668 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
669 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
670 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
671 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
672 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
673 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
674 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
675 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
676 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
677 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
678 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
679 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
680 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
681 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
682 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
683 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
684 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
685 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
686 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
687 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
688 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
689 {N_("/_Message/_Mark/Mark as rea_d"),
690 NULL, mark_as_read_cb, 0, NULL},
691 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
693 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
694 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
695 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
696 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
697 {N_("/_Tools/Add sender to address boo_k"),
698 NULL, add_address_cb, 0, NULL},
699 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
700 {N_("/_Tools/_Harvest addresses/from _Folder..."),
701 NULL, addr_harvest_cb, 0, NULL},
702 {N_("/_Tools/_Harvest addresses/from _Messages..."),
703 NULL, addr_harvest_msg_cb, 0, NULL},
704 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
705 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
706 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
707 {N_("/_Tools/_Create filter rule/_Automatically"),
708 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
709 {N_("/_Tools/_Create filter rule/by _From"),
710 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
711 {N_("/_Tools/_Create filter rule/by _To"),
712 NULL, create_filter_cb, FILTER_BY_TO, NULL},
713 {N_("/_Tools/_Create filter rule/by _Subject"),
714 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
715 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
716 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
717 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
718 {N_("/_Tools/Delete du_plicated messages"),
719 NULL, delete_duplicated_cb, 0, NULL},
720 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
721 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
722 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
723 {N_("/_Tools/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
725 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
726 {N_("/_Configuration/_Common preferences..."),
727 NULL, prefs_common_open_cb, 0, NULL},
728 {N_("/_Configuration/_Filter setting..."),
729 NULL, prefs_filter_open_cb, 0, NULL},
730 {N_("/_Configuration/_Scoring..."),
731 NULL, prefs_scoring_open_cb, 0, NULL},
732 {N_("/_Configuration/_Filtering..."),
733 NULL, prefs_filtering_open_cb, 0, NULL},
734 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
735 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
736 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
737 {N_("/_Configuration/_Preferences for current account..."),
738 NULL, prefs_account_open_cb, 0, NULL},
739 {N_("/_Configuration/Create _new account..."),
740 NULL, new_account_cb, 0, NULL},
741 {N_("/_Configuration/_Edit accounts..."),
742 NULL, account_edit_open, 0, NULL},
743 {N_("/_Configuration/C_hange current account"),
744 NULL, NULL, 0, "<Branch>"},
746 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
747 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
748 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
749 {N_("/_Help/_Manual/_German"), NULL, manual_open_cb, MANUAL_LANG_DE, NULL},
750 {N_("/_Help/_Manual/_Spanish"), NULL, manual_open_cb, MANUAL_LANG_ES, NULL},
751 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
752 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
753 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
754 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
755 {N_("/_Help/_FAQ/_German"), NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
756 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
757 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
758 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
759 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
760 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
762 static GtkItemFactoryEntry reply_popup_entries[] =
764 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
765 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
767 static GtkItemFactoryEntry replyall_popup_entries[] =
769 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
770 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
772 static GtkItemFactoryEntry replysender_popup_entries[] =
774 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
775 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
777 static GtkItemFactoryEntry fwd_popup_entries[] =
779 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
780 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
783 MainWindow *main_window_create(SeparateType type)
789 GtkWidget *handlebox;
790 GtkWidget *vbox_body;
791 GtkWidget *hbox_stat;
792 GtkWidget *statusbar;
793 GtkWidget *progressbar;
794 GtkWidget *statuslabel;
795 GtkWidget *ac_button;
797 GtkWidget *online_status;
798 GtkWidget *offline_status;
799 GtkWidget *online_switch;
800 GtkWidget *offline_switch;
802 FolderView *folderview;
803 SummaryView *summaryview;
804 MessageView *messageview;
805 GdkColormap *colormap;
808 guint n_menu_entries;
809 GtkItemFactory *ifactory;
812 GtkWidget *reply_popup;
813 GtkWidget *replyall_popup;
814 GtkWidget *replysender_popup;
815 GtkWidget *fwd_popup;
818 static GdkGeometry geometry;
820 debug_print(_("Creating main window...\n"));
821 mainwin = g_new0(MainWindow, 1);
824 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
825 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
826 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
827 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
829 if (!geometry.min_height) {
830 geometry.min_width = 320;
831 geometry.min_height = 200;
833 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
836 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
837 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
838 MANAGE_WINDOW_SIGNALS_CONNECT(window);
839 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
840 GTK_SIGNAL_FUNC(key_pressed), mainwin);
842 gtk_widget_realize(window);
843 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
846 gtkut_widget_set_app_icon(window);
848 vbox = gtk_vbox_new(FALSE, 0);
849 gtk_widget_show(vbox);
850 gtk_container_add(GTK_CONTAINER(window), vbox);
853 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
854 menubar = menubar_create(window, mainwin_entries,
855 n_menu_entries, "<Main>", mainwin);
856 gtk_widget_show(menubar);
857 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
858 ifactory = gtk_item_factory_from_widget(menubar);
860 handlebox = gtk_handle_box_new();
861 gtk_widget_show(handlebox);
862 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
864 /* create the popup menus for the reply buttons specials */
865 n_menu_entries = sizeof(reply_popup_entries) /
866 sizeof(reply_popup_entries[0]);
867 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
868 "<ReplyPopup>", mainwin);
869 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
870 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
871 n_menu_entries = sizeof(replyall_popup_entries) /
872 sizeof(replyall_popup_entries[0]);
873 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
874 "<ReplyAllPopup>", mainwin);
875 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
876 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
877 n_menu_entries = sizeof(replysender_popup_entries) /
878 sizeof(replysender_popup_entries[0]);
879 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
880 "<ReplySenderPopup>", mainwin);
881 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
882 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
883 /* create the popup menu for the forward button */
884 n_menu_entries = sizeof(fwd_popup_entries) /
885 sizeof(fwd_popup_entries[0]);
886 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
887 "<ForwardPopup>", mainwin);
888 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
889 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
891 main_window_toolbar_create(mainwin, handlebox);
893 /* vbox that contains body */
894 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
895 gtk_widget_show(vbox_body);
896 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
897 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
899 hbox_stat = gtk_hbox_new(FALSE, 2);
900 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
902 statusbar = statusbar_create();
903 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
905 progressbar = gtk_progress_bar_new();
906 gtk_widget_set_usize(progressbar, 120, 1);
907 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
909 online_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
910 offline_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
911 online_switch = gtk_button_new ();
912 offline_switch = gtk_button_new ();
913 gtk_container_add (GTK_CONTAINER(online_switch), online_status);
914 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
915 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
916 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
917 gtk_container_add (GTK_CONTAINER(offline_switch), offline_status);
918 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
919 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
920 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
922 statuslabel = gtk_label_new("");
923 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
925 ac_button = gtk_button_new();
926 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
927 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
928 gtk_widget_set_usize(ac_button, -1, 1);
929 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
930 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
931 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
933 ac_label = gtk_label_new("");
934 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
936 gtk_widget_show_all(hbox_stat);
938 gtk_widget_hide(offline_switch);
940 mainwin->folderview = folderview = folderview_create();
941 mainwin->summaryview = summaryview = summary_create();
942 mainwin->messageview = messageview = messageview_create();
943 mainwin->logwin = log_window_create();
945 folderview->mainwin = mainwin;
946 folderview->summaryview = summaryview;
948 summaryview->mainwin = mainwin;
949 summaryview->folderview = folderview;
950 summaryview->messageview = messageview;
951 summaryview->window = window;
953 messageview->mainwin = mainwin;
955 mainwin->window = window;
956 mainwin->vbox = vbox;
957 mainwin->menubar = menubar;
958 mainwin->menu_factory = ifactory;
959 mainwin->handlebox = handlebox;
960 mainwin->vbox_body = vbox_body;
961 mainwin->hbox_stat = hbox_stat;
962 mainwin->statusbar = statusbar;
963 mainwin->progressbar = progressbar;
964 mainwin->statuslabel = statuslabel;
965 mainwin->ac_button = ac_button;
966 mainwin->ac_label = ac_label;
968 mainwin->reply_popup = reply_popup;
969 mainwin->replyall_popup = replyall_popup;
970 mainwin->replysender_popup = replysender_popup;
971 mainwin->fwd_popup = fwd_popup;
972 mainwin->online_switch = online_switch;
973 mainwin->offline_switch = offline_switch;
975 /* set context IDs for status bar */
976 mainwin->mainwin_cid = gtk_statusbar_get_context_id
977 (GTK_STATUSBAR(statusbar), "Main Window");
978 mainwin->folderview_cid = gtk_statusbar_get_context_id
979 (GTK_STATUSBAR(statusbar), "Folder View");
980 mainwin->summaryview_cid = gtk_statusbar_get_context_id
981 (GTK_STATUSBAR(statusbar), "Summary View");
983 /* allocate colors for summary view and folder view */
984 summaryview->color_marked.red = summaryview->color_marked.green = 0;
985 summaryview->color_marked.blue = (guint16)65535;
987 summaryview->color_dim.red = summaryview->color_dim.green =
988 summaryview->color_dim.blue = COLOR_DIM;
990 folderview->color_new.red = (guint16)55000;
991 folderview->color_new.green = folderview->color_new.blue = 15000;
993 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
994 &folderview->color_op);
996 summaryview->color_important.red = 0;
997 summaryview->color_important.green = 0;
998 summaryview->color_important.blue = (guint16)65535;
1000 color[0] = summaryview->color_marked;
1001 color[1] = summaryview->color_dim;
1002 color[2] = folderview->color_new;
1003 color[3] = folderview->color_op;
1005 colormap = gdk_window_get_colormap(window->window);
1006 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1007 for (i = 0; i < 4; i++) {
1008 if (success[i] == FALSE)
1009 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1012 debug_print(_("done.\n"));
1014 messageview->visible = TRUE;
1016 main_window_set_widgets(mainwin, type);
1018 /* set menu items */
1019 menuitem = gtk_item_factory_get_item
1020 (ifactory, "/View/Code set/Auto detect");
1021 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1023 switch (prefs_common.toolbar_style) {
1025 menuitem = gtk_item_factory_get_item
1026 (ifactory, "/View/Show or hide/Toolbar/None");
1029 menuitem = gtk_item_factory_get_item
1030 (ifactory, "/View/Show or hide/Toolbar/Icon");
1033 menuitem = gtk_item_factory_get_item
1034 (ifactory, "/View/Show or hide/Toolbar/Text");
1037 menuitem = gtk_item_factory_get_item
1038 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1040 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1042 gtk_widget_hide(mainwin->hbox_stat);
1043 menuitem = gtk_item_factory_get_item
1044 (ifactory, "/View/Show or hide/Status bar");
1045 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1046 prefs_common.show_statusbar);
1048 /* set account selection menu */
1049 ac_menu = gtk_item_factory_get_widget
1050 (ifactory, "/Configuration/Change current account");
1051 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1052 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1053 mainwin->ac_menu = ac_menu;
1055 main_window_set_toolbar_sensitive(mainwin);
1057 /* create actions menu */
1058 update_mainwin_actions_menu(ifactory, mainwin);
1060 /* show main window */
1061 gtk_widget_set_uposition(mainwin->window,
1062 prefs_common.mainwin_x,
1063 prefs_common.mainwin_y);
1064 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1065 prefs_common.mainwin_height);
1066 gtk_widget_show(mainwin->window);
1068 /* initialize views */
1069 folderview_init(folderview);
1070 summary_init(summaryview);
1071 messageview_init(messageview);
1072 log_window_init(mainwin->logwin);
1074 mainwin->lock_count = 0;
1075 mainwin->menu_lock_count = 0;
1076 mainwin->cursor_count = 0;
1079 watch_cursor = gdk_cursor_new(GDK_WATCH);
1081 mainwin_list = g_list_append(mainwin_list, mainwin);
1083 /* init work_offline */
1084 if (prefs_common.work_offline)
1085 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1090 void main_window_cursor_wait(MainWindow *mainwin)
1093 if (mainwin->cursor_count == 0)
1094 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1096 mainwin->cursor_count++;
1101 void main_window_cursor_normal(MainWindow *mainwin)
1103 if (mainwin->cursor_count)
1104 mainwin->cursor_count--;
1106 if (mainwin->cursor_count == 0)
1107 gdk_window_set_cursor(mainwin->window->window, NULL);
1112 /* lock / unlock the user-interface */
1113 void main_window_lock(MainWindow *mainwin)
1115 if (mainwin->lock_count == 0)
1116 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1118 mainwin->lock_count++;
1120 main_window_set_menu_sensitive(mainwin);
1121 main_window_set_toolbar_sensitive(mainwin);
1124 void main_window_unlock(MainWindow *mainwin)
1126 if (mainwin->lock_count)
1127 mainwin->lock_count--;
1129 main_window_set_menu_sensitive(mainwin);
1130 main_window_set_toolbar_sensitive(mainwin);
1132 if (mainwin->lock_count == 0)
1133 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1136 static void main_window_menu_callback_block(MainWindow *mainwin)
1138 mainwin->menu_lock_count++;
1141 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1143 if (mainwin->menu_lock_count)
1144 mainwin->menu_lock_count--;
1147 void main_window_reflect_prefs_all(void)
1149 main_window_reflect_prefs_all_real(FALSE);
1152 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1155 MainWindow *mainwin;
1157 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1158 mainwin = (MainWindow *)cur->data;
1160 main_window_show_cur_account(mainwin);
1161 main_window_set_menu_sensitive(mainwin);
1162 main_window_set_toolbar_sensitive(mainwin);
1165 if (pixmap_theme_changed) {
1166 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1167 mainwin->toolbar = NULL;
1168 main_window_toolbar_create(mainwin, mainwin->handlebox);
1169 set_toolbar_style(mainwin);
1170 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1171 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1172 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1173 sd_reflect_prefs_pixmap_theme();
1176 if (prefs_common.immediate_exec)
1177 gtk_widget_hide(mainwin->exec_btn);
1179 gtk_widget_show(mainwin->exec_btn);
1181 summary_redisplay_msg(mainwin->summaryview);
1182 headerview_set_visibility(mainwin->messageview->headerview,
1183 prefs_common.display_header_pane);
1187 void main_window_set_summary_column(void)
1190 MainWindow *mainwin;
1192 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1193 mainwin = (MainWindow *)cur->data;
1194 summary_set_column_order(mainwin->summaryview);
1198 void main_window_set_account_menu(GList *account_list)
1200 GList *cur, *cur_ac, *cur_item;
1201 GtkWidget *menuitem;
1202 MainWindow *mainwin;
1203 PrefsAccount *ac_prefs;
1205 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1206 mainwin = (MainWindow *)cur->data;
1208 /* destroy all previous menu item */
1209 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1210 while (cur_item != NULL) {
1211 GList *next = cur_item->next;
1212 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1216 for (cur_ac = account_list; cur_ac != NULL;
1217 cur_ac = cur_ac->next) {
1218 ac_prefs = (PrefsAccount *)cur_ac->data;
1220 menuitem = gtk_menu_item_new_with_label
1221 (ac_prefs->account_name
1222 ? ac_prefs->account_name : _("Untitled"));
1223 gtk_widget_show(menuitem);
1224 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1225 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1226 GTK_SIGNAL_FUNC(account_menu_cb),
1232 static void main_window_show_cur_account(MainWindow *mainwin)
1237 ac_name = g_strdup(cur_account
1238 ? (cur_account->account_name
1239 ? cur_account->account_name : _("Untitled"))
1243 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1245 buf = g_strdup(PROG_VERSION);
1246 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1249 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1250 gtk_widget_queue_resize(mainwin->ac_button);
1255 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1257 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1258 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1259 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1261 debug_print(_("Changing window separation type from %d to %d\n"),
1262 mainwin->type, type);
1264 if (mainwin->type == type) return;
1266 /* remove widgets from those containers */
1267 gtk_widget_ref(folder_wid);
1268 gtk_widget_ref(summary_wid);
1269 gtk_widget_ref(message_wid);
1270 gtkut_container_remove
1271 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1272 gtkut_container_remove
1273 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1274 gtkut_container_remove
1275 (GTK_CONTAINER(message_wid->parent), message_wid);
1277 /* clean containers */
1278 switch (mainwin->type) {
1280 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1282 case SEPARATE_FOLDER:
1283 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1284 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1286 case SEPARATE_MESSAGE:
1287 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1288 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1291 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1292 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1296 gtk_widget_hide(mainwin->window);
1297 main_window_set_widgets(mainwin, type);
1298 gtk_widget_show(mainwin->window);
1300 gtk_widget_unref(folder_wid);
1301 gtk_widget_unref(summary_wid);
1302 gtk_widget_unref(message_wid);
1305 void main_window_toggle_message_view(MainWindow *mainwin)
1307 SummaryView *summaryview = mainwin->summaryview;
1308 union CompositeWin *cwin = &mainwin->win;
1309 GtkWidget *vpaned = NULL;
1310 GtkWidget *container = NULL;
1311 GtkWidget *msgwin = NULL;
1313 switch (mainwin->type) {
1315 vpaned = cwin->sep_none.vpaned;
1316 container = cwin->sep_none.hpaned;
1318 case SEPARATE_FOLDER:
1319 vpaned = cwin->sep_folder.vpaned;
1320 container = mainwin->vbox_body;
1322 case SEPARATE_MESSAGE:
1323 msgwin = mainwin->win.sep_message.messagewin;
1326 msgwin = mainwin->win.sep_both.messagewin;
1331 if (GTK_WIDGET_VISIBLE(msgwin)) {
1332 gtk_widget_hide(msgwin);
1333 mainwin->messageview->visible = FALSE;
1334 summaryview->displayed = NULL;
1336 gtk_widget_show(msgwin);
1337 mainwin->messageview->visible = TRUE;
1339 } else if (vpaned->parent != NULL) {
1340 mainwin->messageview->visible = FALSE;
1341 summaryview->displayed = NULL;
1342 gtk_widget_ref(vpaned);
1343 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1344 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1345 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1346 GTK_ARROW_UP, GTK_SHADOW_OUT);
1348 mainwin->messageview->visible = TRUE;
1349 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1350 gtk_container_add(GTK_CONTAINER(container), vpaned);
1351 gtk_widget_unref(vpaned);
1352 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1353 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1356 main_window_set_menu_sensitive(mainwin);
1358 gtk_widget_grab_focus(summaryview->ctree);
1361 void main_window_get_size(MainWindow *mainwin)
1363 GtkAllocation *allocation;
1365 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1367 prefs_common.summaryview_width = allocation->width;
1369 if ((mainwin->type == SEPARATE_NONE ||
1370 mainwin->type == SEPARATE_FOLDER) &&
1371 messageview_is_visible(mainwin->messageview))
1372 prefs_common.summaryview_height = allocation->height;
1374 prefs_common.mainview_width = allocation->width;
1376 allocation = &mainwin->window->allocation;
1378 prefs_common.mainview_height = allocation->height;
1379 prefs_common.mainwin_width = allocation->width;
1380 prefs_common.mainwin_height = allocation->height;
1382 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1384 prefs_common.folderview_width = allocation->width;
1385 prefs_common.folderview_height = allocation->height;
1388 void main_window_get_position(MainWindow *mainwin)
1392 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1394 prefs_common.mainview_x = x;
1395 prefs_common.mainview_y = y;
1396 prefs_common.mainwin_x = x;
1397 prefs_common.mainwin_y = y;
1399 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1402 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1408 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1409 folder = FOLDER(list->data);
1410 if (folder && folder->trash && folder->trash->total > 0)
1414 if (!has_trash) return;
1417 if (alertpanel(_("Empty trash"),
1418 _("Empty all messages in trash?"),
1419 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1421 manage_window_focus_in(mainwin->window, NULL, NULL);
1424 procmsg_empty_trash();
1426 for (list = folder_get_list(); list != NULL; list = list->next) {
1427 folder = list->data;
1428 if (folder && folder->trash) {
1429 folderview_update_item(folder->trash, TRUE);
1433 if (mainwin->summaryview->folder_item &&
1434 mainwin->summaryview->folder_item->stype == F_TRASH)
1435 gtk_widget_grab_focus(mainwin->folderview->ctree);
1438 void main_window_add_mailbox(MainWindow *mainwin)
1443 path = input_dialog(_("Add mailbox"),
1444 _("Input the location of mailbox.\n"
1445 "If the existing mailbox is specified, it will be\n"
1446 "scanned automatically."),
1449 if (folder_find_from_path(path)) {
1450 alertpanel_error(_("The mailbox `%s' already exists."), path);
1454 if (!strcmp(path, "Mail"))
1455 folder = folder_new(F_MH, _("Mailbox"), path);
1457 folder = folder_new(F_MH, g_basename(path), path);
1460 if (folder->create_tree(folder) < 0) {
1461 alertpanel_error(_("Creation of the mailbox failed.\n"
1462 "Maybe some files already exist, or you don't have the permission to write there."));
1463 folder_destroy(folder);
1468 folder_set_ui_func(folder, scan_tree_func, mainwin);
1469 folder_scan_tree(folder);
1470 folder_set_ui_func(folder, NULL, NULL);
1472 folderview_set(mainwin->folderview);
1475 void main_window_add_mbox(MainWindow *mainwin)
1481 path = input_dialog(_("Add mbox mailbox"),
1482 _("Input the location of mailbox."),
1487 if (folder_find_from_path(path)) {
1488 alertpanel_error(_("The mailbox `%s' already exists."), path);
1494 if (!strcmp(path, "Mail"))
1495 folder = folder_new(F_MBOX, _("Mailbox"), path);
1499 folder = folder_new(F_MBOX, g_basename(path), path);
1502 if (folder->create_tree(folder) < 0) {
1503 alertpanel_error(_("Creation of the mailbox failed."));
1504 folder_destroy(folder);
1510 item = folder_item_new(folder, folder->name, NULL);
1511 item->folder = folder;
1512 folder->node = g_node_new(item);
1514 folder->create_folder(folder, item, "inbox");
1515 folder->create_folder(folder, item, "outbox");
1516 folder->create_folder(folder, item, "queue");
1517 folder->create_folder(folder, item, "draft");
1518 folder->create_folder(folder, item, "trash");
1520 folderview_set(mainwin->folderview);
1525 M_UNLOCKED = 1 << 0,
1526 M_MSG_EXIST = 1 << 1,
1527 M_TARGET_EXIST = 1 << 2,
1528 M_SINGLE_TARGET_EXIST = 1 << 3,
1530 M_ALLOW_REEDIT = 1 << 5,
1531 M_HAVE_ACCOUNT = 1 << 6,
1532 M_THREADED = 1 << 7,
1533 M_UNTHREADED = 1 << 8,
1534 M_ALLOW_DELETE = 1 << 9,
1535 M_INC_ACTIVE = 1 << 10,
1537 M_HAVE_NEWS_ACCOUNT = 1 << 12,
1538 M_HIDE_READ_MSG = 1 << 13
1541 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1543 SensitiveCond state = 0;
1544 SummarySelection selection;
1545 FolderItem *item = mainwin->summaryview->folder_item;
1546 GList *account_list = account_get_list();
1548 selection = summary_get_selection_type(mainwin->summaryview);
1550 if (mainwin->lock_count == 0)
1551 state |= M_UNLOCKED;
1552 if (selection != SUMMARY_NONE)
1553 state |= M_MSG_EXIST;
1554 if (item && item->path && item->parent && !item->no_select) {
1557 state |= M_THREADED;
1559 state |= M_UNTHREADED;
1560 /* if (item->folder->type != F_NEWS) */
1561 state |= M_ALLOW_DELETE;
1563 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1564 || selection != SUMMARY_NONE)
1565 state |= M_HIDE_READ_MSG;
1567 if (selection == SUMMARY_SELECTED_SINGLE ||
1568 selection == SUMMARY_SELECTED_MULTIPLE)
1569 state |= M_TARGET_EXIST;
1570 if (selection == SUMMARY_SELECTED_SINGLE)
1571 state |= M_SINGLE_TARGET_EXIST;
1572 if (mainwin->summaryview->folder_item &&
1573 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1575 if (selection == SUMMARY_SELECTED_SINGLE &&
1577 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1578 item->stype == F_QUEUE)))
1579 state |= M_ALLOW_REEDIT;
1581 state |= M_HAVE_ACCOUNT;
1583 for ( ; account_list != NULL; account_list = account_list->next) {
1584 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1585 state |= M_HAVE_NEWS_ACCOUNT;
1590 if (inc_is_active())
1591 state |= M_INC_ACTIVE;
1596 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1598 SensitiveCond state;
1607 #define SET_WIDGET_COND(w, c) \
1609 entry[i].widget = w; \
1610 entry[i].cond = c; \
1614 SET_WIDGET_COND(mainwin->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1615 SET_WIDGET_COND(mainwin->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1616 SET_WIDGET_COND(mainwin->compose_news_btn, M_HAVE_ACCOUNT);
1617 SET_WIDGET_COND(mainwin->reply_btn,
1618 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1619 SET_WIDGET_COND(mainwin->replyall_btn,
1620 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1621 SET_WIDGET_COND(mainwin->replysender_btn,
1622 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1623 SET_WIDGET_COND(mainwin->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
1625 SET_WIDGET_COND(mainwin->prefs_btn, M_UNLOCKED);
1626 SET_WIDGET_COND(mainwin->account_btn, M_UNLOCKED);
1628 SET_WIDGET_COND(mainwin->next_btn, M_MSG_EXIST);
1629 SET_WIDGET_COND(mainwin->delete_btn,
1630 M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
1631 SET_WIDGET_COND(mainwin->exec_btn, M_MSG_EXIST|M_EXEC|M_UNLOCKED);
1632 SET_WIDGET_COND(NULL, 0);
1634 #undef SET_WIDGET_COND
1636 state = main_window_get_current_state(mainwin);
1638 for (i = 0; entry[i].widget != NULL; i++) {
1639 sensitive = ((entry[i].cond & state) == entry[i].cond);
1640 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1643 activate_compose_button(mainwin,
1644 prefs_common.toolbar_style,
1645 mainwin->compose_btn_type);
1648 void main_window_set_menu_sensitive(MainWindow *mainwin)
1650 GtkItemFactory *ifactory = mainwin->menu_factory;
1651 SensitiveCond state;
1653 GtkWidget *menuitem;
1658 static const struct {
1662 {"/File/Add mailbox..." , M_UNLOCKED},
1663 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1664 {"/File/Rescan folder tree" , M_UNLOCKED},
1665 {"/File/Folder" , M_UNLOCKED},
1666 {"/File/Import mbox file..." , M_UNLOCKED},
1667 {"/File/Export to mbox file...", M_UNLOCKED},
1668 {"/File/Empty trash" , M_UNLOCKED},
1669 {"/File/Work offline" , M_UNLOCKED},
1670 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1671 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1672 /* {"/File/Close", M_UNLOCKED}, */
1673 {"/File/Exit" , M_UNLOCKED},
1675 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1676 {"/View/Sort" , M_EXEC},
1677 {"/View/Thread view" , M_EXEC},
1678 {"/View/Expand all threads" , M_MSG_EXIST},
1679 {"/View/Collapse all threads" , M_MSG_EXIST},
1680 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1681 {"/View/Go to/Prev message" , M_MSG_EXIST},
1682 {"/View/Go to/Next message" , M_MSG_EXIST},
1683 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1684 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1685 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1686 {"/View/Go to/Next new message" , M_MSG_EXIST},
1687 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1688 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1689 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1690 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1691 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1692 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1693 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1695 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1696 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1697 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1698 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1699 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1700 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1701 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1702 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1703 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1704 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1705 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1706 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1707 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1708 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1709 {"/Message/Mark" , M_TARGET_EXIST},
1711 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1712 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1713 {"/Tools/Harvest addresses" , M_UNLOCKED},
1714 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1715 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1716 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1717 {"/Tools/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1718 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1720 {"/Configuration", M_UNLOCKED},
1725 state = main_window_get_current_state(mainwin);
1727 for (i = 0; entry[i].entry != NULL; i++) {
1728 sensitive = ((entry[i].cond & state) == entry[i].cond);
1729 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1732 main_window_menu_callback_block(mainwin);
1734 #define SET_CHECK_MENU_ACTIVE(path, active) \
1736 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1737 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1740 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1741 messageview_is_visible(mainwin->messageview));
1743 item = mainwin->summaryview->folder_item;
1744 menu_path = "/View/Sort/Don't sort";
1746 switch (item->sort_key) {
1747 case SORT_BY_NUMBER:
1748 menu_path = "/View/Sort/by number"; break;
1750 menu_path = "/View/Sort/by size"; break;
1752 menu_path = "/View/Sort/by date"; break;
1754 menu_path = "/View/Sort/by from"; break;
1755 case SORT_BY_SUBJECT:
1756 menu_path = "/View/Sort/by subject"; break;
1758 menu_path = "/View/Sort/by color label"; break;
1760 menu_path = "/View/Sort/by mark"; break;
1761 case SORT_BY_UNREAD:
1762 menu_path = "/View/Sort/by unread"; break;
1764 menu_path = "/View/Sort/by attachment"; break;
1766 menu_path = "/View/Sort/by score"; break;
1767 case SORT_BY_LOCKED:
1768 menu_path = "/View/Sort/by locked"; break;
1771 menu_path = "/View/Sort/Don't sort"; break;
1774 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1776 if (!item || item->sort_type == SORT_ASCENDING) {
1777 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1779 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1782 if (item && item->sort_key != SORT_BY_NONE) {
1783 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1784 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1786 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1787 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1790 SET_CHECK_MENU_ACTIVE("/View/Show all header",
1791 mainwin->messageview->textview->show_all_headers);
1792 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1794 #undef SET_CHECK_MENU_ACTIVE
1796 main_window_menu_callback_unblock(mainwin);
1799 void main_window_popup(MainWindow *mainwin)
1805 gdk_window_get_origin(mainwin->window->window, &x, &y);
1806 sx = gdk_screen_width();
1807 sy = gdk_screen_height();
1808 x %= sx; if (x < 0) x = 0;
1809 y %= sy; if (y < 0) y = 0;
1810 gdk_window_move(mainwin->window->window, x, y);
1811 gdk_window_raise(mainwin->window->window);
1812 gdk_window_show(mainwin->window->window);
1814 debug_print("window position: x = %d, y = %d\n", x, y);
1816 switch (mainwin->type) {
1817 case SEPARATE_FOLDER:
1818 widget = mainwin->win.sep_folder.folderwin;
1819 gdk_window_get_origin(widget->window, &x, &y);
1820 x %= sx; if (x < 0) x = 0;
1821 y %= sy; if (y < 0) y = 0;
1822 gdk_window_move(widget->window, x, y);
1823 gdk_window_raise(widget->window);
1825 case SEPARATE_MESSAGE:
1826 widget = mainwin->win.sep_message.messagewin;
1827 gdk_window_get_origin(widget->window, &x, &y);
1828 x %= sx; if (x < 0) x = 0;
1829 y %= sy; if (y < 0) y = 0;
1830 gdk_window_move(widget->window, x, y);
1831 gdk_window_raise(widget->window);
1834 widget = mainwin->win.sep_both.folderwin;
1835 gdk_window_get_origin(widget->window, &x, &y);
1836 x %= sx; if (x < 0) x = 0;
1837 y %= sy; if (y < 0) y = 0;
1838 gdk_window_move(widget->window, x, y);
1839 gdk_window_raise(widget->window);
1840 widget = mainwin->win.sep_both.messagewin;
1841 gdk_window_get_origin(widget->window, &x, &y);
1842 x %= sx; if (x < 0) x = 0;
1843 y %= sy; if (y < 0) y = 0;
1844 gdk_window_move(widget->window, x, y);
1845 gdk_window_raise(widget->window);
1852 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1854 GtkWidget *folderwin = NULL;
1855 GtkWidget *messagewin = NULL;
1858 GtkWidget *vbox_body = mainwin->vbox_body;
1859 GtkItemFactory *ifactory = mainwin->menu_factory;
1860 GtkWidget *menuitem;
1862 debug_print(_("Setting widgets..."));
1864 /* create separated window(s) if needed */
1865 if (type & SEPARATE_FOLDER) {
1866 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1867 gtk_window_set_title(GTK_WINDOW(folderwin),
1868 _("Sylpheed - Folder View"));
1869 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1870 "folder_view", "Sylpheed");
1871 gtk_window_set_policy(GTK_WINDOW(folderwin),
1873 gtk_widget_set_usize(folderwin, -1,
1874 prefs_common.mainview_height);
1875 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1877 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1878 GTK_SIGNAL_FUNC(folder_window_close_cb),
1881 if (type & SEPARATE_MESSAGE) {
1882 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1883 gtk_window_set_title(GTK_WINDOW(messagewin),
1884 _("Sylpheed - Message View"));
1885 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1886 "message_view", "Sylpheed");
1887 gtk_window_set_policy(GTK_WINDOW(messagewin),
1889 gtk_widget_set_usize
1890 (messagewin, prefs_common.mainview_width,
1891 prefs_common.mainview_height
1892 - prefs_common.summaryview_height
1893 + DEFAULT_HEADERVIEW_HEIGHT);
1894 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1896 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1897 GTK_SIGNAL_FUNC(message_window_close_cb),
1903 hpaned = gtk_hpaned_new();
1904 gtk_widget_show(hpaned);
1905 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1906 gtk_paned_add1(GTK_PANED(hpaned),
1907 GTK_WIDGET_PTR(mainwin->folderview));
1909 vpaned = gtk_vpaned_new();
1910 if (messageview_is_visible(mainwin->messageview)) {
1911 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1912 gtk_paned_add1(GTK_PANED(vpaned),
1913 GTK_WIDGET_PTR(mainwin->summaryview));
1915 gtk_paned_add2(GTK_PANED(hpaned),
1916 GTK_WIDGET_PTR(mainwin->summaryview));
1917 gtk_widget_ref(vpaned);
1919 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1920 prefs_common.summaryview_width,
1921 prefs_common.summaryview_height);
1922 gtk_paned_add2(GTK_PANED(vpaned),
1923 GTK_WIDGET_PTR(mainwin->messageview));
1924 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1925 prefs_common.mainview_width, -1);
1926 gtk_widget_set_usize(mainwin->window,
1927 prefs_common.folderview_width +
1928 prefs_common.mainview_width,
1929 prefs_common.mainwin_height);
1930 gtk_widget_show_all(vpaned);
1932 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1933 * lose track of its visibility state */
1934 if (!noticeview_is_visible(mainwin->messageview->noticeview))
1935 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
1937 mainwin->win.sep_none.hpaned = hpaned;
1938 mainwin->win.sep_none.vpaned = vpaned;
1940 case SEPARATE_FOLDER:
1941 vpaned = gtk_vpaned_new();
1942 if (messageview_is_visible(mainwin->messageview)) {
1943 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1945 gtk_paned_add1(GTK_PANED(vpaned),
1946 GTK_WIDGET_PTR(mainwin->summaryview));
1948 gtk_box_pack_start(GTK_BOX(vbox_body),
1949 GTK_WIDGET_PTR(mainwin->summaryview),
1951 gtk_widget_ref(vpaned);
1953 gtk_paned_add2(GTK_PANED(vpaned),
1954 GTK_WIDGET_PTR(mainwin->messageview));
1955 gtk_widget_show_all(vpaned);
1956 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1957 prefs_common.summaryview_width,
1958 prefs_common.summaryview_height);
1959 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1960 prefs_common.mainview_width, -1);
1961 gtk_widget_set_usize(mainwin->window,
1962 prefs_common.mainview_width,
1963 prefs_common.mainview_height);
1965 gtk_container_add(GTK_CONTAINER(folderwin),
1966 GTK_WIDGET_PTR(mainwin->folderview));
1968 mainwin->win.sep_folder.folderwin = folderwin;
1969 mainwin->win.sep_folder.vpaned = vpaned;
1971 gtk_widget_show_all(folderwin);
1973 case SEPARATE_MESSAGE:
1974 hpaned = gtk_hpaned_new();
1975 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1977 gtk_paned_add1(GTK_PANED(hpaned),
1978 GTK_WIDGET_PTR(mainwin->folderview));
1979 gtk_paned_add2(GTK_PANED(hpaned),
1980 GTK_WIDGET_PTR(mainwin->summaryview));
1981 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1982 prefs_common.summaryview_width,
1983 prefs_common.summaryview_height);
1984 gtk_widget_set_usize(mainwin->window,
1985 prefs_common.folderview_width +
1986 prefs_common.mainview_width,
1987 prefs_common.mainwin_height);
1988 gtk_widget_show_all(hpaned);
1989 gtk_container_add(GTK_CONTAINER(messagewin),
1990 GTK_WIDGET_PTR(mainwin->messageview));
1992 mainwin->win.sep_message.messagewin = messagewin;
1993 mainwin->win.sep_message.hpaned = hpaned;
1995 gtk_widget_show_all(messagewin);
1997 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
1998 * lose track of its visibility state */
1999 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2000 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2003 gtk_box_pack_start(GTK_BOX(vbox_body),
2004 GTK_WIDGET_PTR(mainwin->summaryview),
2006 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
2007 prefs_common.summaryview_width,
2008 prefs_common.summaryview_height);
2009 gtk_widget_set_usize(mainwin->window,
2010 prefs_common.mainview_width,
2011 prefs_common.mainwin_height);
2012 gtk_container_add(GTK_CONTAINER(folderwin),
2013 GTK_WIDGET_PTR(mainwin->folderview));
2014 gtk_container_add(GTK_CONTAINER(messagewin),
2015 GTK_WIDGET_PTR(mainwin->messageview));
2017 mainwin->win.sep_both.folderwin = folderwin;
2018 mainwin->win.sep_both.messagewin = messagewin;
2020 gtk_widget_show_all(folderwin);
2021 gtk_widget_show_all(messagewin);
2023 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2024 * lose track of its visibility state */
2025 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2026 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2030 mainwin->type = type;
2032 mainwin->messageview->visible = TRUE;
2034 /* toggle menu state */
2035 menuitem = gtk_item_factory_get_item
2036 (ifactory, "/View/Show or hide/Folder tree");
2037 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2038 menuitem = gtk_item_factory_get_item
2039 (ifactory, "/View/Show or hide/Message view");
2040 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2042 menuitem = gtk_item_factory_get_item
2043 (ifactory, "/View/Separate folder tree");
2044 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2045 ((type & SEPARATE_FOLDER) != 0));
2046 menuitem = gtk_item_factory_get_item
2047 (ifactory, "/View/Separate message view");
2048 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2049 ((type & SEPARATE_MESSAGE) != 0));
2051 debug_print(_("done.\n"));
2054 static void main_window_toolbar_create(MainWindow *mainwin,
2055 GtkWidget *container)
2058 GtkWidget *icon_wid;
2060 GtkWidget *getall_btn;
2061 GtkWidget *compose_mail_btn;
2062 GtkWidget *compose_news_btn;
2063 GtkWidget *reply_btn;
2064 GtkWidget *replyall_btn;
2065 GtkWidget *replysender_btn;
2067 GtkWidget *send_btn;
2069 GtkWidget *prefs_btn;
2070 GtkWidget *account_btn;
2072 GtkWidget *next_btn;
2073 GtkWidget *delete_btn;
2074 GtkWidget *exec_btn;
2076 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
2078 gtk_container_add(GTK_CONTAINER(container), toolbar);
2079 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
2080 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
2081 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
2082 GTK_TOOLBAR_SPACE_LINE);
2084 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
2085 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2087 _("Get new mail from current account"),
2089 icon_wid, toolbar_inc_cb, mainwin);
2090 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
2091 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2093 _("Get new mail from all accounts"),
2099 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2101 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
2102 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2104 _("Send queued message(s)"),
2110 /* insert compose mail button widget */
2111 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
2112 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2114 _("Compose an email message"),
2117 toolbar_compose_mail_cb,
2120 /* insert compose news button widget */
2121 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2122 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2124 _("Compose a news message"),
2127 toolbar_compose_news_cb,
2130 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2134 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
2135 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2137 _("Reply to the message - Right button: more options"),
2143 /* replyall button */
2145 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
2146 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2148 _("Reply to all - Right button: more options"),
2151 toolbar_reply_to_all_cb,
2154 /* reply to sender button */
2155 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
2156 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2158 _("Reply to sender - Right button: more options"),
2161 toolbar_reply_to_sender_cb,
2164 /* forward button */
2165 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
2166 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2168 _("Forward the message - Right button: more options"),
2174 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2176 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
2177 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2179 _("Delete the message"),
2185 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
2186 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2188 _("Execute marked process"),
2194 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
2195 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2197 _("Next unread message"),
2200 toolbar_next_unread_cb,
2204 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2206 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2207 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2209 _("Common preferences"),
2214 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2215 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2217 _("Account setting"),
2222 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2223 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2227 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2228 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2231 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2232 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2235 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2236 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2239 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2240 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2244 mainwin->toolbar = toolbar;
2245 mainwin->get_btn = get_btn;
2246 mainwin->getall_btn = getall_btn;
2247 mainwin->compose_mail_btn = compose_mail_btn;
2248 mainwin->compose_news_btn = compose_news_btn;
2249 mainwin->reply_btn = reply_btn;
2250 mainwin->replyall_btn = replyall_btn;
2251 mainwin->replysender_btn = replysender_btn;
2252 mainwin->fwd_btn = fwd_btn;
2253 mainwin->send_btn = send_btn;
2255 mainwin->prefs_btn = prefs_btn;
2256 mainwin->account_btn = account_btn;
2258 mainwin->next_btn = next_btn;
2259 mainwin->delete_btn = delete_btn;
2260 mainwin->exec_btn = exec_btn;
2262 gtk_widget_show_all(toolbar);
2265 /* callback functions */
2266 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2268 MainWindow *mainwindow = (MainWindow *) data;
2272 if (event->button == 3) {
2273 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2274 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2275 menu_button_position, widget,
2276 event->button, event->time);
2280 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2282 MainWindow *mainwin = (MainWindow *)data;
2284 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2285 manage_window_focus_in(mainwin->window, NULL, NULL);
2288 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2290 MainWindow *mainwindow = (MainWindow *) data;
2294 if (event->button == 3) {
2295 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2296 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2297 menu_button_position, widget,
2298 event->button, event->time);
2302 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2304 MainWindow *mainwin = (MainWindow *)data;
2306 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2307 manage_window_focus_in(mainwin->window, NULL, NULL);
2310 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2312 MainWindow *mainwindow = (MainWindow *) data;
2316 if (event->button == 3) {
2317 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2318 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2319 menu_button_position, widget,
2320 event->button, event->time);
2324 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2326 MainWindow *mainwin = (MainWindow *)data;
2328 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2329 manage_window_focus_in(mainwin->window, NULL, NULL);
2332 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2334 MainWindow *mainwindow = (MainWindow *) data;
2338 if (event->button == 3) {
2339 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2340 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2341 menu_button_position, widget,
2342 event->button, event->time);
2346 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2348 MainWindow *mainwin = (MainWindow *)data;
2350 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2351 manage_window_focus_in(mainwin->window, NULL, NULL);
2354 static void toolbar_inc_cb (GtkWidget *widget,
2357 MainWindow *mainwin = (MainWindow *)data;
2359 inc_mail_cb(mainwin, 0, NULL);
2362 static void toolbar_inc_all_cb (GtkWidget *widget,
2365 MainWindow *mainwin = (MainWindow *)data;
2367 inc_all_account_mail_cb(mainwin, 0, NULL);
2370 static void toolbar_send_cb (GtkWidget *widget,
2373 MainWindow *mainwin = (MainWindow *)data;
2375 send_queue_cb(mainwin, 0, NULL);
2378 static void toolbar_compose_news_cb (GtkWidget *widget,
2381 MainWindow *mainwin = (MainWindow *)data;
2383 compose_news_cb(mainwin, 0, NULL);
2386 static void toolbar_compose_mail_cb (GtkWidget *widget,
2389 MainWindow *mainwin = (MainWindow *)data;
2391 compose_mail_cb(mainwin, 0, NULL);
2394 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2396 MainWindow *mainwin = (MainWindow *)data;
2399 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2400 : COMPOSE_REPLY_WITHOUT_QUOTE,
2404 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2406 MainWindow *mainwin = (MainWindow *)data;
2409 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2410 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2415 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2417 MainWindow *mainwin = (MainWindow *)data;
2420 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2421 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2425 static void toolbar_forward_cb (GtkWidget *widget,
2428 MainWindow *mainwin = (MainWindow *)data;
2430 if (prefs_common.forward_as_attachment)
2431 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2433 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2436 static void toolbar_delete_cb (GtkWidget *widget,
2439 MainWindow *mainwin = (MainWindow *)data;
2441 summary_delete(mainwin->summaryview);
2444 static void toolbar_exec_cb (GtkWidget *widget,
2447 MainWindow *mainwin = (MainWindow *)data;
2449 summary_execute(mainwin->summaryview);
2452 static void toolbar_next_unread_cb (GtkWidget *widget,
2455 MainWindow *mainwin = (MainWindow *)data;
2457 next_unread_cb(mainwin, 0, NULL);
2461 static void toolbar_account_button_pressed(GtkWidget *widget,
2462 GdkEventButton *event,
2465 MainWindow *mainwin = (MainWindow *)data;
2468 if (event->button != 3) return;
2470 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2471 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2474 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2475 menu_button_position, widget,
2476 event->button, event->time);
2480 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2483 MainWindow *mainwin = (MainWindow *)data;
2487 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2488 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2491 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2492 menu_button_position, widget,
2493 event->button, event->time);
2496 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2498 MainWindow *mainwin = (MainWindow *)data;
2501 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2502 if (!button) return;
2503 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2504 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2505 manage_window_focus_in(mainwin->window, NULL, NULL);
2508 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2511 MainWindow *mainwin = (MainWindow *)data;
2513 if (mainwin->lock_count == 0)
2514 app_exit_cb(data, 0, widget);
2519 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2522 MainWindow *mainwin = (MainWindow *)data;
2523 GtkWidget *menuitem;
2525 menuitem = gtk_item_factory_get_item
2526 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2527 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2532 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2535 MainWindow *mainwin = (MainWindow *)data;
2536 GtkWidget *menuitem;
2538 menuitem = gtk_item_factory_get_item
2539 (mainwin->menu_factory, "/View/Show or hide/Message view");
2540 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2545 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2548 main_window_add_mailbox(mainwin);
2551 static void add_mbox_cb(MainWindow *mainwin, guint action,
2554 main_window_add_mbox(mainwin);
2557 static void update_folderview_cb(MainWindow *mainwin, guint action,
2560 summary_show(mainwin->summaryview, NULL);
2561 folderview_check_new_all();
2564 static void new_folder_cb(MainWindow *mainwin, guint action,
2567 folderview_new_folder(mainwin->folderview);
2570 static void rename_folder_cb(MainWindow *mainwin, guint action,
2573 folderview_rename_folder(mainwin->folderview);
2576 static void delete_folder_cb(MainWindow *mainwin, guint action,
2579 folderview_delete_folder(mainwin->folderview);
2582 static void import_mbox_cb(MainWindow *mainwin, guint action,
2585 import_mbox(mainwin->summaryview->folder_item);
2588 static void export_mbox_cb(MainWindow *mainwin, guint action,
2591 export_mbox(mainwin->summaryview->folder_item);
2594 static void empty_trash_cb(MainWindow *mainwin, guint action,
2597 main_window_empty_trash(mainwin, TRUE);
2600 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2602 summary_save_as(mainwin->summaryview);
2605 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2607 summary_print(mainwin->summaryview);
2610 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2612 if (prefs_common.confirm_on_exit) {
2613 if (alertpanel(_("Exit"), _("Exit this program?"),
2614 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2616 manage_window_focus_in(mainwin->window, NULL, NULL);
2619 app_will_exit(widget, mainwin);
2622 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2625 summary_search(mainwin->summaryview);
2627 message_search(mainwin->messageview);
2630 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2635 active = GTK_CHECK_MENU_ITEM(widget)->active;
2637 switch (mainwin->type) {
2639 case SEPARATE_MESSAGE:
2642 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2644 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2647 case SEPARATE_FOLDER:
2648 debug_print("separate folder\n");
2650 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2652 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2656 gtk_widget_show(mainwin->win.sep_both.folderwin);
2658 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2663 static void toggle_message_cb(MainWindow *mainwin, guint action,
2668 active = GTK_CHECK_MENU_ITEM(widget)->active;
2670 if (active != messageview_is_visible(mainwin->messageview))
2671 summary_toggle_view(mainwin->summaryview);
2674 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2677 switch ((ToolbarStyle)action) {
2679 gtk_widget_hide(mainwin->handlebox);
2681 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2685 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2689 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2694 if (action != TOOLBAR_NONE) {
2695 gtk_widget_show(mainwin->handlebox);
2696 gtk_widget_queue_resize(mainwin->handlebox);
2699 mainwin->toolbar_style = (ToolbarStyle)action;
2700 prefs_common.toolbar_style = (ToolbarStyle)action;
2703 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2706 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2707 gtk_widget_show(mainwin->hbox_stat);
2708 prefs_common.show_statusbar = TRUE;
2710 gtk_widget_hide(mainwin->hbox_stat);
2711 prefs_common.show_statusbar = FALSE;
2715 static void separate_widget_cb(MainWindow *mainwin, guint action,
2720 if (GTK_CHECK_MENU_ITEM(widget)->active)
2721 type = mainwin->type | action;
2723 type = mainwin->type & ~action;
2725 main_window_separation_change(mainwin, type);
2727 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2728 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2731 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2733 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2734 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2736 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2740 static void online_switch_clicked (GtkButton *btn, gpointer data)
2742 MainWindow *mainwin;
2743 GtkItemFactory *ifactory;
2744 GtkCheckMenuItem *menuitem;
2746 mainwin = (MainWindow *) data;
2748 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2749 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2751 g_return_if_fail(mainwin != NULL);
2752 g_return_if_fail(menuitem != NULL);
2754 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2756 gtk_widget_hide (mainwin->online_switch);
2757 gtk_widget_show (mainwin->offline_switch);
2758 menuitem->active = TRUE;
2759 prefs_common.work_offline = TRUE;
2760 inc_autocheck_timer_remove();
2763 gtk_widget_hide (mainwin->offline_switch);
2764 gtk_widget_show (mainwin->online_switch);
2765 menuitem->active = FALSE;
2766 prefs_common.work_offline = FALSE;
2767 inc_autocheck_timer_set();
2771 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2774 addressbook_open(NULL);
2777 static void log_window_show_cb(MainWindow *mainwin, guint action,
2780 log_window_show(mainwin->logwin);
2783 static void sel_download_cb(MainWindow *mainwin, guint action,
2786 selective_download(mainwin);
2789 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2791 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2794 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2797 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2800 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2805 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2809 if (prefs_common.work_offline)
2810 if (alertpanel(_("Offline warning"),
2811 _("You're working offline. Override?"),
2812 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
2815 for (list = folder_get_list(); list != NULL; list = list->next) {
2816 Folder *folder = list->data;
2818 if (folder->queue) {
2819 if (procmsg_send_queue
2820 (folder->queue, prefs_common.savemsg) < 0)
2821 alertpanel_error(_("Some errors occurred while sending queued messages."));
2822 statusbar_pop_all();
2823 folder_item_scan(folder->queue);
2824 folderview_update_item(folder->queue, TRUE);
2829 static void compose_mail_cb(MainWindow *mainwin, guint action,
2836 if (mainwin->summaryview->folder_item) {
2837 ac = mainwin->summaryview->folder_item->folder->account;
2838 if (ac && ac->protocol != A_NNTP) {
2839 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2844 if(cur_account && (cur_account->protocol != A_NNTP)) {
2845 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2849 list = account_get_list();
2850 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2851 ac = (PrefsAccount *) cur->data;
2852 if (ac->protocol != A_NNTP) {
2853 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2859 static void compose_news_cb(MainWindow *mainwin, guint action,
2862 PrefsAccount * ac = NULL;
2866 if (mainwin->summaryview->folder_item) {
2867 ac = mainwin->summaryview->folder_item->folder->account;
2868 if (ac && ac->protocol == A_NNTP) {
2870 mainwin->summaryview->folder_item->path,
2876 list = account_get_list();
2877 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2878 ac = (PrefsAccount *) cur->data;
2879 if (ac->protocol == A_NNTP) {
2880 compose_new(ac, NULL, NULL);
2886 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2888 summary_reply(mainwin->summaryview, (ComposeMode)action);
2891 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2893 summary_move_to(mainwin->summaryview);
2896 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2898 summary_copy_to(mainwin->summaryview);
2901 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2903 summary_delete(mainwin->summaryview);
2906 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2908 summary_open_msg(mainwin->summaryview);
2911 static void view_source_cb(MainWindow *mainwin, guint action,
2914 summary_view_source(mainwin->summaryview);
2917 static void show_all_header_cb(MainWindow *mainwin, guint action,
2920 if (mainwin->menu_lock_count) return;
2921 summary_display_msg_selected(mainwin->summaryview,
2922 GTK_CHECK_MENU_ITEM(widget)->active);
2925 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2927 summary_reedit(mainwin->summaryview);
2930 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2932 summary_mark(mainwin->summaryview);
2935 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2937 summary_unmark(mainwin->summaryview);
2940 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2943 summary_mark_as_unread(mainwin->summaryview);
2946 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2949 summary_mark_as_read(mainwin->summaryview);
2952 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2955 summary_mark_all_read(mainwin->summaryview);
2958 static void add_address_cb(MainWindow *mainwin, guint action,
2961 summary_add_address(mainwin->summaryview);
2964 static void set_charset_cb(MainWindow *mainwin, guint action,
2969 str = conv_get_charset_str((CharSet)action);
2970 g_free(prefs_common.force_charset);
2971 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2973 summary_redisplay_msg(mainwin->summaryview);
2975 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2978 static void hide_read_messages (MainWindow *mainwin, guint action,
2981 if (!mainwin->summaryview->folder_item
2982 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2984 summary_toggle_show_read_messages(mainwin->summaryview);
2987 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2989 if (mainwin->menu_lock_count) return;
2990 if (!mainwin->summaryview->folder_item) return;
2992 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2993 summary_thread_build(mainwin->summaryview);
2994 mainwin->summaryview->folder_item->threaded = TRUE;
2996 summary_unthread(mainwin->summaryview);
2997 mainwin->summaryview->folder_item->threaded = FALSE;
3001 static void expand_threads_cb(MainWindow *mainwin, guint action,
3004 summary_expand_threads(mainwin->summaryview);
3007 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3010 summary_collapse_threads(mainwin->summaryview);
3013 static void set_display_item_cb(MainWindow *mainwin, guint action,
3016 prefs_summary_column_open();
3019 static void sort_summary_cb(MainWindow *mainwin, guint action,
3022 FolderItem *item = mainwin->summaryview->folder_item;
3023 GtkWidget *menuitem;
3025 if (mainwin->menu_lock_count) return;
3027 menuitem = gtk_item_factory_get_item
3028 (mainwin->menu_factory, "/View/Sort/Ascending");
3029 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3030 GTK_CHECK_MENU_ITEM(menuitem)->active
3031 ? SORT_ASCENDING : SORT_DESCENDING);
3035 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3038 FolderItem *item = mainwin->summaryview->folder_item;
3040 if (mainwin->menu_lock_count) return;
3042 summary_sort(mainwin->summaryview,
3043 item->sort_key, (FolderSortType)action);
3046 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3049 summary_attract_by_subject(mainwin->summaryview);
3052 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3055 summary_delete_duplicated(mainwin->summaryview);
3058 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3060 summary_filter(mainwin->summaryview);
3063 static void execute_summary_cb(MainWindow *mainwin, guint action,
3066 summary_execute(mainwin->summaryview);
3069 static void update_summary_cb(MainWindow *mainwin, guint action,
3073 FolderView *folderview = mainwin->folderview;
3075 if (!mainwin->summaryview->folder_item) return;
3076 if (!folderview->opened) return;
3078 folder_update_op_count();
3080 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3081 folderview->opened);
3084 folder_item_scan(fitem);
3085 summary_show(mainwin->summaryview, fitem);
3088 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3090 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3093 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3095 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3098 static void prev_unread_cb(MainWindow *mainwin, guint action,
3101 summary_select_prev_unread(mainwin->summaryview);
3104 static void next_unread_cb(MainWindow *mainwin, guint action,
3107 summary_select_next_unread(mainwin->summaryview);
3110 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3112 summary_select_prev_new(mainwin->summaryview);
3115 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3117 summary_select_next_new(mainwin->summaryview);
3120 static void prev_marked_cb(MainWindow *mainwin, guint action,
3123 summary_select_prev_marked(mainwin->summaryview);
3126 static void next_marked_cb(MainWindow *mainwin, guint action,
3129 summary_select_next_marked(mainwin->summaryview);
3132 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3135 summary_select_prev_labeled(mainwin->summaryview);
3138 static void next_labeled_cb(MainWindow *mainwin, guint action,
3141 summary_select_next_labeled(mainwin->summaryview);
3144 static void goto_folder_cb(MainWindow *mainwin, guint action,
3147 FolderItem *to_folder;
3149 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3152 folderview_select(mainwin->folderview, to_folder);
3155 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3157 messageview_copy_clipboard(mainwin->messageview);
3160 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3162 MessageView *msgview = mainwin->messageview;
3164 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3165 summary_select_all(mainwin->summaryview);
3166 else if (messageview_is_visible(msgview) &&
3167 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
3168 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3169 messageview_select_all(mainwin->messageview);
3172 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3174 if (messageview_is_visible(mainwin->summaryview->messageview))
3175 summary_select_thread(mainwin->summaryview);
3178 static void create_filter_cb(MainWindow *mainwin, guint action,
3181 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3184 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3187 prefs_common_open();
3190 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
3193 prefs_filter_open(NULL, NULL);
3196 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3199 prefs_scoring_open(NULL);
3202 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3205 prefs_filtering_open(NULL, NULL, NULL);
3208 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3211 prefs_template_open();
3214 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3217 prefs_actions_open(mainwin);
3220 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3224 new_account_cb(mainwin, 0, widget);
3226 gboolean prev_default = cur_account->is_default;
3228 prefs_account_open(cur_account);
3229 if (!prev_default && cur_account->is_default)
3230 account_set_as_default(cur_account);
3231 account_save_config_all();
3233 main_window_reflect_prefs_all();
3237 static void new_account_cb(MainWindow *mainwin, guint action,
3240 account_edit_open();
3241 if (!compose_get_compose_list()) account_add();
3244 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3246 cur_account = (PrefsAccount *)data;
3247 main_window_reflect_prefs_all();
3250 static void manual_open_cb(MainWindow *mainwin, guint action,
3253 manual_open((ManualLang)action);
3256 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3258 faq_open((ManualLang)action);
3261 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3263 MainWindow *mainwin = (MainWindow *)data;
3267 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3268 LOCAL_FOLDER(folder)->rootpath,
3272 str = g_strdup_printf(_("Scanning folder %s ..."),
3273 LOCAL_FOLDER(folder)->rootpath);
3275 STATUSBAR_PUSH(mainwin, str);
3276 STATUSBAR_POP(mainwin);
3280 static void activate_compose_button (MainWindow *mainwin,
3282 ComposeButtonType type)
3284 if (style == TOOLBAR_NONE)
3287 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
3288 : mainwin->compose_news_btn);
3289 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
3290 : mainwin->compose_mail_btn);
3291 mainwin->compose_btn_type = type;
3294 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
3296 if (mainwin->compose_btn_type != compose_btn_type)
3297 activate_compose_button(mainwin,
3298 prefs_common.toolbar_style,
3302 #define BREAK_ON_MODIFIER_KEY() \
3303 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3305 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3307 MainWindow *mainwin = (MainWindow*) data;
3309 if (!mainwin || !event) return;
3311 switch (event->keyval) {
3312 case GDK_Q: /* Quit */
3313 BREAK_ON_MODIFIER_KEY();
3315 app_exit_cb(mainwin, 0, NULL);
3322 #undef BREAK_ON_MODIFIER_KEY
3324 static void set_toolbar_style(MainWindow *mainwin)
3326 switch (prefs_common.toolbar_style) {
3328 gtk_widget_hide(mainwin->handlebox);
3331 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3335 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3339 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3344 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3345 gtk_widget_show(mainwin->handlebox);
3346 gtk_widget_queue_resize(mainwin->handlebox);
3351 * Harvest addresses for selected folder.
3353 static void addr_harvest_cb( MainWindow *mainwin,
3357 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3361 * Harvest addresses for selected messages in summary view.
3363 static void addr_harvest_msg_cb( MainWindow *mainwin,
3367 summary_harvest_address( mainwin->summaryview );