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 separate_widget_cb (MainWindow *mainwin,
257 static void addressbook_open_cb (MainWindow *mainwin,
260 static void log_window_show_cb (MainWindow *mainwin,
263 static void sel_download_cb (MainWindow *mainwin,
267 static void inc_mail_cb (MainWindow *mainwin,
270 static void inc_all_account_mail_cb (MainWindow *mainwin,
273 static void inc_cancel_cb (MainWindow *mainwin,
277 static void send_queue_cb (MainWindow *mainwin,
281 static void compose_cb (MainWindow *mainwin,
284 static void compose_mail_cb(MainWindow *mainwin, guint action,
286 static void compose_news_cb(MainWindow *mainwin, guint action,
288 static void reply_cb (MainWindow *mainwin,
292 static void open_msg_cb (MainWindow *mainwin,
296 static void view_source_cb (MainWindow *mainwin,
300 static void show_all_header_cb (MainWindow *mainwin,
304 static void reedit_cb (MainWindow *mainwin,
308 static void move_to_cb (MainWindow *mainwin,
311 static void copy_to_cb (MainWindow *mainwin,
314 static void delete_cb (MainWindow *mainwin,
318 static void mark_cb (MainWindow *mainwin,
321 static void unmark_cb (MainWindow *mainwin,
325 static void mark_as_unread_cb (MainWindow *mainwin,
328 static void mark_as_read_cb (MainWindow *mainwin,
331 static void mark_all_read_cb (MainWindow *mainwin,
334 static void add_address_cb (MainWindow *mainwin,
338 static void set_charset_cb (MainWindow *mainwin,
342 static void hide_read_messages (MainWindow *mainwin,
346 static void thread_cb (MainWindow *mainwin,
349 static void expand_threads_cb (MainWindow *mainwin,
352 static void collapse_threads_cb (MainWindow *mainwin,
356 static void set_display_item_cb (MainWindow *mainwin,
359 static void sort_summary_cb (MainWindow *mainwin,
362 static void sort_summary_type_cb (MainWindow *mainwin,
365 static void attract_by_subject_cb(MainWindow *mainwin,
369 static void delete_duplicated_cb (MainWindow *mainwin,
372 static void filter_cb (MainWindow *mainwin,
375 static void execute_summary_cb (MainWindow *mainwin,
378 static void update_summary_cb (MainWindow *mainwin,
382 static void prev_cb (MainWindow *mainwin,
385 static void next_cb (MainWindow *mainwin,
389 static void prev_unread_cb (MainWindow *mainwin,
392 static void next_unread_cb (MainWindow *mainwin,
395 static void prev_marked_cb (MainWindow *mainwin,
398 static void next_marked_cb (MainWindow *mainwin,
401 static void prev_labeled_cb (MainWindow *mainwin,
404 static void next_labeled_cb (MainWindow *mainwin,
408 static void goto_folder_cb (MainWindow *mainwin,
412 static void copy_cb (MainWindow *mainwin,
415 static void allsel_cb (MainWindow *mainwin,
418 static void selthread_cb (MainWindow *mainwin,
421 static void create_filter_cb (MainWindow *mainwin,
425 static void prefs_common_open_cb (MainWindow *mainwin,
428 static void prefs_filter_open_cb (MainWindow *mainwin,
431 static void prefs_scoring_open_cb (MainWindow *mainwin,
434 static void prefs_filtering_open_cb (MainWindow *mainwin,
437 static void prefs_account_open_cb(MainWindow *mainwin,
440 static void prefs_template_open_cb (MainWindow *mainwin,
443 static void prefs_actions_open_cb (MainWindow *mainwin,
447 static void new_account_cb (MainWindow *mainwin,
451 static void account_menu_cb (GtkMenuItem *menuitem,
454 static void online_switch_clicked(GtkButton *btn,
457 static void manual_open_cb (MainWindow *mainwin,
460 static void faq_open_cb (MainWindow *mainwin,
464 static void scan_tree_func (Folder *folder,
468 static void activate_compose_button (MainWindow *mainwin,
470 ComposeButtonType type);
472 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget,
476 static void key_pressed (GtkWidget *widget,
480 static void set_toolbar_style(MainWindow *mainwin);
482 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
484 static void addr_harvest_cb ( MainWindow *mainwin,
488 static void addr_harvest_msg_cb ( MainWindow *mainwin,
492 #define SEPARATE_ACTION 500
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/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
514 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
516 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
517 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
518 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
519 {N_("/_Edit/Select thread"), "<control>Z", selthread_cb, 0, NULL},
520 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
521 {N_("/_Edit/_Find in current message..."),
522 "<control>F", search_cb, 0, NULL},
523 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
524 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
525 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
526 {N_("/_View/Show or hi_de/_Folder tree"),
527 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
528 {N_("/_View/Show or hi_de/_Message view"),
529 "V", toggle_message_cb, 0, "<ToggleItem>"},
530 {N_("/_View/Show or hi_de/_Toolbar"),
531 NULL, NULL, 0, "<Branch>"},
532 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
533 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
534 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
535 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
536 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
537 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
538 {N_("/_View/Show or hi_de/_Toolbar/_None"),
539 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
540 {N_("/_View/Show or hi_de/Status _bar"),
541 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
542 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
543 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
544 {N_("/_View/Separate m_essage view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
545 {N_("/_View/E_xpand Summary View"), "V", toggle_expand_summaryview_cb, 0, "<ToggleItem>"},
546 {N_("/_View/Ex_pand Message View"), "<shift>V", toggle_expand_messageview_cb, 0, "<ToggleItem>"},
547 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
548 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
549 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
550 {N_("/_View/_Sort/by s_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
551 {N_("/_View/_Sort/by _date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
552 {N_("/_View/_Sort/by _from"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
553 {N_("/_View/_Sort/by _subject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
554 {N_("/_View/_Sort/by _color label"),
555 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
556 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
557 {N_("/_View/_Sort/by _unread"), NULL, sort_summary_cb, SORT_BY_UNREAD, "/View/Sort/by number"},
558 {N_("/_View/_Sort/by a_ttachment"),
559 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
560 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
561 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
562 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
563 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
564 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
565 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
566 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
567 {N_("/_View/_Sort/_Attract by subject"),
568 NULL, attract_by_subject_cb, 0, NULL},
569 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
570 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
571 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
572 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
573 {N_("/_View/Set display _item..."), NULL, set_display_item_cb, 0, NULL},
575 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
576 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
577 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
578 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
579 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
580 {N_("/_View/_Go to/P_rev unread message"),
581 "<shift>P", prev_unread_cb, 0, NULL},
582 {N_("/_View/_Go to/N_ext unread message"),
583 "<shift>N", next_unread_cb, 0, NULL},
584 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
585 {N_("/_View/_Go to/Prev _marked message"),
586 NULL, prev_marked_cb, 0, NULL},
587 {N_("/_View/_Go to/Next m_arked message"),
588 NULL, next_marked_cb, 0, NULL},
589 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
590 {N_("/_View/_Go to/Prev _labeled message"),
591 NULL, prev_labeled_cb, 0, NULL},
592 {N_("/_View/_Go to/Next la_beled message"),
593 NULL, next_labeled_cb, 0, NULL},
594 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
595 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
596 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
598 #define CODESET_SEPARATOR \
599 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"}
600 #define CODESET_ACTION(action) \
601 NULL, set_charset_cb, action, "/View/Code set/Auto detect"
603 {N_("/_View/_Code set"), NULL, NULL, 0, "<Branch>"},
604 {N_("/_View/_Code set/_Auto detect"),
605 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
606 {N_("/_View/_Code set/---"), NULL, NULL, 0, "<Separator>"},
607 {N_("/_View/_Code set/7bit ascii (US-ASC_II)"),
608 CODESET_ACTION(C_US_ASCII)},
611 {N_("/_View/_Code set/Unicode (_UTF-8)"),
612 CODESET_ACTION(C_UTF_8)},
615 {N_("/_View/_Code set/Western European (ISO-8859-_1)"),
616 CODESET_ACTION(C_ISO_8859_1)},
617 {N_("/_View/_Code set/Western European (ISO-8859-15)"),
618 CODESET_ACTION(C_ISO_8859_15)},
621 {N_("/_View/_Code set/Central European (ISO-8859-_2)"),
622 CODESET_ACTION(C_ISO_8859_2)},
624 {N_("/_View/_Code set/_Baltic (ISO-8859-13)"),
625 CODESET_ACTION(C_ISO_8859_13)},
626 {N_("/_View/_Code set/Baltic (ISO-8859-_4)"),
627 CODESET_ACTION(C_ISO_8859_4)},
629 {N_("/_View/_Code set/Greek (ISO-8859-_7)"),
630 CODESET_ACTION(C_ISO_8859_7)},
632 {N_("/_View/_Code set/Turkish (ISO-8859-_9)"),
633 CODESET_ACTION(C_ISO_8859_9)},
635 {N_("/_View/_Code set/Cyrillic (ISO-8859-_5)"),
636 CODESET_ACTION(C_ISO_8859_5)},
637 {N_("/_View/_Code set/Cyrillic (KOI8-_R)"),
638 CODESET_ACTION(C_KOI8_R)},
639 {N_("/_View/_Code set/Cyrillic (Windows-1251)"),
640 CODESET_ACTION(C_WINDOWS_1251)},
643 {N_("/_View/_Code set/Japanese (ISO-2022-_JP)"),
644 CODESET_ACTION(C_ISO_2022_JP)},
646 {N_("/_View/_Code set/Japanese (ISO-2022-JP-2)"),
647 CODESET_ACTION(C_ISO_2022_JP_2)},
649 {N_("/_View/_Code set/Japanese (_EUC-JP)"),
650 CODESET_ACTION(C_EUC_JP)},
651 {N_("/_View/_Code set/Japanese (_Shift__JIS)"),
652 CODESET_ACTION(C_SHIFT_JIS)},
655 {N_("/_View/_Code set/Simplified Chinese (_GB2312)"),
656 CODESET_ACTION(C_GB2312)},
657 {N_("/_View/_Code set/Traditional Chinese (_Big5)"),
658 CODESET_ACTION(C_BIG5)},
659 {N_("/_View/_Code set/Traditional Chinese (EUC-_TW)"),
660 CODESET_ACTION(C_EUC_TW)},
661 {N_("/_View/_Code set/Chinese (ISO-2022-_CN)"),
662 CODESET_ACTION(C_ISO_2022_CN)},
664 {N_("/_View/_Code set/Korean (EUC-_KR)"),
665 CODESET_ACTION(C_EUC_KR)},
666 {N_("/_View/_Code set/Korean (ISO-2022-KR)"),
667 CODESET_ACTION(C_ISO_2022_KR)},
669 {N_("/_View/_Code set/Thai (TIS-620)"),
670 CODESET_ACTION(C_TIS_620)},
671 {N_("/_View/_Code set/Thai (Windows-874)"),
672 CODESET_ACTION(C_WINDOWS_874)},
675 #undef CODESET_SEPARATOR
676 #undef CODESET_ACTION
678 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
679 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
680 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
681 {N_("/_View/Show all _header"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
682 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
683 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
685 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
686 {N_("/_Message/Get new ma_il"), "<control>I", inc_mail_cb, 0, NULL},
687 {N_("/_Message/Get from _all accounts"),
688 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
689 {N_("/_Message/Cancel receivin_g"), NULL, inc_cancel_cb, 0, NULL},
690 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
691 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
692 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
693 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
694 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
695 {N_("/_Message/_Reply"), "<control>R", reply_cb, COMPOSE_REPLY, NULL},
696 {N_("/_Message/Repl_y to sender"), "<control><alt>R", reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
697 {N_("/_Message/Follow-up and reply to"), NULL, reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
698 {N_("/_Message/Reply to a_ll"), "<shift><control>R", reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
699 {N_("/_Message/_Forward"), "<control><alt>F", reply_cb, COMPOSE_FORWARD, NULL},
700 {N_("/_Message/Redirect"), NULL, reply_cb, COMPOSE_REDIRECT, NULL},
701 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
702 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
703 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
704 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
705 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
706 {N_("/_Message/_Delete"), "<control>D", delete_cb, 0, NULL},
707 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
708 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
709 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
710 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
711 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
712 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
713 {N_("/_Message/_Mark/Mark as rea_d"),
714 NULL, mark_as_read_cb, 0, NULL},
715 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
717 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
718 {N_("/_Tools/_Selective download..."), "<alt>S", sel_download_cb, 0, NULL},
719 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
720 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
721 {N_("/_Tools/Add sender to address boo_k"),
722 NULL, add_address_cb, 0, NULL},
723 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
724 {N_("/_Tools/_Harvest addresses/from _Folder..."),
725 NULL, addr_harvest_cb, 0, NULL},
726 {N_("/_Tools/_Harvest addresses/from _Messages..."),
727 NULL, addr_harvest_msg_cb, 0, NULL},
728 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
729 {N_("/_Tools/_Filter messages"), NULL, filter_cb, 0, NULL},
730 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
731 {N_("/_Tools/_Create filter rule/_Automatically"),
732 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
733 {N_("/_Tools/_Create filter rule/by _From"),
734 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
735 {N_("/_Tools/_Create filter rule/by _To"),
736 NULL, create_filter_cb, FILTER_BY_TO, NULL},
737 {N_("/_Tools/_Create filter rule/by _Subject"),
738 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
739 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
740 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
741 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
742 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
743 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
744 {N_("/_Tools/Delete du_plicated messages"),
745 NULL, delete_duplicated_cb, 0, NULL},
746 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
747 {N_("/_Tools/_Log window"), "<control>L", log_window_show_cb, 0, NULL},
749 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
750 {N_("/_Configuration/_Common preferences..."),
751 NULL, prefs_common_open_cb, 0, NULL},
752 {N_("/_Configuration/_Filter setting..."),
753 NULL, prefs_filter_open_cb, 0, NULL},
754 {N_("/_Configuration/_Scoring..."),
755 NULL, prefs_scoring_open_cb, 0, NULL},
756 {N_("/_Configuration/_Filtering..."),
757 NULL, prefs_filtering_open_cb, 0, NULL},
758 {N_("/_Configuration/_Template..."), NULL, prefs_template_open_cb, 0, NULL},
759 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
760 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
761 {N_("/_Configuration/_Preferences for current account..."),
762 NULL, prefs_account_open_cb, 0, NULL},
763 {N_("/_Configuration/Create _new account..."),
764 NULL, new_account_cb, 0, NULL},
765 {N_("/_Configuration/_Edit accounts..."),
766 NULL, account_edit_open, 0, NULL},
767 {N_("/_Configuration/C_hange current account"),
768 NULL, NULL, 0, "<Branch>"},
770 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
771 {N_("/_Help/_Manual"), NULL, NULL, 0, "<Branch>"},
772 {N_("/_Help/_Manual/_English"), NULL, manual_open_cb, MANUAL_LANG_EN, NULL},
773 {N_("/_Help/_Manual/_German"), NULL, manual_open_cb, MANUAL_LANG_DE, NULL},
774 {N_("/_Help/_Manual/_Spanish"), NULL, manual_open_cb, MANUAL_LANG_ES, NULL},
775 {N_("/_Help/_Manual/_French"), NULL, manual_open_cb, MANUAL_LANG_FR, NULL},
776 {N_("/_Help/_Manual/_Japanese"), NULL, manual_open_cb, MANUAL_LANG_JA, NULL},
777 {N_("/_Help/_FAQ"), NULL, NULL, 0, "<Branch>"},
778 {N_("/_Help/_FAQ/_English"), NULL, faq_open_cb, MANUAL_LANG_EN, NULL},
779 {N_("/_Help/_FAQ/_German"), NULL, faq_open_cb, MANUAL_LANG_DE, NULL},
780 {N_("/_Help/_FAQ/_Spanish"), NULL, faq_open_cb, MANUAL_LANG_ES, NULL},
781 {N_("/_Help/_FAQ/_French"), NULL, faq_open_cb, MANUAL_LANG_FR, NULL},
782 {N_("/_Help/_FAQ/_Italian"), NULL, faq_open_cb, MANUAL_LANG_IT, NULL},
783 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
784 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
786 static GtkItemFactoryEntry reply_popup_entries[] =
788 {N_("/Reply with _quote"), NULL, reply_cb, COMPOSE_REPLY_WITH_QUOTE, NULL},
789 {N_("/_Reply without quote"), NULL, reply_cb, COMPOSE_REPLY_WITHOUT_QUOTE, NULL}
791 static GtkItemFactoryEntry replyall_popup_entries[] =
793 {N_("/Reply to all with _quote"), "<shift>A", reply_cb, COMPOSE_REPLY_TO_ALL_WITH_QUOTE, NULL},
794 {N_("/_Reply to all without quote"), "a", reply_cb, COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE, NULL}
796 static GtkItemFactoryEntry replysender_popup_entries[] =
798 {N_("/Reply to sender with _quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITH_QUOTE, NULL},
799 {N_("/_Reply to sender without quote"), NULL, reply_cb, COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE, NULL}
801 static GtkItemFactoryEntry fwd_popup_entries[] =
803 {N_("/_Forward message (inline style)"), "f", reply_cb, COMPOSE_FORWARD_INLINE, NULL},
804 {N_("/Forward message as _attachment"), "<shift>F", reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL}
807 MainWindow *main_window_create(SeparateType type)
813 GtkWidget *handlebox;
814 GtkWidget *vbox_body;
815 GtkWidget *hbox_stat;
816 GtkWidget *statusbar;
817 GtkWidget *progressbar;
818 GtkWidget *statuslabel;
819 GtkWidget *ac_button;
821 GtkWidget *online_status;
822 GtkWidget *offline_status;
823 GtkWidget *online_switch;
824 GtkWidget *offline_switch;
826 FolderView *folderview;
827 SummaryView *summaryview;
828 MessageView *messageview;
829 GdkColormap *colormap;
832 guint n_menu_entries;
833 GtkItemFactory *ifactory;
836 GtkWidget *compose_popup;
837 GtkWidget *reply_popup;
838 GtkWidget *replyall_popup;
839 GtkWidget *replysender_popup;
840 GtkWidget *fwd_popup;
843 static GdkGeometry geometry;
845 debug_print(_("Creating main window...\n"));
846 mainwin = g_new0(MainWindow, 1);
849 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
850 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
851 gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
852 gtk_window_set_wmclass(GTK_WINDOW(window), "main_window", "Sylpheed");
854 if (!geometry.min_height) {
855 geometry.min_width = 320;
856 geometry.min_height = 200;
858 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
861 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
862 GTK_SIGNAL_FUNC(main_window_close_cb), mainwin);
863 MANAGE_WINDOW_SIGNALS_CONNECT(window);
864 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
865 GTK_SIGNAL_FUNC(key_pressed), mainwin);
867 gtk_widget_realize(window);
868 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
871 gtkut_widget_set_app_icon(window);
873 vbox = gtk_vbox_new(FALSE, 0);
874 gtk_widget_show(vbox);
875 gtk_container_add(GTK_CONTAINER(window), vbox);
878 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
879 menubar = menubar_create(window, mainwin_entries,
880 n_menu_entries, "<Main>", mainwin);
881 gtk_widget_show(menubar);
882 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
883 ifactory = gtk_item_factory_from_widget(menubar);
885 handlebox = gtk_handle_box_new();
886 gtk_widget_show(handlebox);
887 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
889 /* create the popup menus for the reply buttons specials */
890 n_menu_entries = sizeof(reply_popup_entries) /
891 sizeof(reply_popup_entries[0]);
892 reply_popup = popupmenu_create(window, reply_popup_entries, n_menu_entries,
893 "<ReplyPopup>", mainwin);
894 gtk_signal_connect(GTK_OBJECT(reply_popup), "selection_done",
895 GTK_SIGNAL_FUNC(toolbar_reply_popup_closed_cb), mainwin);
896 n_menu_entries = sizeof(replyall_popup_entries) /
897 sizeof(replyall_popup_entries[0]);
898 replyall_popup = popupmenu_create(window, replyall_popup_entries, n_menu_entries,
899 "<ReplyAllPopup>", mainwin);
900 gtk_signal_connect(GTK_OBJECT(replyall_popup), "selection_done",
901 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_closed_cb), mainwin);
902 n_menu_entries = sizeof(replysender_popup_entries) /
903 sizeof(replysender_popup_entries[0]);
904 replysender_popup = popupmenu_create(window, replysender_popup_entries, n_menu_entries,
905 "<ReplySenderPopup>", mainwin);
906 gtk_signal_connect(GTK_OBJECT(replysender_popup), "selection_done",
907 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_closed_cb), mainwin);
908 /* create the popup menu for the forward button */
909 n_menu_entries = sizeof(fwd_popup_entries) /
910 sizeof(fwd_popup_entries[0]);
911 fwd_popup = popupmenu_create(window, fwd_popup_entries, n_menu_entries,
912 "<ForwardPopup>", mainwin);
913 gtk_signal_connect(GTK_OBJECT(fwd_popup), "selection_done",
914 GTK_SIGNAL_FUNC(toolbar_forward_popup_closed_cb), mainwin);
916 main_window_toolbar_create(mainwin, handlebox);
918 /* vbox that contains body */
919 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
920 gtk_widget_show(vbox_body);
921 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
922 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
924 hbox_stat = gtk_hbox_new(FALSE, 2);
925 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
927 statusbar = statusbar_create();
928 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
930 progressbar = gtk_progress_bar_new();
931 gtk_widget_set_usize(progressbar, 120, 1);
932 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
934 online_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_ONLINE);
935 offline_status = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_WORK_OFFLINE);
936 online_switch = gtk_button_new ();
937 offline_switch = gtk_button_new ();
938 gtk_container_add (GTK_CONTAINER(online_switch), online_status);
939 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
940 gtk_signal_connect (GTK_OBJECT(online_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
941 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
942 gtk_container_add (GTK_CONTAINER(offline_switch), offline_status);
943 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
944 gtk_signal_connect (GTK_OBJECT(offline_switch), "clicked", (GtkSignalFunc)online_switch_clicked, mainwin);
945 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
947 statuslabel = gtk_label_new("");
948 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
950 ac_button = gtk_button_new();
951 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
952 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
953 gtk_widget_set_usize(ac_button, -1, 1);
954 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
955 gtk_signal_connect(GTK_OBJECT(ac_button), "button_press_event",
956 GTK_SIGNAL_FUNC(ac_label_button_pressed), mainwin);
958 ac_label = gtk_label_new("");
959 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
961 gtk_widget_show_all(hbox_stat);
963 gtk_widget_hide(offline_switch);
965 mainwin->folderview = folderview = folderview_create();
966 mainwin->summaryview = summaryview = summary_create();
967 mainwin->messageview = messageview = messageview_create();
968 mainwin->logwin = log_window_create();
970 folderview->mainwin = mainwin;
971 folderview->summaryview = summaryview;
973 summaryview->mainwin = mainwin;
974 summaryview->folderview = folderview;
975 summaryview->messageview = messageview;
976 summaryview->window = window;
978 messageview->mainwin = mainwin;
980 mainwin->window = window;
981 mainwin->vbox = vbox;
982 mainwin->menubar = menubar;
983 mainwin->handlebox = handlebox;
984 mainwin->vbox_body = vbox_body;
985 mainwin->hbox_stat = hbox_stat;
986 mainwin->statusbar = statusbar;
987 mainwin->progressbar = progressbar;
988 mainwin->statuslabel = statuslabel;
989 mainwin->ac_button = ac_button;
990 mainwin->ac_label = ac_label;
991 mainwin->reply_popup = reply_popup;
992 mainwin->replyall_popup = replyall_popup;
993 mainwin->replysender_popup = replysender_popup;
994 mainwin->fwd_popup = fwd_popup;
995 mainwin->online_switch = online_switch;
996 mainwin->offline_switch = offline_switch;
998 /* set context IDs for status bar */
999 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1000 (GTK_STATUSBAR(statusbar), "Main Window");
1001 mainwin->folderview_cid = gtk_statusbar_get_context_id
1002 (GTK_STATUSBAR(statusbar), "Folder View");
1003 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1004 (GTK_STATUSBAR(statusbar), "Summary View");
1006 /* allocate colors for summary view and folder view */
1007 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1008 summaryview->color_marked.blue = (guint16)65535;
1010 summaryview->color_dim.red = summaryview->color_dim.green =
1011 summaryview->color_dim.blue = COLOR_DIM;
1013 folderview->color_new.red = (guint16)55000;
1014 folderview->color_new.green = folderview->color_new.blue = 15000;
1016 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1017 &folderview->color_op);
1019 summaryview->color_important.red = 0;
1020 summaryview->color_important.green = 0;
1021 summaryview->color_important.blue = (guint16)65535;
1023 color[0] = summaryview->color_marked;
1024 color[1] = summaryview->color_dim;
1025 color[2] = folderview->color_new;
1026 color[3] = folderview->color_op;
1028 colormap = gdk_window_get_colormap(window->window);
1029 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1030 for (i = 0; i < 4; i++) {
1031 if (success[i] == FALSE)
1032 g_warning(_("MainWindow: color allocation %d failed\n"), i);
1035 debug_print(_("done.\n"));
1037 messageview->visible = TRUE;
1039 main_window_set_widgets(mainwin, type);
1041 /* set menu items */
1042 ifactory = gtk_item_factory_from_widget(menubar);
1043 menuitem = gtk_item_factory_get_item
1044 (ifactory, "/View/Code set/Auto detect");
1045 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1047 switch (prefs_common.toolbar_style) {
1049 menuitem = gtk_item_factory_get_item
1050 (ifactory, "/View/Show or hide/Toolbar/None");
1053 menuitem = gtk_item_factory_get_item
1054 (ifactory, "/View/Show or hide/Toolbar/Icon");
1057 menuitem = gtk_item_factory_get_item
1058 (ifactory, "/View/Show or hide/Toolbar/Text");
1061 menuitem = gtk_item_factory_get_item
1062 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1064 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1066 gtk_widget_hide(mainwin->hbox_stat);
1067 menuitem = gtk_item_factory_get_item
1068 (ifactory, "/View/Show or hide/Status bar");
1069 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1070 prefs_common.show_statusbar);
1072 /* set account selection menu */
1073 ac_menu = gtk_item_factory_get_widget
1074 (ifactory, "/Configuration/Change current account");
1075 gtk_signal_connect(GTK_OBJECT(ac_menu), "selection_done",
1076 GTK_SIGNAL_FUNC(ac_menu_popup_closed), mainwin);
1077 mainwin->ac_menu = ac_menu;
1079 main_window_set_toolbar_sensitive(mainwin);
1081 /* Create actions menu */
1082 update_mainwin_actions_menu(ifactory, mainwin);
1084 /* show main window */
1085 gtk_widget_set_uposition(mainwin->window,
1086 prefs_common.mainwin_x,
1087 prefs_common.mainwin_y);
1088 gtk_widget_set_usize(window, prefs_common.mainwin_width,
1089 prefs_common.mainwin_height);
1090 gtk_widget_show(mainwin->window);
1092 /* initialize views */
1093 folderview_init(folderview);
1094 summary_init(summaryview);
1095 messageview_init(messageview);
1096 log_window_init(mainwin->logwin);
1098 mainwin->lock_count = 0;
1099 mainwin->menu_lock_count = 0;
1100 mainwin->cursor_count = 0;
1103 watch_cursor = gdk_cursor_new(GDK_WATCH);
1105 mainwin_list = g_list_append(mainwin_list, mainwin);
1107 /* init work_offline */
1108 if (prefs_common.work_offline)
1109 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1114 void main_window_cursor_wait(MainWindow *mainwin)
1117 if (mainwin->cursor_count == 0)
1118 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1120 mainwin->cursor_count++;
1125 void main_window_cursor_normal(MainWindow *mainwin)
1127 if (mainwin->cursor_count)
1128 mainwin->cursor_count--;
1130 if (mainwin->cursor_count == 0)
1131 gdk_window_set_cursor(mainwin->window->window, NULL);
1136 /* lock / unlock the user-interface */
1137 void main_window_lock(MainWindow *mainwin)
1139 if (mainwin->lock_count == 0)
1140 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1142 mainwin->lock_count++;
1144 main_window_set_menu_sensitive(mainwin);
1145 main_window_set_toolbar_sensitive(mainwin);
1148 void main_window_unlock(MainWindow *mainwin)
1150 if (mainwin->lock_count)
1151 mainwin->lock_count--;
1153 main_window_set_menu_sensitive(mainwin);
1154 main_window_set_toolbar_sensitive(mainwin);
1156 if (mainwin->lock_count == 0)
1157 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1160 static void main_window_menu_callback_block(MainWindow *mainwin)
1162 mainwin->menu_lock_count++;
1165 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1167 if (mainwin->menu_lock_count)
1168 mainwin->menu_lock_count--;
1171 void main_window_reflect_prefs_all(void)
1173 main_window_reflect_prefs_all_real(FALSE);
1176 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1179 MainWindow *mainwin;
1181 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1182 mainwin = (MainWindow *)cur->data;
1184 main_window_show_cur_account(mainwin);
1185 main_window_set_menu_sensitive(mainwin);
1186 main_window_set_toolbar_sensitive(mainwin);
1189 if (pixmap_theme_changed)
1191 gtk_container_remove(GTK_CONTAINER(mainwin->handlebox), GTK_WIDGET(mainwin->toolbar));
1192 mainwin->toolbar = NULL;
1193 main_window_toolbar_create(mainwin, mainwin->handlebox);
1194 set_toolbar_style(mainwin);
1195 activate_compose_button(mainwin, prefs_common.toolbar_style, mainwin->compose_btn_type);
1196 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1197 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1200 summary_redisplay_msg(mainwin->summaryview);
1201 headerview_set_visibility(mainwin->messageview->headerview,
1202 prefs_common.display_header_pane);
1206 void main_window_set_summary_column(void)
1209 MainWindow *mainwin;
1211 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1212 mainwin = (MainWindow *)cur->data;
1213 summary_set_column_order(mainwin->summaryview);
1217 void main_window_set_account_menu(GList *account_list)
1219 GList *cur, *cur_ac, *cur_item;
1220 GtkWidget *menuitem;
1221 MainWindow *mainwin;
1222 PrefsAccount *ac_prefs;
1224 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1225 mainwin = (MainWindow *)cur->data;
1227 /* destroy all previous menu item */
1228 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1229 while (cur_item != NULL) {
1230 GList *next = cur_item->next;
1231 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1235 for (cur_ac = account_list; cur_ac != NULL;
1236 cur_ac = cur_ac->next) {
1237 ac_prefs = (PrefsAccount *)cur_ac->data;
1239 menuitem = gtk_menu_item_new_with_label
1240 (ac_prefs->account_name
1241 ? ac_prefs->account_name : _("Untitled"));
1242 gtk_widget_show(menuitem);
1243 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1244 gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
1245 GTK_SIGNAL_FUNC(account_menu_cb),
1251 static void main_window_show_cur_account(MainWindow *mainwin)
1256 ac_name = g_strdup(cur_account
1257 ? (cur_account->account_name
1258 ? cur_account->account_name : _("Untitled"))
1262 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1264 buf = g_strdup(PROG_VERSION);
1265 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1268 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1269 gtk_widget_queue_resize(mainwin->ac_button);
1274 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1276 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1277 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1278 GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview);
1280 debug_print(_("Changing window separation type from %d to %d\n"),
1281 mainwin->type, type);
1283 if (mainwin->type == type) return;
1285 /* remove widgets from those containers */
1286 gtk_widget_ref(folder_wid);
1287 gtk_widget_ref(summary_wid);
1288 gtk_widget_ref(message_wid);
1289 gtkut_container_remove
1290 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1291 gtkut_container_remove
1292 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1293 gtkut_container_remove
1294 (GTK_CONTAINER(message_wid->parent), message_wid);
1296 /* clean containers */
1297 switch (mainwin->type) {
1299 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1301 case SEPARATE_FOLDER:
1302 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1303 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1305 case SEPARATE_MESSAGE:
1306 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1307 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1310 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1311 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1315 gtk_widget_hide(mainwin->window);
1316 main_window_set_widgets(mainwin, type);
1317 gtk_widget_show(mainwin->window);
1319 gtk_widget_unref(folder_wid);
1320 gtk_widget_unref(summary_wid);
1321 gtk_widget_unref(message_wid);
1324 void main_window_toggle_message_view(MainWindow *mainwin)
1326 SummaryView *summaryview = mainwin->summaryview;
1327 union CompositeWin *cwin = &mainwin->win;
1328 GtkWidget *vpaned = NULL;
1329 GtkWidget *container = NULL;
1330 GtkWidget *msgwin = NULL;
1332 switch (mainwin->type) {
1334 vpaned = cwin->sep_none.vpaned;
1335 container = cwin->sep_none.hpaned;
1337 case SEPARATE_FOLDER:
1338 vpaned = cwin->sep_folder.vpaned;
1339 container = mainwin->vbox_body;
1341 case SEPARATE_MESSAGE:
1342 msgwin = mainwin->win.sep_message.messagewin;
1345 msgwin = mainwin->win.sep_both.messagewin;
1350 if (GTK_WIDGET_VISIBLE(msgwin)) {
1351 gtk_widget_hide(msgwin);
1352 mainwin->messageview->visible = FALSE;
1353 summaryview->displayed = NULL;
1355 gtk_widget_show(msgwin);
1356 mainwin->messageview->visible = TRUE;
1358 } else if (vpaned->parent != NULL) {
1359 mainwin->messageview->visible = FALSE;
1360 summaryview->displayed = NULL;
1361 gtk_widget_ref(vpaned);
1362 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1363 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1364 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1365 GTK_ARROW_UP, GTK_SHADOW_OUT);
1367 mainwin->messageview->visible = TRUE;
1368 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1369 gtk_container_add(GTK_CONTAINER(container), vpaned);
1370 gtk_widget_unref(vpaned);
1371 gtk_arrow_set(GTK_ARROW(summaryview->toggle_arrow),
1372 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1375 main_window_set_menu_sensitive(mainwin);
1377 gtk_widget_grab_focus(summaryview->ctree);
1380 void main_window_get_size(MainWindow *mainwin)
1382 GtkAllocation *allocation;
1384 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1386 prefs_common.summaryview_width = allocation->width;
1388 if ((mainwin->type == SEPARATE_NONE ||
1389 mainwin->type == SEPARATE_FOLDER) &&
1390 messageview_is_visible(mainwin->messageview))
1391 prefs_common.summaryview_height = allocation->height;
1393 prefs_common.mainview_width = allocation->width;
1395 allocation = &mainwin->window->allocation;
1397 prefs_common.mainview_height = allocation->height;
1398 prefs_common.mainwin_width = allocation->width;
1399 prefs_common.mainwin_height = allocation->height;
1401 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1403 prefs_common.folderview_width = allocation->width;
1404 prefs_common.folderview_height = allocation->height;
1407 void main_window_get_position(MainWindow *mainwin)
1411 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1413 prefs_common.mainview_x = x;
1414 prefs_common.mainview_y = y;
1415 prefs_common.mainwin_x = x;
1416 prefs_common.mainwin_y = y;
1418 debug_print(_("window position: x = %d, y = %d\n"), x, y);
1421 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1427 for (has_trash = 0, list = folder_get_list(); list != NULL; list = list->next) {
1428 folder = FOLDER(list->data);
1429 if (folder && folder->trash && folder->trash->total > 0)
1433 if (!has_trash) return;
1436 if (alertpanel(_("Empty trash"),
1437 _("Empty all messages in trash?"),
1438 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
1440 manage_window_focus_in(mainwin->window, NULL, NULL);
1443 procmsg_empty_trash();
1445 for (list = folder_get_list(); list != NULL; list = list->next) {
1446 folder = list->data;
1447 if (folder && folder->trash && folder->trash->total != 0) {
1448 folder_item_scan(folder->trash);
1449 folderview_update_item(folder->trash, TRUE);
1453 if (mainwin->summaryview->folder_item &&
1454 mainwin->summaryview->folder_item->stype == F_TRASH)
1455 gtk_widget_grab_focus(mainwin->folderview->ctree);
1458 void main_window_add_mailbox(MainWindow *mainwin)
1463 path = input_dialog(_("Add mailbox"),
1464 _("Input the location of mailbox.\n"
1465 "If the existing mailbox is specified, it will be\n"
1466 "scanned automatically."),
1469 if (folder_find_from_path(path)) {
1470 alertpanel_error(_("The mailbox `%s' already exists."), path);
1474 if (!strcmp(path, "Mail"))
1475 folder = folder_new(F_MH, _("Mailbox"), path);
1477 folder = folder_new(F_MH, g_basename(path), path);
1480 if (folder->create_tree(folder) < 0) {
1481 alertpanel_error(_("Creation of the mailbox failed.\n"
1482 "Maybe some files already exist, or you don't have the permission to write there."));
1483 folder_destroy(folder);
1488 folder_set_ui_func(folder, scan_tree_func, mainwin);
1489 folder->scan_tree(folder);
1490 folder_set_ui_func(folder, NULL, NULL);
1492 folderview_set(mainwin->folderview);
1495 void main_window_add_mbox(MainWindow *mainwin)
1501 path = input_dialog(_("Add mbox mailbox"),
1502 _("Input the location of mailbox."),
1507 if (folder_find_from_path(path)) {
1508 alertpanel_error(_("The mailbox `%s' already exists."), path);
1514 if (!strcmp(path, "Mail"))
1515 folder = folder_new(F_MBOX, _("Mailbox"), path);
1519 folder = folder_new(F_MBOX, g_basename(path), path);
1522 if (folder->create_tree(folder) < 0) {
1523 alertpanel_error(_("Creation of the mailbox failed."));
1524 folder_destroy(folder);
1530 item = folder_item_new(folder->name, NULL);
1531 item->folder = folder;
1532 folder->node = g_node_new(item);
1534 folder->create_folder(folder, item, "inbox");
1535 folder->create_folder(folder, item, "outbox");
1536 folder->create_folder(folder, item, "queue");
1537 folder->create_folder(folder, item, "draft");
1538 folder->create_folder(folder, item, "trash");
1540 folderview_set(mainwin->folderview);
1545 M_UNLOCKED = 1 << 0,
1546 M_MSG_EXIST = 1 << 1,
1547 M_TARGET_EXIST = 1 << 2,
1548 M_SINGLE_TARGET_EXIST = 1 << 3,
1550 M_ALLOW_REEDIT = 1 << 5,
1551 M_HAVE_ACCOUNT = 1 << 6,
1552 M_THREADED = 1 << 7,
1553 M_UNTHREADED = 1 << 8,
1554 M_ALLOW_DELETE = 1 << 9,
1555 M_INC_ACTIVE = 1 << 10,
1557 M_HAVE_NEWS_ACCOUNT = 1 << 12,
1558 M_HIDE_READ_MSG = 1 << 13
1561 static SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1563 SensitiveCond state = 0;
1564 SummarySelection selection;
1565 FolderItem *item = mainwin->summaryview->folder_item;
1566 GList *account_list = account_get_list();
1568 selection = summary_get_selection_type(mainwin->summaryview);
1570 if (mainwin->lock_count == 0)
1571 state |= M_UNLOCKED;
1572 if (selection != SUMMARY_NONE)
1573 state |= M_MSG_EXIST;
1577 state |= M_THREADED;
1579 state |= M_UNTHREADED;
1580 /* if (item->folder->type != F_NEWS) */
1581 state |= M_ALLOW_DELETE;
1583 if (selection == SUMMARY_NONE && item->hide_read_msgs
1584 || selection != SUMMARY_NONE)
1585 state |= M_HIDE_READ_MSG;
1587 if (selection == SUMMARY_SELECTED_SINGLE ||
1588 selection == SUMMARY_SELECTED_MULTIPLE)
1589 state |= M_TARGET_EXIST;
1590 if (selection == SUMMARY_SELECTED_SINGLE)
1591 state |= M_SINGLE_TARGET_EXIST;
1592 if (mainwin->summaryview->folder_item &&
1593 mainwin->summaryview->folder_item->folder->type == F_NEWS)
1595 if (selection == SUMMARY_SELECTED_SINGLE &&
1597 (item->stype == F_OUTBOX || item->stype == F_DRAFT ||
1598 item->stype == F_QUEUE)))
1599 state |= M_ALLOW_REEDIT;
1601 state |= M_HAVE_ACCOUNT;
1603 for ( ; account_list != NULL; account_list = account_list->next) {
1604 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1605 state |= M_HAVE_NEWS_ACCOUNT;
1610 if (inc_is_active())
1611 state |= M_INC_ACTIVE;
1616 void main_window_set_toolbar_sensitive(MainWindow *mainwin)
1618 SensitiveCond state;
1627 #define SET_WIDGET_COND(w, c) \
1629 entry[i].widget = w; \
1630 entry[i].cond = c; \
1634 SET_WIDGET_COND(mainwin->get_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1635 SET_WIDGET_COND(mainwin->getall_btn, M_HAVE_ACCOUNT|M_UNLOCKED);
1636 SET_WIDGET_COND(mainwin->compose_news_btn, M_HAVE_ACCOUNT);
1637 SET_WIDGET_COND(mainwin->reply_btn,
1638 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1639 SET_WIDGET_COND(mainwin->replyall_btn,
1640 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1641 SET_WIDGET_COND(mainwin->replysender_btn,
1642 M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST);
1643 SET_WIDGET_COND(mainwin->fwd_btn, M_HAVE_ACCOUNT|M_TARGET_EXIST);
1645 SET_WIDGET_COND(mainwin->prefs_btn, M_UNLOCKED);
1646 SET_WIDGET_COND(mainwin->account_btn, M_UNLOCKED);
1648 SET_WIDGET_COND(mainwin->next_btn, M_MSG_EXIST);
1649 SET_WIDGET_COND(mainwin->delete_btn,
1650 M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED);
1651 SET_WIDGET_COND(mainwin->exec_btn, M_MSG_EXIST|M_EXEC|M_UNLOCKED);
1652 SET_WIDGET_COND(NULL, 0);
1654 #undef SET_WIDGET_COND
1656 state = main_window_get_current_state(mainwin);
1658 for (i = 0; entry[i].widget != NULL; i++) {
1659 sensitive = ((entry[i].cond & state) == entry[i].cond);
1660 gtk_widget_set_sensitive(entry[i].widget, sensitive);
1663 activate_compose_button(mainwin,
1664 prefs_common.toolbar_style,
1665 mainwin->compose_btn_type);
1668 void main_window_set_menu_sensitive(MainWindow *mainwin)
1670 GtkItemFactory *ifactory;
1671 SensitiveCond state;
1673 GtkWidget *menuitem;
1678 static const struct {
1682 {"/File/Add mailbox..." , M_UNLOCKED},
1683 {"/File/Add mbox mailbox..." , M_UNLOCKED},
1684 {"/File/Rescan folder tree" , M_UNLOCKED},
1685 {"/File/Folder" , M_UNLOCKED},
1686 {"/File/Import mbox file..." , M_UNLOCKED},
1687 {"/File/Export to mbox file...", M_UNLOCKED},
1688 {"/File/Empty trash" , M_UNLOCKED},
1689 {"/File/Work offline" , M_UNLOCKED},
1690 {"/File/Save as...", M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1691 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1692 /* {"/File/Close", M_UNLOCKED}, */
1693 {"/File/Exit" , M_UNLOCKED},
1695 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1696 {"/View/Sort" , M_MSG_EXIST},
1697 {"/View/Thread view" , M_EXEC},
1698 {"/View/Expand all threads" , M_MSG_EXIST},
1699 {"/View/Collapse all threads" , M_MSG_EXIST},
1700 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1701 {"/View/Go to/Prev message" , M_MSG_EXIST},
1702 {"/View/Go to/Next message" , M_MSG_EXIST},
1703 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1704 {"/View/Go to/Next unread message" , M_MSG_EXIST},
1705 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1706 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1707 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1708 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1709 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1710 {"/View/Show all header" , M_SINGLE_TARGET_EXIST},
1711 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1713 {"/Message/Get new mail" , M_HAVE_ACCOUNT|M_UNLOCKED},
1714 {"/Message/Get from all accounts" , M_HAVE_ACCOUNT|M_UNLOCKED},
1715 {"/Message/Cancel receiving" , M_INC_ACTIVE},
1716 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1717 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1718 {"/Message/Reply to sender" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1719 {"/Message/Reply to all" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1720 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1721 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1722 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1723 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1724 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1725 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1726 {"/Message/Delete" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1727 {"/Message/Mark" , M_TARGET_EXIST},
1729 {"/Tools/Selective download..." , M_HAVE_ACCOUNT|M_UNLOCKED},
1730 {"/Tools/Add sender to address book", M_SINGLE_TARGET_EXIST},
1731 {"/Tools/Harvest addresses" , M_UNLOCKED},
1732 {"/Tools/Filter messages" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1733 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1734 {"/Tools/Execute" , M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1735 {"/Tools/Actions" , M_MSG_EXIST},
1736 {"/Tools/Delete duplicated messages", M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1738 {"/Configuration", M_UNLOCKED},
1743 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1744 state = main_window_get_current_state(mainwin);
1746 for (i = 0; entry[i].entry != NULL; i++) {
1747 sensitive = ((entry[i].cond & state) == entry[i].cond);
1748 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1751 main_window_menu_callback_block(mainwin);
1753 #define SET_CHECK_MENU_ACTIVE(path, active) \
1755 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1756 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1759 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1760 messageview_is_visible(mainwin->messageview));
1762 item = mainwin->summaryview->folder_item;
1763 menu_path = "/View/Sort/Don't sort";
1765 switch (item->sort_key) {
1766 case SORT_BY_NUMBER:
1767 menu_path = "/View/Sort/by number"; break;
1769 menu_path = "/View/Sort/by size"; break;
1771 menu_path = "/View/Sort/by date"; break;
1773 menu_path = "/View/Sort/by from"; break;
1774 case SORT_BY_SUBJECT:
1775 menu_path = "/View/Sort/by subject"; break;
1777 menu_path = "/View/Sort/by color label"; break;
1779 menu_path = "/View/Sort/by mark"; break;
1780 case SORT_BY_UNREAD:
1781 menu_path = "/View/Sort/by unread"; break;
1783 menu_path = "/View/Sort/by attachment"; break;
1785 menu_path = "/View/Sort/by score"; break;
1786 case SORT_BY_LOCKED:
1787 menu_path = "/View/Sort/by locked"; break;
1790 menu_path = "/View/Sort/Don't sort"; break;
1793 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1795 if (!item || item->sort_type == SORT_ASCENDING) {
1796 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1798 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1801 if (item && item->sort_key != SORT_BY_NONE) {
1802 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1803 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1805 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1806 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1809 SET_CHECK_MENU_ACTIVE("/View/Show all header",
1810 mainwin->messageview->textview->show_all_headers);
1811 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1813 #undef SET_CHECK_MENU_ACTIVE
1815 main_window_menu_callback_unblock(mainwin);
1818 void main_window_popup(MainWindow *mainwin)
1824 gdk_window_get_origin(mainwin->window->window, &x, &y);
1825 sx = gdk_screen_width();
1826 sy = gdk_screen_height();
1827 x %= sx; if (x < 0) x = 0;
1828 y %= sy; if (y < 0) y = 0;
1829 gdk_window_move(mainwin->window->window, x, y);
1830 gdk_window_raise(mainwin->window->window);
1831 gdk_window_show(mainwin->window->window);
1833 debug_print("window position: x = %d, y = %d\n", x, y);
1835 switch (mainwin->type) {
1836 case SEPARATE_FOLDER:
1837 widget = mainwin->win.sep_folder.folderwin;
1838 gdk_window_get_origin(widget->window, &x, &y);
1839 x %= sx; if (x < 0) x = 0;
1840 y %= sy; if (y < 0) y = 0;
1841 gdk_window_move(widget->window, x, y);
1842 gdk_window_raise(widget->window);
1844 case SEPARATE_MESSAGE:
1845 widget = mainwin->win.sep_message.messagewin;
1846 gdk_window_get_origin(widget->window, &x, &y);
1847 x %= sx; if (x < 0) x = 0;
1848 y %= sy; if (y < 0) y = 0;
1849 gdk_window_move(widget->window, x, y);
1850 gdk_window_raise(widget->window);
1853 widget = mainwin->win.sep_both.folderwin;
1854 gdk_window_get_origin(widget->window, &x, &y);
1855 x %= sx; if (x < 0) x = 0;
1856 y %= sy; if (y < 0) y = 0;
1857 gdk_window_move(widget->window, x, y);
1858 gdk_window_raise(widget->window);
1859 widget = mainwin->win.sep_both.messagewin;
1860 gdk_window_get_origin(widget->window, &x, &y);
1861 x %= sx; if (x < 0) x = 0;
1862 y %= sy; if (y < 0) y = 0;
1863 gdk_window_move(widget->window, x, y);
1864 gdk_window_raise(widget->window);
1871 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
1873 GtkWidget *folderwin = NULL;
1874 GtkWidget *messagewin = NULL;
1877 GtkWidget *vbox_body = mainwin->vbox_body;
1878 GtkItemFactory *ifactory=gtk_item_factory_from_widget(mainwin->menubar);
1879 GtkWidget *menuitem;
1881 debug_print(_("Setting widgets..."));
1883 /* create separated window(s) if needed */
1884 if (type & SEPARATE_FOLDER) {
1885 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1886 gtk_window_set_title(GTK_WINDOW(folderwin),
1887 _("Sylpheed - Folder View"));
1888 gtk_window_set_wmclass(GTK_WINDOW(folderwin),
1889 "folder_view", "Sylpheed");
1890 gtk_window_set_policy(GTK_WINDOW(folderwin),
1892 gtk_widget_set_usize(folderwin, -1,
1893 prefs_common.mainview_height);
1894 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
1896 gtk_signal_connect(GTK_OBJECT(folderwin), "delete_event",
1897 GTK_SIGNAL_FUNC(folder_window_close_cb),
1900 if (type & SEPARATE_MESSAGE) {
1901 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
1902 gtk_window_set_title(GTK_WINDOW(messagewin),
1903 _("Sylpheed - Message View"));
1904 gtk_window_set_wmclass(GTK_WINDOW(messagewin),
1905 "message_view", "Sylpheed");
1906 gtk_window_set_policy(GTK_WINDOW(messagewin),
1908 gtk_widget_set_usize
1909 (messagewin, prefs_common.mainview_width,
1910 prefs_common.mainview_height
1911 - prefs_common.summaryview_height
1912 + DEFAULT_HEADERVIEW_HEIGHT);
1913 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
1915 gtk_signal_connect(GTK_OBJECT(messagewin), "delete_event",
1916 GTK_SIGNAL_FUNC(message_window_close_cb),
1922 hpaned = gtk_hpaned_new();
1923 gtk_widget_show(hpaned);
1924 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1925 gtk_paned_add1(GTK_PANED(hpaned),
1926 GTK_WIDGET_PTR(mainwin->folderview));
1928 vpaned = gtk_vpaned_new();
1929 if (messageview_is_visible(mainwin->messageview)) {
1930 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
1931 gtk_paned_add1(GTK_PANED(vpaned),
1932 GTK_WIDGET_PTR(mainwin->summaryview));
1934 gtk_paned_add2(GTK_PANED(hpaned),
1935 GTK_WIDGET_PTR(mainwin->summaryview));
1936 gtk_widget_ref(vpaned);
1938 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1939 prefs_common.summaryview_width,
1940 prefs_common.summaryview_height);
1941 gtk_paned_add2(GTK_PANED(vpaned),
1942 GTK_WIDGET_PTR(mainwin->messageview));
1943 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1944 prefs_common.mainview_width, -1);
1945 gtk_widget_set_usize(mainwin->window,
1946 prefs_common.folderview_width +
1947 prefs_common.mainview_width,
1948 prefs_common.mainwin_height);
1949 gtk_widget_show_all(vpaned);
1951 mainwin->win.sep_none.hpaned = hpaned;
1952 mainwin->win.sep_none.vpaned = vpaned;
1954 case SEPARATE_FOLDER:
1955 vpaned = gtk_vpaned_new();
1956 if (messageview_is_visible(mainwin->messageview)) {
1957 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
1959 gtk_paned_add1(GTK_PANED(vpaned),
1960 GTK_WIDGET_PTR(mainwin->summaryview));
1962 gtk_box_pack_start(GTK_BOX(vbox_body),
1963 GTK_WIDGET_PTR(mainwin->summaryview),
1965 gtk_widget_ref(vpaned);
1967 gtk_paned_add2(GTK_PANED(vpaned),
1968 GTK_WIDGET_PTR(mainwin->messageview));
1969 gtk_widget_show_all(vpaned);
1970 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1971 prefs_common.summaryview_width,
1972 prefs_common.summaryview_height);
1973 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->messageview),
1974 prefs_common.mainview_width, -1);
1975 gtk_widget_set_usize(mainwin->window,
1976 prefs_common.mainview_width,
1977 prefs_common.mainview_height);
1979 gtk_container_add(GTK_CONTAINER(folderwin),
1980 GTK_WIDGET_PTR(mainwin->folderview));
1982 mainwin->win.sep_folder.folderwin = folderwin;
1983 mainwin->win.sep_folder.vpaned = vpaned;
1985 gtk_widget_show_all(folderwin);
1987 case SEPARATE_MESSAGE:
1988 hpaned = gtk_hpaned_new();
1989 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
1991 gtk_paned_add1(GTK_PANED(hpaned),
1992 GTK_WIDGET_PTR(mainwin->folderview));
1993 gtk_paned_add2(GTK_PANED(hpaned),
1994 GTK_WIDGET_PTR(mainwin->summaryview));
1995 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
1996 prefs_common.summaryview_width,
1997 prefs_common.summaryview_height);
1998 gtk_widget_set_usize(mainwin->window,
1999 prefs_common.folderview_width +
2000 prefs_common.mainview_width,
2001 prefs_common.mainwin_height);
2002 gtk_widget_show_all(hpaned);
2003 gtk_container_add(GTK_CONTAINER(messagewin),
2004 GTK_WIDGET_PTR(mainwin->messageview));
2006 mainwin->win.sep_message.messagewin = messagewin;
2007 mainwin->win.sep_message.hpaned = hpaned;
2009 gtk_widget_show_all(messagewin);
2012 gtk_box_pack_start(GTK_BOX(vbox_body),
2013 GTK_WIDGET_PTR(mainwin->summaryview),
2015 gtk_widget_set_usize(GTK_WIDGET_PTR(mainwin->summaryview),
2016 prefs_common.summaryview_width,
2017 prefs_common.summaryview_height);
2018 gtk_widget_set_usize(mainwin->window,
2019 prefs_common.mainview_width,
2020 prefs_common.mainwin_height);
2021 gtk_container_add(GTK_CONTAINER(folderwin),
2022 GTK_WIDGET_PTR(mainwin->folderview));
2023 gtk_container_add(GTK_CONTAINER(messagewin),
2024 GTK_WIDGET_PTR(mainwin->messageview));
2026 mainwin->win.sep_both.folderwin = folderwin;
2027 mainwin->win.sep_both.messagewin = messagewin;
2029 gtk_widget_show_all(folderwin);
2030 gtk_widget_show_all(messagewin);
2034 mainwin->type = type;
2036 mainwin->messageview->visible = TRUE;
2037 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2039 /* toggle menu state */
2040 menuitem = gtk_item_factory_get_item
2041 (ifactory, "/View/Show or hide/Folder tree");
2042 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2043 menuitem = gtk_item_factory_get_item
2044 (ifactory, "/View/Show or hide/Message view");
2045 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
2047 menuitem = gtk_item_factory_get_item
2048 (ifactory, "/View/Separate folder tree");
2049 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2050 ((type & SEPARATE_FOLDER) != 0));
2051 menuitem = gtk_item_factory_get_item
2052 (ifactory, "/View/Separate message view");
2053 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2054 ((type & SEPARATE_MESSAGE) != 0));
2056 debug_print(_("done.\n"));
2059 static void main_window_toolbar_create(MainWindow *mainwin,
2060 GtkWidget *container)
2063 GtkWidget *icon_wid;
2065 GtkWidget *getall_btn;
2066 GtkWidget *compose_mail_btn;
2067 GtkWidget *compose_news_btn;
2068 GtkWidget *reply_btn;
2069 GtkWidget *replyall_btn;
2070 GtkWidget *replysender_btn;
2072 GtkWidget *send_btn;
2074 GtkWidget *prefs_btn;
2075 GtkWidget *account_btn;
2077 GtkWidget *next_btn;
2078 GtkWidget *delete_btn;
2079 GtkWidget *exec_btn;
2081 GtkTooltips *tooltips;
2083 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,
2085 gtk_container_add(GTK_CONTAINER(container), toolbar);
2086 gtk_container_set_border_width(GTK_CONTAINER(container), 2);
2087 gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
2088 gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar),
2089 GTK_TOOLBAR_SPACE_LINE);
2091 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE);
2092 get_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2094 _("Get new mail from current account"),
2096 icon_wid, toolbar_inc_cb, mainwin);
2097 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_RECEIVE_ALL);
2098 getall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2100 _("Get new mail from all accounts"),
2106 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2108 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_SEND);
2109 send_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2111 _("Send queued message(s)"),
2117 /* insert compose mail button widget */
2118 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_COMPOSE);
2119 compose_mail_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2121 _("Compose an email message"),
2124 toolbar_compose_mail_cb,
2127 /* insert compose news button widget */
2128 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_NEWS_COMPOSE);
2129 compose_news_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2131 _("Compose a news message"),
2134 toolbar_compose_news_cb,
2137 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2141 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY);
2142 reply_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2144 _("Reply to the message - Right button: more options"),
2150 /* replyall button */
2152 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_ALL);
2153 replyall_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2155 _("Reply to all - Right button: more options"),
2158 toolbar_reply_to_all_cb,
2161 /* reply to sender button */
2162 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_REPLY_TO_AUTHOR);
2163 replysender_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2165 _("Reply to sender - Right button: more options"),
2168 toolbar_reply_to_sender_cb,
2171 /* forward button */
2172 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_MAIL_FORWARD);
2173 fwd_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2175 _("Forward the message - Right button: more options"),
2181 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2183 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_CLOSE);
2184 delete_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2186 _("Delete the message"),
2192 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_EXEC);
2193 exec_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2195 _("Execute marked process"),
2201 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_DOWN_ARROW);
2202 next_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2204 _("Next unread message"),
2207 toolbar_next_unread_cb,
2211 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
2213 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PREFERENCES);
2214 prefs_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2216 _("Common preferences"),
2221 icon_wid = stock_pixmap_widget(container, STOCK_PIXMAP_PROPERTIES);
2222 account_btn = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
2224 _("Account setting"),
2229 gtk_signal_connect(GTK_OBJECT(account_btn), "button_press_event",
2230 GTK_SIGNAL_FUNC(toolbar_account_button_pressed),
2234 gtk_signal_connect(GTK_OBJECT(reply_btn), "button_press_event",
2235 GTK_SIGNAL_FUNC(toolbar_reply_popup_cb),
2238 gtk_signal_connect(GTK_OBJECT(replyall_btn), "button_press_event",
2239 GTK_SIGNAL_FUNC(toolbar_reply_to_all_popup_cb),
2242 gtk_signal_connect(GTK_OBJECT(replysender_btn), "button_press_event",
2243 GTK_SIGNAL_FUNC(toolbar_reply_to_sender_popup_cb),
2246 gtk_signal_connect(GTK_OBJECT(fwd_btn), "button_press_event",
2247 GTK_SIGNAL_FUNC(toolbar_forward_popup_cb),
2251 mainwin->toolbar = toolbar;
2252 mainwin->get_btn = get_btn;
2253 mainwin->getall_btn = getall_btn;
2254 mainwin->compose_mail_btn = compose_mail_btn;
2255 mainwin->compose_news_btn = compose_news_btn;
2256 mainwin->reply_btn = reply_btn;
2257 mainwin->replyall_btn = replyall_btn;
2258 mainwin->replysender_btn = replysender_btn;
2259 mainwin->fwd_btn = fwd_btn;
2260 mainwin->send_btn = send_btn;
2262 mainwin->prefs_btn = prefs_btn;
2263 mainwin->account_btn = account_btn;
2265 mainwin->next_btn = next_btn;
2266 mainwin->delete_btn = delete_btn;
2267 mainwin->exec_btn = exec_btn;
2269 gtk_widget_show_all(toolbar);
2272 /* callback functions */
2273 static void toolbar_reply_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2275 MainWindow *mainwindow = (MainWindow *) data;
2279 if (event->button == 3) {
2280 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2281 gtk_menu_popup(GTK_MENU(mainwindow->reply_popup), NULL, NULL,
2282 menu_button_position, widget,
2283 event->button, event->time);
2287 static void toolbar_reply_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2289 MainWindow *mainwin = (MainWindow *)data;
2291 gtk_button_set_relief(GTK_BUTTON(mainwin->reply_btn), GTK_RELIEF_NONE);
2292 manage_window_focus_in(mainwin->window, NULL, NULL);
2295 static void toolbar_reply_to_all_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2297 MainWindow *mainwindow = (MainWindow *) data;
2301 if (event->button == 3) {
2302 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2303 gtk_menu_popup(GTK_MENU(mainwindow->replyall_popup), NULL, NULL,
2304 menu_button_position, widget,
2305 event->button, event->time);
2309 static void toolbar_reply_to_all_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2311 MainWindow *mainwin = (MainWindow *)data;
2313 gtk_button_set_relief(GTK_BUTTON(mainwin->replyall_btn), GTK_RELIEF_NONE);
2314 manage_window_focus_in(mainwin->window, NULL, NULL);
2317 static void toolbar_reply_to_sender_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2319 MainWindow *mainwindow = (MainWindow *) data;
2320 GtkWidget *replysender_menu, *replysender_item;
2324 if (event->button == 3) {
2325 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2326 gtk_menu_popup(GTK_MENU(mainwindow->replysender_popup), NULL, NULL,
2327 menu_button_position, widget,
2328 event->button, event->time);
2332 static void toolbar_reply_to_sender_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2334 MainWindow *mainwin = (MainWindow *)data;
2336 gtk_button_set_relief(GTK_BUTTON(mainwin->replysender_btn), GTK_RELIEF_NONE);
2337 manage_window_focus_in(mainwin->window, NULL, NULL);
2340 static void toolbar_forward_popup_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
2342 MainWindow *mainwindow = (MainWindow *) data;
2346 if (event->button == 3) {
2347 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2348 gtk_menu_popup(GTK_MENU(mainwindow->fwd_popup), NULL, NULL,
2349 menu_button_position, widget,
2350 event->button, event->time);
2354 static void toolbar_forward_popup_closed_cb(GtkMenuShell *menu_shell, gpointer data)
2356 MainWindow *mainwin = (MainWindow *)data;
2358 gtk_button_set_relief(GTK_BUTTON(mainwin->fwd_btn), GTK_RELIEF_NONE);
2359 manage_window_focus_in(mainwin->window, NULL, NULL);
2362 static void toolbar_inc_cb (GtkWidget *widget,
2365 MainWindow *mainwin = (MainWindow *)data;
2367 inc_mail_cb(mainwin, 0, NULL);
2370 static void toolbar_inc_all_cb (GtkWidget *widget,
2373 MainWindow *mainwin = (MainWindow *)data;
2375 inc_all_account_mail_cb(mainwin, 0, NULL);
2378 static void toolbar_send_cb (GtkWidget *widget,
2381 MainWindow *mainwin = (MainWindow *)data;
2383 send_queue_cb(mainwin, 0, NULL);
2386 static void toolbar_compose_cb (GtkWidget *widget,
2389 MainWindow *mainwin = (MainWindow *)data;
2391 if (mainwin->compose_btn_type == COMPOSEBUTTON_MAIL)
2392 compose_cb(mainwin, 0, NULL);
2394 compose_news_cb(mainwin, 0, NULL);
2397 static void toolbar_compose_news_cb (GtkWidget *widget,
2400 MainWindow *mainwin = (MainWindow *)data;
2402 compose_news_cb(mainwin, 0, NULL);
2405 static void toolbar_compose_mail_cb (GtkWidget *widget,
2408 MainWindow *mainwin = (MainWindow *)data;
2410 compose_mail_cb(mainwin, 0, NULL);
2413 static void toolbar_reply_cb(GtkWidget *widget, gpointer data)
2415 MainWindow *mainwin = (MainWindow *)data;
2418 prefs_common.reply_with_quote ? COMPOSE_REPLY_WITH_QUOTE
2419 : COMPOSE_REPLY_WITHOUT_QUOTE,
2423 static void toolbar_reply_to_all_cb(GtkWidget *widget, gpointer data)
2425 MainWindow *mainwin = (MainWindow *)data;
2428 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_ALL_WITH_QUOTE
2429 : COMPOSE_REPLY_TO_ALL_WITHOUT_QUOTE,
2434 static void toolbar_reply_to_sender_cb(GtkWidget *widget, gpointer data)
2436 MainWindow *mainwin = (MainWindow *)data;
2439 prefs_common.reply_with_quote ? COMPOSE_REPLY_TO_SENDER_WITH_QUOTE
2440 : COMPOSE_REPLY_TO_SENDER_WITHOUT_QUOTE,
2444 static void toolbar_forward_cb (GtkWidget *widget,
2447 MainWindow *mainwin = (MainWindow *)data;
2449 if (prefs_common.forward_as_attachment)
2450 reply_cb(mainwin, COMPOSE_FORWARD_AS_ATTACH, NULL);
2452 reply_cb(mainwin, COMPOSE_FORWARD, NULL);
2455 static void toolbar_delete_cb (GtkWidget *widget,
2458 MainWindow *mainwin = (MainWindow *)data;
2460 summary_delete(mainwin->summaryview);
2463 static void toolbar_exec_cb (GtkWidget *widget,
2466 MainWindow *mainwin = (MainWindow *)data;
2468 summary_execute(mainwin->summaryview);
2471 static void toolbar_next_unread_cb (GtkWidget *widget,
2474 MainWindow *mainwin = (MainWindow *)data;
2476 next_unread_cb(mainwin, 0, NULL);
2479 static void toolbar_prefs_cb (GtkWidget *widget,
2482 prefs_common_open();
2485 static void toolbar_account_cb (GtkWidget *widget,
2488 MainWindow *mainwin = (MainWindow *)data;
2490 prefs_account_open_cb(mainwin, 0, NULL);
2494 static void toolbar_account_button_pressed(GtkWidget *widget,
2495 GdkEventButton *event,
2498 MainWindow *mainwin = (MainWindow *)data;
2501 if (event->button != 3) return;
2503 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2504 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2507 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2508 menu_button_position, widget,
2509 event->button, event->time);
2513 static void ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2516 MainWindow *mainwin = (MainWindow *)data;
2520 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2521 gtk_object_set_data(GTK_OBJECT(mainwin->ac_menu), "menu_button",
2524 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2525 menu_button_position, widget,
2526 event->button, event->time);
2529 static void ac_menu_popup_closed(GtkMenuShell *menu_shell, gpointer data)
2531 MainWindow *mainwin = (MainWindow *)data;
2534 button = gtk_object_get_data(GTK_OBJECT(menu_shell), "menu_button");
2535 if (!button) return;
2536 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
2537 gtk_object_remove_data(GTK_OBJECT(mainwin->ac_menu), "menu_button");
2538 manage_window_focus_in(mainwin->window, NULL, NULL);
2541 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2544 MainWindow *mainwin = (MainWindow *)data;
2546 if (mainwin->lock_count == 0)
2547 app_exit_cb(data, 0, widget);
2552 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2555 MainWindow *mainwin = (MainWindow *)data;
2556 GtkItemFactory *ifactory;
2557 GtkWidget *menuitem;
2559 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2560 menuitem = gtk_item_factory_get_item
2561 (ifactory, "/View/Show or hide/Folder tree");
2562 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2567 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2570 MainWindow *mainwin = (MainWindow *)data;
2571 GtkItemFactory *ifactory;
2572 GtkWidget *menuitem;
2574 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2575 menuitem = gtk_item_factory_get_item
2576 (ifactory, "/View/Show or hide/Message view");
2577 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2582 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2585 main_window_add_mailbox(mainwin);
2588 static void add_mbox_cb(MainWindow *mainwin, guint action,
2591 main_window_add_mbox(mainwin);
2594 static void update_folderview_cb(MainWindow *mainwin, guint action,
2597 summary_show(mainwin->summaryview, NULL, FALSE);
2598 folderview_rescan_all();
2601 static void new_folder_cb(MainWindow *mainwin, guint action,
2604 folderview_new_folder(mainwin->folderview);
2607 static void rename_folder_cb(MainWindow *mainwin, guint action,
2610 folderview_rename_folder(mainwin->folderview);
2613 static void delete_folder_cb(MainWindow *mainwin, guint action,
2616 folderview_delete_folder(mainwin->folderview);
2619 static void import_mbox_cb(MainWindow *mainwin, guint action,
2622 import_mbox(mainwin->summaryview->folder_item);
2625 static void export_mbox_cb(MainWindow *mainwin, guint action,
2628 export_mbox(mainwin->summaryview->folder_item);
2631 static void empty_trash_cb(MainWindow *mainwin, guint action,
2634 main_window_empty_trash(mainwin, TRUE);
2637 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2639 summary_save_as(mainwin->summaryview);
2642 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2644 summary_print(mainwin->summaryview);
2647 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2649 if (prefs_common.confirm_on_exit) {
2650 if (alertpanel(_("Exit"), _("Exit this program?"),
2651 _("OK"), _("Cancel"), NULL) != G_ALERTDEFAULT)
2653 manage_window_focus_in(mainwin->window, NULL, NULL);
2656 app_will_exit(widget, mainwin);
2659 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2662 summary_search(mainwin->summaryview);
2664 message_search(mainwin->messageview);
2667 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2672 active = GTK_CHECK_MENU_ITEM(widget)->active;
2674 switch (mainwin->type) {
2676 case SEPARATE_MESSAGE:
2679 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2681 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2684 case SEPARATE_FOLDER:
2686 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2688 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2692 gtk_widget_show(mainwin->win.sep_both.folderwin);
2694 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2699 static void toggle_message_cb(MainWindow *mainwin, guint action,
2704 active = GTK_CHECK_MENU_ITEM(widget)->active;
2706 if (active != messageview_is_visible(mainwin->messageview))
2707 summary_toggle_view(mainwin->summaryview);
2710 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2713 switch ((ToolbarStyle)action) {
2715 gtk_widget_hide(mainwin->handlebox);
2717 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2721 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2725 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
2730 if (action != TOOLBAR_NONE) {
2731 gtk_widget_show(mainwin->handlebox);
2732 gtk_widget_queue_resize(mainwin->handlebox);
2735 mainwin->toolbar_style = (ToolbarStyle)action;
2736 prefs_common.toolbar_style = (ToolbarStyle)action;
2739 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2742 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2743 gtk_widget_show(mainwin->hbox_stat);
2744 prefs_common.show_statusbar = TRUE;
2746 gtk_widget_hide(mainwin->hbox_stat);
2747 prefs_common.show_statusbar = FALSE;
2751 static void separate_widget_cb(MainWindow *mainwin, guint action,
2756 if (GTK_CHECK_MENU_ITEM(widget)->active)
2757 type = mainwin->type | action;
2759 type = mainwin->type & ~action;
2761 main_window_separation_change(mainwin, type);
2763 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2764 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2767 static void toggle_expand_summaryview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2769 summary_toggle_view(mainwin->summaryview);
2772 static void toggle_expand_messageview_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2775 messageview_toggle_view(mainwin->messageview);
2779 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2781 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2782 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2784 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2788 static void online_switch_clicked (GtkButton *btn, gpointer data)
2790 MainWindow *mainwin;
2791 GtkItemFactory *ifactory;
2792 GtkCheckMenuItem *menuitem;
2794 mainwin = (MainWindow *) data;
2796 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2797 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2799 g_return_if_fail(mainwin != NULL);
2800 g_return_if_fail(menuitem != NULL);
2802 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2804 gtk_widget_hide (mainwin->online_switch);
2805 gtk_widget_show (mainwin->offline_switch);
2806 menuitem->active = TRUE;
2807 prefs_common.work_offline = TRUE;
2808 inc_autocheck_timer_remove();
2811 gtk_widget_hide (mainwin->offline_switch);
2812 gtk_widget_show (mainwin->online_switch);
2813 menuitem->active = FALSE;
2814 prefs_common.work_offline = FALSE;
2815 inc_autocheck_timer_set();
2819 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2822 addressbook_open(NULL);
2825 static void log_window_show_cb(MainWindow *mainwin, guint action,
2828 log_window_show(mainwin->logwin);
2831 static void sel_download_cb(MainWindow *mainwin, guint action,
2834 selective_download(mainwin);
2837 static void inc_mail_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2839 inc_mail(mainwin, prefs_common.newmail_notify_manu);
2842 static void inc_all_account_mail_cb(MainWindow *mainwin, guint action,
2845 inc_all_account_mail(mainwin, prefs_common.newmail_notify_manu);
2848 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2853 static void send_queue_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2857 if (prefs_common.work_offline)
2858 if (alertpanel(_("Offline warning"),
2859 _("You're working offline. Override?"),
2860 _("Yes"), _("No"), NULL) != G_ALERTDEFAULT)
2863 for (list = folder_get_list(); list != NULL; list = list->next) {
2864 Folder *folder = list->data;
2866 if (folder->queue) {
2867 if (procmsg_send_queue
2868 (folder->queue, prefs_common.savemsg) < 0)
2869 alertpanel_error(_("Some errors occurred while sending queued messages."));
2870 statusbar_pop_all();
2871 folder_item_scan(folder->queue);
2872 folderview_update_item(folder->queue, TRUE);
2877 static void compose_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2879 if (mainwin->summaryview->folder_item) {
2880 if (mainwin->summaryview->folder_item->folder->account != NULL
2881 && mainwin->summaryview->folder_item->folder->account->protocol == A_NNTP)
2882 compose_new_with_recipient(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item->path);
2884 compose_new_with_folderitem(mainwin->summaryview->folder_item->folder->account, mainwin->summaryview->folder_item);
2890 static void compose_mail_cb(MainWindow *mainwin, guint action,
2897 if (mainwin->summaryview->folder_item) {
2898 ac = mainwin->summaryview->folder_item->folder->account;
2899 if (ac && ac->protocol != A_NNTP) {
2900 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2905 if(cur_account && (cur_account->protocol != A_NNTP)) {
2906 compose_new_with_folderitem(cur_account, mainwin->summaryview->folder_item);
2910 list = account_get_list();
2911 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2912 ac = (PrefsAccount *) cur->data;
2913 if (ac->protocol != A_NNTP) {
2914 compose_new_with_folderitem(ac, mainwin->summaryview->folder_item);
2920 static void compose_news_cb(MainWindow *mainwin, guint action,
2923 PrefsAccount * ac = NULL;
2927 if (mainwin->summaryview->folder_item) {
2928 ac = mainwin->summaryview->folder_item->folder->account;
2929 if (ac && ac->protocol == A_NNTP) {
2930 compose_new_with_recipient
2931 (ac, mainwin->summaryview->folder_item->path);
2936 list = account_get_list();
2937 for(cur = list ; cur != NULL ; cur = g_list_next(cur)) {
2938 ac = (PrefsAccount *) cur->data;
2939 if (ac->protocol == A_NNTP) {
2946 static void reply_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2948 summary_reply(mainwin->summaryview, (ComposeMode)action);
2951 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2953 summary_move_to(mainwin->summaryview);
2956 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2958 summary_copy_to(mainwin->summaryview);
2961 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2963 summary_delete(mainwin->summaryview);
2966 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2968 summary_open_msg(mainwin->summaryview);
2971 static void view_source_cb(MainWindow *mainwin, guint action,
2974 summary_view_source(mainwin->summaryview);
2977 static void show_all_header_cb(MainWindow *mainwin, guint action,
2980 if (mainwin->menu_lock_count) return;
2981 summary_display_msg_selected(mainwin->summaryview,
2982 GTK_CHECK_MENU_ITEM(widget)->active);
2985 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2987 summary_reedit(mainwin->summaryview);
2990 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2992 summary_mark(mainwin->summaryview);
2995 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2997 summary_unmark(mainwin->summaryview);
3000 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3003 summary_mark_as_unread(mainwin->summaryview);
3006 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3009 summary_mark_as_read(mainwin->summaryview);
3012 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3015 summary_mark_all_read(mainwin->summaryview);
3018 static void add_address_cb(MainWindow *mainwin, guint action,
3021 summary_add_address(mainwin->summaryview);
3024 static void set_charset_cb(MainWindow *mainwin, guint action,
3029 str = conv_get_charset_str((CharSet)action);
3030 g_free(prefs_common.force_charset);
3031 prefs_common.force_charset = str ? g_strdup(str) : NULL;
3033 summary_redisplay_msg(mainwin->summaryview);
3035 debug_print(_("forced charset: %s\n"), str ? str : "Auto-Detect");
3038 static void hide_read_messages (MainWindow *mainwin, guint action,
3041 if (!mainwin->summaryview->folder_item
3042 || gtk_object_get_data(GTK_OBJECT(widget), "dont_toggle"))
3044 summary_toggle_show_read_messages(mainwin->summaryview);
3047 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3049 GtkItemFactory *ifactory;
3051 if (mainwin->menu_lock_count) return;
3052 if (!mainwin->summaryview->folder_item) return;
3054 ifactory = gtk_item_factory_from_widget(widget);
3056 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3057 summary_thread_build(mainwin->summaryview);
3058 mainwin->summaryview->folder_item->threaded = TRUE;
3060 summary_unthread(mainwin->summaryview);
3061 mainwin->summaryview->folder_item->threaded = FALSE;
3065 static void expand_threads_cb(MainWindow *mainwin, guint action,
3068 summary_expand_threads(mainwin->summaryview);
3071 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3074 summary_collapse_threads(mainwin->summaryview);
3077 static void set_display_item_cb(MainWindow *mainwin, guint action,
3080 prefs_summary_column_open();
3083 static void sort_summary_cb(MainWindow *mainwin, guint action,
3086 FolderItem *item = mainwin->summaryview->folder_item;
3087 GtkItemFactory *ifactory;
3088 GtkWidget *menuitem;
3090 if (mainwin->menu_lock_count) return;
3092 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3093 menuitem = gtk_item_factory_get_item
3094 (ifactory, "/View/Sort/Ascending");
3095 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3096 GTK_CHECK_MENU_ITEM(menuitem)->active
3097 ? SORT_ASCENDING : SORT_DESCENDING);
3101 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3104 FolderItem *item = mainwin->summaryview->folder_item;
3106 if (mainwin->menu_lock_count) return;
3108 summary_sort(mainwin->summaryview,
3109 item->sort_key, (FolderSortType)action);
3112 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3115 summary_attract_by_subject(mainwin->summaryview);
3118 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3121 summary_delete_duplicated(mainwin->summaryview);
3124 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3126 summary_filter(mainwin->summaryview);
3129 static void execute_summary_cb(MainWindow *mainwin, guint action,
3132 summary_execute(mainwin->summaryview);
3135 static void update_summary_cb(MainWindow *mainwin, guint action,
3139 FolderView *folderview = mainwin->folderview;
3141 if (!mainwin->summaryview->folder_item) return;
3142 if (!folderview->opened) return;
3144 folder_update_op_count();
3146 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3147 folderview->opened);
3150 summary_show(mainwin->summaryview, fitem, TRUE);
3153 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3155 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3158 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3160 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3163 static void prev_unread_cb(MainWindow *mainwin, guint action,
3166 summary_select_prev_unread(mainwin->summaryview);
3169 static void next_unread_cb(MainWindow *mainwin, guint action,
3172 summary_select_next_unread(mainwin->summaryview);
3175 static void prev_marked_cb(MainWindow *mainwin, guint action,
3178 summary_select_prev_marked(mainwin->summaryview);
3181 static void next_marked_cb(MainWindow *mainwin, guint action,
3184 summary_select_next_marked(mainwin->summaryview);
3187 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3190 summary_select_prev_labeled(mainwin->summaryview);
3193 static void next_labeled_cb(MainWindow *mainwin, guint action,
3196 summary_select_next_labeled(mainwin->summaryview);
3199 static void goto_folder_cb(MainWindow *mainwin, guint action,
3202 FolderItem *to_folder;
3204 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3207 folderview_select(mainwin->folderview, to_folder);
3210 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3212 messageview_copy_clipboard(mainwin->messageview);
3215 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3217 MessageView *msgview = mainwin->messageview;
3219 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3220 summary_select_all(mainwin->summaryview);
3221 else if (messageview_is_visible(msgview) &&
3222 (GTK_WIDGET_HAS_FOCUS(msgview->textview->text) ||
3223 GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3224 messageview_select_all(mainwin->messageview);
3227 static void selthread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3229 if (messageview_is_visible(mainwin->summaryview->messageview))
3230 summary_select_thread(mainwin->summaryview);
3233 static void create_filter_cb(MainWindow *mainwin, guint action,
3236 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action);
3239 static void prefs_common_open_cb(MainWindow *mainwin, guint action,
3242 prefs_common_open();
3245 static void prefs_filter_open_cb(MainWindow *mainwin, guint action,
3248 prefs_filter_open(NULL, NULL);
3251 static void prefs_scoring_open_cb(MainWindow *mainwin, guint action,
3254 prefs_scoring_open(NULL);
3257 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3260 prefs_filtering_open(NULL, NULL, NULL);
3263 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3266 prefs_template_open();
3269 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3272 prefs_actions_open(mainwin);
3275 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3279 new_account_cb(mainwin, 0, widget);
3281 gboolean prev_default = cur_account->is_default;
3283 prefs_account_open(cur_account);
3284 if (!prev_default && cur_account->is_default)
3285 account_set_as_default(cur_account);
3286 account_save_config_all();
3288 main_window_reflect_prefs_all();
3292 static void new_account_cb(MainWindow *mainwin, guint action,
3295 account_edit_open();
3296 if (!compose_get_compose_list()) account_add();
3299 static void account_menu_cb(GtkMenuItem *menuitem, gpointer data)
3301 cur_account = (PrefsAccount *)data;
3302 main_window_reflect_prefs_all();
3305 static void manual_open_cb(MainWindow *mainwin, guint action,
3308 manual_open((ManualLang)action);
3311 static void faq_open_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3313 faq_open((ManualLang)action);
3316 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3318 MainWindow *mainwin = (MainWindow *)data;
3322 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3323 LOCAL_FOLDER(folder)->rootpath,
3327 str = g_strdup_printf(_("Scanning folder %s ..."),
3328 LOCAL_FOLDER(folder)->rootpath);
3330 STATUSBAR_PUSH(mainwin, str);
3331 STATUSBAR_POP(mainwin);
3335 static void activate_compose_button (MainWindow *mainwin,
3337 ComposeButtonType type)
3339 SensitiveCond state = main_window_get_current_state(mainwin);
3341 if (style == TOOLBAR_NONE)
3344 gtk_widget_hide(type == COMPOSEBUTTON_NEWS ? mainwin->compose_mail_btn
3345 : mainwin->compose_news_btn);
3346 gtk_widget_show(type == COMPOSEBUTTON_NEWS ? mainwin->compose_news_btn
3347 : mainwin->compose_mail_btn);
3348 mainwin->compose_btn_type = type;
3351 void main_window_toolbar_set_compose_button(MainWindow *mainwin, ComposeButtonType compose_btn_type)
3353 if (mainwin->compose_btn_type != compose_btn_type)
3354 activate_compose_button(mainwin,
3355 prefs_common.toolbar_style,
3359 static void menuitem_expandsummaryview_statechanged (GtkWidget *widget, GtkStateType state, gpointer data)
3361 MainWindow *mainwin = (MainWindow*) data;
3363 if (!mainwin) return;
3365 gtk_widget_set_sensitive(GTK_WIDGET(mainwin->summaryview->toggle_arrow), GTK_WIDGET_IS_SENSITIVE(widget));
3368 #define BREAK_ON_MODIFIER_KEY() \
3369 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3371 static void key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
3373 MainWindow *mainwin = (MainWindow*) data;
3375 if (!mainwin || !event) return;
3377 switch (event->keyval) {
3378 case GDK_Q: /* Quit */
3379 BREAK_ON_MODIFIER_KEY();
3381 app_exit_cb(mainwin, 0, NULL);
3388 #undef BREAK_ON_MODIFIER_KEY
3390 static void set_toolbar_style(MainWindow *mainwin)
3392 switch (prefs_common.toolbar_style) {
3394 gtk_widget_hide(mainwin->handlebox);
3397 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3401 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3405 gtk_toolbar_set_style(GTK_TOOLBAR(mainwin->toolbar),
3410 if (prefs_common.toolbar_style != TOOLBAR_NONE) {
3411 gtk_widget_show(mainwin->handlebox);
3412 gtk_widget_queue_resize(mainwin->handlebox);
3414 if (prefs_common.immediate_exec)
3415 gtk_widget_hide(mainwin->exec_btn);
3417 gtk_widget_show(mainwin->exec_btn);
3422 * Harvest addresses for selected folder.
3424 static void addr_harvest_cb( MainWindow *mainwin,
3428 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3432 * Harvest addresses for selected messages in summary view.
3434 static void addr_harvest_msg_cb( MainWindow *mainwin,
3438 summary_harvest_address( mainwin->summaryview );