2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws team
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #include <glib/gi18n.h>
24 #include <gdk/gdkkeysyms.h>
25 #include <gtk/gtkmain.h>
26 #include <gtk/gtkwindow.h>
27 #include <gtk/gtkwidget.h>
28 #include <gtk/gtksignal.h>
29 #include <gtk/gtkvbox.h>
30 #include <gtk/gtkcontainer.h>
31 #include <gtk/gtkstatusbar.h>
32 #include <gtk/gtkprogressbar.h>
33 #include <gtk/gtkhpaned.h>
34 #include <gtk/gtkvpaned.h>
35 #include <gtk/gtkcheckmenuitem.h>
36 #include <gtk/gtkitemfactory.h>
37 #include <gtk/gtkeditable.h>
38 #include <gtk/gtkmenu.h>
39 #include <gtk/gtkmenuitem.h>
40 #include <gtk/gtkhandlebox.h>
41 #include <gtk/gtktoolbar.h>
42 #include <gtk/gtkbutton.h>
43 #include <gtk/gtktooltips.h>
47 #include "mainwindow.h"
48 #include "folderview.h"
49 #include "foldersel.h"
50 #include "summaryview.h"
51 #include "summary_search.h"
52 #include "messageview.h"
53 #include "message_search.h"
54 #include "headerview.h"
56 #include "stock_pixmap.h"
63 #include "prefs_common.h"
64 #include "prefs_actions.h"
65 #include "prefs_filtering.h"
66 #include "prefs_account.h"
67 #include "prefs_summary_column.h"
68 #include "prefs_folder_column.h"
69 #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 "ssl_manager.h"
85 #include "sslcertwindow.h"
86 #include "prefs_gtk.h"
87 #include "pluginwindow.h"
89 #include "progressindicator.h"
90 #include "localfolder.h"
91 #include "filtering.h"
92 #include "folderutils.h"
93 #include "foldersort.h"
94 #include "icon_legend.h"
96 #define AC_LABEL_WIDTH 240
98 /* list of all instantiated MainWindow */
99 static GList *mainwin_list = NULL;
101 static GdkCursor *watch_cursor;
103 static void main_window_menu_callback_block (MainWindow *mainwin);
104 static void main_window_menu_callback_unblock (MainWindow *mainwin);
106 static void main_window_show_cur_account (MainWindow *mainwin);
108 static void main_window_set_widgets (MainWindow *mainwin,
112 static gboolean toolbar_account_button_pressed (GtkWidget *widget,
113 GdkEventButton *event,
117 static void toolbar_child_attached (GtkWidget *widget,
120 static void toolbar_child_detached (GtkWidget *widget,
124 static gboolean ac_label_button_pressed (GtkWidget *widget,
125 GdkEventButton *event,
128 static gint main_window_close_cb (GtkWidget *widget,
131 static gint folder_window_close_cb (GtkWidget *widget,
134 static gint message_window_close_cb (GtkWidget *widget,
138 static void main_window_size_allocate_cb (GtkWidget *widget,
139 GtkAllocation *allocation,
141 static void folder_window_size_allocate_cb (GtkWidget *widget,
142 GtkAllocation *allocation,
144 static void message_window_size_allocate_cb (GtkWidget *widget,
145 GtkAllocation *allocation,
148 static void update_folderview_cb (MainWindow *mainwin,
151 static void add_mailbox_cb (MainWindow *mainwin,
154 static void foldersort_cb (MainWindow *mainwin,
157 static void import_mbox_cb (MainWindow *mainwin,
160 static void export_mbox_cb (MainWindow *mainwin,
163 static void export_list_mbox_cb (MainWindow *mainwin,
166 static void empty_trash_cb (MainWindow *mainwin,
170 static void save_as_cb (MainWindow *mainwin,
173 static void print_cb (MainWindow *mainwin,
176 static void app_exit_cb (MainWindow *mainwin,
180 static void search_cb (MainWindow *mainwin,
184 static void toggle_folder_cb (MainWindow *mainwin,
187 static void toggle_message_cb (MainWindow *mainwin,
190 static void toggle_toolbar_cb (MainWindow *mainwin,
193 static void toggle_statusbar_cb (MainWindow *mainwin,
196 static void separate_widget_cb (MainWindow *mainwin,
200 static void addressbook_open_cb (MainWindow *mainwin,
203 static void log_window_show_cb (MainWindow *mainwin,
207 static void inc_cancel_cb (MainWindow *mainwin,
211 static void open_msg_cb (MainWindow *mainwin,
215 static void view_source_cb (MainWindow *mainwin,
219 static void show_all_header_cb (MainWindow *mainwin,
223 static void move_to_cb (MainWindow *mainwin,
226 static void copy_to_cb (MainWindow *mainwin,
229 static void delete_cb (MainWindow *mainwin,
232 static void delete_trash_cb (MainWindow *mainwin,
236 static void cancel_cb (MainWindow *mainwin,
240 static void mark_cb (MainWindow *mainwin,
243 static void unmark_cb (MainWindow *mainwin,
247 static void mark_as_unread_cb (MainWindow *mainwin,
250 static void mark_as_read_cb (MainWindow *mainwin,
253 static void mark_all_read_cb (MainWindow *mainwin,
257 static void reedit_cb (MainWindow *mainwin,
261 static void add_address_cb (MainWindow *mainwin,
265 static void set_charset_cb (MainWindow *mainwin,
269 static void set_decode_cb (MainWindow *mainwin,
273 static void hide_read_messages (MainWindow *mainwin,
277 static void thread_cb (MainWindow *mainwin,
280 static void expand_threads_cb (MainWindow *mainwin,
283 static void collapse_threads_cb (MainWindow *mainwin,
287 static void set_summary_display_item_cb (MainWindow *mainwin,
290 static void set_folder_display_item_cb (MainWindow *mainwin,
293 static void sort_summary_cb (MainWindow *mainwin,
296 static void sort_summary_type_cb (MainWindow *mainwin,
299 static void attract_by_subject_cb(MainWindow *mainwin,
303 static void delete_duplicated_cb (MainWindow *mainwin,
306 static void delete_duplicated_all_cb (MainWindow *mainwin,
309 static void filter_cb (MainWindow *mainwin,
312 static void execute_summary_cb (MainWindow *mainwin,
315 static void update_summary_cb (MainWindow *mainwin,
319 static void prev_cb (MainWindow *mainwin,
322 static void next_cb (MainWindow *mainwin,
325 static void next_unread_cb (MainWindow *mainwin,
328 static void prev_unread_cb (MainWindow *mainwin,
332 static void prev_new_cb (MainWindow *mainwin,
335 static void next_new_cb (MainWindow *mainwin,
338 static void prev_marked_cb (MainWindow *mainwin,
341 static void next_marked_cb (MainWindow *mainwin,
344 static void prev_labeled_cb (MainWindow *mainwin,
347 static void next_labeled_cb (MainWindow *mainwin,
351 static void goto_folder_cb (MainWindow *mainwin,
355 static void copy_cb (MainWindow *mainwin,
358 static void allsel_cb (MainWindow *mainwin,
361 static void select_thread_cb (MainWindow *mainwin,
365 static void create_filter_cb (MainWindow *mainwin,
368 static void create_processing_cb (MainWindow *mainwin,
372 static void prefs_template_open_cb (MainWindow *mainwin,
375 static void prefs_actions_open_cb (MainWindow *mainwin,
378 static void prefs_account_open_cb (MainWindow *mainwin,
382 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
386 static void prefs_post_processing_open_cb (MainWindow *mainwin,
390 static void prefs_filtering_open_cb (MainWindow *mainwin,
394 static void ssl_manager_open_cb (MainWindow *mainwin,
398 static void new_account_cb (MainWindow *mainwin,
402 static void account_selector_menu_cb (GtkMenuItem *menuitem,
404 static void account_receive_menu_cb (GtkMenuItem *menuitem,
407 static void prefs_open_cb (GtkMenuItem *menuitem,
409 static void plugins_open_cb (GtkMenuItem *menuitem,
412 static void online_switch_clicked(GtkButton *btn,
415 static void manual_open_cb (MainWindow *mainwin,
419 static void legend_open_cb (GtkMenuItem *menuitem,
422 static void scan_tree_func (Folder *folder,
426 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
428 static void addr_harvest_cb ( MainWindow *mainwin,
432 static void addr_harvest_msg_cb ( MainWindow *mainwin,
435 static void sync_cb ( MainWindow *mainwin,
439 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
440 GdkEventFocus *focus,
442 void main_window_reply_cb (MainWindow *mainwin,
445 gboolean mainwindow_progressindicator_hook (gpointer source,
447 #define SEPARATE_ACTION 500
448 static void mainwindow_quicksearch (MainWindow *mainwin,
452 static GtkItemFactoryEntry mainwin_entries[] =
454 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
455 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
456 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
457 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
458 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
459 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
460 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
461 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
462 {N_("/_File/Exp_ort selected to mbox file..."),
463 NULL, export_list_mbox_cb, 0, NULL},
464 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
465 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
466 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
467 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
468 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
469 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
470 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
471 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
472 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
473 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
474 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
476 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
477 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
478 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
479 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
480 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
481 {N_("/_Edit/_Find in current message..."),
482 "<control>F", search_cb, 0, NULL},
483 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
484 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
485 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
486 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
487 {N_("/_View/Show or hi_de/_Folder tree"),
488 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
489 {N_("/_View/Show or hi_de/_Message view"),
490 "V", toggle_message_cb, 0, "<ToggleItem>"},
491 {N_("/_View/Show or hi_de/_Toolbar"),
492 NULL, NULL, 0, "<Branch>"},
493 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
494 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
495 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
496 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
497 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
498 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
499 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
500 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
501 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
502 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
503 {N_("/_View/Show or hi_de/Status _bar"),
504 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
505 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
506 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
507 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
509 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
510 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
511 {N_("/_View/Separate _message view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
512 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
513 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
514 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
515 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
516 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
517 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
518 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
519 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
520 {N_("/_View/_Sort/by _color label"),
521 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
522 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
523 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
524 {N_("/_View/_Sort/by a_ttachment"),
525 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
526 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
527 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
528 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
529 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
530 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
531 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
532 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
533 {N_("/_View/_Sort/_Attract by subject"),
534 NULL, attract_by_subject_cb, 0, NULL},
535 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
536 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
537 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
538 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
540 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
541 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
542 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
543 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
544 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
545 {N_("/_View/_Go to/P_revious unread message"),
546 "<shift>P", prev_unread_cb, 0, NULL},
547 {N_("/_View/_Go to/N_ext unread message"),
548 "<shift>N", next_unread_cb, 0, NULL},
549 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
550 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
551 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
552 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
553 {N_("/_View/_Go to/Previous _marked message"),
554 NULL, prev_marked_cb, 0, NULL},
555 {N_("/_View/_Go to/Next m_arked message"),
556 NULL, next_marked_cb, 0, NULL},
557 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
558 {N_("/_View/_Go to/Previous _labeled message"),
559 NULL, prev_labeled_cb, 0, NULL},
560 {N_("/_View/_Go to/Next la_beled message"),
561 NULL, next_labeled_cb, 0, NULL},
562 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
563 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
564 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
566 #define ENC_SEPARATOR \
567 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
568 #define ENC_ACTION(action) \
569 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
571 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
572 {N_("/_View/Character _encoding/_Auto detect"),
573 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
574 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
575 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
576 ENC_ACTION(C_US_ASCII)},
577 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
578 ENC_ACTION(C_UTF_8)},
581 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
582 ENC_ACTION(C_ISO_8859_1)},
583 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
584 ENC_ACTION(C_ISO_8859_15)},
585 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
586 ENC_ACTION(C_WINDOWS_1252)},
589 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
590 ENC_ACTION(C_ISO_8859_2)},
593 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
594 ENC_ACTION(C_ISO_8859_13)},
595 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
596 ENC_ACTION(C_ISO_8859_4)},
599 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
600 ENC_ACTION(C_ISO_8859_7)},
603 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
604 ENC_ACTION(C_ISO_8859_8)},
605 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
606 ENC_ACTION(C_CP1255)},
609 {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"),
610 ENC_ACTION(C_ISO_8859_6)},
611 {N_("/_View/Character _encoding/Arabic (Windows-1256)"),
612 ENC_ACTION(C_CP1256)},
615 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
616 ENC_ACTION(C_ISO_8859_9)},
619 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
620 ENC_ACTION(C_ISO_8859_5)},
621 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
622 ENC_ACTION(C_KOI8_R)},
623 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
624 ENC_ACTION(C_KOI8_U)},
625 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
626 ENC_ACTION(C_CP1251)},
629 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
630 ENC_ACTION(C_ISO_2022_JP)},
631 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
632 ENC_ACTION(C_ISO_2022_JP_2)},
633 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
634 ENC_ACTION(C_EUC_JP)},
635 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
636 ENC_ACTION(C_SHIFT_JIS)},
639 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
640 ENC_ACTION(C_GB2312)},
641 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
643 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
645 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
646 ENC_ACTION(C_EUC_TW)},
647 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
648 ENC_ACTION(C_ISO_2022_CN)},
651 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
652 ENC_ACTION(C_EUC_KR)},
653 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
654 ENC_ACTION(C_ISO_2022_KR)},
657 {N_("/_View/Character _encoding/Thai (TIS-620)"),
658 ENC_ACTION(C_TIS_620)},
659 {N_("/_View/Character _encoding/Thai (Windows-874)"),
660 ENC_ACTION(C_WINDOWS_874)},
665 #define DEC_SEPARATOR \
666 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
667 #define DEC_ACTION(action) \
668 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
669 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
670 {N_("/_View/Decode/_Auto detect"),
671 NULL, set_decode_cb, 0, "<RadioItem>"},
672 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
673 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
674 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
675 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
676 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
681 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
682 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
683 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
684 {N_("/_View/Show all headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
685 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
686 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
688 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
689 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
690 {N_("/_Message/Recei_ve/Get from _current account"),
691 "<control>I", inc_mail_cb, 0, NULL},
692 {N_("/_Message/Recei_ve/Get from _all accounts"),
693 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
694 {N_("/_Message/Recei_ve/Cancel receivin_g"),
695 NULL, inc_cancel_cb, 0, NULL},
696 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
697 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
698 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
699 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
700 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
701 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
702 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
703 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
704 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
705 {N_("/_Message/Repl_y to/mailing _list"),
706 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
707 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
708 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
709 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
710 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
711 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
712 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
713 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
714 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
715 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
716 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
717 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
718 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
719 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
720 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
721 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
722 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
723 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
724 {N_("/_Message/_Mark/Mark as rea_d"),
725 NULL, mark_as_read_cb, 0, NULL},
726 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
727 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
728 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
730 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
731 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
732 {N_("/_Tools/Add sender to address boo_k"),
733 NULL, add_address_cb, 0, NULL},
734 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
735 {N_("/_Tools/_Harvest addresses/from _Folder..."),
736 NULL, addr_harvest_cb, 0, NULL},
737 {N_("/_Tools/_Harvest addresses/from _Messages..."),
738 NULL, addr_harvest_msg_cb, 0, NULL},
739 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
740 {N_("/_Tools/_Filter all messages in folder"),
741 NULL, filter_cb, 0, NULL},
742 {N_("/_Tools/Filter _selected messages"),
743 NULL, filter_cb, 1, NULL},
744 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
745 {N_("/_Tools/_Create filter rule/_Automatically"),
746 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
747 {N_("/_Tools/_Create filter rule/by _From"),
748 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
749 {N_("/_Tools/_Create filter rule/by _To"),
750 NULL, create_filter_cb, FILTER_BY_TO, NULL},
751 {N_("/_Tools/_Create filter rule/by _Subject"),
752 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
753 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
754 {N_("/_Tools/C_reate processing rule/_Automatically"),
755 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
756 {N_("/_Tools/C_reate processing rule/by _From"),
757 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
758 {N_("/_Tools/C_reate processing rule/by _To"),
759 NULL, create_processing_cb, FILTER_BY_TO, NULL},
760 {N_("/_Tools/C_reate processing rule/by _Subject"),
761 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
762 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
763 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
764 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
765 {N_("/_Tools/Ch_eck for new messages in all folders"),
766 NULL, update_folderview_cb, 0, NULL},
767 {N_("/_Tools/Delete du_plicated messages"),
768 NULL, NULL, 0, "<Branch>"},
769 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
770 NULL, delete_duplicated_cb, 0, NULL},
771 {N_("/_Tools/Delete du_plicated messages/In all folders"),
772 NULL, delete_duplicated_all_cb, 0, NULL},
773 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
774 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
776 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
777 {N_("/_Tools/SSL cer_tificates..."),
778 NULL, ssl_manager_open_cb, 0, NULL},
780 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
781 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
783 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
784 {N_("/_Configuration/C_hange current account"),
785 NULL, NULL, 0, "<Branch>"},
786 {N_("/_Configuration/_Preferences for current account..."),
787 NULL, prefs_account_open_cb, 0, NULL},
788 {N_("/_Configuration/Create _new account..."),
789 NULL, new_account_cb, 0, NULL},
790 {N_("/_Configuration/_Edit accounts..."),
791 NULL, account_edit_open, 0, NULL},
792 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
793 {N_("/_Configuration/P_references..."),
794 NULL, prefs_open_cb, 0, NULL},
795 {N_("/_Configuration/Pre-pr_ocessing..."),
796 NULL, prefs_pre_processing_open_cb, 0, NULL},
797 {N_("/_Configuration/Post-pro_cessing..."),
798 NULL, prefs_post_processing_open_cb, 0, NULL},
799 {N_("/_Configuration/_Filtering..."),
800 NULL, prefs_filtering_open_cb, 0, NULL},
801 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
802 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
803 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
805 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
806 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
807 {N_("/_Help/_Online User-contributed FAQ"),
808 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
809 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
810 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
811 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
814 static gboolean offline_ask_sync = TRUE;
816 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
822 MainWindow *mainwin = (MainWindow *)user_data;
824 if (mainwin->summaryview &&
825 mainwin->summaryview->quicksearch &&
826 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
827 (mod == 0 || mod == GDK_SHIFT_MASK)) {
828 quicksearch_pass_key(mainwin->summaryview->quicksearch, value, mod);
834 MainWindow *main_window_create(SeparateType type)
840 GtkWidget *handlebox;
841 GtkWidget *vbox_body;
842 GtkWidget *hbox_stat;
843 GtkWidget *statusbar;
844 GtkWidget *progressbar;
845 GtkWidget *statuslabel;
846 GtkWidget *ac_button;
848 GtkWidget *online_pixmap;
849 GtkWidget *offline_pixmap;
850 GtkWidget *online_switch;
851 GtkWidget *offline_switch;
852 GtkTooltips *offline_tip;
853 GtkTooltips *online_tip;
854 GtkTooltips *sel_ac_tip;
856 FolderView *folderview;
857 SummaryView *summaryview;
858 MessageView *messageview;
859 GdkColormap *colormap;
862 GtkItemFactory *ifactory;
866 guint n_menu_entries;
868 static GdkGeometry geometry;
870 debug_print("Creating main window...\n");
871 mainwin = g_new0(MainWindow, 1);
874 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
875 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
876 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
878 if (!geometry.min_height) {
879 geometry.min_width = 320;
880 geometry.min_height = 200;
882 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
885 g_signal_connect(G_OBJECT(window), "delete_event",
886 G_CALLBACK(main_window_close_cb), mainwin);
887 MANAGE_WINDOW_SIGNALS_CONNECT(window);
888 g_signal_connect(G_OBJECT(window), "focus_in_event",
889 G_CALLBACK(mainwindow_focus_in_event),
891 g_signal_connect(G_OBJECT(window), "key_press_event",
892 G_CALLBACK(mainwindow_key_pressed), mainwin);
894 gtk_widget_realize(window);
895 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
898 gtkut_widget_set_app_icon(window);
900 vbox = gtk_vbox_new(FALSE, 0);
901 gtk_widget_show(vbox);
902 gtk_container_add(GTK_CONTAINER(window), vbox);
905 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
906 menubar = menubar_create(window, mainwin_entries,
907 n_menu_entries, "<Main>", mainwin);
908 gtk_widget_show(menubar);
909 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
910 ifactory = gtk_item_factory_from_widget(menubar);
912 menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
914 if (prefs_common.toolbar_detachable) {
915 handlebox = gtk_handle_box_new();
916 gtk_widget_show(handlebox);
917 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
918 g_signal_connect(G_OBJECT(handlebox), "child_attached",
919 G_CALLBACK(toolbar_child_attached), mainwin);
920 g_signal_connect(G_OBJECT(handlebox), "child_detached",
921 G_CALLBACK(toolbar_child_detached), mainwin);
923 handlebox = gtk_hbox_new(FALSE, 0);
924 gtk_widget_show(handlebox);
925 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
927 /* link window to mainwin->window to avoid gdk warnings */
928 mainwin->window = window;
931 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
935 /* vbox that contains body */
936 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
937 gtk_widget_show(vbox_body);
938 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
939 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
941 hbox_stat = gtk_hbox_new(FALSE, 2);
942 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
944 statusbar = statusbar_create();
945 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
947 progressbar = gtk_progress_bar_new();
948 gtk_widget_set_size_request(progressbar, 120, 1);
949 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
951 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
952 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
953 online_tip = gtk_tooltips_new();
954 online_switch = gtk_button_new ();
955 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
956 _("You are online. Click the icon to go offline"), NULL);
957 offline_tip = gtk_tooltips_new();
958 offline_switch = gtk_button_new ();
959 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
960 _("You are offline. Click the icon to go online"),
962 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
963 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
964 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
965 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
966 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
967 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
968 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
969 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
971 statuslabel = gtk_label_new("");
972 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
974 sel_ac_tip = gtk_tooltips_new();
975 ac_button = gtk_button_new();
976 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
977 ac_button, _("Select account"), NULL);
978 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
979 gtk_widget_set_size_request(ac_button, -1, 0);
980 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
981 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
982 G_CALLBACK(ac_label_button_pressed), mainwin);
984 ac_label = gtk_label_new("");
985 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
987 gtk_widget_show_all(hbox_stat);
989 gtk_widget_hide(offline_switch);
991 mainwin->folderview = folderview = folderview_create();
992 mainwin->summaryview = summaryview = summary_create();
993 mainwin->messageview = messageview = messageview_create(mainwin);
994 mainwin->logwin = log_window_create();
996 folderview->mainwin = mainwin;
997 folderview->summaryview = summaryview;
999 summaryview->mainwin = mainwin;
1000 summaryview->folderview = folderview;
1001 summaryview->messageview = messageview;
1002 summaryview->window = window;
1004 messageview->statusbar = statusbar;
1005 mainwin->vbox = vbox;
1006 mainwin->menubar = menubar;
1007 mainwin->menu_factory = ifactory;
1008 mainwin->handlebox = handlebox;
1009 mainwin->vbox_body = vbox_body;
1010 mainwin->hbox_stat = hbox_stat;
1011 mainwin->statusbar = statusbar;
1012 mainwin->progressbar = progressbar;
1013 mainwin->statuslabel = statuslabel;
1014 mainwin->online_switch = online_switch;
1015 mainwin->online_pixmap = online_pixmap;
1016 mainwin->offline_pixmap = offline_pixmap;
1017 mainwin->ac_button = ac_button;
1018 mainwin->ac_label = ac_label;
1019 mainwin->offline_switch = offline_switch;
1021 /* set context IDs for status bar */
1022 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1023 (GTK_STATUSBAR(statusbar), "Main Window");
1024 mainwin->folderview_cid = gtk_statusbar_get_context_id
1025 (GTK_STATUSBAR(statusbar), "Folder View");
1026 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1027 (GTK_STATUSBAR(statusbar), "Summary View");
1028 mainwin->messageview_cid = gtk_statusbar_get_context_id
1029 (GTK_STATUSBAR(statusbar), "Message View");
1031 messageview->statusbar_cid = mainwin->messageview_cid;
1033 /* allocate colors for summary view and folder view */
1034 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1035 summaryview->color_marked.blue = (guint16)65535;
1037 summaryview->color_dim.red = summaryview->color_dim.green =
1038 summaryview->color_dim.blue = COLOR_DIM;
1040 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1041 &folderview->color_new);
1043 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1044 &folderview->color_op);
1046 summaryview->color_important.red = 0;
1047 summaryview->color_important.green = 0;
1048 summaryview->color_important.blue = (guint16)65535;
1050 color[0] = summaryview->color_marked;
1051 color[1] = summaryview->color_dim;
1052 color[2] = folderview->color_new;
1053 color[3] = folderview->color_op;
1055 colormap = gdk_drawable_get_colormap(window->window);
1056 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1057 for (i = 0; i < 4; i++) {
1058 if (success[i] == FALSE)
1059 g_warning("MainWindow: color allocation %d failed\n", i);
1062 debug_print("done.\n");
1064 messageview->visible = prefs_common.msgview_visible;
1066 main_window_set_widgets(mainwin, type);
1068 g_signal_connect(G_OBJECT(window), "size_allocate",
1069 G_CALLBACK(main_window_size_allocate_cb),
1072 /* set menu items */
1073 menuitem = gtk_item_factory_get_item
1074 (ifactory, "/View/Character encoding/Auto detect");
1075 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1077 switch (prefs_common.toolbar_style) {
1079 menuitem = gtk_item_factory_get_item
1080 (ifactory, "/View/Show or hide/Toolbar/Hide");
1083 menuitem = gtk_item_factory_get_item
1084 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1087 menuitem = gtk_item_factory_get_item
1088 (ifactory, "/View/Show or hide/Toolbar/Text only");
1091 menuitem = gtk_item_factory_get_item
1092 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1094 case TOOLBAR_BOTH_HORIZ:
1095 menuitem = gtk_item_factory_get_item
1097 "/View/Show or hide/Toolbar/Text beside icons");
1099 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1101 gtk_widget_hide(mainwin->hbox_stat);
1102 menuitem = gtk_item_factory_get_item
1103 (ifactory, "/View/Show or hide/Status bar");
1104 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1105 prefs_common.show_statusbar);
1107 /* set account selection menu */
1108 ac_menu = gtk_item_factory_get_widget
1109 (ifactory, "/Configuration/Change current account");
1110 mainwin->ac_menu = ac_menu;
1112 toolbar_main_set_sensitive(mainwin);
1114 /* create actions menu */
1115 main_window_update_actions_menu(mainwin);
1117 /* attach accel groups to main window */
1118 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1119 gtk_window_add_accel_group \
1121 gtk_item_factory_from_widget(menu)->accel_group); \
1122 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1124 G_CALLBACK(main_window_accel_activate), mainwin);
1127 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1129 /* connect the accelerators for equivalent
1130 menu items in different menus */
1131 menu_connect_identical_items();
1134 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1136 gtk_widget_show(mainwin->window);
1138 /* initialize views */
1139 folderview_init(folderview);
1140 summary_init(summaryview);
1141 messageview_init(messageview);
1142 log_window_init(mainwin->logwin);
1143 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1144 prefs_common.loglength);
1146 sslcertwindow_register_hook();
1148 mainwin->lock_count = 0;
1149 mainwin->menu_lock_count = 0;
1150 mainwin->cursor_count = 0;
1152 mainwin->progressindicator_hook =
1153 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1156 watch_cursor = gdk_cursor_new(GDK_WATCH);
1158 mainwin_list = g_list_append(mainwin_list, mainwin);
1160 /* init work_offline */
1161 if (prefs_common.work_offline)
1162 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1167 void main_window_destroy(MainWindow *mainwin)
1169 /* TODO : destroy other component */
1170 messageview_destroy(mainwin->messageview);
1171 mainwin->messageview = NULL;
1174 void main_window_update_actions_menu(MainWindow *mainwin)
1176 GtkItemFactory *ifactory;
1178 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1179 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1182 void main_window_cursor_wait(MainWindow *mainwin)
1185 if (mainwin->cursor_count == 0)
1186 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1188 mainwin->cursor_count++;
1193 void main_window_cursor_normal(MainWindow *mainwin)
1195 if (mainwin->cursor_count)
1196 mainwin->cursor_count--;
1198 if (mainwin->cursor_count == 0)
1199 gdk_window_set_cursor(mainwin->window->window, NULL);
1204 /* lock / unlock the user-interface */
1205 void main_window_lock(MainWindow *mainwin)
1207 if (mainwin->lock_count == 0)
1208 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1210 mainwin->lock_count++;
1212 main_window_set_menu_sensitive(mainwin);
1213 toolbar_main_set_sensitive(mainwin);
1216 void main_window_unlock(MainWindow *mainwin)
1218 if (mainwin->lock_count)
1219 mainwin->lock_count--;
1221 main_window_set_menu_sensitive(mainwin);
1222 toolbar_main_set_sensitive(mainwin);
1224 if (mainwin->lock_count == 0)
1225 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1228 static void main_window_menu_callback_block(MainWindow *mainwin)
1230 mainwin->menu_lock_count++;
1233 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1235 if (mainwin->menu_lock_count)
1236 mainwin->menu_lock_count--;
1239 static guint prefs_tag = 0;
1241 void main_window_reflect_prefs_all(void)
1243 main_window_reflect_prefs_all_real(FALSE);
1246 static gboolean reflect_prefs_timeout_cb(gpointer data)
1248 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1250 MainWindow *mainwin;
1253 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1254 mainwin = (MainWindow *)cur->data;
1256 main_window_show_cur_account(mainwin);
1257 main_window_set_menu_sensitive(mainwin);
1258 toolbar_main_set_sensitive(mainwin);
1261 if (pixmap_theme_changed) {
1262 toolbar_update(TOOLBAR_MAIN, mainwin);
1263 messageview_reflect_prefs_pixmap_theme();
1264 compose_reflect_prefs_pixmap_theme();
1265 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1266 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1268 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1269 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1270 mainwin->online_pixmap);
1271 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1272 gtk_widget_show(pixmap);
1273 mainwin->online_pixmap = pixmap;
1274 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1275 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1276 mainwin->offline_pixmap);
1277 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1278 gtk_widget_show(pixmap);
1279 mainwin->offline_pixmap = pixmap;
1282 headerview_set_font(mainwin->messageview->headerview);
1283 headerview_set_visibility(mainwin->messageview->headerview,
1284 prefs_common.display_header_pane);
1285 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1286 folderview_reflect_prefs();
1287 summary_reflect_prefs();
1288 summary_redisplay_msg(mainwin->summaryview);
1294 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1296 if (prefs_tag == 0 || pixmap_theme_changed) {
1297 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1298 GINT_TO_POINTER(pixmap_theme_changed));
1302 void main_window_set_summary_column(void)
1305 MainWindow *mainwin;
1307 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1308 mainwin = (MainWindow *)cur->data;
1309 summary_set_column_order(mainwin->summaryview);
1313 void main_window_set_folder_column(void)
1316 MainWindow *mainwin;
1318 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1319 mainwin = (MainWindow *)cur->data;
1320 folderview_set_column_order(mainwin->folderview);
1324 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1325 GList *account_list)
1327 GList *cur_ac, *cur_item;
1328 GtkWidget *menuitem;
1329 PrefsAccount *ac_prefs;
1331 /* destroy all previous menu item */
1332 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1333 while (cur_item != NULL) {
1334 GList *next = cur_item->next;
1335 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1339 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1340 ac_prefs = (PrefsAccount *)cur_ac->data;
1342 menuitem = gtk_menu_item_new_with_label
1343 (ac_prefs->account_name
1344 ? ac_prefs->account_name : _("Untitled"));
1345 gtk_widget_show(menuitem);
1346 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1347 g_signal_connect(G_OBJECT(menuitem), "activate",
1348 G_CALLBACK(account_selector_menu_cb),
1353 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1354 GList *account_list)
1356 GList *cur_ac, *cur_item;
1358 GtkWidget *menuitem;
1359 PrefsAccount *ac_prefs;
1361 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1362 "/Message/Receive");
1364 /* search for separator */
1365 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1366 cur_item = cur_item->next) {
1367 if (GTK_BIN(cur_item->data)->child == NULL) {
1368 cur_item = cur_item->next;
1373 /* destroy all previous menu item */
1374 while (cur_item != NULL) {
1375 GList *next = cur_item->next;
1376 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1380 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1381 ac_prefs = (PrefsAccount *)cur_ac->data;
1383 menuitem = gtk_menu_item_new_with_label
1384 (ac_prefs->account_name ? ac_prefs->account_name
1386 gtk_widget_show(menuitem);
1387 gtk_menu_append(GTK_MENU(menu), menuitem);
1388 g_signal_connect(G_OBJECT(menuitem), "activate",
1389 G_CALLBACK(account_receive_menu_cb),
1394 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
1395 GList *account_list)
1397 GList *cur_ac, *cur_item;
1398 GtkWidget *menuitem;
1399 PrefsAccount *ac_prefs;
1400 GtkWidget *menu = NULL;
1402 if (mainwin->toolbar->getall_btn == NULL
1403 || mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
1406 menu = mainwin->toolbar->getall_combo->menu;
1408 /* destroy all previous menu item */
1409 cur_item = GTK_MENU_SHELL(menu)->children;
1410 while (cur_item != NULL) {
1411 GList *next = cur_item->next;
1412 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1416 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1417 ac_prefs = (PrefsAccount *)cur_ac->data;
1419 menuitem = gtk_menu_item_new_with_label
1420 (ac_prefs->account_name
1421 ? ac_prefs->account_name : _("Untitled"));
1422 gtk_widget_show(menuitem);
1423 gtk_menu_append(GTK_MENU(menu), menuitem);
1424 g_signal_connect(G_OBJECT(menuitem), "activate",
1425 G_CALLBACK(account_receive_menu_cb),
1430 void main_window_set_account_menu(GList *account_list)
1433 MainWindow *mainwin;
1435 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1436 mainwin = (MainWindow *)cur->data;
1437 main_window_set_account_selector_menu(mainwin, account_list);
1438 main_window_set_account_receive_menu(mainwin, account_list);
1439 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1443 void main_window_set_account_menu_only_toolbar(GList *account_list)
1446 MainWindow *mainwin;
1448 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1449 mainwin = (MainWindow *)cur->data;
1450 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1454 static void main_window_show_cur_account(MainWindow *mainwin)
1459 ac_name = g_strdup(cur_account
1460 ? (cur_account->account_name
1461 ? cur_account->account_name : _("Untitled"))
1465 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1467 buf = g_strdup(PROG_VERSION);
1468 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1471 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1472 gtk_widget_queue_resize(mainwin->ac_button);
1477 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1479 switch (mainwin->type) {
1480 case SEPARATE_FOLDER:
1481 return mainwin->win.sep_folder.folderwin;
1483 return mainwin->win.sep_both.folderwin;
1489 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1491 switch (mainwin->type) {
1492 case SEPARATE_MESSAGE:
1493 return mainwin->win.sep_message.messagewin;
1495 return mainwin->win.sep_both.messagewin;
1501 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1503 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1504 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1505 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1506 GtkWidget *message_wid = mainwin->messageview->vbox;
1508 debug_print("Changing window separation type from %d to %d\n",
1509 mainwin->type, type);
1511 if (mainwin->type == type) return;
1513 /* remove widgets from those containers */
1514 gtk_widget_ref(folder_wid);
1515 gtk_widget_ref(summary_wid);
1516 gtk_widget_ref(message_wid);
1517 gtkut_container_remove
1518 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1519 gtkut_container_remove
1520 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1521 gtkut_container_remove
1522 (GTK_CONTAINER(message_wid->parent), message_wid);
1524 /* clean containers */
1525 switch (mainwin->type) {
1527 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1529 case SEPARATE_FOLDER:
1530 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1531 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1533 case SEPARATE_MESSAGE:
1534 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1535 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1538 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1539 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1543 gtk_widget_hide(mainwin->window);
1544 main_window_set_widgets(mainwin, type);
1545 gtk_widget_show(mainwin->window);
1547 gtk_widget_unref(folder_wid);
1548 gtk_widget_unref(summary_wid);
1549 gtk_widget_unref(message_wid);
1552 void main_window_toggle_message_view(MainWindow *mainwin)
1554 SummaryView *summaryview = mainwin->summaryview;
1555 union CompositeWin *cwin = &mainwin->win;
1556 GtkWidget *vpaned = NULL;
1557 GtkWidget *container = NULL;
1558 GtkWidget *msgwin = NULL;
1560 switch (mainwin->type) {
1562 vpaned = cwin->sep_none.vpaned;
1563 container = cwin->sep_none.hpaned;
1565 case SEPARATE_FOLDER:
1566 vpaned = cwin->sep_folder.vpaned;
1567 container = mainwin->vbox_body;
1569 case SEPARATE_MESSAGE:
1570 msgwin = mainwin->win.sep_message.messagewin;
1573 msgwin = mainwin->win.sep_both.messagewin;
1578 if (GTK_WIDGET_VISIBLE(msgwin)) {
1579 gtk_widget_hide(msgwin);
1580 mainwin->messageview->visible = FALSE;
1581 summaryview->displayed = NULL;
1583 gtk_widget_show(msgwin);
1584 mainwin->messageview->visible = TRUE;
1586 } else if (vpaned->parent != NULL) {
1587 mainwin->messageview->visible = FALSE;
1588 summaryview->displayed = NULL;
1589 gtk_widget_ref(vpaned);
1590 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1591 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1593 mainwin->messageview->visible = TRUE;
1594 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1595 gtk_container_add(GTK_CONTAINER(container), vpaned);
1596 gtk_widget_unref(vpaned);
1599 if (messageview_is_visible(mainwin->messageview))
1600 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1601 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1603 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1604 GTK_ARROW_UP, GTK_SHADOW_OUT);
1606 if (mainwin->messageview->visible == FALSE)
1607 messageview_clear(mainwin->messageview);
1609 main_window_set_menu_sensitive(mainwin);
1611 prefs_common.msgview_visible = mainwin->messageview->visible;
1613 gtk_widget_grab_focus(summaryview->ctree);
1616 void main_window_get_size(MainWindow *mainwin)
1618 GtkAllocation *allocation;
1620 if (mainwin->messageview == NULL) {
1621 debug_print("called after messageview "
1622 "has been deallocated!\n");
1626 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1628 if (allocation->width > 1 && allocation->height > 1) {
1629 prefs_common.summaryview_width = allocation->width;
1631 if ((mainwin->type == SEPARATE_NONE ||
1632 mainwin->type == SEPARATE_FOLDER) &&
1633 messageview_is_visible(mainwin->messageview))
1634 prefs_common.summaryview_height = allocation->height;
1636 prefs_common.mainview_width = allocation->width;
1639 allocation = &mainwin->window->allocation;
1640 if (allocation->width > 1 && allocation->height > 1) {
1641 prefs_common.mainview_height = allocation->height;
1642 prefs_common.mainwin_width = allocation->width;
1643 prefs_common.mainwin_height = allocation->height;
1646 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1647 if (allocation->width > 1 && allocation->height > 1) {
1648 prefs_common.folderview_width = allocation->width;
1649 prefs_common.folderview_height = allocation->height;
1652 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1653 if (allocation->width > 1 && allocation->height > 1) {
1654 prefs_common.msgview_width = allocation->width;
1655 prefs_common.msgview_height = allocation->height;
1658 /* debug_print("summaryview size: %d x %d\n",
1659 prefs_common.summaryview_width,
1660 prefs_common.summaryview_height);
1661 debug_print("folderview size: %d x %d\n",
1662 prefs_common.folderview_width,
1663 prefs_common.folderview_height);
1664 debug_print("messageview size: %d x %d\n",
1665 prefs_common.msgview_width,
1666 prefs_common.msgview_height); */
1669 void main_window_get_position(MainWindow *mainwin)
1674 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1676 prefs_common.mainview_x = x;
1677 prefs_common.mainview_y = y;
1678 prefs_common.mainwin_x = x;
1679 prefs_common.mainwin_y = y;
1681 debug_print("main window position: %d, %d\n", x, y);
1683 window = main_window_get_folder_window(mainwin);
1685 gtkut_widget_get_uposition(window, &x, &y);
1686 prefs_common.folderwin_x = x;
1687 prefs_common.folderwin_y = y;
1688 debug_print("folder window position: %d, %d\n", x, y);
1690 window = main_window_get_message_window(mainwin);
1692 gtkut_widget_get_uposition(window, &x, &y);
1693 prefs_common.main_msgwin_x = x;
1694 prefs_common.main_msgwin_y = y;
1695 debug_print("message window position: %d, %d\n", x, y);
1699 void main_window_progress_on(MainWindow *mainwin)
1701 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1704 void main_window_progress_off(MainWindow *mainwin)
1706 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1707 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1710 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1714 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1715 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
1716 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
1717 (cur == 0 && total == 0) ? 0 :
1718 (gfloat)cur / (gfloat)total);
1721 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1724 if (alertpanel(_("Empty trash"),
1725 _("Delete all messages in trash folders?"),
1726 GTK_STOCK_CANCEL, _("+_Empty trash"), NULL)
1727 != G_ALERTALTERNATE)
1729 manage_window_focus_in(mainwin->window, NULL, NULL);
1732 procmsg_empty_all_trash();
1734 if (mainwin->summaryview->folder_item &&
1735 mainwin->summaryview->folder_item->stype == F_TRASH)
1736 gtk_widget_grab_focus(mainwin->folderview->ctree);
1739 void main_window_add_mailbox(MainWindow *mainwin)
1744 path = input_dialog(_("Add mailbox"),
1745 _("Input the location of mailbox.\n"
1746 "If the existing mailbox is specified, it will be\n"
1747 "scanned automatically."),
1750 if (folder_find_from_path(path)) {
1751 alertpanel_error(_("The mailbox '%s' already exists."), path);
1755 folder = folder_new(folder_get_class_from_string("mh"),
1756 !strcmp(path, "Mail") ? _("Mailbox") :
1757 g_path_get_basename(path), path);
1760 if (folder->klass->create_tree(folder) < 0) {
1761 alertpanel_error(_("Creation of the mailbox failed.\n"
1762 "Maybe some files already exist, or you don't have the permission to write there."));
1763 folder_destroy(folder);
1768 folder_set_ui_func(folder, scan_tree_func, mainwin);
1769 folder_scan_tree(folder, TRUE);
1770 folder_set_ui_func(folder, NULL, NULL);
1773 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1775 SensitiveCond state = 0;
1776 SummarySelection selection;
1777 FolderItem *item = mainwin->summaryview->folder_item;
1778 GList *account_list = account_get_list();
1780 selection = summary_get_selection_type(mainwin->summaryview);
1782 if (mainwin->lock_count == 0)
1783 state |= M_UNLOCKED;
1784 if (selection != SUMMARY_NONE)
1785 state |= M_MSG_EXIST;
1786 if (item && item->path && folder_item_parent(item) && !item->no_select) {
1788 /* if (item->folder->type != F_NEWS) */
1789 state |= M_ALLOW_DELETE;
1791 if (prefs_common.immediate_exec == 0
1792 && mainwin->lock_count == 0)
1793 state |= M_DELAY_EXEC;
1795 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1796 || selection != SUMMARY_NONE)
1797 state |= M_HIDE_READ_MSG;
1799 if (mainwin->summaryview->threaded)
1800 state |= M_THREADED;
1802 state |= M_UNTHREADED;
1803 if (selection == SUMMARY_SELECTED_SINGLE ||
1804 selection == SUMMARY_SELECTED_MULTIPLE)
1805 state |= M_TARGET_EXIST;
1806 if (selection == SUMMARY_SELECTED_SINGLE)
1807 state |= M_SINGLE_TARGET_EXIST;
1808 if (mainwin->summaryview->folder_item &&
1809 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1812 state |= M_NOT_NEWS;
1813 if (selection == SUMMARY_SELECTED_SINGLE &&
1815 (folder_has_parent_of_type(item, F_DRAFT) ||
1816 folder_has_parent_of_type(item, F_OUTBOX) ||
1817 folder_has_parent_of_type(item, F_QUEUE))))
1818 state |= M_ALLOW_REEDIT;
1820 state |= M_HAVE_ACCOUNT;
1822 for ( ; account_list != NULL; account_list = account_list->next) {
1823 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1824 state |= M_HAVE_NEWS_ACCOUNT;
1829 if (inc_is_active())
1830 state |= M_INC_ACTIVE;
1832 if (mainwin->summaryview->deleted > 0 ||
1833 mainwin->summaryview->moved > 0 ||
1834 mainwin->summaryview->copied > 0)
1835 state |= M_DELAY_EXEC;
1842 void main_window_set_menu_sensitive(MainWindow *mainwin)
1844 GtkItemFactory *ifactory = mainwin->menu_factory;
1845 SensitiveCond state;
1848 GtkWidget *menuitem;
1849 SummaryView *summaryview;
1854 static const struct {
1858 {"/File/Save as...", M_TARGET_EXIST},
1859 {"/File/Print..." , M_TARGET_EXIST},
1860 {"/File/Exit" , M_UNLOCKED},
1862 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1864 {"/View/Sort" , M_EXEC},
1865 {"/View/Thread view" , M_EXEC},
1866 {"/View/Expand all threads" , M_MSG_EXIST},
1867 {"/View/Collapse all threads" , M_MSG_EXIST},
1868 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1869 {"/View/Go to/Previous message" , M_MSG_EXIST},
1870 {"/View/Go to/Next message" , M_MSG_EXIST},
1871 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
1872 {"/View/Go to/Previous new message" , M_MSG_EXIST},
1873 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
1874 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1875 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
1876 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1877 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1878 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1879 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1881 {"/Message/Receive/Get from current account"
1882 , M_HAVE_ACCOUNT|M_UNLOCKED},
1883 {"/Message/Receive/Get from all accounts"
1884 , M_HAVE_ACCOUNT|M_UNLOCKED},
1885 {"/Message/Receive/Cancel receiving"
1888 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1889 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1890 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1891 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1892 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1893 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1894 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1895 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
1896 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
1897 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
1898 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
1899 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
1900 {"/Message/Mark" , M_TARGET_EXIST},
1901 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1903 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
1904 {"/Tools/Harvest addresses" , M_MSG_EXIST},
1905 {"/Tools/Harvest addresses/from Messages..."
1907 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
1908 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
1909 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1910 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1911 {"/Tools/Actions" , M_TARGET_EXIST},
1912 {"/Tools/Execute" , M_DELAY_EXEC},
1913 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
1915 {"/Configuration", M_UNLOCKED},
1920 state = main_window_get_current_state(mainwin);
1922 for (i = 0; entry[i].entry != NULL; i++) {
1923 sensitive = ((entry[i].cond & state) == entry[i].cond);
1924 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1927 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1929 /* search for separator */
1930 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1931 cur_item = cur_item->next) {
1932 if (GTK_BIN(cur_item->data)->child == NULL) {
1933 cur_item = cur_item->next;
1938 for (; cur_item != NULL; cur_item = cur_item->next) {
1939 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1940 (M_UNLOCKED & state) != 0);
1943 main_window_menu_callback_block(mainwin);
1945 #define SET_CHECK_MENU_ACTIVE(path, active) \
1947 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1948 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1951 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1952 messageview_is_visible(mainwin->messageview));
1954 summaryview = mainwin->summaryview;
1955 menu_path = "/View/Sort/Don't sort";
1957 switch (summaryview->sort_key) {
1958 case SORT_BY_NUMBER:
1959 menu_path = "/View/Sort/by number"; break;
1961 menu_path = "/View/Sort/by Size"; break;
1963 menu_path = "/View/Sort/by Date"; break;
1965 menu_path = "/View/Sort/by From"; break;
1967 menu_path = "/View/Sort/by To"; break;
1968 case SORT_BY_SUBJECT:
1969 menu_path = "/View/Sort/by Subject"; break;
1971 menu_path = "/View/Sort/by color label"; break;
1973 menu_path = "/View/Sort/by mark"; break;
1974 case SORT_BY_STATUS:
1975 menu_path = "/View/Sort/by status"; break;
1977 menu_path = "/View/Sort/by attachment"; break;
1979 menu_path = "/View/Sort/by score"; break;
1980 case SORT_BY_LOCKED:
1981 menu_path = "/View/Sort/by locked"; break;
1984 menu_path = "/View/Sort/Don't sort"; break;
1986 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1988 if (summaryview->sort_type == SORT_ASCENDING) {
1989 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1991 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1994 if (summaryview->sort_key != SORT_BY_NONE) {
1995 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1996 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1998 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1999 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2002 if (mainwin->messageview
2003 && mainwin->messageview->mimeview
2004 && mainwin->messageview->mimeview->textview)
2005 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
2006 mainwin->messageview->mimeview->textview->show_all_headers);
2007 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2009 #undef SET_CHECK_MENU_ACTIVE
2011 main_window_menu_callback_unblock(mainwin);
2014 void main_window_popup(MainWindow *mainwin)
2016 gtkut_window_popup(mainwin->window);
2018 switch (mainwin->type) {
2019 case SEPARATE_FOLDER:
2020 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
2022 case SEPARATE_MESSAGE:
2023 gtkut_window_popup(mainwin->win.sep_message.messagewin);
2026 gtkut_window_popup(mainwin->win.sep_both.folderwin);
2027 gtkut_window_popup(mainwin->win.sep_both.messagewin);
2034 void main_window_show(MainWindow *mainwin)
2036 gtk_widget_show(mainwin->window);
2037 gtk_widget_show(mainwin->vbox_body);
2039 gtk_widget_set_uposition(mainwin->window,
2040 prefs_common.mainwin_x,
2041 prefs_common.mainwin_y);
2043 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2044 prefs_common.folderview_width,
2045 prefs_common.folderview_height);
2046 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2047 prefs_common.summaryview_width,
2048 prefs_common.summaryview_height);
2049 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2050 prefs_common.msgview_width,
2051 prefs_common.msgview_height);
2053 if (mainwin->type & SEPARATE_FOLDER) {
2054 GtkWidget *folderwin;
2056 folderwin = main_window_get_folder_window(mainwin);
2057 gtk_widget_show(folderwin);
2058 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
2059 prefs_common.folderwin_y);
2062 if (mainwin->type & SEPARATE_MESSAGE) {
2063 GtkWidget *messagewin;
2065 messagewin = main_window_get_message_window(mainwin);
2066 gtk_widget_show(messagewin);
2067 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
2068 prefs_common.main_msgwin_y);
2072 void main_window_hide(MainWindow *mainwin)
2074 main_window_get_size(mainwin);
2075 main_window_get_position(mainwin);
2077 gtk_widget_hide(mainwin->window);
2078 gtk_widget_hide(mainwin->vbox_body);
2080 if (mainwin->type & SEPARATE_FOLDER) {
2081 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2084 if (mainwin->type & SEPARATE_MESSAGE) {
2085 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2089 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
2091 GtkWidget *folderwin = NULL;
2092 GtkWidget *messagewin = NULL;
2095 GtkWidget *vbox_body = mainwin->vbox_body;
2096 GtkItemFactory *ifactory = mainwin->menu_factory;
2097 GtkWidget *menuitem;
2098 GtkItemFactory *msgview_ifactory;
2100 debug_print("Setting widgets... ");
2102 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2103 prefs_common.folderview_width,
2104 prefs_common.folderview_height);
2105 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2106 prefs_common.summaryview_width,
2107 prefs_common.summaryview_height);
2108 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2109 prefs_common.msgview_width,
2110 prefs_common.msgview_height);
2112 /* create separated window(s) if needed */
2113 if (type & SEPARATE_FOLDER) {
2114 static GdkGeometry folderwin_geometry;
2116 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2117 gtk_window_set_title(GTK_WINDOW(folderwin),
2118 _("Sylpheed-Claws - Folder View"));
2120 gtk_window_move(GTK_WINDOW(folderwin),
2121 prefs_common.folderwin_x,
2122 prefs_common.folderwin_y);
2124 if (!folderwin_geometry.min_height) {
2125 folderwin_geometry.min_width = 320;
2126 folderwin_geometry.min_height = 200;
2128 gtk_window_set_geometry_hints(GTK_WINDOW(folderwin), NULL,
2129 &folderwin_geometry, GDK_HINT_MIN_SIZE);
2131 gtk_widget_set_size_request(folderwin,
2132 prefs_common.folderview_width,
2133 prefs_common.folderview_height);
2135 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
2138 g_signal_connect(G_OBJECT(folderwin), "delete_event",
2139 G_CALLBACK(folder_window_close_cb),
2141 gtk_container_add(GTK_CONTAINER(folderwin),
2142 GTK_WIDGET_PTR(mainwin->folderview));
2143 gtk_widget_realize(folderwin);
2145 if (prefs_common.folderview_visible)
2146 gtk_widget_show(folderwin);
2149 if (type & SEPARATE_MESSAGE) {
2150 static GdkGeometry msgwin_geometry;
2152 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2153 gtk_window_set_title(GTK_WINDOW(messagewin),
2154 _("Sylpheed-Claws - Message View"));
2156 gtk_window_move(GTK_WINDOW(messagewin),
2157 prefs_common.main_msgwin_x,
2158 prefs_common.main_msgwin_y);
2160 if (!msgwin_geometry.min_height) {
2161 msgwin_geometry.min_width = 320;
2162 msgwin_geometry.min_height = 200;
2164 gtk_window_set_geometry_hints(GTK_WINDOW(messagewin), NULL,
2165 &msgwin_geometry, GDK_HINT_MIN_SIZE);
2167 gtk_widget_set_size_request(messagewin,
2168 prefs_common.msgwin_width,
2169 prefs_common.msgwin_height);
2171 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2173 g_signal_connect(G_OBJECT(messagewin), "delete_event",
2174 G_CALLBACK(message_window_close_cb),
2176 if (messageview_is_visible(mainwin->messageview))
2177 gtk_widget_show(messagewin);
2179 mainwin->messageview->statusbar = mainwin->statusbar;
2180 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2185 hpaned = gtk_hpaned_new();
2186 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2187 gtk_paned_add1(GTK_PANED(hpaned),
2188 GTK_WIDGET_PTR(mainwin->folderview));
2189 gtk_widget_show(hpaned);
2190 gtk_widget_queue_resize(hpaned);
2192 vpaned = gtk_vpaned_new();
2193 if (messageview_is_visible(mainwin->messageview)) {
2194 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2195 gtk_paned_add1(GTK_PANED(vpaned),
2196 GTK_WIDGET_PTR(mainwin->summaryview));
2198 gtk_paned_add2(GTK_PANED(hpaned),
2199 GTK_WIDGET_PTR(mainwin->summaryview));
2200 gtk_widget_ref(vpaned);
2202 gtk_paned_add2(GTK_PANED(vpaned),
2203 GTK_WIDGET_PTR(mainwin->messageview));
2204 gtk_widget_show(vpaned);
2205 gtk_widget_queue_resize(vpaned);
2207 mainwin->win.sep_none.hpaned = hpaned;
2208 mainwin->win.sep_none.vpaned = vpaned;
2210 /* remove headerview if not in prefs */
2211 headerview_set_visibility(mainwin->messageview->headerview,
2212 prefs_common.display_header_pane);
2214 case SEPARATE_FOLDER:
2215 vpaned = gtk_vpaned_new();
2216 if (messageview_is_visible(mainwin->messageview)) {
2217 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2219 gtk_paned_add1(GTK_PANED(vpaned),
2220 GTK_WIDGET_PTR(mainwin->summaryview));
2222 gtk_box_pack_start(GTK_BOX(vbox_body),
2223 GTK_WIDGET_PTR(mainwin->summaryview),
2225 gtk_widget_ref(vpaned);
2227 gtk_paned_add2(GTK_PANED(vpaned),
2228 GTK_WIDGET_PTR(mainwin->messageview));
2229 gtk_widget_show(vpaned);
2230 gtk_widget_queue_resize(vpaned);
2232 mainwin->win.sep_folder.folderwin = folderwin;
2233 mainwin->win.sep_folder.vpaned = vpaned;
2235 /* remove headerview if not in prefs */
2236 headerview_set_visibility(mainwin->messageview->headerview,
2237 prefs_common.display_header_pane);
2240 case SEPARATE_MESSAGE:
2241 hpaned = gtk_hpaned_new();
2242 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2243 gtk_paned_add1(GTK_PANED(hpaned),
2244 GTK_WIDGET_PTR(mainwin->folderview));
2245 gtk_paned_add2(GTK_PANED(hpaned),
2246 GTK_WIDGET_PTR(mainwin->summaryview));
2247 gtk_widget_show(hpaned);
2248 gtk_widget_queue_resize(hpaned);
2249 messageview_add_toolbar(mainwin->messageview, messagewin);
2250 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2251 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2253 mainwin->win.sep_message.messagewin = messagewin;
2254 mainwin->win.sep_message.hpaned = hpaned;
2256 gtk_widget_realize(messagewin);
2257 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2258 gtk_widget_show_all(messagewin);
2259 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2260 mainwin->messageview->handlebox,
2261 prefs_common.toolbar_style);
2265 messageview_add_toolbar(mainwin->messageview, messagewin);
2266 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2267 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2269 gtk_box_pack_start(GTK_BOX(vbox_body),
2270 GTK_WIDGET_PTR(mainwin->summaryview),
2273 mainwin->win.sep_both.folderwin = folderwin;
2274 mainwin->win.sep_both.messagewin = messagewin;
2276 gtk_widget_realize(messagewin);
2277 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2278 gtk_widget_show_all(messagewin);
2279 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2280 mainwin->messageview->handlebox,
2281 prefs_common.toolbar_style);
2286 if (messageview_is_visible(mainwin->messageview))
2287 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2288 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2290 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2291 GTK_ARROW_UP, GTK_SHADOW_OUT);
2293 gtk_window_move(GTK_WINDOW(mainwin->window),
2294 prefs_common.mainwin_x,
2295 prefs_common.mainwin_y);
2297 gtk_widget_queue_resize(vbox_body);
2298 gtk_widget_queue_resize(mainwin->vbox);
2299 gtk_widget_queue_resize(mainwin->window);
2300 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2301 * and mimeview icon list/ctree lose track of their visibility states */
2302 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2303 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2304 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2305 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2306 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2307 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2309 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2311 mainwin->type = type;
2314 /* toggle menu state */
2315 menuitem = gtk_item_factory_get_item
2316 (ifactory, "/View/Show or hide/Folder tree");
2317 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2318 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2319 prefs_common.folderview_visible);
2320 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2321 menuitem = gtk_item_factory_get_item
2322 (ifactory, "/View/Show or hide/Message view");
2323 gtk_check_menu_item_set_active
2324 (GTK_CHECK_MENU_ITEM(menuitem),
2325 messageview_is_visible(mainwin->messageview));
2327 menuitem = gtk_item_factory_get_item
2328 (ifactory, "/View/Separate folder tree");
2329 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2330 ((type & SEPARATE_FOLDER) != 0));
2331 menuitem = gtk_item_factory_get_item
2332 (ifactory, "/View/Separate message view");
2333 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2334 ((type & SEPARATE_MESSAGE) != 0));
2338 (G_OBJECT(folderwin), "size_allocate",
2339 G_CALLBACK(folder_window_size_allocate_cb),
2344 (G_OBJECT(messagewin), "size_allocate",
2345 G_CALLBACK(message_window_size_allocate_cb),
2349 debug_print("done.\n");
2352 void main_window_destroy_all(void)
2354 while (mainwin_list != NULL) {
2355 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2357 /* free toolbar stuff */
2358 toolbar_clear_list(TOOLBAR_MAIN);
2359 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2360 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2362 mainwin->folderview->mainwin = NULL;
2363 mainwin->summaryview->mainwin = NULL;
2364 mainwin->messageview->mainwin = NULL;
2366 g_free(mainwin->toolbar);
2369 mainwin_list = g_list_remove(mainwin_list, mainwin);
2371 g_list_free(mainwin_list);
2372 mainwin_list = NULL;
2376 static gboolean toolbar_account_button_pressed(GtkWidget *widget,
2377 GdkEventButton *event,
2380 MainWindow *mainwin = (MainWindow *)data;
2382 if (!event) return FALSE;
2383 if (event->button != 3) return FALSE;
2385 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2386 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2389 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2390 menu_button_position, widget,
2391 event->button, event->time);
2397 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2400 gtk_widget_set_size_request(child, 1, -1);
2403 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2406 gtk_widget_set_size_request(child, -1, -1);
2409 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2412 MainWindow *mainwin = (MainWindow *)data;
2414 if (!event) return FALSE;
2416 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2417 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2420 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2421 menu_button_position, widget,
2422 event->button, event->time);
2427 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2430 MainWindow *mainwin = (MainWindow *)data;
2432 if (mainwin->lock_count == 0)
2433 app_exit_cb(data, 0, widget);
2438 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2441 MainWindow *mainwin = (MainWindow *)data;
2442 GtkWidget *menuitem;
2444 menuitem = gtk_item_factory_get_item
2445 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2446 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2451 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2454 MainWindow *mainwin = (MainWindow *)data;
2455 GtkWidget *menuitem;
2457 menuitem = gtk_item_factory_get_item
2458 (mainwin->menu_factory, "/View/Show or hide/Message view");
2459 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2461 mainwin->messageview->statusbar = mainwin->statusbar;
2462 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2467 static void main_window_size_allocate_cb(GtkWidget *widget,
2468 GtkAllocation *allocation,
2471 MainWindow *mainwin = (MainWindow *)data;
2473 main_window_get_size(mainwin);
2476 static void folder_window_size_allocate_cb(GtkWidget *widget,
2477 GtkAllocation *allocation,
2480 MainWindow *mainwin = (MainWindow *)data;
2482 main_window_get_size(mainwin);
2485 static void message_window_size_allocate_cb(GtkWidget *widget,
2486 GtkAllocation *allocation,
2489 MainWindow *mainwin = (MainWindow *)data;
2491 main_window_get_size(mainwin);
2494 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2497 main_window_add_mailbox(mainwin);
2500 static void update_folderview_cb(MainWindow *mainwin, guint action,
2503 summary_show(mainwin->summaryview, NULL);
2504 folderview_check_new_all();
2507 static void foldersort_cb(MainWindow *mainwin, guint action,
2513 static void import_mbox_cb(MainWindow *mainwin, guint action,
2516 import_mbox(mainwin->summaryview->folder_item);
2519 static void export_mbox_cb(MainWindow *mainwin, guint action,
2522 export_mbox(mainwin->summaryview->folder_item);
2525 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
2528 summaryview_export_mbox_list(mainwin->summaryview);
2531 static void empty_trash_cb(MainWindow *mainwin, guint action,
2534 main_window_empty_trash(mainwin, TRUE);
2537 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2539 summary_save_as(mainwin->summaryview);
2542 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2544 summary_print(mainwin->summaryview);
2547 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2549 if (prefs_common.confirm_on_exit) {
2550 if (alertpanel(_("Exit"), _("Exit Sylpheed-Claws?"),
2551 GTK_STOCK_CANCEL, GTK_STOCK_OK, NULL)
2552 != G_ALERTALTERNATE)
2554 manage_window_focus_in(mainwin->window, NULL, NULL);
2557 app_will_exit(widget, mainwin);
2560 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2563 summary_search(mainwin->summaryview);
2565 message_search(mainwin->messageview);
2568 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
2570 prefs_common.show_searchbar = TRUE;
2571 summaryview_activate_quicksearch(mainwin->summaryview);
2574 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2579 active = GTK_CHECK_MENU_ITEM(widget)->active;
2581 switch (mainwin->type) {
2583 case SEPARATE_MESSAGE:
2586 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2588 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2591 case SEPARATE_FOLDER:
2592 debug_print("separate folder\n");
2594 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2596 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2600 gtk_widget_show(mainwin->win.sep_both.folderwin);
2602 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2606 prefs_common.folderview_visible = active;
2609 static void toggle_message_cb(MainWindow *mainwin, guint action,
2614 active = GTK_CHECK_MENU_ITEM(widget)->active;
2616 if (active != messageview_is_visible(mainwin->messageview))
2617 summary_toggle_view(mainwin->summaryview);
2620 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2623 toolbar_toggle(action, mainwin);
2626 void main_window_reply_cb(MainWindow *mainwin, guint action,
2629 MessageView *msgview = (MessageView*)mainwin->messageview;
2630 GSList *msginfo_list = NULL;
2632 g_return_if_fail(msgview != NULL);
2634 msginfo_list = summary_get_selection(mainwin->summaryview);
2635 g_return_if_fail(msginfo_list != NULL);
2636 compose_reply_from_messageview(msgview, msginfo_list, action);
2637 g_slist_free(msginfo_list);
2641 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2644 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2645 gtk_widget_show(mainwin->hbox_stat);
2646 prefs_common.show_statusbar = TRUE;
2648 gtk_widget_hide(mainwin->hbox_stat);
2649 prefs_common.show_statusbar = FALSE;
2653 static void separate_widget_cb(MainWindow *mainwin, guint action,
2658 if (GTK_CHECK_MENU_ITEM(widget)->active)
2659 type = mainwin->type | action;
2661 type = mainwin->type & ~action;
2663 main_window_separation_change(mainwin, type);
2665 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2666 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2669 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
2672 offline_ask_sync = ask_sync;
2674 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2676 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2677 offline_ask_sync = TRUE;
2680 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2682 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
2685 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
2687 GList *folderlist = folder_get_list();
2688 gboolean found = FALSE;
2690 /* see if there are synchronised folders */
2691 for (; folderlist; folderlist = folderlist->next) {
2692 Folder *folder = (Folder *)folderlist->data;
2693 if (folder_want_synchronise(folder)) {
2702 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
2703 _("Do you want to synchronise your folders now?"),
2704 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
2707 folder_synchronise(NULL);
2710 static void online_switch_clicked (GtkButton *btn, gpointer data)
2712 MainWindow *mainwin;
2713 GtkItemFactory *ifactory;
2714 GtkCheckMenuItem *menuitem;
2716 mainwin = (MainWindow *) data;
2718 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2719 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2721 g_return_if_fail(mainwin != NULL);
2722 g_return_if_fail(menuitem != NULL);
2724 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2726 mainwindow_check_synchronise(mainwin, TRUE);
2727 gtk_widget_hide (mainwin->online_switch);
2728 gtk_widget_show (mainwin->offline_switch);
2729 menuitem->active = TRUE;
2730 prefs_common.work_offline = TRUE;
2731 inc_autocheck_timer_remove();
2734 gtk_widget_hide (mainwin->offline_switch);
2735 gtk_widget_show (mainwin->online_switch);
2736 menuitem->active = FALSE;
2737 prefs_common.work_offline = FALSE;
2738 inc_autocheck_timer_set();
2742 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2745 addressbook_open(NULL);
2748 static void log_window_show_cb(MainWindow *mainwin, guint action,
2751 log_window_show(mainwin->logwin);
2754 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2759 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2761 summary_move_to(mainwin->summaryview);
2764 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2766 summary_copy_to(mainwin->summaryview);
2769 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2771 summary_delete(mainwin->summaryview);
2774 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2776 summary_delete_trash(mainwin->summaryview);
2779 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2781 summary_cancel(mainwin->summaryview);
2784 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2786 summary_open_msg(mainwin->summaryview);
2789 static void view_source_cb(MainWindow *mainwin, guint action,
2792 summary_view_source(mainwin->summaryview);
2795 static void show_all_header_cb(MainWindow *mainwin, guint action,
2798 if (mainwin->menu_lock_count) return;
2799 mainwin->summaryview->messageview->all_headers =
2800 GTK_CHECK_MENU_ITEM(widget)->active;
2801 summary_display_msg_selected(mainwin->summaryview,
2802 GTK_CHECK_MENU_ITEM(widget)->active);
2805 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2807 summary_mark(mainwin->summaryview);
2810 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2812 summary_unmark(mainwin->summaryview);
2815 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2818 summary_mark_as_unread(mainwin->summaryview);
2821 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2824 summary_mark_as_read(mainwin->summaryview);
2827 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2830 summary_mark_all_read(mainwin->summaryview);
2833 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2835 summary_reedit(mainwin->summaryview);
2838 static void add_address_cb(MainWindow *mainwin, guint action,
2841 summary_add_address(mainwin->summaryview);
2844 static void set_charset_cb(MainWindow *mainwin, guint action,
2849 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2850 str = conv_get_charset_str((CharSet)action);
2852 g_free(mainwin->messageview->forced_charset);
2853 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
2854 procmime_force_charset(str);
2856 summary_redisplay_msg(mainwin->summaryview);
2858 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2862 static void set_decode_cb(MainWindow *mainwin, guint action,
2865 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2866 mainwin->messageview->forced_encoding = (EncodingType)action;
2868 summary_redisplay_msg(mainwin->summaryview);
2870 debug_print("forced encoding: %d\n", action);
2874 static void hide_read_messages (MainWindow *mainwin, guint action,
2877 if (!mainwin->summaryview->folder_item
2878 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
2880 summary_toggle_show_read_messages(mainwin->summaryview);
2883 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2885 if (mainwin->menu_lock_count) return;
2886 if (!mainwin->summaryview->folder_item) return;
2888 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2889 summary_thread_build(mainwin->summaryview);
2890 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2892 summary_unthread(mainwin->summaryview);
2893 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2897 static void expand_threads_cb(MainWindow *mainwin, guint action,
2900 summary_expand_threads(mainwin->summaryview);
2903 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2906 summary_collapse_threads(mainwin->summaryview);
2909 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
2912 prefs_summary_column_open();
2915 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
2918 prefs_folder_column_open();
2921 static void sort_summary_cb(MainWindow *mainwin, guint action,
2924 FolderItem *item = mainwin->summaryview->folder_item;
2925 GtkWidget *menuitem;
2927 if (mainwin->menu_lock_count) return;
2929 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2930 menuitem = gtk_item_factory_get_item
2931 (mainwin->menu_factory, "/View/Sort/Ascending");
2932 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2933 GTK_CHECK_MENU_ITEM(menuitem)->active
2934 ? SORT_ASCENDING : SORT_DESCENDING);
2935 item->sort_key = action;
2939 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2942 FolderItem *item = mainwin->summaryview->folder_item;
2944 if (mainwin->menu_lock_count) return;
2946 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2947 summary_sort(mainwin->summaryview,
2948 item->sort_key, (FolderSortType)action);
2951 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2954 summary_attract_by_subject(mainwin->summaryview);
2957 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2962 item = folderview_get_selected_item(mainwin->folderview);
2964 main_window_cursor_wait(mainwin);
2965 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
2967 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
2968 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
2970 STATUSBAR_POP(mainwin);
2971 main_window_cursor_normal(mainwin);
2981 static void deldup_all(FolderItem *item, gpointer _data)
2983 struct DelDupsData *data = _data;
2986 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
2988 data->dups += result;
2993 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
2996 struct DelDupsData data = {0, 0};
2998 folder_func_to_all_folders(deldup_all, &data);
2999 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
3000 "Deleted %d duplicate messages in %d folders.\n",
3002 data.dups, data.folders);
3005 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3007 summary_filter(mainwin->summaryview, (gboolean)action);
3010 static void execute_summary_cb(MainWindow *mainwin, guint action,
3013 summary_execute(mainwin->summaryview);
3016 static void update_summary_cb(MainWindow *mainwin, guint action,
3020 FolderView *folderview = mainwin->folderview;
3022 if (!mainwin->summaryview->folder_item) return;
3023 if (!folderview->opened) return;
3025 folder_update_op_count();
3027 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3028 folderview->opened);
3031 folder_item_scan(fitem);
3032 summary_show(mainwin->summaryview, fitem);
3035 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3037 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3040 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3042 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3045 static void prev_unread_cb(MainWindow *mainwin, guint action,
3048 summary_select_prev_unread(mainwin->summaryview);
3051 static void next_unread_cb(MainWindow *mainwin, guint action,
3054 summary_select_next_unread(mainwin->summaryview);
3057 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3059 summary_select_prev_new(mainwin->summaryview);
3062 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3064 summary_select_next_new(mainwin->summaryview);
3067 static void prev_marked_cb(MainWindow *mainwin, guint action,
3070 summary_select_prev_marked(mainwin->summaryview);
3073 static void next_marked_cb(MainWindow *mainwin, guint action,
3076 summary_select_next_marked(mainwin->summaryview);
3079 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3082 summary_select_prev_labeled(mainwin->summaryview);
3085 static void next_labeled_cb(MainWindow *mainwin, guint action,
3088 summary_select_next_labeled(mainwin->summaryview);
3091 static void goto_folder_cb(MainWindow *mainwin, guint action,
3094 FolderItem *to_folder;
3096 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3099 folderview_select(mainwin->folderview, to_folder);
3102 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3104 messageview_copy_clipboard(mainwin->messageview);
3107 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3109 MessageView *msgview = mainwin->messageview;
3111 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3112 summary_select_all(mainwin->summaryview);
3113 else if (messageview_is_visible(msgview) &&
3114 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3115 messageview_select_all(mainwin->messageview);
3118 static void select_thread_cb(MainWindow *mainwin, guint action,
3121 summary_select_thread(mainwin->summaryview);
3124 static void create_filter_cb(MainWindow *mainwin, guint action,
3127 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3130 static void create_processing_cb(MainWindow *mainwin, guint action,
3133 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3136 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3139 prefs_filtering_open(&pre_global_processing,
3140 _("Processing rules to apply before folder rules"),
3144 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3147 prefs_filtering_open(&post_global_processing,
3148 _("Processing rules to apply after folder rules"),
3152 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3155 prefs_filtering_open(&filtering_rules,
3156 _("Filtering configuration"),
3160 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3163 prefs_template_open();
3166 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3169 prefs_actions_open(mainwin);
3172 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3175 ssl_manager_open(mainwin);
3178 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3182 new_account_cb(mainwin, 0, widget);
3184 account_open(cur_account);
3188 static void new_account_cb(MainWindow *mainwin, guint action,
3191 account_edit_open();
3192 if (!compose_get_compose_list()) account_add();
3195 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3197 FolderItem *item = NULL;
3198 cur_account = (PrefsAccount *)data;
3200 if (!mainwindow_get_mainwindow())
3202 main_window_show_cur_account(mainwindow_get_mainwindow());
3203 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
3204 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
3205 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
3206 item = folderview_get_selected_item(
3207 mainwindow_get_mainwindow()->folderview);
3209 toolbar_set_compose_button
3210 (mainwindow_get_mainwindow()->toolbar,
3211 FOLDER_TYPE(item->folder) == F_NEWS ?
3212 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
3216 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3218 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3219 PrefsAccount *account = (PrefsAccount *)data;
3221 inc_account_mail(mainwin, account);
3224 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3229 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3231 pluginwindow_create();
3234 static void manual_open_cb(MainWindow *mainwin, guint action,
3237 manual_open((ManualType)action);
3240 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
3245 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3247 MainWindow *mainwin = (MainWindow *)data;
3251 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3252 LOCAL_FOLDER(folder)->rootpath,
3256 str = g_strdup_printf(_("Scanning folder %s ..."),
3257 LOCAL_FOLDER(folder)->rootpath);
3259 STATUSBAR_PUSH(mainwin, str);
3260 STATUSBAR_POP(mainwin);
3264 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3267 SummaryView *summary;
3269 g_return_val_if_fail(data, FALSE);
3270 summary = ((MainWindow *)data)->summaryview;
3271 g_return_val_if_fail(summary, FALSE);
3273 if (GTK_CLIST(summary->ctree)->selection &&
3274 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3277 if (summary->selected != summary->displayed)
3278 summary_select_node(summary, summary->displayed, FALSE, TRUE);
3282 #define BREAK_ON_MODIFIER_KEY() \
3283 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3285 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3288 MainWindow *mainwin = (MainWindow*) data;
3290 if (!mainwin || !event)
3293 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3296 switch (event->keyval) {
3297 case GDK_Q: /* Quit */
3298 BREAK_ON_MODIFIER_KEY();
3300 app_exit_cb(mainwin, 0, NULL);
3303 if (mainwin->folderview && mainwin->summaryview
3304 && !mainwin->summaryview->displayed) {
3305 summary_lock(mainwin->summaryview);
3306 folderview_select_next_unread(mainwin->folderview);
3307 summary_unlock(mainwin->summaryview);