2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2002 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
55 #include "stock_pixmap.h"
62 #include "prefs_common.h"
63 #include "prefs_filter.h"
64 #include "prefs_actions.h"
65 #include "prefs_filtering.h"
66 #include "prefs_scoring.h"
67 #include "prefs_account.h"
68 #include "prefs_folder_item.h"
69 #include "prefs_summary_column.h"
70 #include "prefs_template.h"
72 #include "addressbook.h"
73 #include "logwindow.h"
74 #include "manage_window.h"
75 #include "alertpanel.h"
76 #include "statusbar.h"
77 #include "inputdialog.h"
84 #include "selective_download.h"
86 #define AC_LABEL_WIDTH 240
88 #define STATUSBAR_PUSH(mainwin, str) \
90 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
91 mainwin->mainwin_cid, str); \
92 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
95 #define STATUSBAR_POP(mainwin) \
97 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
98 mainwin->mainwin_cid); \
101 /* list of all instantiated MainWindow */
102 static GList *mainwin_list = NULL;
104 static GdkCursor *watch_cursor;
106 static void main_window_menu_callback_block (MainWindow *mainwin);
107 static void main_window_menu_callback_unblock (MainWindow *mainwin);
109 static void main_window_show_cur_account (MainWindow *mainwin);
111 static void main_window_set_widgets (MainWindow *mainwin,
113 static void main_window_toolbar_create (MainWindow *mainwin,
114 GtkWidget *container);
116 /* callback functions */
117 static void toolbar_inc_cb (GtkWidget *widget,
119 static void toolbar_inc_all_cb (GtkWidget *widget,
121 static void toolbar_send_cb (GtkWidget *widget,
124 static void toolbar_compose_news_cb (GtkWidget *widget,
126 static void toolbar_compose_mail_cb (GtkWidget *widget,
128 static void toolbar_reply_cb (GtkWidget *widget,
130 static void toolbar_reply_popup_cb (GtkWidget *widget,
131 GdkEventButton *event,
133 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell,
135 static void toolbar_reply_to_all_cb (GtkWidget *widget,
137 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget,
138 GdkEventButton *event,
140 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell,
142 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
144 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
145 GdkEventButton *event,
147 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell,
149 static void toolbar_forward_cb (GtkWidget *widget,
151 static void toolbar_forward_popup_cb (GtkWidget *widget,
152 GdkEventButton *event,
154 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell,
157 static void toolbar_delete_cb (GtkWidget *widget,
159 static void toolbar_exec_cb (GtkWidget *widget,
162 static void toolbar_next_unread_cb (GtkWidget *widget,
167 static void toolbar_account_button_pressed (GtkWidget *widget,
168 GdkEventButton *event,
171 static void ac_label_button_pressed (GtkWidget *widget,
172 GdkEventButton *event,
174 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
177 static gint main_window_close_cb (GtkWidget *widget,
180 static gint folder_window_close_cb (GtkWidget *widget,
183 static gint message_window_close_cb (GtkWidget *widget,
187 static void add_mailbox_cb (MainWindow *mainwin,
190 static void add_mbox_cb (MainWindow *mainwin,
193 static void update_folderview_cb (MainWindow *mainwin,
196 static void new_folder_cb (MainWindow *mainwin,
199 static void rename_folder_cb (MainWindow *mainwin,
202 static void delete_folder_cb (MainWindow *mainwin,
205 static void import_mbox_cb (MainWindow *mainwin,
208 static void export_mbox_cb (MainWindow *mainwin,
211 static void empty_trash_cb (MainWindow *mainwin,
215 static void save_as_cb (MainWindow *mainwin,
218 static void print_cb (MainWindow *mainwin,
221 static void app_exit_cb (MainWindow *mainwin,
225 static void search_cb (MainWindow *mainwin,
229 static void toggle_folder_cb (MainWindow *mainwin,
232 static void toggle_message_cb (MainWindow *mainwin,
235 static void toggle_toolbar_cb (MainWindow *mainwin,
238 static void toggle_statusbar_cb (MainWindow *mainwin,
241 static void separate_widget_cb (MainWindow *mainwin,
245 static void addressbook_open_cb (MainWindow *mainwin,
248 static void log_window_show_cb (MainWindow *mainwin,
251 static void sel_download_cb (MainWindow *mainwin,
255 static void inc_mail_cb (MainWindow *mainwin,
258 static void inc_all_account_mail_cb (MainWindow *mainwin,
261 static void inc_cancel_cb (MainWindow *mainwin,
265 static void send_queue_cb (MainWindow *mainwin,
269 static void compose_mail_cb(MainWindow *mainwin, guint action,
271 static void compose_news_cb(MainWindow *mainwin, guint action,
273 static void reply_cb (MainWindow *mainwin,
277 static void open_msg_cb (MainWindow *mainwin,
281 static void view_source_cb (MainWindow *mainwin,
285 static void show_all_header_cb (MainWindow *mainwin,
289 static void reedit_cb (MainWindow *mainwin,
293 static void move_to_cb (MainWindow *mainwin,
296 static void copy_to_cb (MainWindow *mainwin,
299 static void delete_cb (MainWindow *mainwin,
303 static void mark_cb (MainWindow *mainwin,
306 static void unmark_cb (MainWindow *mainwin,
310 static void mark_as_unread_cb (MainWindow *mainwin,
313 static void mark_as_read_cb (MainWindow *mainwin,
316 static void mark_all_read_cb (MainWindow *mainwin,
319 static void add_address_cb (MainWindow *mainwin,
323 static void set_charset_cb (MainWindow *mainwin,
327 static void hide_read_messages (MainWindow *mainwin,
331 static void thread_cb (MainWindow *mainwin,
334 static void expand_threads_cb (MainWindow *mainwin,
337 static void collapse_threads_cb (MainWindow *mainwin,
341 static void set_display_item_cb (MainWindow *mainwin,
344 static void sort_summary_cb (MainWindow *mainwin,
347 static void sort_summary_type_cb (MainWindow *mainwin,
350 static void attract_by_subject_cb(MainWindow *mainwin,
354 static void delete_duplicated_cb (MainWindow *mainwin,
357 static void filter_cb (MainWindow *mainwin,
360 static void execute_summary_cb (MainWindow *mainwin,
363 static void update_summary_cb (MainWindow *mainwin,
367 static void prev_cb (MainWindow *mainwin,
370 static void next_cb (MainWindow *mainwin,
374 static void prev_unread_cb (MainWindow *mainwin,
377 static void next_unread_cb (MainWindow *mainwin,
380 static void prev_new_cb (MainWindow *mainwin,
383 static void next_new_cb (MainWindow *mainwin,
386 static void prev_marked_cb (MainWindow *mainwin,
389 static void next_marked_cb (MainWindow *mainwin,
392 static void prev_labeled_cb (MainWindow *mainwin,
395 static void next_labeled_cb (MainWindow *mainwin,
399 static void goto_folder_cb (MainWindow *mainwin,
403 static void copy_cb (MainWindow *mainwin,
406 static void allsel_cb (MainWindow *mainwin,
409 static void selthread_cb (MainWindow *mainwin,
412 static void create_filter_cb (MainWindow *mainwin,
416 static void prefs_common_open_cb (MainWindow *mainwin,
419 static void prefs_filter_open_cb (MainWindow *mainwin,
422 static void prefs_scoring_open_cb (MainWindow *mainwin,
425 static void prefs_filtering_open_cb (MainWindow *mainwin,
428 static void prefs_account_open_cb(MainWindow *mainwin,
431 static void prefs_template_open_cb (MainWindow *mainwin,
434 static void prefs_actions_open_cb (MainWindow *mainwin,
438 static void new_account_cb (MainWindow *mainwin,
442 static void account_menu_cb (GtkMenuItem *menuitem,
445 static void online_switch_clicked(GtkButton *btn,
448 static void manual_open_cb (MainWindow *mainwin,
451 static void faq_open_cb (MainWindow *mainwin,
455 static void scan_tree_func (Folder *folder,
459 static void activate_compose_button (MainWindow *mainwin,
461 ComposeButtonType type);
463 static void key_pressed (GtkWidget *widget,
467 static void set_toolbar_style(MainWindow *mainwin);
469 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
471 static void addr_harvest_cb ( MainWindow *mainwin,
475 static void addr_harvest_msg_cb ( MainWindow *mainwin,
479 #define SEPARATE_ACTION 500
481 static GtkItemFactoryEntry mainwin_entries[] =
483 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
484 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
485 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
486 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
487 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
488 {N_("/_File/_Folder/Create _new folder..."),
489 NULL, new_folder_cb, 0, NULL},
490 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
491 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
492 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
493 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
494 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
495 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
496 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
497 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
498 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
499 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
500 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
501 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
503 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
504 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
505 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
506 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
507 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
508 {N_("/_Edit/_Find in current message..."),
509 "<control>F", search_cb, 0, NULL},
510 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
511 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
512 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
513 {N_("/_View/Show or hi_de/_Folder tree"),
514 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
515 {N_("/_View/Show or hi_de/_Message view"),
516 "V", toggle_message_cb, 0, "<ToggleItem>"},
517 {N_("/_View/Show or hi_de/_Toolbar"),
518 NULL, NULL, 0, "<Branch>"},
519 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
520 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
521 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
522 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
523 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
524 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
525 {N_("/_View/Show or hi_de/_Toolbar/_None"),
526 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
527 {N_("/_View/Show or hi_de/Status _bar"),
528 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
529 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
530 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
531 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
532 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
533 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
534 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
535 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
536 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
537 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
538 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
539 {N_("/_View/_Sort/by _color label"),
540 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
541 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
542 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
543 {N_("/_View/_Sort/by a_ttachment"),
544 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
545 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
546 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
547 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
548 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
549 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
550 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
551 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
552 {N_("/_View/_Sort/_Attract by subject"),
553 NULL, attract_by_subject_cb, 0, NULL},
554 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
555 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
556 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
557 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
558 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
560 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
561 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
562 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
563 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
564 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
565 {N_("/_View/_Go to/P_rev unread message"),
566 "<shift>P", prev_unread_cb, 0, NULL},
567 {N_("/_View/_Go to/N_ext unread message"),
568 "<shift>N", next_unread_cb, 0, NULL},
569 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
570 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
571 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
572 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
573 {N_("/_View/_Go to/Prev _marked message"),
574 NULL, prev_marked_cb, 0, NULL},
575 {N_("/_View/_Go to/Next m_arked message"),
576 NULL, next_marked_cb, 0, NULL},
577 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
578 {N_("/_View/_Go to/Prev _labeled message"),
579 NULL, prev_labeled_cb, 0, NULL},
580 {N_("/_View/_Go to/Next la_beled message"),
581 NULL, next_labeled_cb, 0, NULL},
582 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
583 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
584 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
586 #define CODESET_SEPARATOR \
587 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
588 #define CODESET_ACTION(action) \
589 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
591 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
592 {N_("/_View/_Code set/_Auto detect"),
593 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
594 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
595 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
596 CODESET_ACTION(C_US_ASCII)},
599 {N_("/_View/_Code set/Unicode (_UTF-8)"),
600 CODESET_ACTION(C_UTF_8)},
603 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
604 CODESET_ACTION(C_ISO_8859_1)},
605 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
606 CODESET_ACTION(C_ISO_8859_15)},
609 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
610 CODESET_ACTION(C_ISO_8859_2)},
612 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
613 CODESET_ACTION(C_ISO_8859_13)},
614 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
615 CODESET_ACTION(C_ISO_8859_4)},
617 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
618 CODESET_ACTION(C_ISO_8859_7)},
620 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
621 CODESET_ACTION(C_ISO_8859_9)},
623 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
624 CODESET_ACTION(C_ISO_8859_5)},
625 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
626 CODESET_ACTION(C_KOI8_R)},
627 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
628 CODESET_ACTION(C_WINDOWS_1251)},
631 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
632 CODESET_ACTION(C_ISO_2022_JP)},
634 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
635 CODESET_ACTION(C_ISO_2022_JP_2)},
637 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
638 CODESET_ACTION(C_EUC_JP)},
639 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
640 CODESET_ACTION(C_SHIFT_JIS)},
643 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
644 CODESET_ACTION(C_GB2312)},
645 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
646 CODESET_ACTION(C_BIG5)},
647 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
648 CODESET_ACTION(C_EUC_TW)},
649 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
650 CODESET_ACTION(C_ISO_2022_CN)},
652 {N_("/_View/_Code set/Korean (EUC-_KR)"),
653 CODESET_ACTION(C_EUC_KR)},
654 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
655 CODESET_ACTION(C_ISO_2022_KR)},
657 {N_("/_View/_Code set/Thai (TIS-620)"),
658 CODESET_ACTION(C_TIS_620)},
659 {N_("/_View/_Code set/Thai (Windows-874)"),
660 CODESET_ACTION(C_WINDOWS_874)},
663 #undef CODESET_SEPARATOR
664 #undef CODESET_ACTION
666 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
667 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
668 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
669 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
670 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
671 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
673 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
674 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
675 {N_("/_Message/Get from _all accounts"),
676 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
677 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
678 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
679 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
680 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
681 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
682 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
683 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
684 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
685 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
686 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
687 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
688 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
689 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
690 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
691 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
692 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
693 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
694 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
695 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
696 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
697 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
698 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
699 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
700 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
701 {N_("/_Message/_Mark/Mark as rea_d"),
702 NULL, mark_as_read_cb, 0, NULL},
703 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
705 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
706 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
707 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
708 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
709 {N_("/_Tools/Add sender to address boo_k"),
710 NULL, add_address_cb, 0, NULL},
711 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
712 {N_("/_Tools/_Harvest addresses/from _Folder..."),
713 NULL, addr_harvest_cb, 0, NULL},
714 {N_("/_Tools/_Harvest addresses/from _Messages..."),
715 NULL, addr_harvest_msg_cb, 0, NULL},
716 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
717 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
718 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
719 {N_("/_Tools/_Create filter rule/_Automatically"),
720 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
721 {N_("/_Tools/_Create filter rule/by _From"),
722 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
723 {N_("/_Tools/_Create filter rule/by _To"),
724 NULL, create_filter_cb, FILTER_BY_TO, NULL},
725 {N_("/_Tools/_Create filter rule/by _Subject"),
726 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
727 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
728 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
729 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
730 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
731 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
732 {N_("/_Tools/Delete du_plicated messages"),
733 NULL, delete_duplicated_cb, 0, NULL},
734 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
735 {N_("/_Tools/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
737 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
738 {N_("/_Configuration/_Common preferences..."),
739 NULL, prefs_common_open_cb, 0, NULL},
740 {N_("/_Configuration/_Filter setting..."),
741 NULL, prefs_filter_open_cb, 0, NULL},
742 {N_("/_Configuration/_Scoring..."),
743 NULL, prefs_scoring_open_cb, 0, NULL},
744 {N_("/_Configuration/_Filtering..."),
745 NULL, prefs_filtering_open_cb, 0, NULL},
746 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
747 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
748 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
749 {N_("/_Configuration/_Preferences for current account..."),
750 NULL, prefs_account_open_cb, 0, NULL},
751 {N_("/_Configuration/Create _new account..."),
752 NULL, new_account_cb, 0, NULL},
753 {N_("/_Configuration/_Edit accounts..."),
754 NULL, account_edit_open, 0, NULL},
755 {N_("/_Configuration/C_hange current account"),
756 NULL, NULL, 0, "<Branch>"},
758 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
759 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
760 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
761 {N_("/_Help/_Manual/_German"), NULL, manual_open_cb, MANUAL_LANG_DE, NULL},
762 {N_("/_Help/_Manual/_Spanish"), NULL, manual_open_cb, MANUAL_LANG_ES, NULL},
763 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
764 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
765 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
766 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
767 {N_("/_Help/_FAQ/_German"), NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
768 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
769 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
770 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
771 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
772 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
774 static GtkItemFactoryEntry reply_popup_entries[] =
776 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
777 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
779 static GtkItemFactoryEntry replyall_popup_entries[] =
781 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
782 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
784 static GtkItemFactoryEntry replysender_popup_entries[] =
786 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
787 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
789 static GtkItemFactoryEntry fwd_popup_entries[] =
791 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
792 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
795 MainWindow *main_window_create(SeparateType type)
801 GtkWidget *handlebox;
802 GtkWidget *vbox_body;
803 GtkWidget *hbox_stat;
804 GtkWidget *statusbar;
805 GtkWidget *progressbar;
806 GtkWidget *statuslabel;
807 GtkWidget *ac_button;
809 GtkWidget *online_status;
810 GtkWidget *offline_status;
811 GtkWidget *online_switch;
812 GtkWidget *offline_switch;
814 FolderView *folderview;
815 SummaryView *summaryview;
816 MessageView *messageview;
817 GdkColormap *colormap;
820 guint n_menu_entries;
821 GtkItemFactory *ifactory;
824 GtkWidget *reply_popup;
825 GtkWidget *replyall_popup;
826 GtkWidget *replysender_popup;
827 GtkWidget *fwd_popup;
830 static GdkGeometry geometry;
832 debug_print(_("Creating main window...\n"));
833 mainwin = g_new0(MainWindow, 1);
836 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
837 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
838 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
839 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
841 if (!geometry.min_height) {
842 geometry.min_width = 320;
843 geometry.min_height = 200;
845 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
848 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
849 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
850 MANAGE_WINDOW_SIGNALS_CONNECT(window);
851 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
852 GTK_SIGNAL_FUNC(key_pressed), mainwin);
854 gtk_widget_realize(window);
855 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
858 gtkut_widget_set_app_icon(window);
860 vbox = gtk_vbox_new(FALSE, 0);
861 gtk_widget_show(vbox);
862 gtk_container_add(GTK_CONTAINER(window), vbox);
865 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
866 menubar = menubar_create(window, mainwin_entries,
867 n_menu_entries, "<Main>", mainwin);
868 gtk_widget_show(menubar);
869 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
870 ifactory = gtk_item_factory_from_widget(menubar);
872 handlebox = gtk_handle_box_new();
873 gtk_widget_show(handlebox);
874 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
876 /* create the popup menus for the reply buttons specials */
877 n_menu_entries = sizeof(reply_popup_entries) /
878 sizeof(reply_popup_entries[0]);
879 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
880 "<ReplyPopup>", mainwin);
881 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
882 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
883 n_menu_entries = sizeof(replyall_popup_entries) /
884 sizeof(replyall_popup_entries[0]);
885 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
886 "<ReplyAllPopup>", mainwin);
887 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
888 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
889 n_menu_entries = sizeof(replysender_popup_entries) /
890 sizeof(replysender_popup_entries[0]);
891 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
892 "<ReplySenderPopup>", mainwin);
893 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
894 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
895 /* create the popup menu for the forward button */
896 n_menu_entries = sizeof(fwd_popup_entries) /
897 sizeof(fwd_popup_entries[0]);
898 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
899 "<ForwardPopup>", mainwin);
900 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
901 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
903 main_window_toolbar_create(mainwin, handlebox);
905 /* vbox that contains body */
906 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
907 gtk_widget_show(vbox_body);
908 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
909 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
911 hbox_stat = gtk_hbox_new(FALSE, 2);
912 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
914 statusbar = statusbar_create();
915 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
917 progressbar = gtk_progress_bar_new();
918 gtk_widget_set_usize(progressbar, 120, 1);
919 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
921 online_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
922 offline_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
923 online_switch = gtk_button_new ();
924 offline_switch = gtk_button_new ();
925 gtk_container_add (GTK_CONTAINER(online_switch), online_status);
926 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
927 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
928 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
929 gtk_container_add (GTK_CONTAINER(offline_switch), offline_status);
930 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
931 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
932 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
934 statuslabel = gtk_label_new("");
935 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
937 ac_button = gtk_button_new();
938 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
939 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
940 gtk_widget_set_usize(ac_button, -1, 1);
941 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
942 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
943 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
945 ac_label = gtk_label_new("");
946 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
948 gtk_widget_show_all(hbox_stat);
950 gtk_widget_hide(offline_switch);
952 mainwin->folderview = folderview = folderview_create();
953 mainwin->summaryview = summaryview = summary_create();
954 mainwin->messageview = messageview = messageview_create();
955 mainwin->logwin = log_window_create();
957 folderview->mainwin = mainwin;
958 folderview->summaryview = summaryview;
960 summaryview->mainwin = mainwin;
961 summaryview->folderview = folderview;
962 summaryview->messageview = messageview;
963 summaryview->window = window;
965 messageview->mainwin = mainwin;
967 mainwin->window = window;
968 mainwin->vbox = vbox;
969 mainwin->menubar = menubar;
970 mainwin->menu_factory = ifactory;
971 mainwin->handlebox = handlebox;
972 mainwin->vbox_body = vbox_body;
973 mainwin->hbox_stat = hbox_stat;
974 mainwin->statusbar = statusbar;
975 mainwin->progressbar = progressbar;
976 mainwin->statuslabel = statuslabel;
977 mainwin->ac_button = ac_button;
978 mainwin->ac_label = ac_label;
980 mainwin->reply_popup = reply_popup;
981 mainwin->replyall_popup = replyall_popup;
982 mainwin->replysender_popup = replysender_popup;
983 mainwin->fwd_popup = fwd_popup;
984 mainwin->online_switch = online_switch;
985 mainwin->offline_switch = offline_switch;
987 /* set context IDs for status bar */
988 mainwin->mainwin_cid = gtk_statusbar_get_context_id
989 (GTK_STATUSBAR(statusbar), "Main Window");
990 mainwin->folderview_cid = gtk_statusbar_get_context_id
991 (GTK_STATUSBAR(statusbar), "Folder View");
992 mainwin->summaryview_cid = gtk_statusbar_get_context_id
993 (GTK_STATUSBAR(statusbar), "Summary View");
995 /* allocate colors for summary view and folder view */
996 summaryview->color_marked.red = summaryview->color_marked.green = 0;
997 summaryview->color_marked.blue = (guint16)65535;
999 summaryview->color_dim.red = summaryview->color_dim.green =
1000 summaryview->color_dim.blue = COLOR_DIM;
1002 folderview->color_new.red = (guint16)55000;
1003 folderview->color_new.green = folderview->color_new.blue = 15000;
1005 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1006 &folderview->color_op);
1008 summaryview->color_important.red = 0;
1009 summaryview->color_important.green = 0;
1010 summaryview->color_important.blue = (guint16)65535;
1012 color[0] = summaryview->color_marked;
1013 color[1] = summaryview->color_dim;
1014 color[2] = folderview->color_new;
1015 color[3] = folderview->color_op;
1017 colormap = gdk_window_get_colormap(window->window);
1018 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1019 for (i = 0; i < 4; i++) {
1020 if (success[i] == FALSE)
1021 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1024 debug_print(_("done.\n"));
1026 messageview->visible = TRUE;
1028 main_window_set_widgets(mainwin, type);
1030 /* set menu items */
1031 menuitem = gtk_item_factory_get_item
1032 (ifactory, "/View/Code set/Auto detect");
1033 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1035 switch (prefs_common.toolbar_style) {
1037 menuitem = gtk_item_factory_get_item
1038 (ifactory, "/View/Show or hide/Toolbar/None");
1041 menuitem = gtk_item_factory_get_item
1042 (ifactory, "/View/Show or hide/Toolbar/Icon");
1045 menuitem = gtk_item_factory_get_item
1046 (ifactory, "/View/Show or hide/Toolbar/Text");
1049 menuitem = gtk_item_factory_get_item
1050 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1052 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1054 gtk_widget_hide(mainwin->hbox_stat);
1055 menuitem = gtk_item_factory_get_item
1056 (ifactory, "/View/Show or hide/Status bar");
1057 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1058 prefs_common.show_statusbar);
1060 /* set account selection menu */
1061 ac_menu = gtk_item_factory_get_widget
1062 (ifactory, "/Configuration/Change current account");
1063 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1064 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1065 mainwin->ac_menu = ac_menu;
1067 main_window_set_toolbar_sensitive(mainwin);
1069 /* Create actions menu */
1070 update_mainwin_actions_menu(ifactory, mainwin);
1072 /* show main window */
1073 gtk_widget_set_uposition(mainwin->window,
1074 prefs_common.mainwin_x,
1075 prefs_common.mainwin_y);
1076 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1077 prefs_common.mainwin_height);
1078 gtk_widget_show(mainwin->window);
1080 /* initialize views */
1081 folderview_init(folderview);
1082 summary_init(summaryview);
1083 messageview_init(messageview);
1084 log_window_init(mainwin->logwin);
1086 mainwin->lock_count = 0;
1087 mainwin->menu_lock_count = 0;
1088 mainwin->cursor_count = 0;
1091 watch_cursor = gdk_cursor_new(GDK_WATCH);
1093 mainwin_list = g_list_append(mainwin_list, mainwin);
1095 /* init work_offline */
1096 if (prefs_common.work_offline)
1097 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1102 void main_window_cursor_wait(MainWindow *mainwin)
1105 if (mainwin->cursor_count == 0)
1106 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1108 mainwin->cursor_count++;
1113 void main_window_cursor_normal(MainWindow *mainwin)
1115 if (mainwin->cursor_count)
1116 mainwin->cursor_count--;
1118 if (mainwin->cursor_count == 0)
1119 gdk_window_set_cursor(mainwin->window->window, NULL);
1124 /* lock / unlock the user-interface */
1125 void main_window_lock(MainWindow *mainwin)
1127 if (mainwin->lock_count == 0)
1128 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1130 mainwin->lock_count++;
1132 main_window_set_menu_sensitive(mainwin);
1133 main_window_set_toolbar_sensitive(mainwin);
1136 void main_window_unlock(MainWindow *mainwin)
1138 if (mainwin->lock_count)
1139 mainwin->lock_count--;
1141 main_window_set_menu_sensitive(mainwin);
1142 main_window_set_toolbar_sensitive(mainwin);
1144 if (mainwin->lock_count == 0)
1145 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1148 static void main_window_menu_callback_block(MainWindow *mainwin)
1150 mainwin->menu_lock_count++;
1153 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1155 if (mainwin->menu_lock_count)
1156 mainwin->menu_lock_count--;
1159 void main_window_reflect_prefs_all(void)
1161 main_window_reflect_prefs_all_real(FALSE);
1164 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1167 MainWindow *mainwin;
1169 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1170 mainwin = (MainWindow *)cur->data;
1172 main_window_show_cur_account(mainwin);
1173 main_window_set_menu_sensitive(mainwin);
1174 main_window_set_toolbar_sensitive(mainwin);
1177 if (pixmap_theme_changed) {
1178 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1179 mainwin->toolbar = NULL;
1180 main_window_toolbar_create(mainwin, mainwin->handlebox);
1181 set_toolbar_style(mainwin);
1182 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1183 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1184 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1187 if (prefs_common.immediate_exec)
1188 gtk_widget_hide(mainwin->exec_btn);
1190 gtk_widget_show(mainwin->exec_btn);
1192 summary_redisplay_msg(mainwin->summaryview);
1193 headerview_set_visibility(mainwin->messageview->headerview,
1194 prefs_common.display_header_pane);
1198 void main_window_set_summary_column(void)
1201 MainWindow *mainwin;
1203 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1204 mainwin = (MainWindow *)cur->data;
1205 summary_set_column_order(mainwin->summaryview);
1209 void main_window_set_account_menu(GList *account_list)
1211 GList *cur, *cur_ac, *cur_item;
1212 GtkWidget *menuitem;
1213 MainWindow *mainwin;
1214 PrefsAccount *ac_prefs;
1216 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1217 mainwin = (MainWindow *)cur->data;
1219 /* destroy all previous menu item */
1220 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1221 while (cur_item != NULL) {
1222 GList *next = cur_item->next;
1223 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1227 for (cur_ac = account_list; cur_ac != NULL;
1228 cur_ac = cur_ac->next) {
1229 ac_prefs = (PrefsAccount *)cur_ac->data;
1231 menuitem = gtk_menu_item_new_with_label
1232 (ac_prefs->account_name
1233 ? ac_prefs->account_name : _("Untitled"));
1234 gtk_widget_show(menuitem);
1235 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1236 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1237 GTK_SIGNAL_FUNC(account_menu_cb),
1243 static void main_window_show_cur_account(MainWindow *mainwin)
1248 ac_name = g_strdup(cur_account
1249 ? (cur_account->account_name
1250 ? cur_account->account_name : _("Untitled"))
1254 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1256 buf = g_strdup(PROG_VERSION);
1257 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1260 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1261 gtk_widget_queue_resize(mainwin->ac_button);
1266 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1268 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1269 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1270 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1272 debug_print(_("Changing window separation type from %d to %d\n"),
1273 mainwin->type, type);
1275 if (mainwin->type == type) return;
1277 /* remove widgets from those containers */
1278 gtk_widget_ref(folder_wid);
1279 gtk_widget_ref(summary_wid);
1280 gtk_widget_ref(message_wid);
1281 gtkut_container_remove
1282 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1283 gtkut_container_remove
1284 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1285 gtkut_container_remove
1286 (GTK_CONTAINER(message_wid->parent), message_wid);
1288 /* clean containers */
1289 switch (mainwin->type) {
1291 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1293 case SEPARATE_FOLDER:
1294 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1295 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1297 case SEPARATE_MESSAGE:
1298 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1299 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1302 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1303 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1307 gtk_widget_hide(mainwin->window);
1308 main_window_set_widgets(mainwin, type);
1309 gtk_widget_show(mainwin->window);
1311 gtk_widget_unref(folder_wid);
1312 gtk_widget_unref(summary_wid);
1313 gtk_widget_unref(message_wid);
1316 void main_window_toggle_message_view(MainWindow *mainwin)
1318 SummaryView *summaryview = mainwin->summaryview;
1319 union CompositeWin *cwin = &mainwin->win;
1320 GtkWidget *vpaned = NULL;
1321 GtkWidget *container = NULL;
1322 GtkWidget *msgwin = NULL;
1324 switch (mainwin->type) {
1326 vpaned = cwin->sep_none.vpaned;
1327 container = cwin->sep_none.hpaned;
1329 case SEPARATE_FOLDER:
1330 vpaned = cwin->sep_folder.vpaned;
1331 container = mainwin->vbox_body;
1333 case SEPARATE_MESSAGE:
1334 msgwin = mainwin->win.sep_message.messagewin;
1337 msgwin = mainwin->win.sep_both.messagewin;
1342 if (GTK_WIDGET_VISIBLE(msgwin)) {
1343 gtk_widget_hide(msgwin);
1344 mainwin->messageview->visible = FALSE;
1345 summaryview->displayed = NULL;
1347 gtk_widget_show(msgwin);
1348 mainwin->messageview->visible = TRUE;
1350 } else if (vpaned->parent != NULL) {
1351 mainwin->messageview->visible = FALSE;
1352 summaryview->displayed = NULL;
1353 gtk_widget_ref(vpaned);
1354 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1355 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1356 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1357 GTK_ARROW_UP, GTK_SHADOW_OUT);
1359 mainwin->messageview->visible = TRUE;
1360 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1361 gtk_container_add(GTK_CONTAINER(container), vpaned);
1362 gtk_widget_unref(vpaned);
1363 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1364 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1367 main_window_set_menu_sensitive(mainwin);
1369 gtk_widget_grab_focus(summaryview->ctree);
1372 void main_window_get_size(MainWindow *mainwin)
1374 GtkAllocation *allocation;
1376 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1378 prefs_common.summaryview_width = allocation->width;
1380 if ((mainwin->type == SEPARATE_NONE ||
1381 mainwin->type == SEPARATE_FOLDER) &&
1382 messageview_is_visible(mainwin->messageview))
1383 prefs_common.summaryview_height = allocation->height;
1385 prefs_common.mainview_width = allocation->width;
1387 allocation = &mainwin->window->allocation;
1389 prefs_common.mainview_height = allocation->height;
1390 prefs_common.mainwin_width = allocation->width;
1391 prefs_common.mainwin_height = allocation->height;
1393 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1395 prefs_common.folderview_width = allocation->width;
1396 prefs_common.folderview_height = allocation->height;
1399 void main_window_get_position(MainWindow *mainwin)
1403 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1405 prefs_common.mainview_x = x;
1406 prefs_common.mainview_y = y;
1407 prefs_common.mainwin_x = x;
1408 prefs_common.mainwin_y = y;
1410 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1413 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1419 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1420 folder = FOLDER(list->data);
1421 if (folder && folder->trash && folder->trash->total > 0)
1425 if (!has_trash) return;
1428 if (alertpanel(_("Empty trash"),
1429 _("Empty all messages in trash?"),
1430 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1432 manage_window_focus_in(mainwin->window, NULL, NULL);
1435 procmsg_empty_trash();
1437 for (list = folder_get_list(); list != NULL; list = list->next) {
1438 folder = list->data;
1439 if (folder && folder->trash && folder->trash->total != 0) {
1440 folderview_update_item(folder->trash, TRUE);
1444 if (mainwin->summaryview->folder_item &&
1445 mainwin->summaryview->folder_item->stype == F_TRASH)
1446 gtk_widget_grab_focus(mainwin->folderview->ctree);
1449 void main_window_add_mailbox(MainWindow *mainwin)
1454 path = input_dialog(_("Add mailbox"),
1455 _("Input the location of mailbox.\n"
1456 "If the existing mailbox is specified, it will be\n"
1457 "scanned automatically."),
1460 if (folder_find_from_path(path)) {
1461 alertpanel_error(_("The mailbox `%s' already exists."), path);
1465 if (!strcmp(path, "Mail"))
1466 folder = folder_new(F_MH, _("Mailbox"), path);
1468 folder = folder_new(F_MH, g_basename(path), path);
1471 if (folder->create_tree(folder) < 0) {
1472 alertpanel_error(_("Creation of the mailbox failed.\n"
1473 "Maybe some files already exist, or you don't have the permission to write there."));
1474 folder_destroy(folder);
1479 folder_set_ui_func(folder, scan_tree_func, mainwin);
1480 folder_scan_tree(folder);
1481 folder_set_ui_func(folder, NULL, NULL);
1483 folderview_set(mainwin->folderview);
1486 void main_window_add_mbox(MainWindow *mainwin)
1492 path = input_dialog(_("Add mbox mailbox"),
1493 _("Input the location of mailbox."),
1498 if (folder_find_from_path(path)) {
1499 alertpanel_error(_("The mailbox `%s' already exists."), path);
1505 if (!strcmp(path, "Mail"))
1506 folder = folder_new(F_MBOX, _("Mailbox"), path);
1510 folder = folder_new(F_MBOX, g_basename(path), path);
1513 if (folder->create_tree(folder) < 0) {
1514 alertpanel_error(_("Creation of the mailbox failed."));
1515 folder_destroy(folder);
1521 item = folder_item_new(folder->name, NULL);
1522 item->folder = folder;
1523 folder->node = g_node_new(item);
1525 folder->create_folder(folder, item, "inbox");
1526 folder->create_folder(folder, item, "outbox");
1527 folder->create_folder(folder, item, "queue");
1528 folder->create_folder(folder, item, "draft");
1529 folder->create_folder(folder, item, "trash");
1531 folderview_set(mainwin->folderview);
1536 M_UNLOCKED = 1 << 0,
1537 M_MSG_EXIST = 1 << 1,
1538 M_TARGET_EXIST = 1 << 2,
1539 M_SINGLE_TARGET_EXIST = 1 << 3,
1541 M_ALLOW_REEDIT = 1 << 5,
1542 M_HAVE_ACCOUNT = 1 << 6,
1543 M_THREADED = 1 << 7,
1544 M_UNTHREADED = 1 << 8,
1545 M_ALLOW_DELETE = 1 << 9,
1546 M_INC_ACTIVE = 1 << 10,
1548 M_HAVE_NEWS_ACCOUNT = 1 << 12,
1549 M_HIDE_READ_MSG = 1 << 13
1552 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1554 SensitiveCond state = 0;
1555 SummarySelection selection;
1556 FolderItem *item = mainwin->summaryview->folder_item;
1557 GList *account_list = account_get_list();
1559 selection = summary_get_selection_type(mainwin->summaryview);
1561 if (mainwin->lock_count == 0)
1562 state |= M_UNLOCKED;
1563 if (selection != SUMMARY_NONE)
1564 state |= M_MSG_EXIST;
1565 if (item && item->path && item->parent && !item->no_select) {
1568 state |= M_THREADED;
1570 state |= M_UNTHREADED;
1571 /* if (item->folder->type != F_NEWS) */
1572 state |= M_ALLOW_DELETE;
1574 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1575 || selection != SUMMARY_NONE)
1576 state |= M_HIDE_READ_MSG;
1578 if (selection == SUMMARY_SELECTED_SINGLE ||
1579 selection == SUMMARY_SELECTED_MULTIPLE)
1580 state |= M_TARGET_EXIST;
1581 if (selection == SUMMARY_SELECTED_SINGLE)
1582 state |= M_SINGLE_TARGET_EXIST;
1583 if (mainwin->summaryview->folder_item &&
1584 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1586 if (selection == SUMMARY_SELECTED_SINGLE &&
1588 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1589 item->stype == F_QUEUE)))
1590 state |= M_ALLOW_REEDIT;
1592 state |= M_HAVE_ACCOUNT;
1594 for ( ; account_list != NULL; account_list = account_list->next) {
1595 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1596 state |= M_HAVE_NEWS_ACCOUNT;
1601 if (inc_is_active())
1602 state |= M_INC_ACTIVE;
1607 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1609 SensitiveCond state;
1618 #define SET_WIDGET_COND(w, c) \
1620 entry[i].widget = w; \
1621 entry[i].cond = c; \
1625 SET_WIDGET_COND(mainwin->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1626 SET_WIDGET_COND(mainwin->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1627 SET_WIDGET_COND(mainwin->compose_news_btn, M_HAVE_ACCOUNT);
1628 SET_WIDGET_COND(mainwin->reply_btn,
1629 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1630 SET_WIDGET_COND(mainwin->replyall_btn,
1631 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1632 SET_WIDGET_COND(mainwin->replysender_btn,
1633 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1634 SET_WIDGET_COND(mainwin->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
1636 SET_WIDGET_COND(mainwin->prefs_btn, M_UNLOCKED);
1637 SET_WIDGET_COND(mainwin->account_btn, M_UNLOCKED);
1639 SET_WIDGET_COND(mainwin->next_btn, M_MSG_EXIST);
1640 SET_WIDGET_COND(mainwin->delete_btn,
1641 M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
1642 SET_WIDGET_COND(mainwin->exec_btn, M_MSG_EXIST|M_EXEC|M_UNLOCKED);
1643 SET_WIDGET_COND(NULL, 0);
1645 #undef SET_WIDGET_COND
1647 state = main_window_get_current_state(mainwin);
1649 for (i = 0; entry[i].widget != NULL; i++) {
1650 sensitive = ((entry[i].cond & state) == entry[i].cond);
1651 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1654 activate_compose_button(mainwin,
1655 prefs_common.toolbar_style,
1656 mainwin->compose_btn_type);
1659 void main_window_set_menu_sensitive(MainWindow *mainwin)
1661 GtkItemFactory *ifactory = mainwin->menu_factory;
1662 SensitiveCond state;
1664 GtkWidget *menuitem;
1669 static const struct {
1673 {"/File/Add mailbox..." , M_UNLOCKED},
1674 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1675 {"/File/Rescan folder tree" , M_UNLOCKED},
1676 {"/File/Folder" , M_UNLOCKED},
1677 {"/File/Import mbox file..." , M_UNLOCKED},
1678 {"/File/Export to mbox file...", M_UNLOCKED},
1679 {"/File/Empty trash" , M_UNLOCKED},
1680 {"/File/Work offline" , M_UNLOCKED},
1681 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1682 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1683 /* {"/File/Close", M_UNLOCKED}, */
1684 {"/File/Exit" , M_UNLOCKED},
1686 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1687 {"/View/Sort" , M_EXEC},
1688 {"/View/Thread view" , M_EXEC},
1689 {"/View/Expand all threads" , M_MSG_EXIST},
1690 {"/View/Collapse all threads" , M_MSG_EXIST},
1691 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1692 {"/View/Go to/Prev message" , M_MSG_EXIST},
1693 {"/View/Go to/Next message" , M_MSG_EXIST},
1694 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1695 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1696 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1697 {"/View/Go to/Next new message" , M_MSG_EXIST},
1698 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1699 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1700 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1701 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1702 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1703 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1704 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1706 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1707 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1708 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1709 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1710 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1711 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1712 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1713 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1714 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1715 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1716 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1717 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1718 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1719 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1720 {"/Message/Mark" , M_TARGET_EXIST},
1722 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1723 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1724 {"/Tools/Harvest addresses" , M_UNLOCKED},
1725 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1726 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1727 {"/Tools/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1728 {"/Tools/Actions" , M_MSG_EXIST},
1729 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1731 {"/Configuration", M_UNLOCKED},
1736 state = main_window_get_current_state(mainwin);
1738 for (i = 0; entry[i].entry != NULL; i++) {
1739 sensitive = ((entry[i].cond & state) == entry[i].cond);
1740 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1743 main_window_menu_callback_block(mainwin);
1745 #define SET_CHECK_MENU_ACTIVE(path, active) \
1747 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1748 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1751 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1752 messageview_is_visible(mainwin->messageview));
1754 item = mainwin->summaryview->folder_item;
1755 menu_path = "/View/Sort/Don't sort";
1757 switch (item->sort_key) {
1758 case SORT_BY_NUMBER:
1759 menu_path = "/View/Sort/by number"; break;
1761 menu_path = "/View/Sort/by size"; break;
1763 menu_path = "/View/Sort/by date"; break;
1765 menu_path = "/View/Sort/by from"; break;
1766 case SORT_BY_SUBJECT:
1767 menu_path = "/View/Sort/by subject"; break;
1769 menu_path = "/View/Sort/by color label"; break;
1771 menu_path = "/View/Sort/by mark"; break;
1772 case SORT_BY_UNREAD:
1773 menu_path = "/View/Sort/by unread"; break;
1775 menu_path = "/View/Sort/by attachment"; break;
1777 menu_path = "/View/Sort/by score"; break;
1778 case SORT_BY_LOCKED:
1779 menu_path = "/View/Sort/by locked"; break;
1782 menu_path = "/View/Sort/Don't sort"; break;
1785 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1787 if (!item || item->sort_type == SORT_ASCENDING) {
1788 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1790 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1793 if (item && item->sort_key != SORT_BY_NONE) {
1794 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1795 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1797 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1798 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1801 SET_CHECK_MENU_ACTIVE("/View/Show all header",
1802 mainwin->messageview->textview->show_all_headers);
1803 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1805 #undef SET_CHECK_MENU_ACTIVE
1807 main_window_menu_callback_unblock(mainwin);
1810 void main_window_popup(MainWindow *mainwin)
1816 gdk_window_get_origin(mainwin->window->window, &x, &y);
1817 sx = gdk_screen_width();
1818 sy = gdk_screen_height();
1819 x %= sx; if (x < 0) x = 0;
1820 y %= sy; if (y < 0) y = 0;
1821 gdk_window_move(mainwin->window->window, x, y);
1822 gdk_window_raise(mainwin->window->window);
1823 gdk_window_show(mainwin->window->window);
1825 debug_print("window position: x = %d, y = %d\n", x, y);
1827 switch (mainwin->type) {
1828 case SEPARATE_FOLDER:
1829 widget = mainwin->win.sep_folder.folderwin;
1830 gdk_window_get_origin(widget->window, &x, &y);
1831 x %= sx; if (x < 0) x = 0;
1832 y %= sy; if (y < 0) y = 0;
1833 gdk_window_move(widget->window, x, y);
1834 gdk_window_raise(widget->window);
1836 case SEPARATE_MESSAGE:
1837 widget = mainwin->win.sep_message.messagewin;
1838 gdk_window_get_origin(widget->window, &x, &y);
1839 x %= sx; if (x < 0) x = 0;
1840 y %= sy; if (y < 0) y = 0;
1841 gdk_window_move(widget->window, x, y);
1842 gdk_window_raise(widget->window);
1845 widget = mainwin->win.sep_both.folderwin;
1846 gdk_window_get_origin(widget->window, &x, &y);
1847 x %= sx; if (x < 0) x = 0;
1848 y %= sy; if (y < 0) y = 0;
1849 gdk_window_move(widget->window, x, y);
1850 gdk_window_raise(widget->window);
1851 widget = mainwin->win.sep_both.messagewin;
1852 gdk_window_get_origin(widget->window, &x, &y);
1853 x %= sx; if (x < 0) x = 0;
1854 y %= sy; if (y < 0) y = 0;
1855 gdk_window_move(widget->window, x, y);
1856 gdk_window_raise(widget->window);
1863 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1865 GtkWidget *folderwin = NULL;
1866 GtkWidget *messagewin = NULL;
1869 GtkWidget *vbox_body = mainwin->vbox_body;
1870 GtkItemFactory *ifactory = mainwin->menu_factory;
1871 GtkWidget *menuitem;
1873 debug_print(_("Setting widgets..."));
1875 /* create separated window(s) if needed */
1876 if (type & SEPARATE_FOLDER) {
1877 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1878 gtk_window_set_title(GTK_WINDOW(folderwin),
1879 _("Sylpheed - Folder View"));
1880 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1881 "folder_view", "Sylpheed");
1882 gtk_window_set_policy(GTK_WINDOW(folderwin),
1884 gtk_widget_set_usize(folderwin, -1,
1885 prefs_common.mainview_height);
1886 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1888 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1889 GTK_SIGNAL_FUNC(folder_window_close_cb),
1892 if (type & SEPARATE_MESSAGE) {
1893 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1894 gtk_window_set_title(GTK_WINDOW(messagewin),
1895 _("Sylpheed - Message View"));
1896 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1897 "message_view", "Sylpheed");
1898 gtk_window_set_policy(GTK_WINDOW(messagewin),
1900 gtk_widget_set_usize
1901 (messagewin, prefs_common.mainview_width,
1902 prefs_common.mainview_height
1903 - prefs_common.summaryview_height
1904 + DEFAULT_HEADERVIEW_HEIGHT);
1905 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1907 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1908 GTK_SIGNAL_FUNC(message_window_close_cb),
1914 hpaned = gtk_hpaned_new();
1915 gtk_widget_show(hpaned);
1916 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1917 gtk_paned_add1(GTK_PANED(hpaned),
1918 GTK_WIDGET_PTR(mainwin->folderview));
1920 vpaned = gtk_vpaned_new();
1921 if (messageview_is_visible(mainwin->messageview)) {
1922 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1923 gtk_paned_add1(GTK_PANED(vpaned),
1924 GTK_WIDGET_PTR(mainwin->summaryview));
1926 gtk_paned_add2(GTK_PANED(hpaned),
1927 GTK_WIDGET_PTR(mainwin->summaryview));
1928 gtk_widget_ref(vpaned);
1930 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1931 prefs_common.summaryview_width,
1932 prefs_common.summaryview_height);
1933 gtk_paned_add2(GTK_PANED(vpaned),
1934 GTK_WIDGET_PTR(mainwin->messageview));
1935 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1936 prefs_common.mainview_width, -1);
1937 gtk_widget_set_usize(mainwin->window,
1938 prefs_common.folderview_width +
1939 prefs_common.mainview_width,
1940 prefs_common.mainwin_height);
1941 gtk_widget_show_all(vpaned);
1943 mainwin->win.sep_none.hpaned = hpaned;
1944 mainwin->win.sep_none.vpaned = vpaned;
1946 case SEPARATE_FOLDER:
1947 vpaned = gtk_vpaned_new();
1948 if (messageview_is_visible(mainwin->messageview)) {
1949 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1951 gtk_paned_add1(GTK_PANED(vpaned),
1952 GTK_WIDGET_PTR(mainwin->summaryview));
1954 gtk_box_pack_start(GTK_BOX(vbox_body),
1955 GTK_WIDGET_PTR(mainwin->summaryview),
1957 gtk_widget_ref(vpaned);
1959 gtk_paned_add2(GTK_PANED(vpaned),
1960 GTK_WIDGET_PTR(mainwin->messageview));
1961 gtk_widget_show_all(vpaned);
1962 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1963 prefs_common.summaryview_width,
1964 prefs_common.summaryview_height);
1965 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1966 prefs_common.mainview_width, -1);
1967 gtk_widget_set_usize(mainwin->window,
1968 prefs_common.mainview_width,
1969 prefs_common.mainview_height);
1971 gtk_container_add(GTK_CONTAINER(folderwin),
1972 GTK_WIDGET_PTR(mainwin->folderview));
1974 mainwin->win.sep_folder.folderwin = folderwin;
1975 mainwin->win.sep_folder.vpaned = vpaned;
1977 gtk_widget_show_all(folderwin);
1979 case SEPARATE_MESSAGE:
1980 hpaned = gtk_hpaned_new();
1981 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1983 gtk_paned_add1(GTK_PANED(hpaned),
1984 GTK_WIDGET_PTR(mainwin->folderview));
1985 gtk_paned_add2(GTK_PANED(hpaned),
1986 GTK_WIDGET_PTR(mainwin->summaryview));
1987 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1988 prefs_common.summaryview_width,
1989 prefs_common.summaryview_height);
1990 gtk_widget_set_usize(mainwin->window,
1991 prefs_common.folderview_width +
1992 prefs_common.mainview_width,
1993 prefs_common.mainwin_height);
1994 gtk_widget_show_all(hpaned);
1995 gtk_container_add(GTK_CONTAINER(messagewin),
1996 GTK_WIDGET_PTR(mainwin->messageview));
1998 mainwin->win.sep_message.messagewin = messagewin;
1999 mainwin->win.sep_message.hpaned = hpaned;
2001 gtk_widget_show_all(messagewin);
2004 gtk_box_pack_start(GTK_BOX(vbox_body),
2005 GTK_WIDGET_PTR(mainwin->summaryview),
2007 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
2008 prefs_common.summaryview_width,
2009 prefs_common.summaryview_height);
2010 gtk_widget_set_usize(mainwin->window,
2011 prefs_common.mainview_width,
2012 prefs_common.mainwin_height);
2013 gtk_container_add(GTK_CONTAINER(folderwin),
2014 GTK_WIDGET_PTR(mainwin->folderview));
2015 gtk_container_add(GTK_CONTAINER(messagewin),
2016 GTK_WIDGET_PTR(mainwin->messageview));
2018 mainwin->win.sep_both.folderwin = folderwin;
2019 mainwin->win.sep_both.messagewin = messagewin;
2021 gtk_widget_show_all(folderwin);
2022 gtk_widget_show_all(messagewin);
2026 mainwin->type = type;
2028 mainwin->messageview->visible = TRUE;
2030 /* toggle menu state */
2031 menuitem = gtk_item_factory_get_item
2032 (ifactory, "/View/Show or hide/Folder tree");
2033 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2034 menuitem = gtk_item_factory_get_item
2035 (ifactory, "/View/Show or hide/Message view");
2036 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2038 menuitem = gtk_item_factory_get_item
2039 (ifactory, "/View/Separate folder tree");
2040 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2041 ((type & SEPARATE_FOLDER) != 0));
2042 menuitem = gtk_item_factory_get_item
2043 (ifactory, "/View/Separate message view");
2044 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2045 ((type & SEPARATE_MESSAGE) != 0));
2047 debug_print(_("done.\n"));
2050 static void main_window_toolbar_create(MainWindow *mainwin,
2051 GtkWidget *container)
2054 GtkWidget *icon_wid;
2056 GtkWidget *getall_btn;
2057 GtkWidget *compose_mail_btn;
2058 GtkWidget *compose_news_btn;
2059 GtkWidget *reply_btn;
2060 GtkWidget *replyall_btn;
2061 GtkWidget *replysender_btn;
2063 GtkWidget *send_btn;
2065 GtkWidget *prefs_btn;
2066 GtkWidget *account_btn;
2068 GtkWidget *next_btn;
2069 GtkWidget *delete_btn;
2070 GtkWidget *exec_btn;
2072 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
2074 gtk_container_add(GTK_CONTAINER(container), toolbar);
2075 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
2076 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
2077 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
2078 GTK_TOOLBAR_SPACE_LINE);
2080 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
2081 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2083 _("Get new mail from current account"),
2085 icon_wid, toolbar_inc_cb, mainwin);
2086 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
2087 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2089 _("Get new mail from all accounts"),
2095 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2097 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
2098 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2100 _("Send queued message(s)"),
2106 /* insert compose mail button widget */
2107 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
2108 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2110 _("Compose an email message"),
2113 toolbar_compose_mail_cb,
2116 /* insert compose news button widget */
2117 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2118 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2120 _("Compose a news message"),
2123 toolbar_compose_news_cb,
2126 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2130 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
2131 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2133 _("Reply to the message - Right button: more options"),
2139 /* replyall button */
2141 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
2142 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2144 _("Reply to all - Right button: more options"),
2147 toolbar_reply_to_all_cb,
2150 /* reply to sender button */
2151 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
2152 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2154 _("Reply to sender - Right button: more options"),
2157 toolbar_reply_to_sender_cb,
2160 /* forward button */
2161 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
2162 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2164 _("Forward the message - Right button: more options"),
2170 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2172 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
2173 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2175 _("Delete the message"),
2181 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
2182 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2184 _("Execute marked process"),
2190 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
2191 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2193 _("Next unread message"),
2196 toolbar_next_unread_cb,
2200 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2202 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2203 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2205 _("Common preferences"),
2210 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2211 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2213 _("Account setting"),
2218 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2219 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2223 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2224 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2227 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2228 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2231 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2232 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2235 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2236 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2240 mainwin->toolbar = toolbar;
2241 mainwin->get_btn = get_btn;
2242 mainwin->getall_btn = getall_btn;
2243 mainwin->compose_mail_btn = compose_mail_btn;
2244 mainwin->compose_news_btn = compose_news_btn;
2245 mainwin->reply_btn = reply_btn;
2246 mainwin->replyall_btn = replyall_btn;
2247 mainwin->replysender_btn = replysender_btn;
2248 mainwin->fwd_btn = fwd_btn;
2249 mainwin->send_btn = send_btn;
2251 mainwin->prefs_btn = prefs_btn;
2252 mainwin->account_btn = account_btn;
2254 mainwin->next_btn = next_btn;
2255 mainwin->delete_btn = delete_btn;
2256 mainwin->exec_btn = exec_btn;
2258 gtk_widget_show_all(toolbar);
2261 /* callback functions */
2262 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2264 MainWindow *mainwindow = (MainWindow *) data;
2268 if (event->button == 3) {
2269 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2270 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2271 menu_button_position, widget,
2272 event->button, event->time);
2276 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2278 MainWindow *mainwin = (MainWindow *)data;
2280 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2281 manage_window_focus_in(mainwin->window, NULL, NULL);
2284 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2286 MainWindow *mainwindow = (MainWindow *) data;
2290 if (event->button == 3) {
2291 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2292 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2293 menu_button_position, widget,
2294 event->button, event->time);
2298 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2300 MainWindow *mainwin = (MainWindow *)data;
2302 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2303 manage_window_focus_in(mainwin->window, NULL, NULL);
2306 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2308 MainWindow *mainwindow = (MainWindow *) data;
2312 if (event->button == 3) {
2313 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2314 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2315 menu_button_position, widget,
2316 event->button, event->time);
2320 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2322 MainWindow *mainwin = (MainWindow *)data;
2324 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2325 manage_window_focus_in(mainwin->window, NULL, NULL);
2328 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2330 MainWindow *mainwindow = (MainWindow *) data;
2334 if (event->button == 3) {
2335 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2336 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2337 menu_button_position, widget,
2338 event->button, event->time);
2342 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2344 MainWindow *mainwin = (MainWindow *)data;
2346 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2347 manage_window_focus_in(mainwin->window, NULL, NULL);
2350 static void toolbar_inc_cb (GtkWidget *widget,
2353 MainWindow *mainwin = (MainWindow *)data;
2355 inc_mail_cb(mainwin, 0, NULL);
2358 static void toolbar_inc_all_cb (GtkWidget *widget,
2361 MainWindow *mainwin = (MainWindow *)data;
2363 inc_all_account_mail_cb(mainwin, 0, NULL);
2366 static void toolbar_send_cb (GtkWidget *widget,
2369 MainWindow *mainwin = (MainWindow *)data;
2371 send_queue_cb(mainwin, 0, NULL);
2374 static void toolbar_compose_news_cb (GtkWidget *widget,
2377 MainWindow *mainwin = (MainWindow *)data;
2379 compose_news_cb(mainwin, 0, NULL);
2382 static void toolbar_compose_mail_cb (GtkWidget *widget,
2385 MainWindow *mainwin = (MainWindow *)data;
2387 compose_mail_cb(mainwin, 0, NULL);
2390 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2392 MainWindow *mainwin = (MainWindow *)data;
2395 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2396 : COMPOSE_REPLY_WITHOUT_QUOTE,
2400 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2402 MainWindow *mainwin = (MainWindow *)data;
2405 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2406 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2411 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2413 MainWindow *mainwin = (MainWindow *)data;
2416 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2417 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2421 static void toolbar_forward_cb (GtkWidget *widget,
2424 MainWindow *mainwin = (MainWindow *)data;
2426 if (prefs_common.forward_as_attachment)
2427 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2429 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2432 static void toolbar_delete_cb (GtkWidget *widget,
2435 MainWindow *mainwin = (MainWindow *)data;
2437 summary_delete(mainwin->summaryview);
2440 static void toolbar_exec_cb (GtkWidget *widget,
2443 MainWindow *mainwin = (MainWindow *)data;
2445 summary_execute(mainwin->summaryview);
2448 static void toolbar_next_unread_cb (GtkWidget *widget,
2451 MainWindow *mainwin = (MainWindow *)data;
2453 next_unread_cb(mainwin, 0, NULL);
2457 static void toolbar_account_button_pressed(GtkWidget *widget,
2458 GdkEventButton *event,
2461 MainWindow *mainwin = (MainWindow *)data;
2464 if (event->button != 3) return;
2466 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2467 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2470 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2471 menu_button_position, widget,
2472 event->button, event->time);
2476 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2479 MainWindow *mainwin = (MainWindow *)data;
2483 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2484 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2487 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2488 menu_button_position, widget,
2489 event->button, event->time);
2492 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2494 MainWindow *mainwin = (MainWindow *)data;
2497 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2498 if (!button) return;
2499 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2500 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2501 manage_window_focus_in(mainwin->window, NULL, NULL);
2504 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2507 MainWindow *mainwin = (MainWindow *)data;
2509 if (mainwin->lock_count == 0)
2510 app_exit_cb(data, 0, widget);
2515 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2518 MainWindow *mainwin = (MainWindow *)data;
2519 GtkWidget *menuitem;
2521 menuitem = gtk_item_factory_get_item
2522 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2523 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2528 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2531 MainWindow *mainwin = (MainWindow *)data;
2532 GtkWidget *menuitem;
2534 menuitem = gtk_item_factory_get_item
2535 (mainwin->menu_factory, "/View/Show or hide/Message view");
2536 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2541 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2544 main_window_add_mailbox(mainwin);
2547 static void add_mbox_cb(MainWindow *mainwin, guint action,
2550 main_window_add_mbox(mainwin);
2553 static void update_folderview_cb(MainWindow *mainwin, guint action,
2556 summary_show(mainwin->summaryview, NULL, FALSE);
2557 folderview_rescan_all();
2560 static void new_folder_cb(MainWindow *mainwin, guint action,
2563 folderview_new_folder(mainwin->folderview);
2566 static void rename_folder_cb(MainWindow *mainwin, guint action,
2569 folderview_rename_folder(mainwin->folderview);
2572 static void delete_folder_cb(MainWindow *mainwin, guint action,
2575 folderview_delete_folder(mainwin->folderview);
2578 static void import_mbox_cb(MainWindow *mainwin, guint action,
2581 import_mbox(mainwin->summaryview->folder_item);
2584 static void export_mbox_cb(MainWindow *mainwin, guint action,
2587 export_mbox(mainwin->summaryview->folder_item);
2590 static void empty_trash_cb(MainWindow *mainwin, guint action,
2593 main_window_empty_trash(mainwin, TRUE);
2596 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2598 summary_save_as(mainwin->summaryview);
2601 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2603 summary_print(mainwin->summaryview);
2606 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2608 if (prefs_common.confirm_on_exit) {
2609 if (alertpanel(_("Exit"), _("Exit this program?"),
2610 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2612 manage_window_focus_in(mainwin->window, NULL, NULL);
2615 app_will_exit(widget, mainwin);
2618 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2621 summary_search(mainwin->summaryview);
2623 message_search(mainwin->messageview);
2626 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2631 active = GTK_CHECK_MENU_ITEM(widget)->active;
2633 switch (mainwin->type) {
2635 case SEPARATE_MESSAGE:
2638 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2640 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2643 case SEPARATE_FOLDER:
2644 debug_print("separate folder\n");
2646 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2648 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2652 gtk_widget_show(mainwin->win.sep_both.folderwin);
2654 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2659 static void toggle_message_cb(MainWindow *mainwin, guint action,
2664 active = GTK_CHECK_MENU_ITEM(widget)->active;
2666 if (active != messageview_is_visible(mainwin->messageview))
2667 summary_toggle_view(mainwin->summaryview);
2670 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2673 switch ((ToolbarStyle)action) {
2675 gtk_widget_hide(mainwin->handlebox);
2677 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2681 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2685 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2690 if (action != TOOLBAR_NONE) {
2691 gtk_widget_show(mainwin->handlebox);
2692 gtk_widget_queue_resize(mainwin->handlebox);
2695 mainwin->toolbar_style = (ToolbarStyle)action;
2696 prefs_common.toolbar_style = (ToolbarStyle)action;
2699 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2702 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2703 gtk_widget_show(mainwin->hbox_stat);
2704 prefs_common.show_statusbar = TRUE;
2706 gtk_widget_hide(mainwin->hbox_stat);
2707 prefs_common.show_statusbar = FALSE;
2711 static void separate_widget_cb(MainWindow *mainwin, guint action,
2716 if (GTK_CHECK_MENU_ITEM(widget)->active)
2717 type = mainwin->type | action;
2719 type = mainwin->type & ~action;
2721 main_window_separation_change(mainwin, type);
2723 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2724 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2727 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2729 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2730 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2732 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2736 static void online_switch_clicked (GtkButton *btn, gpointer data)
2738 MainWindow *mainwin;
2739 GtkItemFactory *ifactory;
2740 GtkCheckMenuItem *menuitem;
2742 mainwin = (MainWindow *) data;
2744 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2745 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2747 g_return_if_fail(mainwin != NULL);
2748 g_return_if_fail(menuitem != NULL);
2750 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2752 gtk_widget_hide (mainwin->online_switch);
2753 gtk_widget_show (mainwin->offline_switch);
2754 menuitem->active = TRUE;
2755 prefs_common.work_offline = TRUE;
2756 inc_autocheck_timer_remove();
2759 gtk_widget_hide (mainwin->offline_switch);
2760 gtk_widget_show (mainwin->online_switch);
2761 menuitem->active = FALSE;
2762 prefs_common.work_offline = FALSE;
2763 inc_autocheck_timer_set();
2767 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2770 addressbook_open(NULL);
2773 static void log_window_show_cb(MainWindow *mainwin, guint action,
2776 log_window_show(mainwin->logwin);
2779 static void sel_download_cb(MainWindow *mainwin, guint action,
2782 selective_download(mainwin);
2785 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2787 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2790 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2793 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2796 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2801 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2805 if (prefs_common.work_offline)
2806 if (alertpanel(_("Offline warning"),
2807 _("You're working offline. Override?"),
2808 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
2811 for (list = folder_get_list(); list != NULL; list = list->next) {
2812 Folder *folder = list->data;
2814 if (folder->queue) {
2815 if (procmsg_send_queue
2816 (folder->queue, prefs_common.savemsg) < 0)
2817 alertpanel_error(_("Some errors occurred while sending queued messages."));
2818 statusbar_pop_all();
2819 folder_item_scan(folder->queue);
2820 folderview_update_item(folder->queue, TRUE);
2825 static void compose_mail_cb(MainWindow *mainwin, guint action,
2832 if (mainwin->summaryview->folder_item) {
2833 ac = mainwin->summaryview->folder_item->folder->account;
2834 if (ac && ac->protocol != A_NNTP) {
2835 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2840 if(cur_account && (cur_account->protocol != A_NNTP)) {
2841 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2845 list = account_get_list();
2846 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2847 ac = (PrefsAccount *) cur->data;
2848 if (ac->protocol != A_NNTP) {
2849 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2855 static void compose_news_cb(MainWindow *mainwin, guint action,
2858 PrefsAccount * ac = NULL;
2862 if (mainwin->summaryview->folder_item) {
2863 ac = mainwin->summaryview->folder_item->folder->account;
2864 if (ac && ac->protocol == A_NNTP) {
2865 compose_new_with_recipient
2866 (ac, mainwin->summaryview->folder_item->path);
2871 list = account_get_list();
2872 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2873 ac = (PrefsAccount *) cur->data;
2874 if (ac->protocol == A_NNTP) {
2881 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2883 summary_reply(mainwin->summaryview, (ComposeMode)action);
2886 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2888 summary_move_to(mainwin->summaryview);
2891 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2893 summary_copy_to(mainwin->summaryview);
2896 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2898 summary_delete(mainwin->summaryview);
2901 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2903 summary_open_msg(mainwin->summaryview);
2906 static void view_source_cb(MainWindow *mainwin, guint action,
2909 summary_view_source(mainwin->summaryview);
2912 static void show_all_header_cb(MainWindow *mainwin, guint action,
2915 if (mainwin->menu_lock_count) return;
2916 summary_display_msg_selected(mainwin->summaryview,
2917 GTK_CHECK_MENU_ITEM(widget)->active);
2920 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2922 summary_reedit(mainwin->summaryview);
2925 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2927 summary_mark(mainwin->summaryview);
2930 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2932 summary_unmark(mainwin->summaryview);
2935 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2938 summary_mark_as_unread(mainwin->summaryview);
2941 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2944 summary_mark_as_read(mainwin->summaryview);
2947 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2950 summary_mark_all_read(mainwin->summaryview);
2953 static void add_address_cb(MainWindow *mainwin, guint action,
2956 summary_add_address(mainwin->summaryview);
2959 static void set_charset_cb(MainWindow *mainwin, guint action,
2964 str = conv_get_charset_str((CharSet)action);
2965 g_free(prefs_common.force_charset);
2966 prefs_common.force_charset = str ? g_strdup(str) : NULL;
2968 summary_redisplay_msg(mainwin->summaryview);
2970 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
2973 static void hide_read_messages (MainWindow *mainwin, guint action,
2976 if (!mainwin->summaryview->folder_item
2977 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
2979 summary_toggle_show_read_messages(mainwin->summaryview);
2982 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2984 if (mainwin->menu_lock_count) return;
2985 if (!mainwin->summaryview->folder_item) return;
2987 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2988 summary_thread_build(mainwin->summaryview);
2989 mainwin->summaryview->folder_item->threaded = TRUE;
2991 summary_unthread(mainwin->summaryview);
2992 mainwin->summaryview->folder_item->threaded = FALSE;
2996 static void expand_threads_cb(MainWindow *mainwin, guint action,
2999 summary_expand_threads(mainwin->summaryview);
3002 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3005 summary_collapse_threads(mainwin->summaryview);
3008 static void set_display_item_cb(MainWindow *mainwin, guint action,
3011 prefs_summary_column_open();
3014 static void sort_summary_cb(MainWindow *mainwin, guint action,
3017 FolderItem *item = mainwin->summaryview->folder_item;
3018 GtkWidget *menuitem;
3020 if (mainwin->menu_lock_count) return;
3022 menuitem = gtk_item_factory_get_item
3023 (mainwin->menu_factory, "/View/Sort/Ascending");
3024 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3025 GTK_CHECK_MENU_ITEM(menuitem)->active
3026 ? SORT_ASCENDING : SORT_DESCENDING);
3030 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3033 FolderItem *item = mainwin->summaryview->folder_item;
3035 if (mainwin->menu_lock_count) return;
3037 summary_sort(mainwin->summaryview,
3038 item->sort_key, (FolderSortType)action);
3041 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3044 summary_attract_by_subject(mainwin->summaryview);
3047 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3050 summary_delete_duplicated(mainwin->summaryview);
3053 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3055 summary_filter(mainwin->summaryview);
3058 static void execute_summary_cb(MainWindow *mainwin, guint action,
3061 summary_execute(mainwin->summaryview);
3064 static void update_summary_cb(MainWindow *mainwin, guint action,
3068 FolderView *folderview = mainwin->folderview;
3070 if (!mainwin->summaryview->folder_item) return;
3071 if (!folderview->opened) return;
3073 folder_update_op_count();
3075 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3076 folderview->opened);
3079 folder_item_scan(fitem);
3080 summary_show(mainwin->summaryview, fitem, TRUE);
3083 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3085 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3088 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3090 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3093 static void prev_unread_cb(MainWindow *mainwin, guint action,
3096 summary_select_prev_unread(mainwin->summaryview);
3099 static void next_unread_cb(MainWindow *mainwin, guint action,
3102 summary_select_next_unread(mainwin->summaryview);
3105 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3107 summary_select_prev_new(mainwin->summaryview);
3110 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3112 summary_select_next_new(mainwin->summaryview);
3115 static void prev_marked_cb(MainWindow *mainwin, guint action,
3118 summary_select_prev_marked(mainwin->summaryview);
3121 static void next_marked_cb(MainWindow *mainwin, guint action,
3124 summary_select_next_marked(mainwin->summaryview);
3127 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3130 summary_select_prev_labeled(mainwin->summaryview);
3133 static void next_labeled_cb(MainWindow *mainwin, guint action,
3136 summary_select_next_labeled(mainwin->summaryview);
3139 static void goto_folder_cb(MainWindow *mainwin, guint action,
3142 FolderItem *to_folder;
3144 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3147 folderview_select(mainwin->folderview, to_folder);
3150 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3152 messageview_copy_clipboard(mainwin->messageview);
3155 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3157 MessageView *msgview = mainwin->messageview;
3159 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3160 summary_select_all(mainwin->summaryview);
3161 else if (messageview_is_visible(msgview) &&
3162 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
3163 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3164 messageview_select_all(mainwin->messageview);
3167 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3169 if (messageview_is_visible(mainwin->summaryview->messageview))
3170 summary_select_thread(mainwin->summaryview);
3173 static void create_filter_cb(MainWindow *mainwin, guint action,
3176 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3179 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3182 prefs_common_open();
3185 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
3188 prefs_filter_open(NULL, NULL);
3191 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3194 prefs_scoring_open(NULL);
3197 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3200 prefs_filtering_open(NULL, NULL, NULL);
3203 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3206 prefs_template_open();
3209 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3212 prefs_actions_open(mainwin);
3215 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3219 new_account_cb(mainwin, 0, widget);
3221 gboolean prev_default = cur_account->is_default;
3223 prefs_account_open(cur_account);
3224 if (!prev_default && cur_account->is_default)
3225 account_set_as_default(cur_account);
3226 account_save_config_all();
3228 main_window_reflect_prefs_all();
3232 static void new_account_cb(MainWindow *mainwin, guint action,
3235 account_edit_open();
3236 if (!compose_get_compose_list()) account_add();
3239 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3241 cur_account = (PrefsAccount *)data;
3242 main_window_reflect_prefs_all();
3245 static void manual_open_cb(MainWindow *mainwin, guint action,
3248 manual_open((ManualLang)action);
3251 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3253 faq_open((ManualLang)action);
3256 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3258 MainWindow *mainwin = (MainWindow *)data;
3262 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3263 LOCAL_FOLDER(folder)->rootpath,
3267 str = g_strdup_printf(_("Scanning folder %s ..."),
3268 LOCAL_FOLDER(folder)->rootpath);
3270 STATUSBAR_PUSH(mainwin, str);
3271 STATUSBAR_POP(mainwin);
3275 static void activate_compose_button (MainWindow *mainwin,
3277 ComposeButtonType type)
3279 if (style == TOOLBAR_NONE)
3282 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
3283 : mainwin->compose_news_btn);
3284 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
3285 : mainwin->compose_mail_btn);
3286 mainwin->compose_btn_type = type;
3289 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
3291 if (mainwin->compose_btn_type != compose_btn_type)
3292 activate_compose_button(mainwin,
3293 prefs_common.toolbar_style,
3297 #define BREAK_ON_MODIFIER_KEY() \
3298 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3300 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3302 MainWindow *mainwin = (MainWindow*) data;
3304 if (!mainwin || !event) return;
3306 switch (event->keyval) {
3307 case GDK_Q: /* Quit */
3308 BREAK_ON_MODIFIER_KEY();
3310 app_exit_cb(mainwin, 0, NULL);
3317 #undef BREAK_ON_MODIFIER_KEY
3319 static void set_toolbar_style(MainWindow *mainwin)
3321 switch (prefs_common.toolbar_style) {
3323 gtk_widget_hide(mainwin->handlebox);
3326 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3330 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3334 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3339 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3340 gtk_widget_show(mainwin->handlebox);
3341 gtk_widget_queue_resize(mainwin->handlebox);
3346 * Harvest addresses for selected folder.
3348 static void addr_harvest_cb( MainWindow *mainwin,
3352 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3356 * Harvest addresses for selected messages in summary view.
3358 static void addr_harvest_msg_cb( MainWindow *mainwin,
3362 summary_harvest_address( mainwin->summaryview );