2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2002 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
55 #include "stock_pixmap.h"
62 #include "prefs_common.h"
63 #include "prefs_filter.h"
64 #include "prefs_actions.h"
65 #include "prefs_filtering.h"
66 #include "prefs_scoring.h"
67 #include "prefs_account.h"
68 #include "prefs_folder_item.h"
69 #include "prefs_summary_column.h"
70 #include "prefs_template.h"
72 #include "addressbook.h"
73 #include "logwindow.h"
74 #include "manage_window.h"
75 #include "alertpanel.h"
76 #include "statusbar.h"
77 #include "inputdialog.h"
84 #include "selective_download.h"
86 #define AC_LABEL_WIDTH 240
88 #define STATUSBAR_PUSH(mainwin, str) \
90 gtk_statusbar_push(GTK_STATUSBAR(mainwin->statusbar), \
91 mainwin->mainwin_cid, str); \
92 gtkut_widget_wait_for_draw(mainwin->hbox_stat); \
95 #define STATUSBAR_POP(mainwin) \
97 gtk_statusbar_pop(GTK_STATUSBAR(mainwin->statusbar), \
98 mainwin->mainwin_cid); \
101 /* list of all instantiated MainWindow */
102 static GList *mainwin_list = NULL;
104 static GdkCursor *watch_cursor;
106 static void main_window_menu_callback_block (MainWindow *mainwin);
107 static void main_window_menu_callback_unblock (MainWindow *mainwin);
109 static void main_window_show_cur_account (MainWindow *mainwin);
111 static void main_window_set_widgets (MainWindow *mainwin,
113 static void main_window_toolbar_create (MainWindow *mainwin,
114 GtkWidget *container);
116 /* callback functions */
117 static void toolbar_inc_cb (GtkWidget *widget,
119 static void toolbar_inc_all_cb (GtkWidget *widget,
121 static void toolbar_send_cb (GtkWidget *widget,
124 static void toolbar_compose_cb (GtkWidget *widget,
126 static void toolbar_compose_news_cb (GtkWidget *widget,
128 static void toolbar_compose_mail_cb (GtkWidget *widget,
130 static void toolbar_reply_cb (GtkWidget *widget,
132 static void toolbar_reply_popup_cb (GtkWidget *widget,
133 GdkEventButton *event,
135 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell,
137 static void toolbar_reply_to_all_cb (GtkWidget *widget,
139 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget,
140 GdkEventButton *event,
142 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell,
144 static void toolbar_reply_to_sender_cb (GtkWidget *widget,
146 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget,
147 GdkEventButton *event,
149 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell,
151 static void toolbar_forward_cb (GtkWidget *widget,
153 static void toolbar_forward_popup_cb (GtkWidget *widget,
154 GdkEventButton *event,
156 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell,
159 static void toolbar_delete_cb (GtkWidget *widget,
161 static void toolbar_exec_cb (GtkWidget *widget,
164 static void toolbar_next_unread_cb (GtkWidget *widget,
167 static void toolbar_prefs_cb (GtkWidget *widget,
169 static void toolbar_account_cb (GtkWidget *widget,
173 static void toolbar_account_button_pressed (GtkWidget *widget,
174 GdkEventButton *event,
177 static void ac_label_button_pressed (GtkWidget *widget,
178 GdkEventButton *event,
180 static void ac_menu_popup_closed (GtkMenuShell *menu_shell,
183 static gint main_window_close_cb (GtkWidget *widget,
186 static gint folder_window_close_cb (GtkWidget *widget,
189 static gint message_window_close_cb (GtkWidget *widget,
193 static void add_mailbox_cb (MainWindow *mainwin,
196 static void add_mbox_cb (MainWindow *mainwin,
199 static void update_folderview_cb (MainWindow *mainwin,
202 static void new_folder_cb (MainWindow *mainwin,
205 static void rename_folder_cb (MainWindow *mainwin,
208 static void delete_folder_cb (MainWindow *mainwin,
211 static void import_mbox_cb (MainWindow *mainwin,
214 static void export_mbox_cb (MainWindow *mainwin,
217 static void empty_trash_cb (MainWindow *mainwin,
221 static void save_as_cb (MainWindow *mainwin,
224 static void print_cb (MainWindow *mainwin,
227 static void app_exit_cb (MainWindow *mainwin,
231 static void search_cb (MainWindow *mainwin,
235 static void toggle_folder_cb (MainWindow *mainwin,
238 static void toggle_message_cb (MainWindow *mainwin,
241 static void toggle_toolbar_cb (MainWindow *mainwin,
244 static void toggle_statusbar_cb (MainWindow *mainwin,
247 static void toggle_expand_summaryview_cb (MainWindow *mainwin,
250 static void toggle_expand_messageview_cb (MainWindow *mainwin,
253 static void toggle_work_offline_cb (MainWindow *mainwin,
256 static void separate_widget_cb (GtkCheckMenuItem *checkitem,
260 static void addressbook_open_cb (MainWindow *mainwin,
263 static void log_window_show_cb (MainWindow *mainwin,
266 static void sel_download_cb (MainWindow *mainwin,
270 static void inc_mail_cb (MainWindow *mainwin,
273 static void inc_all_account_mail_cb (MainWindow *mainwin,
276 static void inc_cancel_cb (MainWindow *mainwin,
280 static void send_queue_cb (MainWindow *mainwin,
284 static void compose_cb (MainWindow *mainwin,
287 static void compose_mail_cb(MainWindow *mainwin, guint action,
289 static void compose_news_cb(MainWindow *mainwin, guint action,
291 static void reply_cb (MainWindow *mainwin,
295 static void open_msg_cb (MainWindow *mainwin,
299 static void view_source_cb (MainWindow *mainwin,
303 static void show_all_header_cb (MainWindow *mainwin,
307 static void reedit_cb (MainWindow *mainwin,
311 static void move_to_cb (MainWindow *mainwin,
314 static void copy_to_cb (MainWindow *mainwin,
317 static void delete_cb (MainWindow *mainwin,
321 static void mark_cb (MainWindow *mainwin,
324 static void unmark_cb (MainWindow *mainwin,
328 static void mark_as_unread_cb (MainWindow *mainwin,
331 static void mark_as_read_cb (MainWindow *mainwin,
334 static void mark_all_read_cb (MainWindow *mainwin,
337 static void add_address_cb (MainWindow *mainwin,
341 static void set_charset_cb (MainWindow *mainwin,
345 static void hide_read_messages (MainWindow *mainwin,
349 static void thread_cb (MainWindow *mainwin,
352 static void expand_threads_cb (MainWindow *mainwin,
355 static void collapse_threads_cb (MainWindow *mainwin,
359 static void set_display_item_cb (MainWindow *mainwin,
362 static void sort_summary_cb (MainWindow *mainwin,
365 static void sort_summary_type_cb (MainWindow *mainwin,
368 static void attract_by_subject_cb(MainWindow *mainwin,
372 static void delete_duplicated_cb (MainWindow *mainwin,
375 static void filter_cb (MainWindow *mainwin,
378 static void execute_summary_cb (MainWindow *mainwin,
381 static void update_summary_cb (MainWindow *mainwin,
385 static void prev_cb (MainWindow *mainwin,
388 static void next_cb (MainWindow *mainwin,
392 static void prev_unread_cb (MainWindow *mainwin,
395 static void next_unread_cb (MainWindow *mainwin,
398 static void prev_marked_cb (MainWindow *mainwin,
401 static void next_marked_cb (MainWindow *mainwin,
404 static void prev_labeled_cb (MainWindow *mainwin,
407 static void next_labeled_cb (MainWindow *mainwin,
411 static void goto_folder_cb (MainWindow *mainwin,
415 static void copy_cb (MainWindow *mainwin,
418 static void allsel_cb (MainWindow *mainwin,
421 static void selthread_cb (MainWindow *mainwin,
424 static void create_filter_cb (MainWindow *mainwin,
428 static void prefs_common_open_cb (MainWindow *mainwin,
431 static void prefs_filter_open_cb (MainWindow *mainwin,
434 static void prefs_scoring_open_cb (MainWindow *mainwin,
437 static void prefs_filtering_open_cb (MainWindow *mainwin,
440 static void prefs_account_open_cb(MainWindow *mainwin,
443 static void prefs_template_open_cb (MainWindow *mainwin,
446 static void prefs_actions_open_cb (MainWindow *mainwin,
449 static void new_account_cb (MainWindow *mainwin,
453 static void account_menu_cb (GtkMenuItem *menuitem,
456 static void online_switch_clicked(GtkButton *btn,
459 static void manual_open_cb (MainWindow *mainwin,
462 static void faq_open_cb (MainWindow *mainwin,
466 static void scan_tree_func (Folder *folder,
470 static void activate_compose_button (MainWindow *mainwin,
472 ComposeButtonType type);
474 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
478 static void key_pressed (GtkWidget *widget,
482 static void set_toolbar_style(MainWindow *mainwin);
484 static void addr_harvest_cb ( MainWindow *mainwin,
488 static void addr_harvest_msg_cb ( MainWindow *mainwin,
492 #define SEPARATE_ACTION 667
494 static GtkItemFactoryEntry mainwin_entries[] =
496 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
497 {N_("/_File/_Add mailbox..."), NULL, add_mailbox_cb, 0, NULL},
498 {N_("/_File/_Add mbox mailbox..."), NULL, add_mbox_cb, 0, NULL},
499 {N_("/_File/_Rescan folder tree"), NULL, update_folderview_cb, 0, NULL},
500 {N_("/_File/_Folder"), NULL, NULL, 0, "<Branch>"},
501 {N_("/_File/_Folder/Create _new folder..."),
502 NULL, new_folder_cb, 0, NULL},
503 {N_("/_File/_Folder/_Rename folder..."),NULL, rename_folder_cb, 0, NULL},
504 {N_("/_File/_Folder/_Delete folder"), NULL, delete_folder_cb, 0, NULL},
505 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
506 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
507 {N_("/_File/Empty _trash"), "<shift>D", empty_trash_cb, 0, NULL},
508 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
509 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
510 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
511 {N_("/_File/_Print..."), NULL, print_cb, 0, NULL},
512 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
513 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
515 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
516 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
517 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
518 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
519 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
520 {N_("/_Edit/_Find in current message..."),
521 "<control>F", search_cb, 0, NULL},
522 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
523 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
524 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
525 {N_("/_View/Show or hi_de/_Toolbar"),
526 NULL, NULL, 0, "<Branch>"},
527 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
528 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
529 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
530 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
531 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
532 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
533 {N_("/_View/Show or hi_de/_Toolbar/_None"),
534 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
535 {N_("/_View/Show or hi_de/Status _bar"),
536 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
537 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
538 {N_("/_View/Separate _Folder Tree"), NULL, NULL, SEPARATE_ACTION + SEPARATE_FOLDER, "<ToggleItem>"},
539 {N_("/_View/Separate _Message View"), NULL, NULL, SEPARATE_ACTION + SEPARATE_MESSAGE, "<ToggleItem>"},
540 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
541 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
542 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
543 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
544 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
545 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
546 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
547 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
548 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
549 {N_("/_View/_Sort/by _color label"),
550 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
551 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
552 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
553 {N_("/_View/_Sort/by a_ttachment"),
554 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
555 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
556 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
557 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
558 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
559 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
560 {N_("/_View/_Sort/_Attract by subject"),
561 NULL, attract_by_subject_cb, 0, NULL},
562 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
563 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
564 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
565 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
566 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
568 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
569 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
570 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
571 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
572 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
573 {N_("/_View/_Go to/P_rev unread message"),
574 "<shift>P", prev_unread_cb, 0, NULL},
575 {N_("/_View/_Go to/N_ext unread message"),
576 "<shift>N", next_unread_cb, 0, NULL},
577 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
578 {N_("/_View/_Go to/Prev _marked message"),
579 NULL, prev_marked_cb, 0, NULL},
580 {N_("/_View/_Go to/Next m_arked message"),
581 NULL, next_marked_cb, 0, NULL},
582 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
583 {N_("/_View/_Go to/Prev _labeled message"),
584 NULL, prev_labeled_cb, 0, NULL},
585 {N_("/_View/_Go to/Next la_beled message"),
586 NULL, next_labeled_cb, 0, NULL},
587 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
588 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
589 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
591 #define CODESET_SEPARATOR \
592 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
593 #define CODESET_ACTION(action) \
594 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
596 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
597 {N_("/_View/_Code set/_Auto detect"),
598 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
599 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
600 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
601 CODESET_ACTION(C_US_ASCII)},
604 {N_("/_View/_Code set/Unicode (_UTF-8)"),
605 CODESET_ACTION(C_UTF_8)},
608 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
609 CODESET_ACTION(C_ISO_8859_1)},
610 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
611 CODESET_ACTION(C_ISO_8859_15)},
614 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
615 CODESET_ACTION(C_ISO_8859_2)},
617 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
618 CODESET_ACTION(C_ISO_8859_13)},
619 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
620 CODESET_ACTION(C_ISO_8859_4)},
622 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
623 CODESET_ACTION(C_ISO_8859_7)},
625 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
626 CODESET_ACTION(C_ISO_8859_9)},
628 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
629 CODESET_ACTION(C_ISO_8859_5)},
630 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
631 CODESET_ACTION(C_KOI8_R)},
632 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
633 CODESET_ACTION(C_WINDOWS_1251)},
636 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
637 CODESET_ACTION(C_ISO_2022_JP)},
639 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
640 CODESET_ACTION(C_ISO_2022_JP_2)},
642 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
643 CODESET_ACTION(C_EUC_JP)},
644 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
645 CODESET_ACTION(C_SHIFT_JIS)},
648 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
649 CODESET_ACTION(C_GB2312)},
650 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
651 CODESET_ACTION(C_BIG5)},
652 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
653 CODESET_ACTION(C_EUC_TW)},
654 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
655 CODESET_ACTION(C_ISO_2022_CN)},
657 {N_("/_View/_Code set/Korean (EUC-_KR)"),
658 CODESET_ACTION(C_EUC_KR)},
659 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
660 CODESET_ACTION(C_ISO_2022_KR)},
662 {N_("/_View/_Code set/Thai (TIS-620)"),
663 CODESET_ACTION(C_TIS_620)},
664 {N_("/_View/_Code set/Thai (Windows-874)"),
665 CODESET_ACTION(C_WINDOWS_874)},
668 #undef CODESET_SEPARATOR
669 #undef CODESET_ACTION
671 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
672 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
673 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
674 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
675 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
676 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
678 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
679 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
680 {N_("/_Message/Get from _all accounts"),
681 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
682 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
683 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
684 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
685 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
686 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
687 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
688 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
689 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
690 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
691 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
692 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
693 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
694 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
695 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
696 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
697 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
698 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
699 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
700 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
701 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
702 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
703 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
704 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
705 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
706 {N_("/_Message/_Mark/Mark as rea_d"),
707 NULL, mark_as_read_cb, 0, NULL},
708 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
710 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
711 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
712 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
713 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
714 {N_("/_Tools/Add sender to address boo_k"),
715 NULL, add_address_cb, 0, NULL},
716 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
717 {N_("/_Tools/_Harvest addresses/from _Folder..."),
718 NULL, addr_harvest_cb, 0, NULL},
719 {N_("/_Tools/_Harvest addresses/from _Messages..."),
720 NULL, addr_harvest_msg_cb, 0, NULL},
721 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
722 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
723 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
724 {N_("/_Tools/_Create filter rule/_Automatically"),
725 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
726 {N_("/_Tools/_Create filter rule/by _From"),
727 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
728 {N_("/_Tools/_Create filter rule/by _To"),
729 NULL, create_filter_cb, FILTER_BY_TO, NULL},
730 {N_("/_Tools/_Create filter rule/by _Subject"),
731 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
732 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
733 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
734 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
735 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
736 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
737 {N_("/_Tools/Delete du_plicated messages"),
738 NULL, delete_duplicated_cb, 0, NULL},
739 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
740 {N_("/_Tools/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
742 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
743 {N_("/_Configuration/_Common preferences..."),
744 NULL, prefs_common_open_cb, 0, NULL},
745 {N_("/_Configuration/_Filter setting..."),
746 NULL, prefs_filter_open_cb, 0, NULL},
747 {N_("/_Configuration/_Scoring..."),
748 NULL, prefs_scoring_open_cb, 0, NULL},
749 {N_("/_Configuration/_Filtering..."),
750 NULL, prefs_filtering_open_cb, 0, NULL},
751 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
752 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
753 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
754 {N_("/_Configuration/_Preferences for current account..."),
755 NULL, prefs_account_open_cb, 0, NULL},
756 {N_("/_Configuration/Create _new account..."),
757 NULL, new_account_cb, 0, NULL},
758 {N_("/_Configuration/_Edit accounts..."),
759 NULL, account_edit_open, 0, NULL},
760 {N_("/_Configuration/C_hange current account"),
761 NULL, NULL, 0, "<Branch>"},
763 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
764 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
765 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
766 {N_("/_Help/_Manual/_German"), NULL, manual_open_cb, MANUAL_LANG_DE, NULL},
767 {N_("/_Help/_Manual/_Spanish"), NULL, manual_open_cb, MANUAL_LANG_ES, NULL},
768 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
769 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
770 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
771 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
772 {N_("/_Help/_FAQ/_German"), NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
773 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
774 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
775 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
776 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
777 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
779 static GtkItemFactoryEntry reply_popup_entries[] =
781 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
782 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
784 static GtkItemFactoryEntry replyall_popup_entries[] =
786 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
787 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
789 static GtkItemFactoryEntry replysender_popup_entries[] =
791 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
792 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
794 static GtkItemFactoryEntry fwd_popup_entries[] =
796 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
797 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
800 MainWindow *main_window_create(SeparateType type)
806 GtkWidget *handlebox;
807 GtkWidget *vbox_body;
808 GtkWidget *hbox_stat;
809 GtkWidget *statusbar;
810 GtkWidget *progressbar;
811 GtkWidget *statuslabel;
812 GtkWidget *ac_button;
814 GtkWidget *online_status;
815 GtkWidget *offline_status;
816 GtkWidget *online_switch;
817 GtkWidget *offline_switch;
819 FolderView *folderview;
820 SummaryView *summaryview;
821 MessageView *messageview;
822 GdkColormap *colormap;
825 guint n_menu_entries;
826 GtkItemFactory *ifactory;
829 GtkWidget *compose_popup;
830 GtkWidget *reply_popup;
831 GtkWidget *replyall_popup;
832 GtkWidget *replysender_popup;
833 GtkWidget *fwd_popup;
836 static GdkGeometry geometry;
838 debug_print(_("Creating main window...\n"));
839 mainwin = g_new0(MainWindow, 1);
842 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
843 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
844 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
845 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
847 if (!geometry.min_height) {
848 geometry.min_width = 320;
849 geometry.min_height = 200;
851 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
854 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
855 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
856 MANAGE_WINDOW_SIGNALS_CONNECT(window);
857 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
858 GTK_SIGNAL_FUNC(key_pressed), mainwin);
860 gtk_widget_realize(window);
861 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
864 gtkut_widget_set_app_icon(window);
866 vbox = gtk_vbox_new(FALSE, 0);
867 gtk_widget_show(vbox);
868 gtk_container_add(GTK_CONTAINER(window), vbox);
871 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
872 menubar = menubar_create(window, mainwin_entries,
873 n_menu_entries, "<Main>", mainwin);
874 gtk_widget_show(menubar);
875 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
876 ifactory = gtk_item_factory_from_widget(menubar);
878 handlebox = gtk_handle_box_new();
879 gtk_widget_show(handlebox);
880 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
882 /* create the popup menus for the reply buttons specials */
883 n_menu_entries = sizeof(reply_popup_entries) /
884 sizeof(reply_popup_entries[0]);
885 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
886 "<ReplyPopup>", mainwin);
887 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
888 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
889 n_menu_entries = sizeof(replyall_popup_entries) /
890 sizeof(replyall_popup_entries[0]);
891 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
892 "<ReplyAllPopup>", mainwin);
893 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
894 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
895 n_menu_entries = sizeof(replysender_popup_entries) /
896 sizeof(replysender_popup_entries[0]);
897 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
898 "<ReplySenderPopup>", mainwin);
899 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
900 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
901 /* create the popup menu for the forward button */
902 n_menu_entries = sizeof(fwd_popup_entries) /
903 sizeof(fwd_popup_entries[0]);
904 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
905 "<ForwardPopup>", mainwin);
906 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
907 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
909 main_window_toolbar_create(mainwin, handlebox);
911 /* vbox that contains body */
912 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
913 gtk_widget_show(vbox_body);
914 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
915 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
917 hbox_stat = gtk_hbox_new(FALSE, 2);
918 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
920 statusbar = statusbar_create();
921 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
923 progressbar = gtk_progress_bar_new();
924 gtk_widget_set_usize(progressbar, 120, 1);
925 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
927 online_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
928 offline_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
929 online_switch = gtk_button_new ();
930 offline_switch = gtk_button_new ();
931 gtk_container_add (GTK_CONTAINER(online_switch), online_status);
932 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
933 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
934 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
935 gtk_container_add (GTK_CONTAINER(offline_switch), offline_status);
936 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
937 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
938 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
940 statuslabel = gtk_label_new("");
941 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
943 ac_button = gtk_button_new();
944 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
945 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
946 gtk_widget_set_usize(ac_button, -1, 1);
947 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
948 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
949 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
951 ac_label = gtk_label_new("");
952 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
954 gtk_widget_show_all(hbox_stat);
956 gtk_widget_hide(offline_switch);
958 mainwin->folderview = folderview = folderview_create();
959 mainwin->summaryview = summaryview = summary_create();
960 mainwin->messageview = messageview = messageview_create();
961 mainwin->logwin = log_window_create();
963 folderview->mainwin = mainwin;
964 folderview->summaryview = summaryview;
966 summaryview->mainwin = mainwin;
967 summaryview->folderview = folderview;
968 summaryview->messageview = messageview;
969 summaryview->window = window;
971 messageview->mainwin = mainwin;
973 mainwin->window = window;
974 mainwin->vbox = vbox;
975 mainwin->menubar = menubar;
976 mainwin->handlebox = handlebox;
977 mainwin->vbox_body = vbox_body;
978 mainwin->hbox_stat = hbox_stat;
979 mainwin->statusbar = statusbar;
980 mainwin->progressbar = progressbar;
981 mainwin->statuslabel = statuslabel;
982 mainwin->ac_button = ac_button;
983 mainwin->ac_label = ac_label;
984 mainwin->reply_popup = reply_popup;
985 mainwin->replyall_popup = replyall_popup;
986 mainwin->replysender_popup = replysender_popup;
987 mainwin->fwd_popup = fwd_popup;
988 mainwin->online_switch = online_switch;
989 mainwin->offline_switch = offline_switch;
991 /* set context IDs for status bar */
992 mainwin->mainwin_cid = gtk_statusbar_get_context_id
993 (GTK_STATUSBAR(statusbar), "Main Window");
994 mainwin->folderview_cid = gtk_statusbar_get_context_id
995 (GTK_STATUSBAR(statusbar), "Folder View");
996 mainwin->summaryview_cid = gtk_statusbar_get_context_id
997 (GTK_STATUSBAR(statusbar), "Summary View");
999 /* allocate colors for summary view and folder view */
1000 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1001 summaryview->color_marked.blue = (guint16)65535;
1003 summaryview->color_dim.red = summaryview->color_dim.green =
1004 summaryview->color_dim.blue = COLOR_DIM;
1006 folderview->color_new.red = (guint16)55000;
1007 folderview->color_new.green = folderview->color_new.blue = 15000;
1009 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1010 &folderview->color_op);
1012 summaryview->color_important.red = 0;
1013 summaryview->color_important.green = 0;
1014 summaryview->color_important.blue = (guint16)65535;
1016 color[0] = summaryview->color_marked;
1017 color[1] = summaryview->color_dim;
1018 color[2] = folderview->color_new;
1019 color[3] = folderview->color_op;
1021 colormap = gdk_window_get_colormap(window->window);
1022 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1023 for (i = 0; i < 4; i++) {
1024 if (success[i] == FALSE)
1025 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1028 debug_print(_("done.\n"));
1030 main_window_set_widgets(mainwin, type);
1032 /* set menu items */
1033 ifactory = gtk_item_factory_from_widget(menubar);
1034 menuitem = gtk_item_factory_get_item
1035 (ifactory, "/View/Code set/Auto detect");
1036 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1038 switch (prefs_common.toolbar_style) {
1040 menuitem = gtk_item_factory_get_item
1041 (ifactory, "/View/Show or hide/Toolbar/None");
1044 menuitem = gtk_item_factory_get_item
1045 (ifactory, "/View/Show or hide/Toolbar/Icon");
1048 menuitem = gtk_item_factory_get_item
1049 (ifactory, "/View/Show or hide/Toolbar/Text");
1052 menuitem = gtk_item_factory_get_item
1053 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1055 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1057 gtk_widget_hide(mainwin->hbox_stat);
1058 menuitem = gtk_item_factory_get_item
1059 (ifactory, "/View/Show or hide/Status bar");
1060 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1061 prefs_common.show_statusbar);
1062 #if 0 /* FIXED SEPARATE WINDOWS */
1063 /* Message view and Folder tree are always shown at startup
1064 * make that in the menu visible */
1065 menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Message View");
1066 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1067 menuitem = gtk_item_factory_get_item(ifactory, "/View/Separate Folder Tree");
1068 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1070 /* set the check of the SEPARATE_xxx menu items. we also need the main window
1071 * as a property and pass the action type to the callback */
1072 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_FOLDER);
1074 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_FOLDER);
1075 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
1076 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
1077 GUINT_TO_POINTER(SEPARATE_FOLDER));
1079 menuitem = gtk_item_factory_get_widget_by_action(ifactory, SEPARATE_ACTION + SEPARATE_MESSAGE);
1081 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), type & SEPARATE_MESSAGE);
1082 gtk_object_set_data(GTK_OBJECT(menuitem), "mainwindow", mainwin);
1083 gtk_signal_connect(GTK_OBJECT(menuitem), "toggled", GTK_SIGNAL_FUNC(separate_widget_cb),
1084 GUINT_TO_POINTER(SEPARATE_MESSAGE));
1086 menuitem = gtk_item_factory_get_item(ifactory, "/View/Expand Summary View");
1087 gtk_signal_connect(GTK_OBJECT(menuitem), "state-changed", GTK_SIGNAL_FUNC(menuitem_expandsummaryview_statechanged),
1090 /* set account selection menu */
1091 ac_menu = gtk_item_factory_get_widget
1092 (ifactory, "/Configuration/Change current account");
1093 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1094 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1095 mainwin->ac_menu = ac_menu;
1097 main_window_set_toolbar_sensitive(mainwin);
1099 /* Create actions menu */
1100 update_mainwin_actions_menu(ifactory, mainwin);
1102 /* show main window */
1103 gtk_widget_set_uposition(mainwin->window,
1104 prefs_common.mainwin_x,
1105 prefs_common.mainwin_y);
1106 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1107 prefs_common.mainwin_height);
1108 gtk_widget_show(mainwin->window);
1110 /* initialize views */
1111 folderview_init(folderview);
1112 summary_init(summaryview);
1113 messageview_init(messageview);
1114 log_window_init(mainwin->logwin);
1116 mainwin->lock_count = 0;
1117 mainwin->menu_lock_count = 0;
1118 mainwin->cursor_count = 0;
1121 watch_cursor = gdk_cursor_new(GDK_WATCH);
1123 mainwin_list = g_list_append(mainwin_list, mainwin);
1125 /* init work_offline */
1126 if (prefs_common.work_offline)
1127 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1132 void main_window_cursor_wait(MainWindow *mainwin)
1135 if (mainwin->cursor_count == 0)
1136 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1138 mainwin->cursor_count++;
1143 void main_window_cursor_normal(MainWindow *mainwin)
1145 if (mainwin->cursor_count)
1146 mainwin->cursor_count--;
1148 if (mainwin->cursor_count == 0)
1149 gdk_window_set_cursor(mainwin->window->window, NULL);
1154 /* lock / unlock the user-interface */
1155 void main_window_lock(MainWindow *mainwin)
1157 if (mainwin->lock_count == 0)
1158 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1160 mainwin->lock_count++;
1162 main_window_set_menu_sensitive(mainwin);
1163 main_window_set_toolbar_sensitive(mainwin);
1166 void main_window_unlock(MainWindow *mainwin)
1168 if (mainwin->lock_count)
1169 mainwin->lock_count--;
1171 main_window_set_menu_sensitive(mainwin);
1172 main_window_set_toolbar_sensitive(mainwin);
1174 if (mainwin->lock_count == 0)
1175 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1178 static void main_window_menu_callback_block(MainWindow *mainwin)
1180 mainwin->menu_lock_count++;
1183 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1185 if (mainwin->menu_lock_count)
1186 mainwin->menu_lock_count--;
1189 void main_window_reflect_prefs_all(void)
1191 main_window_reflect_prefs_all_real(FALSE);
1194 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1197 MainWindow *mainwin;
1199 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1200 mainwin = (MainWindow *)cur->data;
1202 main_window_show_cur_account(mainwin);
1203 main_window_set_menu_sensitive(mainwin);
1204 main_window_set_toolbar_sensitive(mainwin);
1207 if (pixmap_theme_changed)
1209 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1210 mainwin->toolbar = NULL;
1211 main_window_toolbar_create(mainwin, mainwin->handlebox);
1212 set_toolbar_style(mainwin);
1213 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1214 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1215 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1218 summary_redisplay_msg(mainwin->summaryview);
1219 headerview_set_visibility(mainwin->messageview->headerview,
1220 prefs_common.display_header_pane);
1224 void main_window_set_summary_column(void)
1227 MainWindow *mainwin;
1229 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1230 mainwin = (MainWindow *)cur->data;
1231 summary_set_column_order(mainwin->summaryview);
1235 void main_window_set_account_menu(GList *account_list)
1237 GList *cur, *cur_ac, *cur_item;
1238 GtkWidget *menuitem;
1239 MainWindow *mainwin;
1240 PrefsAccount *ac_prefs;
1242 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1243 mainwin = (MainWindow *)cur->data;
1245 /* destroy all previous menu item */
1246 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1247 while (cur_item != NULL) {
1248 GList *next = cur_item->next;
1249 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1253 for (cur_ac = account_list; cur_ac != NULL;
1254 cur_ac = cur_ac->next) {
1255 ac_prefs = (PrefsAccount *)cur_ac->data;
1257 menuitem = gtk_menu_item_new_with_label
1258 (ac_prefs->account_name
1259 ? ac_prefs->account_name : _("Untitled"));
1260 gtk_widget_show(menuitem);
1261 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1262 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1263 GTK_SIGNAL_FUNC(account_menu_cb),
1269 static void main_window_show_cur_account(MainWindow *mainwin)
1274 ac_name = g_strdup(cur_account
1275 ? (cur_account->account_name
1276 ? cur_account->account_name : _("Untitled"))
1280 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1282 buf = g_strdup(PROG_VERSION);
1283 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1286 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1287 gtk_widget_queue_resize(mainwin->ac_button);
1292 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1294 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1295 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1296 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1298 debug_print(_("Changing window separation type from %d to %d\n"),
1299 mainwin->type, type);
1301 if (mainwin->type == type) return;
1303 /* remove widgets from those containers */
1304 gtk_widget_ref(folder_wid);
1305 gtk_widget_ref(summary_wid);
1306 gtk_widget_ref(message_wid);
1307 gtkut_container_remove
1308 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1309 gtkut_container_remove
1310 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1311 gtkut_container_remove
1312 (GTK_CONTAINER(message_wid->parent), message_wid);
1314 /* clean containers */
1315 switch (mainwin->type) {
1317 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1319 case SEPARATE_FOLDER:
1320 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1321 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1323 case SEPARATE_MESSAGE:
1324 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1325 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1328 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1329 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1333 gtk_widget_hide(mainwin->window);
1334 main_window_set_widgets(mainwin, type);
1335 gtk_widget_show(mainwin->window);
1337 gtk_widget_unref(folder_wid);
1338 gtk_widget_unref(summary_wid);
1339 gtk_widget_unref(message_wid);
1342 void main_window_get_size(MainWindow *mainwin)
1344 GtkAllocation *allocation;
1346 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1348 prefs_common.summaryview_width = allocation->width;
1350 if (mainwin->summaryview->msg_is_toggled_on)
1351 prefs_common.summaryview_height = allocation->height;
1353 prefs_common.mainview_width = allocation->width;
1355 allocation = &mainwin->window->allocation;
1357 prefs_common.mainview_height = allocation->height;
1358 prefs_common.mainwin_width = allocation->width;
1359 prefs_common.mainwin_height = allocation->height;
1361 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1363 prefs_common.folderview_width = allocation->width;
1364 prefs_common.folderview_height = allocation->height;
1367 void main_window_get_position(MainWindow *mainwin)
1371 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1373 prefs_common.mainview_x = x;
1374 prefs_common.mainview_y = y;
1375 prefs_common.mainwin_x = x;
1376 prefs_common.mainwin_y = y;
1378 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1381 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1387 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1388 folder = FOLDER(list->data);
1389 if (folder && folder->trash && folder->trash->total > 0)
1393 if (!has_trash) return;
1396 if (alertpanel(_("Empty trash"),
1397 _("Empty all messages in trash?"),
1398 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1400 manage_window_focus_in(mainwin->window, NULL, NULL);
1403 procmsg_empty_trash();
1405 for (list = folder_get_list(); list != NULL; list = list->next) {
1406 folder = list->data;
1407 if (folder && folder->trash && folder->trash->total != 0) {
1408 folder_item_scan(folder->trash);
1409 folderview_update_item(folder->trash, TRUE);
1413 if (mainwin->summaryview->folder_item &&
1414 mainwin->summaryview->folder_item->stype == F_TRASH)
1415 gtk_widget_grab_focus(mainwin->folderview->ctree);
1418 void main_window_add_mailbox(MainWindow *mainwin)
1423 path = input_dialog(_("Add mailbox"),
1424 _("Input the location of mailbox.\n"
1425 "If the existing mailbox is specified, it will be\n"
1426 "scanned automatically."),
1429 if (folder_find_from_path(path)) {
1430 alertpanel_error(_("The mailbox `%s' already exists."), path);
1434 if (!strcmp(path, "Mail"))
1435 folder = folder_new(F_MH, _("Mailbox"), path);
1437 folder = folder_new(F_MH, g_basename(path), path);
1440 if (folder->create_tree(folder) < 0) {
1441 alertpanel_error(_("Creation of the mailbox failed.\n"
1442 "Maybe some files already exist, or you don't have the permission to write there."));
1443 folder_destroy(folder);
1448 folder_set_ui_func(folder, scan_tree_func, mainwin);
1449 folder->scan_tree(folder);
1450 folder_set_ui_func(folder, NULL, NULL);
1452 folderview_set(mainwin->folderview);
1455 void main_window_add_mbox(MainWindow *mainwin)
1461 path = input_dialog(_("Add mbox mailbox"),
1462 _("Input the location of mailbox."),
1467 if (folder_find_from_path(path)) {
1468 alertpanel_error(_("The mailbox `%s' already exists."), path);
1474 if (!strcmp(path, "Mail"))
1475 folder = folder_new(F_MBOX, _("Mailbox"), path);
1479 folder = folder_new(F_MBOX, g_basename(path), path);
1482 if (folder->create_tree(folder) < 0) {
1483 alertpanel_error(_("Creation of the mailbox failed."));
1484 folder_destroy(folder);
1490 item = folder_item_new(folder->name, NULL);
1491 item->folder = folder;
1492 folder->node = g_node_new(item);
1494 folder->create_folder(folder, item, "inbox");
1495 folder->create_folder(folder, item, "outbox");
1496 folder->create_folder(folder, item, "queue");
1497 folder->create_folder(folder, item, "draft");
1498 folder->create_folder(folder, item, "trash");
1500 folderview_set(mainwin->folderview);
1505 M_UNLOCKED = 1 << 0,
1506 M_MSG_EXIST = 1 << 1,
1507 M_TARGET_EXIST = 1 << 2,
1508 M_SINGLE_TARGET_EXIST = 1 << 3,
1510 M_ALLOW_REEDIT = 1 << 5,
1511 M_HAVE_ACCOUNT = 1 << 6,
1512 M_THREADED = 1 << 7,
1513 M_UNTHREADED = 1 << 8,
1514 M_ALLOW_DELETE = 1 << 9,
1515 M_INC_ACTIVE = 1 << 10,
1517 M_HAVE_NEWS_ACCOUNT = 1 << 12,
1518 M_HIDE_READ_MSG = 1 << 13
1521 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1523 SensitiveCond state = 0;
1524 SummarySelection selection;
1525 FolderItem *item = mainwin->summaryview->folder_item;
1526 GList *account_list = account_get_list();
1528 selection = summary_get_selection_type(mainwin->summaryview);
1530 if (mainwin->lock_count == 0)
1531 state |= M_UNLOCKED;
1532 if (selection != SUMMARY_NONE)
1533 state |= M_MSG_EXIST;
1537 state |= M_THREADED;
1539 state |= M_UNTHREADED;
1540 /* if (item->folder->type != F_NEWS) */
1541 state |= M_ALLOW_DELETE;
1543 if (selection == SUMMARY_NONE && item->hide_read_msgs
1544 || selection != SUMMARY_NONE)
1545 state |= M_HIDE_READ_MSG;
1547 if (selection == SUMMARY_SELECTED_SINGLE ||
1548 selection == SUMMARY_SELECTED_MULTIPLE)
1549 state |= M_TARGET_EXIST;
1550 if (selection == SUMMARY_SELECTED_SINGLE)
1551 state |= M_SINGLE_TARGET_EXIST;
1552 if (mainwin->summaryview->folder_item &&
1553 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1555 if (selection == SUMMARY_SELECTED_SINGLE &&
1557 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1558 item->stype == F_QUEUE)))
1559 state |= M_ALLOW_REEDIT;
1561 state |= M_HAVE_ACCOUNT;
1563 for ( ; account_list != NULL; account_list = account_list->next) {
1564 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1565 state |= M_HAVE_NEWS_ACCOUNT;
1570 if (inc_is_active())
1571 state |= M_INC_ACTIVE;
1576 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1578 SensitiveCond state;
1587 #define SET_WIDGET_COND(w, c) \
1589 entry[i].widget = w; \
1590 entry[i].cond = c; \
1594 SET_WIDGET_COND(mainwin->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1595 SET_WIDGET_COND(mainwin->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1596 SET_WIDGET_COND(mainwin->compose_news_btn, M_HAVE_ACCOUNT);
1597 SET_WIDGET_COND(mainwin->reply_btn,
1598 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1599 SET_WIDGET_COND(mainwin->replyall_btn,
1600 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1601 SET_WIDGET_COND(mainwin->replysender_btn,
1602 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1603 SET_WIDGET_COND(mainwin->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
1605 SET_WIDGET_COND(mainwin->prefs_btn, M_UNLOCKED);
1606 SET_WIDGET_COND(mainwin->account_btn, M_UNLOCKED);
1608 SET_WIDGET_COND(mainwin->next_btn, M_MSG_EXIST);
1609 SET_WIDGET_COND(mainwin->delete_btn,
1610 M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
1611 SET_WIDGET_COND(mainwin->exec_btn, M_MSG_EXIST|M_EXEC|M_UNLOCKED);
1612 SET_WIDGET_COND(NULL, 0);
1614 #undef SET_WIDGET_COND
1616 state = main_window_get_current_state(mainwin);
1618 for (i = 0; entry[i].widget != NULL; i++) {
1619 sensitive = ((entry[i].cond & state) == entry[i].cond);
1620 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1623 activate_compose_button(mainwin,
1624 prefs_common.toolbar_style,
1625 mainwin->compose_btn_type);
1628 void main_window_set_menu_sensitive(MainWindow *mainwin)
1630 GtkItemFactory *ifactory;
1631 SensitiveCond state;
1633 GtkWidget *menuitem;
1638 static const struct {
1642 {"/File/Add mailbox..." , M_UNLOCKED},
1643 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1644 {"/File/Rescan folder tree" , M_UNLOCKED},
1645 {"/File/Folder" , M_UNLOCKED},
1646 {"/File/Import mbox file..." , M_UNLOCKED},
1647 {"/File/Export to mbox file...", M_UNLOCKED},
1648 {"/File/Empty trash" , M_UNLOCKED},
1649 {"/File/Work offline" , M_UNLOCKED},
1650 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1651 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1652 /* {"/File/Close", M_UNLOCKED}, */
1653 {"/File/Exit" , M_UNLOCKED},
1655 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1656 {"/View/Sort" , M_MSG_EXIST},
1657 {"/View/Thread view" , M_EXEC},
1658 {"/View/Expand all threads" , M_MSG_EXIST},
1659 {"/View/Collapse all threads" , M_MSG_EXIST},
1660 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1661 {"/View/Go to/Prev message" , M_MSG_EXIST},
1662 {"/View/Go to/Next message" , M_MSG_EXIST},
1663 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1664 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1665 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1666 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1667 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1668 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1669 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1670 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1671 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1673 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1674 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1675 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1676 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1677 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1678 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1679 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1680 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1681 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1682 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1683 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1684 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1685 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1686 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1687 {"/Message/Mark" , M_TARGET_EXIST},
1689 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1690 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1691 {"/Tools/Harvest addresses" , M_UNLOCKED},
1692 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1693 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1694 {"/Tools/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1695 {"/Tools/Actions" , M_MSG_EXIST},
1696 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1698 {"/Configuration", M_UNLOCKED},
1703 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1704 state = main_window_get_current_state(mainwin);
1706 for (i = 0; entry[i].entry != NULL; i++) {
1707 sensitive = ((entry[i].cond & state) == entry[i].cond);
1708 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1711 main_window_menu_callback_block(mainwin);
1713 #define SET_CHECK_MENU_ACTIVE(path, active) \
1715 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1716 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1719 item = mainwin->summaryview->folder_item;
1720 menu_path = "/View/Sort/Don't sort";
1722 switch (item->sort_key) {
1723 case SORT_BY_NUMBER:
1724 menu_path = "/View/Sort/by number"; break;
1726 menu_path = "/View/Sort/by size"; break;
1728 menu_path = "/View/Sort/by date"; break;
1730 menu_path = "/View/Sort/by from"; break;
1731 case SORT_BY_SUBJECT:
1732 menu_path = "/View/Sort/by subject"; break;
1734 menu_path = "/View/Sort/by color label"; break;
1736 menu_path = "/View/Sort/by mark"; break;
1737 case SORT_BY_UNREAD:
1738 menu_path = "/View/Sort/by unread"; break;
1740 menu_path = "/View/Sort/by attachment"; break;
1743 menu_path = "/View/Sort/Don't sort"; break;
1746 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1748 if (!item || item->sort_type == SORT_ASCENDING) {
1749 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1751 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1754 if (item && item->sort_key != SORT_BY_NONE) {
1755 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1756 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1758 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1759 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1762 SET_CHECK_MENU_ACTIVE("/View/Show all header",
1763 mainwin->messageview->textview->show_all_headers);
1764 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1766 #undef SET_CHECK_MENU_ACTIVE
1768 main_window_menu_callback_unblock(mainwin);
1771 void main_window_popup(MainWindow *mainwin)
1777 gdk_window_get_origin(mainwin->window->window, &x, &y);
1778 sx = gdk_screen_width();
1779 sy = gdk_screen_height();
1780 x %= sx; if (x < 0) x = 0;
1781 y %= sy; if (y < 0) y = 0;
1782 gdk_window_move(mainwin->window->window, x, y);
1783 gdk_window_raise(mainwin->window->window);
1784 gdk_window_show(mainwin->window->window);
1786 debug_print("window position: x = %d, y = %d\n", x, y);
1788 switch (mainwin->type) {
1789 case SEPARATE_FOLDER:
1790 widget = mainwin->win.sep_folder.folderwin;
1791 gdk_window_get_origin(widget->window, &x, &y);
1792 x %= sx; if (x < 0) x = 0;
1793 y %= sy; if (y < 0) y = 0;
1794 gdk_window_move(widget->window, x, y);
1795 gdk_window_raise(widget->window);
1797 case SEPARATE_MESSAGE:
1798 widget = mainwin->win.sep_message.messagewin;
1799 gdk_window_get_origin(widget->window, &x, &y);
1800 x %= sx; if (x < 0) x = 0;
1801 y %= sy; if (y < 0) y = 0;
1802 gdk_window_move(widget->window, x, y);
1803 gdk_window_raise(widget->window);
1806 widget = mainwin->win.sep_both.folderwin;
1807 gdk_window_get_origin(widget->window, &x, &y);
1808 x %= sx; if (x < 0) x = 0;
1809 y %= sy; if (y < 0) y = 0;
1810 gdk_window_move(widget->window, x, y);
1811 gdk_window_raise(widget->window);
1812 widget = mainwin->win.sep_both.messagewin;
1813 gdk_window_get_origin(widget->window, &x, &y);
1814 x %= sx; if (x < 0) x = 0;
1815 y %= sy; if (y < 0) y = 0;
1816 gdk_window_move(widget->window, x, y);
1817 gdk_window_raise(widget->window);
1824 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1826 GtkWidget *folderwin = NULL;
1827 GtkWidget *messagewin = NULL;
1830 GtkWidget *vbox_body = mainwin->vbox_body;
1831 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1832 GtkWidget *menuitem;
1834 debug_print(_("Setting widgets..."));
1836 /* create separated window(s) if needed */
1837 if (type & SEPARATE_FOLDER) {
1838 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1839 gtk_window_set_title(GTK_WINDOW(folderwin),
1840 _("Sylpheed - Folder View"));
1841 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1842 "folder_view", "Sylpheed");
1843 gtk_window_set_policy(GTK_WINDOW(folderwin),
1845 gtk_widget_set_usize(folderwin, -1,
1846 prefs_common.mainview_height);
1847 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1849 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1850 GTK_SIGNAL_FUNC(folder_window_close_cb),
1853 if (type & SEPARATE_MESSAGE) {
1854 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1855 gtk_window_set_title(GTK_WINDOW(messagewin),
1856 _("Sylpheed - Message View"));
1857 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1858 "message_view", "Sylpheed");
1859 gtk_window_set_policy(GTK_WINDOW(messagewin),
1861 gtk_widget_set_usize
1862 (messagewin, prefs_common.mainview_width,
1863 prefs_common.mainview_height
1864 - prefs_common.summaryview_height
1865 + DEFAULT_HEADERVIEW_HEIGHT);
1866 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1868 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1869 GTK_SIGNAL_FUNC(message_window_close_cb),
1875 hpaned = gtk_hpaned_new();
1876 gtk_widget_show(hpaned);
1877 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1878 gtk_paned_add1(GTK_PANED(hpaned),
1879 GTK_WIDGET_PTR(mainwin->folderview));
1881 vpaned = gtk_vpaned_new();
1882 if (mainwin->summaryview->msg_is_toggled_on) {
1883 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1884 gtk_paned_add1(GTK_PANED(vpaned),
1885 GTK_WIDGET_PTR(mainwin->summaryview));
1887 gtk_paned_add2(GTK_PANED(hpaned),
1888 GTK_WIDGET_PTR(mainwin->summaryview));
1889 gtk_widget_ref(vpaned);
1891 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1892 prefs_common.summaryview_width,
1893 prefs_common.summaryview_height);
1894 gtk_paned_add2(GTK_PANED(vpaned),
1895 GTK_WIDGET_PTR(mainwin->messageview));
1896 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1897 prefs_common.mainview_width, -1);
1898 gtk_widget_set_usize(mainwin->window,
1899 prefs_common.folderview_width +
1900 prefs_common.mainview_width,
1901 prefs_common.mainwin_height);
1902 gtk_widget_show_all(vpaned);
1904 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1905 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1906 menu_set_sensitive(ifactory, "/View/Expand Summary View", TRUE);
1907 menu_set_sensitive(ifactory, "/View/Expand Message View", TRUE);
1908 menuitem = gtk_item_factory_get_widget(ifactory, "/View/Expand Message View");
1909 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
1911 mainwin->win.sep_none.hpaned = hpaned;
1912 mainwin->win.sep_none.vpaned = vpaned;
1914 case SEPARATE_FOLDER:
1915 vpaned = gtk_vpaned_new();
1916 if (mainwin->summaryview->msg_is_toggled_on) {
1917 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1919 gtk_paned_add1(GTK_PANED(vpaned),
1920 GTK_WIDGET_PTR(mainwin->summaryview));
1922 gtk_box_pack_start(GTK_BOX(vbox_body),
1923 GTK_WIDGET_PTR(mainwin->summaryview),
1925 gtk_widget_ref(vpaned);
1927 gtk_paned_add2(GTK_PANED(vpaned),
1928 GTK_WIDGET_PTR(mainwin->messageview));
1929 gtk_widget_show_all(vpaned);
1930 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1931 prefs_common.summaryview_width,
1932 prefs_common.summaryview_height);
1933 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1934 prefs_common.mainview_width, -1);
1935 gtk_widget_set_usize(mainwin->window,
1936 prefs_common.mainview_width,
1937 prefs_common.mainview_height);
1939 gtk_container_add(GTK_CONTAINER(folderwin),
1940 GTK_WIDGET_PTR(mainwin->folderview));
1942 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1943 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1945 mainwin->win.sep_folder.folderwin = folderwin;
1946 mainwin->win.sep_folder.vpaned = vpaned;
1948 gtk_widget_show_all(folderwin);
1950 case SEPARATE_MESSAGE:
1951 hpaned = gtk_hpaned_new();
1952 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1954 gtk_paned_add1(GTK_PANED(hpaned),
1955 GTK_WIDGET_PTR(mainwin->folderview));
1956 gtk_paned_add2(GTK_PANED(hpaned),
1957 GTK_WIDGET_PTR(mainwin->summaryview));
1958 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1959 prefs_common.summaryview_width,
1960 prefs_common.summaryview_height);
1961 gtk_widget_set_usize(mainwin->window,
1962 prefs_common.folderview_width +
1963 prefs_common.mainview_width,
1964 prefs_common.mainwin_height);
1965 gtk_widget_show_all(hpaned);
1966 gtk_container_add(GTK_CONTAINER(messagewin),
1967 GTK_WIDGET_PTR(mainwin->messageview));
1969 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1970 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1971 menu_set_sensitive(ifactory, "/View/Expand Summary View", FALSE);
1972 menu_set_sensitive(ifactory, "/View/Expand Message View", FALSE);
1974 mainwin->win.sep_message.messagewin = messagewin;
1975 mainwin->win.sep_message.hpaned = hpaned;
1977 gtk_widget_show_all(messagewin);
1980 gtk_box_pack_start(GTK_BOX(vbox_body),
1981 GTK_WIDGET_PTR(mainwin->summaryview),
1983 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1984 prefs_common.summaryview_width,
1985 prefs_common.summaryview_height);
1986 gtk_widget_set_usize(mainwin->window,
1987 prefs_common.mainview_width,
1988 prefs_common.mainwin_height);
1989 gtk_container_add(GTK_CONTAINER(folderwin),
1990 GTK_WIDGET_PTR(mainwin->folderview));
1991 gtk_container_add(GTK_CONTAINER(messagewin),
1992 GTK_WIDGET_PTR(mainwin->messageview));
1994 menu_set_sensitive(ifactory, "/View/Separate Message View", TRUE);
1995 menu_set_sensitive(ifactory, "/View/Separate Folder Tree", TRUE);
1997 mainwin->win.sep_both.folderwin = folderwin;
1998 mainwin->win.sep_both.messagewin = messagewin;
2000 gtk_widget_show_all(folderwin);
2001 gtk_widget_show_all(messagewin);
2005 mainwin->type = type;
2007 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2009 menuitem = gtk_item_factory_get_item
2010 (ifactory, "/View/Show or hide/Folder tree");
2011 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2012 menuitem = gtk_item_factory_get_item
2013 (ifactory, "/View/Show or hide/Message view");
2014 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2016 menuitem = gtk_item_factory_get_item
2017 (ifactory, "/View/Separate folder tree");
2018 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2019 ((type & SEPARATE_FOLDER) != 0));
2020 menuitem = gtk_item_factory_get_item
2021 (ifactory, "/View/Separate message view");
2022 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2023 ((type & SEPARATE_MESSAGE) != 0));
2025 debug_print(_("done.\n"));
2028 static void main_window_toolbar_create(MainWindow *mainwin,
2029 GtkWidget *container)
2032 GtkWidget *icon_wid;
2034 GtkWidget *getall_btn;
2035 GtkWidget *compose_mail_btn;
2036 GtkWidget *compose_news_btn;
2037 GtkWidget *reply_btn;
2038 GtkWidget *replyall_btn;
2039 GtkWidget *replysender_btn;
2041 GtkWidget *send_btn;
2043 GtkWidget *prefs_btn;
2044 GtkWidget *account_btn;
2046 GtkWidget *next_btn;
2047 GtkWidget *delete_btn;
2048 GtkWidget *exec_btn;
2050 GtkTooltips *tooltips;
2052 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
2054 gtk_container_add(GTK_CONTAINER(container), toolbar);
2055 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
2056 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
2057 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
2058 GTK_TOOLBAR_SPACE_LINE);
2060 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
2061 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2063 _("Get new mail from current account"),
2065 icon_wid, toolbar_inc_cb, mainwin);
2066 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
2067 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2069 _("Get new mail from all accounts"),
2075 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2077 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
2078 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2080 _("Send queued message(s)"),
2086 /* insert compose mail button widget */
2087 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
2088 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2090 _("Compose an email message"),
2093 toolbar_compose_mail_cb,
2096 /* insert compose news button widget */
2097 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2098 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2100 _("Compose a news message"),
2103 toolbar_compose_news_cb,
2106 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2110 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
2111 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2113 _("Reply to the message - Right button: more options"),
2119 /* replyall button */
2121 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
2122 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2124 _("Reply to all - Right button: more options"),
2127 toolbar_reply_to_all_cb,
2130 /* reply to sender button */
2131 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
2132 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2134 _("Reply to sender - Right button: more options"),
2137 toolbar_reply_to_sender_cb,
2140 /* forward button */
2141 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
2142 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2144 _("Forward the message - Right button: more options"),
2150 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2152 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
2153 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2155 _("Delete the message"),
2161 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
2162 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2164 _("Execute marked process"),
2170 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
2171 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2173 _("Next unread message"),
2176 toolbar_next_unread_cb,
2180 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2182 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2183 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2185 _("Common preferences"),
2190 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2191 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2193 _("Account setting"),
2198 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2199 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2203 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2204 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2207 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2208 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2211 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2212 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2215 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2216 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2220 mainwin->toolbar = toolbar;
2221 mainwin->get_btn = get_btn;
2222 mainwin->getall_btn = getall_btn;
2223 mainwin->compose_mail_btn = compose_mail_btn;
2224 mainwin->compose_news_btn = compose_news_btn;
2225 mainwin->reply_btn = reply_btn;
2226 mainwin->replyall_btn = replyall_btn;
2227 mainwin->replysender_btn = replysender_btn;
2228 mainwin->fwd_btn = fwd_btn;
2229 mainwin->send_btn = send_btn;
2231 mainwin->prefs_btn = prefs_btn;
2232 mainwin->account_btn = account_btn;
2234 mainwin->next_btn = next_btn;
2235 mainwin->delete_btn = delete_btn;
2236 mainwin->exec_btn = exec_btn;
2238 gtk_widget_show_all(toolbar);
2241 /* callback functions */
2242 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2244 MainWindow *mainwindow = (MainWindow *) data;
2248 if (event->button == 3) {
2249 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2250 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2251 menu_button_position, widget,
2252 event->button, event->time);
2256 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2258 MainWindow *mainwin = (MainWindow *)data;
2260 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2261 manage_window_focus_in(mainwin->window, NULL, NULL);
2264 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2266 MainWindow *mainwindow = (MainWindow *) data;
2270 if (event->button == 3) {
2271 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2272 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2273 menu_button_position, widget,
2274 event->button, event->time);
2278 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2280 MainWindow *mainwin = (MainWindow *)data;
2282 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2283 manage_window_focus_in(mainwin->window, NULL, NULL);
2286 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2288 MainWindow *mainwindow = (MainWindow *) data;
2289 GtkWidget *replysender_menu, *replysender_item;
2293 if (event->button == 3) {
2294 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2295 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2296 menu_button_position, widget,
2297 event->button, event->time);
2301 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2303 MainWindow *mainwin = (MainWindow *)data;
2305 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2306 manage_window_focus_in(mainwin->window, NULL, NULL);
2309 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2311 MainWindow *mainwindow = (MainWindow *) data;
2315 if (event->button == 3) {
2316 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2317 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2318 menu_button_position, widget,
2319 event->button, event->time);
2323 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2325 MainWindow *mainwin = (MainWindow *)data;
2327 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2328 manage_window_focus_in(mainwin->window, NULL, NULL);
2331 static void toolbar_inc_cb (GtkWidget *widget,
2334 MainWindow *mainwin = (MainWindow *)data;
2336 inc_mail_cb(mainwin, 0, NULL);
2339 static void toolbar_inc_all_cb (GtkWidget *widget,
2342 MainWindow *mainwin = (MainWindow *)data;
2344 inc_all_account_mail_cb(mainwin, 0, NULL);
2347 static void toolbar_send_cb (GtkWidget *widget,
2350 MainWindow *mainwin = (MainWindow *)data;
2352 send_queue_cb(mainwin, 0, NULL);
2355 static void toolbar_compose_cb (GtkWidget *widget,
2358 MainWindow *mainwin = (MainWindow *)data;
2360 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2361 compose_cb(mainwin, 0, NULL);
2363 compose_news_cb(mainwin, 0, NULL);
2366 static void toolbar_compose_news_cb (GtkWidget *widget,
2369 MainWindow *mainwin = (MainWindow *)data;
2371 compose_news_cb(mainwin, 0, NULL);
2374 static void toolbar_compose_mail_cb (GtkWidget *widget,
2377 MainWindow *mainwin = (MainWindow *)data;
2379 compose_mail_cb(mainwin, 0, NULL);
2382 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2384 MainWindow *mainwin = (MainWindow *)data;
2387 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2388 : COMPOSE_REPLY_WITHOUT_QUOTE,
2392 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2394 MainWindow *mainwin = (MainWindow *)data;
2397 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2398 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2403 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2405 MainWindow *mainwin = (MainWindow *)data;
2408 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2409 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2413 static void toolbar_forward_cb (GtkWidget *widget,
2416 MainWindow *mainwin = (MainWindow *)data;
2418 if (prefs_common.forward_as_attachment)
2419 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2421 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2424 static void toolbar_delete_cb (GtkWidget *widget,
2427 MainWindow *mainwin = (MainWindow *)data;
2429 summary_delete(mainwin->summaryview);
2432 static void toolbar_exec_cb (GtkWidget *widget,
2435 MainWindow *mainwin = (MainWindow *)data;
2437 summary_execute(mainwin->summaryview);
2440 static void toolbar_next_unread_cb (GtkWidget *widget,
2443 MainWindow *mainwin = (MainWindow *)data;
2445 next_unread_cb(mainwin, 0, NULL);
2448 static void toolbar_prefs_cb (GtkWidget *widget,
2451 prefs_common_open();
2454 static void toolbar_account_cb (GtkWidget *widget,
2457 MainWindow *mainwin = (MainWindow *)data;
2459 prefs_account_open_cb(mainwin, 0, NULL);
2463 static void toolbar_account_button_pressed(GtkWidget *widget,
2464 GdkEventButton *event,
2467 MainWindow *mainwin = (MainWindow *)data;
2470 if (event->button != 3) return;
2472 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2473 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2476 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2477 menu_button_position, widget,
2478 event->button, event->time);
2482 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2485 MainWindow *mainwin = (MainWindow *)data;
2489 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2490 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2493 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2494 menu_button_position, widget,
2495 event->button, event->time);
2498 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2500 MainWindow *mainwin = (MainWindow *)data;
2503 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2504 if (!button) return;
2505 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2506 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2507 manage_window_focus_in(mainwin->window, NULL, NULL);
2510 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2513 MainWindow *mainwin = (MainWindow *)data;
2515 if (mainwin->lock_count == 0)
2516 app_exit_cb(data, 0, widget);
2521 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2524 MainWindow *mainwin = (MainWindow *)data;
2525 GtkItemFactory *ifactory;
2526 GtkWidget *menuitem;
2528 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2529 menuitem = gtk_item_factory_get_item
2530 (ifactory, "/View/Expand Summary View");
2531 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2536 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2539 MainWindow *mainwin = (MainWindow *)data;
2540 GtkItemFactory *ifactory;
2541 GtkWidget *menuitem;
2543 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2544 menuitem = gtk_item_factory_get_item
2545 (ifactory, "/View/Expand Message View");
2546 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2551 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2554 main_window_add_mailbox(mainwin);
2557 static void add_mbox_cb(MainWindow *mainwin, guint action,
2560 main_window_add_mbox(mainwin);
2563 static void update_folderview_cb(MainWindow *mainwin, guint action,
2566 summary_show(mainwin->summaryview, NULL, FALSE);
2567 folderview_rescan_all();
2570 static void new_folder_cb(MainWindow *mainwin, guint action,
2573 folderview_new_folder(mainwin->folderview);
2576 static void rename_folder_cb(MainWindow *mainwin, guint action,
2579 folderview_rename_folder(mainwin->folderview);
2582 static void delete_folder_cb(MainWindow *mainwin, guint action,
2585 folderview_delete_folder(mainwin->folderview);
2588 static void import_mbox_cb(MainWindow *mainwin, guint action,
2591 import_mbox(mainwin->summaryview->folder_item);
2594 static void export_mbox_cb(MainWindow *mainwin, guint action,
2597 export_mbox(mainwin->summaryview->folder_item);
2600 static void empty_trash_cb(MainWindow *mainwin, guint action,
2603 main_window_empty_trash(mainwin, TRUE);
2606 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2608 summary_save_as(mainwin->summaryview);
2611 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2613 summary_print(mainwin->summaryview);
2616 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2618 if (prefs_common.confirm_on_exit) {
2619 if (alertpanel(_("Exit"), _("Exit this program?"),
2620 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2622 manage_window_focus_in(mainwin->window, NULL, NULL);
2625 app_will_exit(widget, mainwin);
2628 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2631 summary_search(mainwin->summaryview);
2633 message_search(mainwin->messageview);
2636 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2641 active = GTK_CHECK_MENU_ITEM(widget)->active;
2643 switch (mainwin->type) {
2645 case SEPARATE_MESSAGE:
2648 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2650 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2653 case SEPARATE_FOLDER:
2655 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2657 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2661 gtk_widget_show(mainwin->win.sep_both.folderwin);
2663 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2668 static void toggle_message_cb(MainWindow *mainwin, guint action,
2673 active = GTK_CHECK_MENU_ITEM(widget)->active;
2675 switch (mainwin->type) {
2677 case SEPARATE_FOLDER:
2679 case SEPARATE_MESSAGE:
2681 gtk_widget_show(mainwin->win.sep_message.messagewin);
2683 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2687 gtk_widget_show(mainwin->win.sep_both.messagewin);
2689 gtk_widget_hide(mainwin->win.sep_both.messagewin);
2694 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2697 /* activate_compose_button(mainwin, (ToolbarStyle)action,
2698 mainwin->compose_btn_type);
2699 set_toolbar_reply_button(mainwin, (ToolbarStyle)action);
2700 set_toolbar_replyall_button(mainwin, (ToolbarStyle)action);
2701 set_toolbar_replysender_button(mainwin, (ToolbarStyle)action);
2702 set_toolbar_forward_button(mainwin, (ToolbarStyle)action);*/
2704 mainwin->toolbar_style = (ToolbarStyle)action;
2705 prefs_common.toolbar_style = (ToolbarStyle)action;
2707 set_toolbar_style(mainwin);
2710 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2713 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2714 gtk_widget_show(mainwin->hbox_stat);
2715 prefs_common.show_statusbar = TRUE;
2717 gtk_widget_hide(mainwin->hbox_stat);
2718 prefs_common.show_statusbar = FALSE;
2722 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2724 summary_toggle_view_real(mainwin->summaryview);
2727 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2729 messageview_toggle_view_real(mainwin->messageview);
2732 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2734 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2735 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2737 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2741 static void online_switch_clicked (GtkButton *btn, gpointer data)
2743 MainWindow *mainwin;
2744 GtkItemFactory *ifactory;
2745 GtkCheckMenuItem *menuitem;
2747 mainwin = (MainWindow *) data;
2749 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2750 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2752 g_return_if_fail(mainwin != NULL);
2753 g_return_if_fail(menuitem != NULL);
2755 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2757 gtk_widget_hide (mainwin->online_switch);
2758 gtk_widget_show (mainwin->offline_switch);
2759 menuitem->active = TRUE;
2760 prefs_common.work_offline = TRUE;
2761 inc_autocheck_timer_remove();
2764 gtk_widget_hide (mainwin->offline_switch);
2765 gtk_widget_show (mainwin->online_switch);
2766 menuitem->active = FALSE;
2767 prefs_common.work_offline = FALSE;
2768 inc_autocheck_timer_set();
2772 static void separate_widget_cb(GtkCheckMenuItem *checkitem, guint action, GtkWidget *widget)
2774 MainWindow *mainwin;
2777 if (GTK_CHECK_MENU_ITEM(widget)->active)
2778 type = mainwin->type | action;
2780 type = mainwin->type & ~action;
2782 main_window_separation_change(mainwin, type);
2784 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2785 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2788 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2791 addressbook_open(NULL);
2794 static void log_window_show_cb(MainWindow *mainwin, guint action,
2797 log_window_show(mainwin->logwin);
2800 static void sel_download_cb(MainWindow *mainwin, guint action,
2803 selective_download(mainwin);
2806 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2808 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2811 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2814 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2817 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2822 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2826 if (prefs_common.work_offline)
2827 if (alertpanel(_("Offline warning"),
2828 _("You're working offline. Override?"),
2829 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
2832 for (list = folder_get_list(); list != NULL; list = list->next) {
2833 Folder *folder = list->data;
2835 if (folder->queue) {
2836 if (procmsg_send_queue
2837 (folder->queue, prefs_common.savemsg) < 0)
2838 alertpanel_error(_("Some errors occurred while sending queued messages."));
2839 statusbar_pop_all();
2840 folder_item_scan(folder->queue);
2841 folderview_update_item(folder->queue, TRUE);
2846 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2848 if (mainwin->summaryview->folder_item) {
2849 if (mainwin->summaryview->folder_item->folder->account != NULL
2850 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2851 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2853 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2859 static void compose_mail_cb(MainWindow *mainwin, guint action,
2866 if (mainwin->summaryview->folder_item) {
2867 ac = mainwin->summaryview->folder_item->folder->account;
2868 if (ac && ac->protocol != A_NNTP) {
2869 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2874 if(cur_account && (cur_account->protocol != A_NNTP)) {
2875 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2879 list = account_get_list();
2880 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2881 ac = (PrefsAccount *) cur->data;
2882 if (ac->protocol != A_NNTP) {
2883 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2889 static void compose_news_cb(MainWindow *mainwin, guint action,
2892 PrefsAccount * ac = NULL;
2896 if (mainwin->summaryview->folder_item) {
2897 ac = mainwin->summaryview->folder_item->folder->account;
2898 if (ac && ac->protocol == A_NNTP) {
2899 compose_new_with_recipient
2900 (ac, mainwin->summaryview->folder_item->path);
2905 list = account_get_list();
2906 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2907 ac = (PrefsAccount *) cur->data;
2908 if (ac->protocol == A_NNTP) {
2915 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2917 summary_reply(mainwin->summaryview, (ComposeMode)action);
2920 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2922 summary_move_to(mainwin->summaryview);
2925 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2927 summary_copy_to(mainwin->summaryview);
2930 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2932 summary_delete(mainwin->summaryview);
2935 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2937 summary_open_msg(mainwin->summaryview);
2940 static void view_source_cb(MainWindow *mainwin, guint action,
2943 summary_view_source(mainwin->summaryview);
2946 static void show_all_header_cb(MainWindow *mainwin, guint action,
2949 if (mainwin->menu_lock_count) return;
2950 summary_display_msg_selected(mainwin->summaryview,
2951 GTK_CHECK_MENU_ITEM(widget)->active);
2954 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2956 summary_reedit(mainwin->summaryview);
2959 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2961 summary_mark(mainwin->summaryview);
2964 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2966 summary_unmark(mainwin->summaryview);
2969 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2972 summary_mark_as_unread(mainwin->summaryview);
2975 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2978 summary_mark_as_read(mainwin->summaryview);
2981 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2984 summary_mark_all_read(mainwin->summaryview);
2987 static void add_address_cb(MainWindow *mainwin, guint action,
2990 summary_add_address(mainwin->summaryview);
2993 static void set_charset_cb(MainWindow *mainwin, guint action,
2998 str = conv_get_charset_str((CharSet)action);
2999 g_free(prefs_common.force_charset);
3000 prefs_common.force_charset = str ? g_strdup(str) : NULL;
3002 summary_redisplay_msg(mainwin->summaryview);
3004 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
3007 static void hide_read_messages (MainWindow *mainwin, guint action,
3010 if (!mainwin->summaryview->folder_item
3011 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
3013 summary_toggle_show_read_messages(mainwin->summaryview);
3016 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3018 GtkItemFactory *ifactory;
3020 if (mainwin->menu_lock_count) return;
3021 if (!mainwin->summaryview->folder_item) return;
3023 ifactory = gtk_item_factory_from_widget(widget);
3025 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3026 summary_thread_build(mainwin->summaryview);
3027 mainwin->summaryview->folder_item->threaded = TRUE;
3029 summary_unthread(mainwin->summaryview);
3030 mainwin->summaryview->folder_item->threaded = FALSE;
3034 static void expand_threads_cb(MainWindow *mainwin, guint action,
3037 summary_expand_threads(mainwin->summaryview);
3040 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3043 summary_collapse_threads(mainwin->summaryview);
3046 static void set_display_item_cb(MainWindow *mainwin, guint action,
3049 prefs_summary_column_open();
3052 static void sort_summary_cb(MainWindow *mainwin, guint action,
3055 FolderItem *item = mainwin->summaryview->folder_item;
3056 GtkItemFactory *ifactory;
3057 GtkWidget *menuitem;
3059 if (mainwin->menu_lock_count) return;
3061 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3062 menuitem = gtk_item_factory_get_item
3063 (ifactory, "/View/Sort/Ascending");
3064 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3065 GTK_CHECK_MENU_ITEM(menuitem)->active
3066 ? SORT_ASCENDING : SORT_DESCENDING);
3070 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3073 FolderItem *item = mainwin->summaryview->folder_item;
3075 if (mainwin->menu_lock_count) return;
3077 summary_sort(mainwin->summaryview,
3078 item->sort_key, (FolderSortType)action);
3081 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3084 summary_attract_by_subject(mainwin->summaryview);
3087 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3090 summary_delete_duplicated(mainwin->summaryview);
3093 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3095 summary_filter(mainwin->summaryview);
3098 static void execute_summary_cb(MainWindow *mainwin, guint action,
3101 summary_execute(mainwin->summaryview);
3104 static void update_summary_cb(MainWindow *mainwin, guint action,
3108 FolderView *folderview = mainwin->folderview;
3110 if (!mainwin->summaryview->folder_item) return;
3111 if (!folderview->opened) return;
3113 folder_update_op_count();
3115 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3116 folderview->opened);
3119 summary_show(mainwin->summaryview, fitem, TRUE);
3122 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3124 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3127 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3129 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3132 static void prev_unread_cb(MainWindow *mainwin, guint action,
3135 summary_select_prev_unread(mainwin->summaryview);
3138 static void next_unread_cb(MainWindow *mainwin, guint action,
3141 summary_select_next_unread(mainwin->summaryview);
3144 static void prev_marked_cb(MainWindow *mainwin, guint action,
3147 summary_select_prev_marked(mainwin->summaryview);
3150 static void next_marked_cb(MainWindow *mainwin, guint action,
3153 summary_select_next_marked(mainwin->summaryview);
3156 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3159 summary_select_prev_labeled(mainwin->summaryview);
3162 static void next_labeled_cb(MainWindow *mainwin, guint action,
3165 summary_select_next_labeled(mainwin->summaryview);
3168 static void goto_folder_cb(MainWindow *mainwin, guint action,
3171 FolderItem *to_folder;
3173 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3176 folderview_select(mainwin->folderview, to_folder);
3179 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3181 messageview_copy_clipboard(mainwin->messageview);
3184 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3186 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3187 summary_select_all(mainwin->summaryview);
3188 else if (mainwin->summaryview->msg_is_toggled_on && (
3189 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->textview->text) ||
3190 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->mimeview->ctree) ||
3191 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->mimeview->notebook) ||
3192 GTK_WIDGET_HAS_FOCUS(mainwin->messageview->mimeview->textview->text)))
3193 messageview_select_all(mainwin->messageview);
3196 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3198 if (mainwin->summaryview->msg_is_toggled_on)
3199 summary_select_thread(mainwin->summaryview);
3202 static void create_filter_cb(MainWindow *mainwin, guint action,
3205 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3208 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3211 prefs_common_open();
3214 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
3217 prefs_filter_open(NULL, NULL);
3220 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3223 prefs_scoring_open(NULL);
3226 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3229 prefs_filtering_open(NULL, NULL, NULL);
3232 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3235 prefs_template_open();
3238 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3241 prefs_actions_open(mainwin);
3244 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3248 new_account_cb(mainwin, 0, widget);
3250 gboolean prev_default = cur_account->is_default;
3252 prefs_account_open(cur_account);
3253 if (!prev_default && cur_account->is_default)
3254 account_set_as_default(cur_account);
3255 account_save_config_all();
3257 main_window_reflect_prefs_all();
3261 static void new_account_cb(MainWindow *mainwin, guint action,
3264 account_edit_open();
3265 if (!compose_get_compose_list()) account_add();
3268 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3270 cur_account = (PrefsAccount *)data;
3271 main_window_reflect_prefs_all();
3274 static void manual_open_cb(MainWindow *mainwin, guint action,
3277 manual_open((ManualLang)action);
3280 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3282 faq_open((ManualLang)action);
3285 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3287 MainWindow *mainwin = (MainWindow *)data;
3291 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3292 LOCAL_FOLDER(folder)->rootpath,
3296 str = g_strdup_printf(_("Scanning folder %s ..."),
3297 LOCAL_FOLDER(folder)->rootpath);
3299 STATUSBAR_PUSH(mainwin, str);
3300 STATUSBAR_POP(mainwin);
3304 static void activate_compose_button (MainWindow *mainwin,
3306 ComposeButtonType type)
3308 SensitiveCond state = main_window_get_current_state(mainwin);
3310 if (style == TOOLBAR_NONE)
3313 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
3314 : mainwin->compose_news_btn);
3315 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
3316 : mainwin->compose_mail_btn);
3317 mainwin->compose_btn_type = type;
3320 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
3322 if (mainwin->compose_btn_type != compose_btn_type)
3323 activate_compose_button(mainwin,
3324 prefs_common.toolbar_style,
3328 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
3330 MainWindow *mainwin = (MainWindow*) data;
3332 if (!mainwin) return;
3334 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_view_btn), GTK_WIDGET_IS_SENSITIVE(widget));
3337 #define BREAK_ON_MODIFIER_KEY() \
3338 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3340 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3342 MainWindow *mainwin = (MainWindow*) data;
3344 if (!mainwin || !event) return;
3346 switch (event->keyval) {
3347 case GDK_Q: /* Quit */
3348 BREAK_ON_MODIFIER_KEY();
3350 app_exit_cb(mainwin, 0, NULL);
3357 #undef BREAK_ON_MODIFIER_KEY
3359 static void set_toolbar_style(MainWindow *mainwin)
3361 switch (prefs_common.toolbar_style) {
3363 gtk_widget_hide(mainwin->handlebox);
3366 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3370 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3374 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3379 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3380 gtk_widget_show(mainwin->handlebox);
3381 gtk_widget_queue_resize(mainwin->handlebox);
3383 if (prefs_common.immediate_exec)
3384 gtk_widget_hide(mainwin->exec_btn);
3386 gtk_widget_show(mainwin->exec_btn);
3391 * Harvest addresses for selected folder.
3393 static void addr_harvest_cb( MainWindow *mainwin,
3397 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3401 * Harvest addresses for selected messages in summary view.
3403 static void addr_harvest_msg_cb( MainWindow *mainwin,
3407 summary_harvest_address( mainwin->summaryview );