2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2005 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 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/---"), NULL, NULL, 0, "<Separator>"},
506 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
507 {N_("/_View/Separate _message view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
508 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
509 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
510 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
511 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
512 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
513 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
514 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
515 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
516 {N_("/_View/_Sort/by _color label"),
517 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
518 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
519 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
520 {N_("/_View/_Sort/by a_ttachment"),
521 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
522 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
523 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
524 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
525 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
526 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
527 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
528 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
529 {N_("/_View/_Sort/_Attract by subject"),
530 NULL, attract_by_subject_cb, 0, NULL},
531 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
532 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
533 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
534 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
535 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
536 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
537 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
539 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
540 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
541 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
542 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
543 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
544 {N_("/_View/_Go to/P_rev unread message"),
545 "<shift>P", prev_unread_cb, 0, NULL},
546 {N_("/_View/_Go to/N_ext unread message"),
547 "<shift>N", next_unread_cb, 0, NULL},
548 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
549 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
550 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
551 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
552 {N_("/_View/_Go to/Prev _marked message"),
553 NULL, prev_marked_cb, 0, NULL},
554 {N_("/_View/_Go to/Next m_arked message"),
555 NULL, next_marked_cb, 0, NULL},
556 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
557 {N_("/_View/_Go to/Prev _labeled message"),
558 NULL, prev_labeled_cb, 0, NULL},
559 {N_("/_View/_Go to/Next la_beled message"),
560 NULL, next_labeled_cb, 0, NULL},
561 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
562 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
563 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
565 #define ENC_SEPARATOR \
566 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
567 #define ENC_ACTION(action) \
568 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
570 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
571 {N_("/_View/Character _encoding/_Auto detect"),
572 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
573 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
574 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
575 ENC_ACTION(C_US_ASCII)},
576 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
577 ENC_ACTION(C_UTF_8)},
580 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
581 ENC_ACTION(C_ISO_8859_1)},
582 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
583 ENC_ACTION(C_ISO_8859_15)},
584 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
585 ENC_ACTION(C_WINDOWS_1252)},
588 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
589 ENC_ACTION(C_ISO_8859_2)},
592 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
593 ENC_ACTION(C_ISO_8859_13)},
594 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
595 ENC_ACTION(C_ISO_8859_4)},
598 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
599 ENC_ACTION(C_ISO_8859_7)},
602 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
603 ENC_ACTION(C_ISO_8859_8)},
604 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
605 ENC_ACTION(C_CP1255)},
608 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
609 ENC_ACTION(C_ISO_8859_9)},
612 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
613 ENC_ACTION(C_ISO_8859_5)},
614 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
615 ENC_ACTION(C_KOI8_R)},
616 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
617 ENC_ACTION(C_KOI8_U)},
618 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
619 ENC_ACTION(C_CP1251)},
622 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
623 ENC_ACTION(C_ISO_2022_JP)},
624 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
625 ENC_ACTION(C_ISO_2022_JP_2)},
626 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
627 ENC_ACTION(C_EUC_JP)},
628 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
629 ENC_ACTION(C_SHIFT_JIS)},
632 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
633 ENC_ACTION(C_GB2312)},
634 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
636 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
638 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
639 ENC_ACTION(C_EUC_TW)},
640 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
641 ENC_ACTION(C_ISO_2022_CN)},
644 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
645 ENC_ACTION(C_EUC_KR)},
646 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
647 ENC_ACTION(C_ISO_2022_KR)},
650 {N_("/_View/Character _encoding/Thai (TIS-620)"),
651 ENC_ACTION(C_TIS_620)},
652 {N_("/_View/Character _encoding/Thai (Windows-874)"),
653 ENC_ACTION(C_WINDOWS_874)},
658 #define DEC_SEPARATOR \
659 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
660 #define DEC_ACTION(action) \
661 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
662 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
663 {N_("/_View/Decode/_Auto detect"),
664 NULL, set_decode_cb, 0, "<RadioItem>"},
665 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
666 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
667 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
668 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
669 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
674 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
675 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
676 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
677 {N_("/_View/Show all headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
678 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
679 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
681 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
682 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
683 {N_("/_Message/Recei_ve/Get from _current account"),
684 "<control>I", inc_mail_cb, 0, NULL},
685 {N_("/_Message/Recei_ve/Get from _all accounts"),
686 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
687 {N_("/_Message/Recei_ve/Cancel receivin_g"),
688 NULL, inc_cancel_cb, 0, NULL},
689 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
690 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
691 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
692 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
693 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
694 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
695 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
696 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
697 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
698 {N_("/_Message/Repl_y to/mailing _list"),
699 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
700 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
701 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
702 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
703 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
704 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
705 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
706 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
707 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
708 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
709 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
710 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
711 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
712 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
713 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
714 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
715 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
716 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
717 {N_("/_Message/_Mark/Mark as rea_d"),
718 NULL, mark_as_read_cb, 0, NULL},
719 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
720 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
721 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
723 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
724 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
725 {N_("/_Tools/Add sender to address boo_k"),
726 NULL, add_address_cb, 0, NULL},
727 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
728 {N_("/_Tools/_Harvest addresses/from _Folder..."),
729 NULL, addr_harvest_cb, 0, NULL},
730 {N_("/_Tools/_Harvest addresses/from _Messages..."),
731 NULL, addr_harvest_msg_cb, 0, NULL},
732 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
733 {N_("/_Tools/_Filter all messages in folder"),
734 NULL, filter_cb, 0, NULL},
735 {N_("/_Tools/Filter _selected messages"),
736 NULL, filter_cb, 1, NULL},
737 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
738 {N_("/_Tools/_Create filter rule/_Automatically"),
739 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
740 {N_("/_Tools/_Create filter rule/by _From"),
741 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
742 {N_("/_Tools/_Create filter rule/by _To"),
743 NULL, create_filter_cb, FILTER_BY_TO, NULL},
744 {N_("/_Tools/_Create filter rule/by _Subject"),
745 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
746 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
747 {N_("/_Tools/C_reate processing rule/_Automatically"),
748 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
749 {N_("/_Tools/C_reate processing rule/by _From"),
750 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
751 {N_("/_Tools/C_reate processing rule/by _To"),
752 NULL, create_processing_cb, FILTER_BY_TO, NULL},
753 {N_("/_Tools/C_reate processing rule/by _Subject"),
754 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
755 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
756 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
757 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
758 {N_("/_Tools/Ch_eck for new messages in all folders"),
759 NULL, update_folderview_cb, 0, NULL},
760 {N_("/_Tools/Delete du_plicated messages"),
761 NULL, NULL, 0, "<Branch>"},
762 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
763 NULL, delete_duplicated_cb, 0, NULL},
764 {N_("/_Tools/Delete du_plicated messages/In all folders"),
765 NULL, delete_duplicated_all_cb, 0, NULL},
766 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
767 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
769 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
770 {N_("/_Tools/SSL cer_tificates..."),
771 NULL, ssl_manager_open_cb, 0, NULL},
773 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
774 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
776 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
777 {N_("/_Configuration/C_hange current account"),
778 NULL, NULL, 0, "<Branch>"},
779 {N_("/_Configuration/_Preferences for current account..."),
780 NULL, prefs_account_open_cb, 0, NULL},
781 {N_("/_Configuration/Create _new account..."),
782 NULL, new_account_cb, 0, NULL},
783 {N_("/_Configuration/_Edit accounts..."),
784 NULL, account_edit_open, 0, NULL},
785 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
786 {N_("/_Configuration/P_references..."),
787 NULL, prefs_open_cb, 0, NULL},
788 {N_("/_Configuration/Pre-pr_ocessing..."),
789 NULL, prefs_pre_processing_open_cb, 0, NULL},
790 {N_("/_Configuration/Post-pro_cessing..."),
791 NULL, prefs_post_processing_open_cb, 0, NULL},
792 {N_("/_Configuration/_Filtering..."),
793 NULL, prefs_filtering_open_cb, 0, NULL},
794 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
795 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
796 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
798 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
799 #if 0 /* waiting for the new manual to be finished */
800 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
802 {N_("/_Help/_Online User-contributed FAQ"),
803 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
804 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
805 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
806 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
809 static gboolean offline_ask_sync = TRUE;
811 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
817 MainWindow *mainwin = (MainWindow *)user_data;
819 if (mainwin->summaryview &&
820 mainwin->summaryview->quicksearch &&
821 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
822 (mod == 0 || mod == GDK_SHIFT_MASK)) {
823 quicksearch_pass_key(mainwin->summaryview->quicksearch, value, mod);
829 MainWindow *main_window_create(SeparateType type)
835 GtkWidget *handlebox;
836 GtkWidget *vbox_body;
837 GtkWidget *hbox_stat;
838 GtkWidget *statusbar;
839 GtkWidget *progressbar;
840 GtkWidget *statuslabel;
841 GtkWidget *ac_button;
843 GtkWidget *online_pixmap;
844 GtkWidget *offline_pixmap;
845 GtkWidget *online_switch;
846 GtkWidget *offline_switch;
847 GtkTooltips *offline_tip;
848 GtkTooltips *online_tip;
849 GtkTooltips *sel_ac_tip;
851 FolderView *folderview;
852 SummaryView *summaryview;
853 MessageView *messageview;
854 GdkColormap *colormap;
857 GtkItemFactory *ifactory;
861 guint n_menu_entries;
863 static GdkGeometry geometry;
865 debug_print("Creating main window...\n");
866 mainwin = g_new0(MainWindow, 1);
869 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
870 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
871 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
873 if (!geometry.min_height) {
874 geometry.min_width = 320;
875 geometry.min_height = 200;
877 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
880 g_signal_connect(G_OBJECT(window), "delete_event",
881 G_CALLBACK(main_window_close_cb), mainwin);
882 MANAGE_WINDOW_SIGNALS_CONNECT(window);
883 g_signal_connect(G_OBJECT(window), "focus_in_event",
884 G_CALLBACK(mainwindow_focus_in_event),
886 g_signal_connect(G_OBJECT(window), "key_press_event",
887 G_CALLBACK(mainwindow_key_pressed), mainwin);
889 gtk_widget_realize(window);
890 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
893 gtkut_widget_set_app_icon(window);
895 vbox = gtk_vbox_new(FALSE, 0);
896 gtk_widget_show(vbox);
897 gtk_container_add(GTK_CONTAINER(window), vbox);
900 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
901 menubar = menubar_create(window, mainwin_entries,
902 n_menu_entries, "<Main>", mainwin);
903 gtk_widget_show(menubar);
904 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
905 ifactory = gtk_item_factory_from_widget(menubar);
907 #if 0 /* waiting for the new manual to be finished */
908 menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
911 if (prefs_common.toolbar_detachable) {
912 handlebox = gtk_handle_box_new();
913 gtk_widget_show(handlebox);
914 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
915 g_signal_connect(G_OBJECT(handlebox), "child_attached",
916 G_CALLBACK(toolbar_child_attached), mainwin);
917 g_signal_connect(G_OBJECT(handlebox), "child_detached",
918 G_CALLBACK(toolbar_child_detached), mainwin);
920 handlebox = gtk_hbox_new(FALSE, 0);
921 gtk_widget_show(handlebox);
922 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
924 /* link window to mainwin->window to avoid gdk warnings */
925 mainwin->window = window;
928 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
932 /* vbox that contains body */
933 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
934 gtk_widget_show(vbox_body);
935 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
936 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
938 hbox_stat = gtk_hbox_new(FALSE, 2);
939 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
941 statusbar = statusbar_create();
942 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
944 progressbar = gtk_progress_bar_new();
945 gtk_widget_set_size_request(progressbar, 120, 1);
946 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
948 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
949 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
950 online_tip = gtk_tooltips_new();
951 online_switch = gtk_button_new ();
952 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
953 _("You are online. Click the icon to go offline"), NULL);
954 offline_tip = gtk_tooltips_new();
955 offline_switch = gtk_button_new ();
956 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
957 _("You are offline. Click the icon to go online"),
959 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
960 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
961 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
962 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
963 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
964 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
965 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
966 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
968 statuslabel = gtk_label_new("");
969 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
971 sel_ac_tip = gtk_tooltips_new();
972 ac_button = gtk_button_new();
973 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
974 ac_button, _("Select account"), NULL);
975 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
976 gtk_widget_set_size_request(ac_button, -1, 0);
977 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
978 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
979 G_CALLBACK(ac_label_button_pressed), mainwin);
981 ac_label = gtk_label_new("");
982 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
984 gtk_widget_show_all(hbox_stat);
986 gtk_widget_hide(offline_switch);
988 mainwin->folderview = folderview = folderview_create();
989 mainwin->summaryview = summaryview = summary_create();
990 mainwin->messageview = messageview = messageview_create(mainwin);
991 mainwin->logwin = log_window_create();
993 folderview->mainwin = mainwin;
994 folderview->summaryview = summaryview;
996 summaryview->mainwin = mainwin;
997 summaryview->folderview = folderview;
998 summaryview->messageview = messageview;
999 summaryview->window = window;
1001 messageview->statusbar = statusbar;
1002 mainwin->vbox = vbox;
1003 mainwin->menubar = menubar;
1004 mainwin->menu_factory = ifactory;
1005 mainwin->handlebox = handlebox;
1006 mainwin->vbox_body = vbox_body;
1007 mainwin->hbox_stat = hbox_stat;
1008 mainwin->statusbar = statusbar;
1009 mainwin->progressbar = progressbar;
1010 mainwin->statuslabel = statuslabel;
1011 mainwin->online_switch = online_switch;
1012 mainwin->online_pixmap = online_pixmap;
1013 mainwin->offline_pixmap = offline_pixmap;
1014 mainwin->ac_button = ac_button;
1015 mainwin->ac_label = ac_label;
1016 mainwin->offline_switch = offline_switch;
1018 /* set context IDs for status bar */
1019 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1020 (GTK_STATUSBAR(statusbar), "Main Window");
1021 mainwin->folderview_cid = gtk_statusbar_get_context_id
1022 (GTK_STATUSBAR(statusbar), "Folder View");
1023 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1024 (GTK_STATUSBAR(statusbar), "Summary View");
1025 mainwin->messageview_cid = gtk_statusbar_get_context_id
1026 (GTK_STATUSBAR(statusbar), "Message View");
1028 messageview->statusbar_cid = mainwin->messageview_cid;
1030 /* allocate colors for summary view and folder view */
1031 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1032 summaryview->color_marked.blue = (guint16)65535;
1034 summaryview->color_dim.red = summaryview->color_dim.green =
1035 summaryview->color_dim.blue = COLOR_DIM;
1037 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1038 &folderview->color_new);
1040 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1041 &folderview->color_op);
1043 summaryview->color_important.red = 0;
1044 summaryview->color_important.green = 0;
1045 summaryview->color_important.blue = (guint16)65535;
1047 color[0] = summaryview->color_marked;
1048 color[1] = summaryview->color_dim;
1049 color[2] = folderview->color_new;
1050 color[3] = folderview->color_op;
1052 colormap = gdk_drawable_get_colormap(window->window);
1053 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1054 for (i = 0; i < 4; i++) {
1055 if (success[i] == FALSE)
1056 g_warning("MainWindow: color allocation %d failed\n", i);
1059 debug_print("done.\n");
1061 messageview->visible = prefs_common.msgview_visible;
1063 main_window_set_widgets(mainwin, type);
1065 g_signal_connect(G_OBJECT(window), "size_allocate",
1066 G_CALLBACK(main_window_size_allocate_cb),
1069 /* set menu items */
1070 menuitem = gtk_item_factory_get_item
1071 (ifactory, "/View/Character encoding/Auto detect");
1072 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1074 switch (prefs_common.toolbar_style) {
1076 menuitem = gtk_item_factory_get_item
1077 (ifactory, "/View/Show or hide/Toolbar/Hide");
1080 menuitem = gtk_item_factory_get_item
1081 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1084 menuitem = gtk_item_factory_get_item
1085 (ifactory, "/View/Show or hide/Toolbar/Text only");
1088 menuitem = gtk_item_factory_get_item
1089 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1091 case TOOLBAR_BOTH_HORIZ:
1092 menuitem = gtk_item_factory_get_item
1094 "/View/Show or hide/Toolbar/Text beside icons");
1096 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1098 gtk_widget_hide(mainwin->hbox_stat);
1099 menuitem = gtk_item_factory_get_item
1100 (ifactory, "/View/Show or hide/Status bar");
1101 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1102 prefs_common.show_statusbar);
1104 /* set account selection menu */
1105 ac_menu = gtk_item_factory_get_widget
1106 (ifactory, "/Configuration/Change current account");
1107 mainwin->ac_menu = ac_menu;
1109 toolbar_main_set_sensitive(mainwin);
1111 /* create actions menu */
1112 main_window_update_actions_menu(mainwin);
1114 /* attach accel groups to main window */
1115 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1116 gtk_window_add_accel_group \
1118 gtk_item_factory_from_widget(menu)->accel_group); \
1119 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1121 G_CALLBACK(main_window_accel_activate), mainwin);
1124 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1126 /* connect the accelerators for equivalent
1127 menu items in different menus */
1128 menu_connect_identical_items();
1131 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1133 gtk_widget_show(mainwin->window);
1135 /* initialize views */
1136 folderview_init(folderview);
1137 summary_init(summaryview);
1138 messageview_init(messageview);
1139 log_window_init(mainwin->logwin);
1140 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1141 prefs_common.loglength);
1143 sslcertwindow_register_hook();
1145 mainwin->lock_count = 0;
1146 mainwin->menu_lock_count = 0;
1147 mainwin->cursor_count = 0;
1149 mainwin->progressindicator_hook =
1150 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1153 watch_cursor = gdk_cursor_new(GDK_WATCH);
1155 mainwin_list = g_list_append(mainwin_list, mainwin);
1157 /* init work_offline */
1158 if (prefs_common.work_offline)
1159 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1164 void main_window_destroy(MainWindow *mainwin)
1166 /* TODO : destroy other component */
1167 messageview_destroy(mainwin->messageview);
1168 mainwin->messageview = NULL;
1171 void main_window_update_actions_menu(MainWindow *mainwin)
1173 GtkItemFactory *ifactory;
1175 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1176 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1179 void main_window_cursor_wait(MainWindow *mainwin)
1182 if (mainwin->cursor_count == 0)
1183 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1185 mainwin->cursor_count++;
1190 void main_window_cursor_normal(MainWindow *mainwin)
1192 if (mainwin->cursor_count)
1193 mainwin->cursor_count--;
1195 if (mainwin->cursor_count == 0)
1196 gdk_window_set_cursor(mainwin->window->window, NULL);
1201 /* lock / unlock the user-interface */
1202 void main_window_lock(MainWindow *mainwin)
1204 if (mainwin->lock_count == 0)
1205 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1207 mainwin->lock_count++;
1209 main_window_set_menu_sensitive(mainwin);
1210 toolbar_main_set_sensitive(mainwin);
1213 void main_window_unlock(MainWindow *mainwin)
1215 if (mainwin->lock_count)
1216 mainwin->lock_count--;
1218 main_window_set_menu_sensitive(mainwin);
1219 toolbar_main_set_sensitive(mainwin);
1221 if (mainwin->lock_count == 0)
1222 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1225 static void main_window_menu_callback_block(MainWindow *mainwin)
1227 mainwin->menu_lock_count++;
1230 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1232 if (mainwin->menu_lock_count)
1233 mainwin->menu_lock_count--;
1236 static guint prefs_tag = 0;
1238 void main_window_reflect_prefs_all(void)
1240 main_window_reflect_prefs_all_real(FALSE);
1243 static gboolean reflect_prefs_timeout_cb(gpointer data)
1245 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1247 MainWindow *mainwin;
1250 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1251 mainwin = (MainWindow *)cur->data;
1253 main_window_show_cur_account(mainwin);
1254 main_window_set_menu_sensitive(mainwin);
1255 toolbar_main_set_sensitive(mainwin);
1258 if (pixmap_theme_changed) {
1259 toolbar_update(TOOLBAR_MAIN, mainwin);
1260 messageview_reflect_prefs_pixmap_theme();
1261 compose_reflect_prefs_pixmap_theme();
1262 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1263 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1265 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1266 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1267 mainwin->online_pixmap);
1268 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1269 gtk_widget_show(pixmap);
1270 mainwin->online_pixmap = pixmap;
1271 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1272 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1273 mainwin->offline_pixmap);
1274 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1275 gtk_widget_show(pixmap);
1276 mainwin->offline_pixmap = pixmap;
1279 headerview_set_font(mainwin->messageview->headerview);
1280 headerview_set_visibility(mainwin->messageview->headerview,
1281 prefs_common.display_header_pane);
1282 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1283 folderview_reflect_prefs();
1284 summary_reflect_prefs();
1285 summary_redisplay_msg(mainwin->summaryview);
1291 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1293 if (prefs_tag == 0 || pixmap_theme_changed) {
1294 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1295 GINT_TO_POINTER(pixmap_theme_changed));
1299 void main_window_set_summary_column(void)
1302 MainWindow *mainwin;
1304 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1305 mainwin = (MainWindow *)cur->data;
1306 summary_set_column_order(mainwin->summaryview);
1310 void main_window_set_folder_column(void)
1313 MainWindow *mainwin;
1315 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1316 mainwin = (MainWindow *)cur->data;
1317 folderview_set_column_order(mainwin->folderview);
1321 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1322 GList *account_list)
1324 GList *cur_ac, *cur_item;
1325 GtkWidget *menuitem;
1326 PrefsAccount *ac_prefs;
1328 /* destroy all previous menu item */
1329 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1330 while (cur_item != NULL) {
1331 GList *next = cur_item->next;
1332 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1336 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1337 ac_prefs = (PrefsAccount *)cur_ac->data;
1339 menuitem = gtk_menu_item_new_with_label
1340 (ac_prefs->account_name
1341 ? ac_prefs->account_name : _("Untitled"));
1342 gtk_widget_show(menuitem);
1343 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1344 g_signal_connect(G_OBJECT(menuitem), "activate",
1345 G_CALLBACK(account_selector_menu_cb),
1350 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1351 GList *account_list)
1353 GList *cur_ac, *cur_item;
1355 GtkWidget *menuitem;
1356 PrefsAccount *ac_prefs;
1358 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1359 "/Message/Receive");
1361 /* search for separator */
1362 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1363 cur_item = cur_item->next) {
1364 if (GTK_BIN(cur_item->data)->child == NULL) {
1365 cur_item = cur_item->next;
1370 /* destroy all previous menu item */
1371 while (cur_item != NULL) {
1372 GList *next = cur_item->next;
1373 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1377 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1378 ac_prefs = (PrefsAccount *)cur_ac->data;
1380 menuitem = gtk_menu_item_new_with_label
1381 (ac_prefs->account_name ? ac_prefs->account_name
1383 gtk_widget_show(menuitem);
1384 gtk_menu_append(GTK_MENU(menu), menuitem);
1385 g_signal_connect(G_OBJECT(menuitem), "activate",
1386 G_CALLBACK(account_receive_menu_cb),
1391 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
1392 GList *account_list)
1394 GList *cur_ac, *cur_item;
1395 GtkWidget *menuitem;
1396 PrefsAccount *ac_prefs;
1397 GtkWidget *menu = NULL;
1399 if (mainwin->toolbar->getall_btn == NULL
1400 || mainwin->toolbar->getall_combo == NULL) /* button doesn't exist */
1403 menu = mainwin->toolbar->getall_combo->menu;
1405 /* destroy all previous menu item */
1406 cur_item = GTK_MENU_SHELL(menu)->children;
1407 while (cur_item != NULL) {
1408 GList *next = cur_item->next;
1409 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1413 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1414 ac_prefs = (PrefsAccount *)cur_ac->data;
1416 menuitem = gtk_menu_item_new_with_label
1417 (ac_prefs->account_name
1418 ? ac_prefs->account_name : _("Untitled"));
1419 gtk_widget_show(menuitem);
1420 gtk_menu_append(GTK_MENU(menu), menuitem);
1421 g_signal_connect(G_OBJECT(menuitem), "activate",
1422 G_CALLBACK(account_receive_menu_cb),
1427 void main_window_set_account_menu(GList *account_list)
1430 MainWindow *mainwin;
1432 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1433 mainwin = (MainWindow *)cur->data;
1434 main_window_set_account_selector_menu(mainwin, account_list);
1435 main_window_set_account_receive_menu(mainwin, account_list);
1436 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1440 void main_window_set_account_menu_only_toolbar(GList *account_list)
1443 MainWindow *mainwin;
1445 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1446 mainwin = (MainWindow *)cur->data;
1447 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
1451 static void main_window_show_cur_account(MainWindow *mainwin)
1456 ac_name = g_strdup(cur_account
1457 ? (cur_account->account_name
1458 ? cur_account->account_name : _("Untitled"))
1462 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1464 buf = g_strdup(PROG_VERSION);
1465 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1468 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1469 gtk_widget_queue_resize(mainwin->ac_button);
1474 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1476 switch (mainwin->type) {
1477 case SEPARATE_FOLDER:
1478 return mainwin->win.sep_folder.folderwin;
1480 return mainwin->win.sep_both.folderwin;
1486 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1488 switch (mainwin->type) {
1489 case SEPARATE_MESSAGE:
1490 return mainwin->win.sep_message.messagewin;
1492 return mainwin->win.sep_both.messagewin;
1498 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1500 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1501 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1502 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1503 GtkWidget *message_wid = mainwin->messageview->vbox;
1505 debug_print("Changing window separation type from %d to %d\n",
1506 mainwin->type, type);
1508 if (mainwin->type == type) return;
1510 /* remove widgets from those containers */
1511 gtk_widget_ref(folder_wid);
1512 gtk_widget_ref(summary_wid);
1513 gtk_widget_ref(message_wid);
1514 gtkut_container_remove
1515 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1516 gtkut_container_remove
1517 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1518 gtkut_container_remove
1519 (GTK_CONTAINER(message_wid->parent), message_wid);
1521 /* clean containers */
1522 switch (mainwin->type) {
1524 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1526 case SEPARATE_FOLDER:
1527 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1528 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1530 case SEPARATE_MESSAGE:
1531 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1532 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1535 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1536 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1540 gtk_widget_hide(mainwin->window);
1541 main_window_set_widgets(mainwin, type);
1542 gtk_widget_show(mainwin->window);
1544 gtk_widget_unref(folder_wid);
1545 gtk_widget_unref(summary_wid);
1546 gtk_widget_unref(message_wid);
1549 void main_window_toggle_message_view(MainWindow *mainwin)
1551 SummaryView *summaryview = mainwin->summaryview;
1552 union CompositeWin *cwin = &mainwin->win;
1553 GtkWidget *vpaned = NULL;
1554 GtkWidget *container = NULL;
1555 GtkWidget *msgwin = NULL;
1557 switch (mainwin->type) {
1559 vpaned = cwin->sep_none.vpaned;
1560 container = cwin->sep_none.hpaned;
1562 case SEPARATE_FOLDER:
1563 vpaned = cwin->sep_folder.vpaned;
1564 container = mainwin->vbox_body;
1566 case SEPARATE_MESSAGE:
1567 msgwin = mainwin->win.sep_message.messagewin;
1570 msgwin = mainwin->win.sep_both.messagewin;
1575 if (GTK_WIDGET_VISIBLE(msgwin)) {
1576 gtk_widget_hide(msgwin);
1577 mainwin->messageview->visible = FALSE;
1578 summaryview->displayed = NULL;
1580 gtk_widget_show(msgwin);
1581 mainwin->messageview->visible = TRUE;
1583 } else if (vpaned->parent != NULL) {
1584 mainwin->messageview->visible = FALSE;
1585 summaryview->displayed = NULL;
1586 gtk_widget_ref(vpaned);
1587 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1588 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1590 mainwin->messageview->visible = TRUE;
1591 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1592 gtk_container_add(GTK_CONTAINER(container), vpaned);
1593 gtk_widget_unref(vpaned);
1596 if (messageview_is_visible(mainwin->messageview))
1597 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1598 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1600 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1601 GTK_ARROW_UP, GTK_SHADOW_OUT);
1603 if (mainwin->messageview->visible == FALSE)
1604 messageview_clear(mainwin->messageview);
1606 main_window_set_menu_sensitive(mainwin);
1608 prefs_common.msgview_visible = mainwin->messageview->visible;
1610 gtk_widget_grab_focus(summaryview->ctree);
1613 void main_window_get_size(MainWindow *mainwin)
1615 GtkAllocation *allocation;
1617 if (mainwin->messageview == NULL) {
1618 debug_print("called after messageview "
1619 "has been deallocated!\n");
1623 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1625 if (allocation->width > 1 && allocation->height > 1) {
1626 prefs_common.summaryview_width = allocation->width;
1628 if ((mainwin->type == SEPARATE_NONE ||
1629 mainwin->type == SEPARATE_FOLDER) &&
1630 messageview_is_visible(mainwin->messageview))
1631 prefs_common.summaryview_height = allocation->height;
1633 prefs_common.mainview_width = allocation->width;
1636 allocation = &mainwin->window->allocation;
1637 if (allocation->width > 1 && allocation->height > 1) {
1638 prefs_common.mainview_height = allocation->height;
1639 prefs_common.mainwin_width = allocation->width;
1640 prefs_common.mainwin_height = allocation->height;
1643 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1644 if (allocation->width > 1 && allocation->height > 1) {
1645 prefs_common.folderview_width = allocation->width;
1646 prefs_common.folderview_height = allocation->height;
1649 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1650 if (allocation->width > 1 && allocation->height > 1) {
1651 prefs_common.msgview_width = allocation->width;
1652 prefs_common.msgview_height = allocation->height;
1655 /* debug_print("summaryview size: %d x %d\n",
1656 prefs_common.summaryview_width,
1657 prefs_common.summaryview_height);
1658 debug_print("folderview size: %d x %d\n",
1659 prefs_common.folderview_width,
1660 prefs_common.folderview_height);
1661 debug_print("messageview size: %d x %d\n",
1662 prefs_common.msgview_width,
1663 prefs_common.msgview_height); */
1666 void main_window_get_position(MainWindow *mainwin)
1671 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1673 prefs_common.mainview_x = x;
1674 prefs_common.mainview_y = y;
1675 prefs_common.mainwin_x = x;
1676 prefs_common.mainwin_y = y;
1678 debug_print("main window position: %d, %d\n", x, y);
1680 window = main_window_get_folder_window(mainwin);
1682 gtkut_widget_get_uposition(window, &x, &y);
1683 prefs_common.folderwin_x = x;
1684 prefs_common.folderwin_y = y;
1685 debug_print("folder window position: %d, %d\n", x, y);
1687 window = main_window_get_message_window(mainwin);
1689 gtkut_widget_get_uposition(window, &x, &y);
1690 prefs_common.main_msgwin_x = x;
1691 prefs_common.main_msgwin_y = y;
1692 debug_print("message window position: %d, %d\n", x, y);
1696 void main_window_progress_on(MainWindow *mainwin)
1698 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1701 void main_window_progress_off(MainWindow *mainwin)
1703 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1704 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1707 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1711 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1712 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
1713 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
1714 (cur == 0 && total == 0) ? 0 :
1715 (gfloat)cur / (gfloat)total);
1718 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1721 if (alertpanel(_("Empty trash"),
1722 _("Delete all messages in trash folders?"),
1723 GTK_STOCK_YES, GTK_STOCK_NO, NULL)
1726 manage_window_focus_in(mainwin->window, NULL, NULL);
1729 procmsg_empty_all_trash();
1731 if (mainwin->summaryview->folder_item &&
1732 mainwin->summaryview->folder_item->stype == F_TRASH)
1733 gtk_widget_grab_focus(mainwin->folderview->ctree);
1736 void main_window_add_mailbox(MainWindow *mainwin)
1741 path = input_dialog(_("Add mailbox"),
1742 _("Input the location of mailbox.\n"
1743 "If the existing mailbox is specified, it will be\n"
1744 "scanned automatically."),
1747 if (folder_find_from_path(path)) {
1748 alertpanel_error(_("The mailbox '%s' already exists."), path);
1752 folder = folder_new(folder_get_class_from_string("mh"),
1753 !strcmp(path, "Mail") ? _("Mailbox") :
1754 g_path_get_basename(path), path);
1757 if (folder->klass->create_tree(folder) < 0) {
1758 alertpanel_error(_("Creation of the mailbox failed.\n"
1759 "Maybe some files already exist, or you don't have the permission to write there."));
1760 folder_destroy(folder);
1765 folder_set_ui_func(folder, scan_tree_func, mainwin);
1766 folder_scan_tree(folder, TRUE);
1767 folder_set_ui_func(folder, NULL, NULL);
1770 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1772 SensitiveCond state = 0;
1773 SummarySelection selection;
1774 FolderItem *item = mainwin->summaryview->folder_item;
1775 GList *account_list = account_get_list();
1777 selection = summary_get_selection_type(mainwin->summaryview);
1779 if (mainwin->lock_count == 0)
1780 state |= M_UNLOCKED;
1781 if (selection != SUMMARY_NONE)
1782 state |= M_MSG_EXIST;
1783 if (item && item->path && folder_item_parent(item) && !item->no_select) {
1785 /* if (item->folder->type != F_NEWS) */
1786 state |= M_ALLOW_DELETE;
1788 if (prefs_common.immediate_exec == 0
1789 && mainwin->lock_count == 0)
1790 state |= M_DELAY_EXEC;
1792 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1793 || selection != SUMMARY_NONE)
1794 state |= M_HIDE_READ_MSG;
1796 if (mainwin->summaryview->threaded)
1797 state |= M_THREADED;
1799 state |= M_UNTHREADED;
1800 if (selection == SUMMARY_SELECTED_SINGLE ||
1801 selection == SUMMARY_SELECTED_MULTIPLE)
1802 state |= M_TARGET_EXIST;
1803 if (selection == SUMMARY_SELECTED_SINGLE)
1804 state |= M_SINGLE_TARGET_EXIST;
1805 if (mainwin->summaryview->folder_item &&
1806 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1809 state |= M_NOT_NEWS;
1810 if (selection == SUMMARY_SELECTED_SINGLE &&
1812 (folder_has_parent_of_type(item, F_DRAFT) ||
1813 folder_has_parent_of_type(item, F_OUTBOX) ||
1814 folder_has_parent_of_type(item, F_QUEUE))))
1815 state |= M_ALLOW_REEDIT;
1817 state |= M_HAVE_ACCOUNT;
1819 for ( ; account_list != NULL; account_list = account_list->next) {
1820 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1821 state |= M_HAVE_NEWS_ACCOUNT;
1826 if (inc_is_active())
1827 state |= M_INC_ACTIVE;
1829 if (mainwin->summaryview->deleted > 0 ||
1830 mainwin->summaryview->moved > 0 ||
1831 mainwin->summaryview->copied > 0)
1832 state |= M_DELAY_EXEC;
1839 void main_window_set_menu_sensitive(MainWindow *mainwin)
1841 GtkItemFactory *ifactory = mainwin->menu_factory;
1842 SensitiveCond state;
1845 GtkWidget *menuitem;
1846 SummaryView *summaryview;
1851 static const struct {
1855 {"/File/Save as...", M_TARGET_EXIST},
1856 {"/File/Print..." , M_TARGET_EXIST},
1857 {"/File/Exit" , M_UNLOCKED},
1859 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1861 {"/View/Sort" , M_EXEC},
1862 {"/View/Thread view" , M_EXEC},
1863 {"/View/Expand all threads" , M_MSG_EXIST},
1864 {"/View/Collapse all threads" , M_MSG_EXIST},
1865 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1866 {"/View/Go to/Prev message" , M_MSG_EXIST},
1867 {"/View/Go to/Next message" , M_MSG_EXIST},
1868 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1869 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1870 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1871 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1872 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1873 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1874 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1875 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1876 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1878 {"/Message/Receive/Get from current account"
1879 , M_HAVE_ACCOUNT|M_UNLOCKED},
1880 {"/Message/Receive/Get from all accounts"
1881 , M_HAVE_ACCOUNT|M_UNLOCKED},
1882 {"/Message/Receive/Cancel receiving"
1885 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1886 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1887 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1888 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1889 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1890 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1891 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1892 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
1893 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
1894 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
1895 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
1896 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
1897 {"/Message/Mark" , M_TARGET_EXIST},
1898 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1900 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
1901 {"/Tools/Harvest addresses/from Folder..."
1903 {"/Tools/Harvest addresses/from Messages..."
1904 , M_MSG_EXIST|M_TARGET_EXIST},
1905 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
1906 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
1907 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1908 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1909 {"/Tools/Actions" , M_TARGET_EXIST},
1910 {"/Tools/Execute" , M_DELAY_EXEC},
1911 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
1913 {"/Configuration", M_UNLOCKED},
1918 state = main_window_get_current_state(mainwin);
1920 for (i = 0; entry[i].entry != NULL; i++) {
1921 sensitive = ((entry[i].cond & state) == entry[i].cond);
1922 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1925 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1927 /* search for separator */
1928 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1929 cur_item = cur_item->next) {
1930 if (GTK_BIN(cur_item->data)->child == NULL) {
1931 cur_item = cur_item->next;
1936 for (; cur_item != NULL; cur_item = cur_item->next) {
1937 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1938 (M_UNLOCKED & state) != 0);
1941 main_window_menu_callback_block(mainwin);
1943 #define SET_CHECK_MENU_ACTIVE(path, active) \
1945 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1946 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1949 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1950 messageview_is_visible(mainwin->messageview));
1952 summaryview = mainwin->summaryview;
1953 menu_path = "/View/Sort/Don't sort";
1955 switch (summaryview->sort_key) {
1956 case SORT_BY_NUMBER:
1957 menu_path = "/View/Sort/by number"; break;
1959 menu_path = "/View/Sort/by Size"; break;
1961 menu_path = "/View/Sort/by Date"; break;
1963 menu_path = "/View/Sort/by From"; break;
1965 menu_path = "/View/Sort/by To"; break;
1966 case SORT_BY_SUBJECT:
1967 menu_path = "/View/Sort/by Subject"; break;
1969 menu_path = "/View/Sort/by color label"; break;
1971 menu_path = "/View/Sort/by mark"; break;
1972 case SORT_BY_STATUS:
1973 menu_path = "/View/Sort/by status"; break;
1975 menu_path = "/View/Sort/by attachment"; break;
1977 menu_path = "/View/Sort/by score"; break;
1978 case SORT_BY_LOCKED:
1979 menu_path = "/View/Sort/by locked"; break;
1982 menu_path = "/View/Sort/Don't sort"; break;
1984 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1986 if (summaryview->sort_type == SORT_ASCENDING) {
1987 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1989 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1992 if (summaryview->sort_key != SORT_BY_NONE) {
1993 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1994 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1996 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1997 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2000 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
2001 mainwin->messageview->mimeview->textview->show_all_headers);
2002 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2004 #undef SET_CHECK_MENU_ACTIVE
2006 main_window_menu_callback_unblock(mainwin);
2009 void main_window_popup(MainWindow *mainwin)
2011 gtkut_window_popup(mainwin->window);
2013 switch (mainwin->type) {
2014 case SEPARATE_FOLDER:
2015 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
2017 case SEPARATE_MESSAGE:
2018 gtkut_window_popup(mainwin->win.sep_message.messagewin);
2021 gtkut_window_popup(mainwin->win.sep_both.folderwin);
2022 gtkut_window_popup(mainwin->win.sep_both.messagewin);
2029 void main_window_show(MainWindow *mainwin)
2031 gtk_widget_show(mainwin->window);
2032 gtk_widget_show(mainwin->vbox_body);
2034 gtk_widget_set_uposition(mainwin->window,
2035 prefs_common.mainwin_x,
2036 prefs_common.mainwin_y);
2038 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2039 prefs_common.folderview_width,
2040 prefs_common.folderview_height);
2041 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2042 prefs_common.summaryview_width,
2043 prefs_common.summaryview_height);
2044 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2045 prefs_common.msgview_width,
2046 prefs_common.msgview_height);
2048 if (mainwin->type & SEPARATE_FOLDER) {
2049 GtkWidget *folderwin;
2051 folderwin = main_window_get_folder_window(mainwin);
2052 gtk_widget_show(folderwin);
2053 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
2054 prefs_common.folderwin_y);
2057 if (mainwin->type & SEPARATE_MESSAGE) {
2058 GtkWidget *messagewin;
2060 messagewin = main_window_get_message_window(mainwin);
2061 gtk_widget_show(messagewin);
2062 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
2063 prefs_common.main_msgwin_y);
2067 void main_window_hide(MainWindow *mainwin)
2069 main_window_get_size(mainwin);
2070 main_window_get_position(mainwin);
2072 gtk_widget_hide(mainwin->window);
2073 gtk_widget_hide(mainwin->vbox_body);
2075 if (mainwin->type & SEPARATE_FOLDER) {
2076 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2079 if (mainwin->type & SEPARATE_MESSAGE) {
2080 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2084 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
2086 GtkWidget *folderwin = NULL;
2087 GtkWidget *messagewin = NULL;
2090 GtkWidget *vbox_body = mainwin->vbox_body;
2091 GtkItemFactory *ifactory = mainwin->menu_factory;
2092 GtkWidget *menuitem;
2093 GtkItemFactory *msgview_ifactory;
2095 debug_print("Setting widgets... ");
2097 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2098 prefs_common.folderview_width,
2099 prefs_common.folderview_height);
2100 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2101 prefs_common.summaryview_width,
2102 prefs_common.summaryview_height);
2103 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2104 prefs_common.msgview_width,
2105 prefs_common.msgview_height);
2107 /* create separated window(s) if needed */
2108 if (type & SEPARATE_FOLDER) {
2109 static GdkGeometry folderwin_geometry;
2111 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2112 gtk_window_set_title(GTK_WINDOW(folderwin),
2113 _("Sylpheed-Claws - Folder View"));
2115 gtk_window_move(GTK_WINDOW(folderwin),
2116 prefs_common.folderwin_x,
2117 prefs_common.folderwin_y);
2119 if (!folderwin_geometry.min_height) {
2120 folderwin_geometry.min_width = 320;
2121 folderwin_geometry.min_height = 200;
2123 gtk_window_set_geometry_hints(GTK_WINDOW(folderwin), NULL,
2124 &folderwin_geometry, GDK_HINT_MIN_SIZE);
2126 gtk_widget_set_size_request(folderwin,
2127 prefs_common.folderview_width,
2128 prefs_common.folderview_height);
2130 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
2133 g_signal_connect(G_OBJECT(folderwin), "delete_event",
2134 G_CALLBACK(folder_window_close_cb),
2136 gtk_container_add(GTK_CONTAINER(folderwin),
2137 GTK_WIDGET_PTR(mainwin->folderview));
2138 gtk_widget_realize(folderwin);
2140 if (prefs_common.folderview_visible)
2141 gtk_widget_show(folderwin);
2144 if (type & SEPARATE_MESSAGE) {
2145 static GdkGeometry msgwin_geometry;
2147 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2148 gtk_window_set_title(GTK_WINDOW(messagewin),
2149 _("Sylpheed-Claws - Message View"));
2151 gtk_window_move(GTK_WINDOW(messagewin),
2152 prefs_common.main_msgwin_x,
2153 prefs_common.main_msgwin_y);
2155 if (!msgwin_geometry.min_height) {
2156 msgwin_geometry.min_width = 320;
2157 msgwin_geometry.min_height = 200;
2159 gtk_window_set_geometry_hints(GTK_WINDOW(messagewin), NULL,
2160 &msgwin_geometry, GDK_HINT_MIN_SIZE);
2162 gtk_widget_set_size_request(messagewin,
2163 prefs_common.msgwin_width,
2164 prefs_common.msgwin_height);
2166 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2168 g_signal_connect(G_OBJECT(messagewin), "delete_event",
2169 G_CALLBACK(message_window_close_cb),
2171 if (messageview_is_visible(mainwin->messageview))
2172 gtk_widget_show(messagewin);
2174 mainwin->messageview->statusbar = mainwin->statusbar;
2175 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2180 hpaned = gtk_hpaned_new();
2181 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2182 gtk_paned_add1(GTK_PANED(hpaned),
2183 GTK_WIDGET_PTR(mainwin->folderview));
2184 gtk_widget_show(hpaned);
2185 gtk_widget_queue_resize(hpaned);
2187 vpaned = gtk_vpaned_new();
2188 if (messageview_is_visible(mainwin->messageview)) {
2189 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2190 gtk_paned_add1(GTK_PANED(vpaned),
2191 GTK_WIDGET_PTR(mainwin->summaryview));
2193 gtk_paned_add2(GTK_PANED(hpaned),
2194 GTK_WIDGET_PTR(mainwin->summaryview));
2195 gtk_widget_ref(vpaned);
2197 gtk_paned_add2(GTK_PANED(vpaned),
2198 GTK_WIDGET_PTR(mainwin->messageview));
2199 gtk_widget_show(vpaned);
2200 gtk_widget_queue_resize(vpaned);
2202 mainwin->win.sep_none.hpaned = hpaned;
2203 mainwin->win.sep_none.vpaned = vpaned;
2205 /* remove headerview if not in prefs */
2206 headerview_set_visibility(mainwin->messageview->headerview,
2207 prefs_common.display_header_pane);
2209 case SEPARATE_FOLDER:
2210 vpaned = gtk_vpaned_new();
2211 if (messageview_is_visible(mainwin->messageview)) {
2212 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2214 gtk_paned_add1(GTK_PANED(vpaned),
2215 GTK_WIDGET_PTR(mainwin->summaryview));
2217 gtk_box_pack_start(GTK_BOX(vbox_body),
2218 GTK_WIDGET_PTR(mainwin->summaryview),
2220 gtk_widget_ref(vpaned);
2222 gtk_paned_add2(GTK_PANED(vpaned),
2223 GTK_WIDGET_PTR(mainwin->messageview));
2224 gtk_widget_show(vpaned);
2225 gtk_widget_queue_resize(vpaned);
2227 mainwin->win.sep_folder.folderwin = folderwin;
2228 mainwin->win.sep_folder.vpaned = vpaned;
2230 /* remove headerview if not in prefs */
2231 headerview_set_visibility(mainwin->messageview->headerview,
2232 prefs_common.display_header_pane);
2235 case SEPARATE_MESSAGE:
2236 hpaned = gtk_hpaned_new();
2237 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2238 gtk_paned_add1(GTK_PANED(hpaned),
2239 GTK_WIDGET_PTR(mainwin->folderview));
2240 gtk_paned_add2(GTK_PANED(hpaned),
2241 GTK_WIDGET_PTR(mainwin->summaryview));
2242 gtk_widget_show(hpaned);
2243 gtk_widget_queue_resize(hpaned);
2244 messageview_add_toolbar(mainwin->messageview, messagewin);
2245 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2246 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2248 mainwin->win.sep_message.messagewin = messagewin;
2249 mainwin->win.sep_message.hpaned = hpaned;
2251 gtk_widget_realize(messagewin);
2252 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2253 gtk_widget_show_all(messagewin);
2254 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2255 mainwin->messageview->handlebox,
2256 prefs_common.toolbar_style);
2260 messageview_add_toolbar(mainwin->messageview, messagewin);
2261 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2262 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2264 gtk_box_pack_start(GTK_BOX(vbox_body),
2265 GTK_WIDGET_PTR(mainwin->summaryview),
2268 mainwin->win.sep_both.folderwin = folderwin;
2269 mainwin->win.sep_both.messagewin = messagewin;
2271 gtk_widget_realize(messagewin);
2272 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2273 gtk_widget_show_all(messagewin);
2274 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2275 mainwin->messageview->handlebox,
2276 prefs_common.toolbar_style);
2281 if (messageview_is_visible(mainwin->messageview))
2282 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2283 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2285 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2286 GTK_ARROW_UP, GTK_SHADOW_OUT);
2288 gtk_window_move(GTK_WINDOW(mainwin->window),
2289 prefs_common.mainwin_x,
2290 prefs_common.mainwin_y);
2292 gtk_widget_queue_resize(vbox_body);
2293 gtk_widget_queue_resize(mainwin->vbox);
2294 gtk_widget_queue_resize(mainwin->window);
2295 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2296 * and mimeview icon list/ctree lose track of their visibility states */
2297 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2298 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2299 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2300 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2301 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2302 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2304 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2306 mainwin->type = type;
2309 /* toggle menu state */
2310 menuitem = gtk_item_factory_get_item
2311 (ifactory, "/View/Show or hide/Folder tree");
2312 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2313 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2314 prefs_common.folderview_visible);
2315 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2316 menuitem = gtk_item_factory_get_item
2317 (ifactory, "/View/Show or hide/Message view");
2318 gtk_check_menu_item_set_active
2319 (GTK_CHECK_MENU_ITEM(menuitem),
2320 messageview_is_visible(mainwin->messageview));
2322 menuitem = gtk_item_factory_get_item
2323 (ifactory, "/View/Separate folder tree");
2324 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2325 ((type & SEPARATE_FOLDER) != 0));
2326 menuitem = gtk_item_factory_get_item
2327 (ifactory, "/View/Separate message view");
2328 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2329 ((type & SEPARATE_MESSAGE) != 0));
2333 (G_OBJECT(folderwin), "size_allocate",
2334 G_CALLBACK(folder_window_size_allocate_cb),
2339 (G_OBJECT(messagewin), "size_allocate",
2340 G_CALLBACK(message_window_size_allocate_cb),
2344 debug_print("done.\n");
2347 void main_window_destroy_all(void)
2349 while (mainwin_list != NULL) {
2350 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2352 /* free toolbar stuff */
2353 toolbar_clear_list(TOOLBAR_MAIN);
2354 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2355 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2357 g_free(mainwin->toolbar);
2360 mainwin_list = g_list_remove(mainwin_list, mainwin);
2362 g_list_free(mainwin_list);
2366 static gboolean toolbar_account_button_pressed(GtkWidget *widget,
2367 GdkEventButton *event,
2370 MainWindow *mainwin = (MainWindow *)data;
2372 if (!event) return FALSE;
2373 if (event->button != 3) return FALSE;
2375 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2376 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2379 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2380 menu_button_position, widget,
2381 event->button, event->time);
2387 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2390 gtk_widget_set_size_request(child, 1, -1);
2393 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2396 gtk_widget_set_size_request(child, -1, -1);
2399 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2402 MainWindow *mainwin = (MainWindow *)data;
2404 if (!event) return FALSE;
2406 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2407 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2410 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2411 menu_button_position, widget,
2412 event->button, event->time);
2417 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2420 MainWindow *mainwin = (MainWindow *)data;
2422 if (mainwin->lock_count == 0)
2423 app_exit_cb(data, 0, widget);
2428 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2431 MainWindow *mainwin = (MainWindow *)data;
2432 GtkWidget *menuitem;
2434 menuitem = gtk_item_factory_get_item
2435 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2436 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2441 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2444 MainWindow *mainwin = (MainWindow *)data;
2445 GtkWidget *menuitem;
2447 menuitem = gtk_item_factory_get_item
2448 (mainwin->menu_factory, "/View/Show or hide/Message view");
2449 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2451 mainwin->messageview->statusbar = mainwin->statusbar;
2452 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2457 static void main_window_size_allocate_cb(GtkWidget *widget,
2458 GtkAllocation *allocation,
2461 MainWindow *mainwin = (MainWindow *)data;
2463 main_window_get_size(mainwin);
2466 static void folder_window_size_allocate_cb(GtkWidget *widget,
2467 GtkAllocation *allocation,
2470 MainWindow *mainwin = (MainWindow *)data;
2472 main_window_get_size(mainwin);
2475 static void message_window_size_allocate_cb(GtkWidget *widget,
2476 GtkAllocation *allocation,
2479 MainWindow *mainwin = (MainWindow *)data;
2481 main_window_get_size(mainwin);
2484 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2487 main_window_add_mailbox(mainwin);
2490 static void update_folderview_cb(MainWindow *mainwin, guint action,
2493 summary_show(mainwin->summaryview, NULL);
2494 folderview_check_new_all();
2497 static void foldersort_cb(MainWindow *mainwin, guint action,
2503 static void import_mbox_cb(MainWindow *mainwin, guint action,
2506 import_mbox(mainwin->summaryview->folder_item);
2509 static void export_mbox_cb(MainWindow *mainwin, guint action,
2512 export_mbox(mainwin->summaryview->folder_item);
2515 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
2518 summaryview_export_mbox_list(mainwin->summaryview);
2521 static void empty_trash_cb(MainWindow *mainwin, guint action,
2524 main_window_empty_trash(mainwin, TRUE);
2527 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2529 summary_save_as(mainwin->summaryview);
2532 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2534 summary_print(mainwin->summaryview);
2537 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2539 if (prefs_common.confirm_on_exit) {
2540 if (alertpanel(_("Exit"), _("Exit Sylpheed-Claws?"),
2541 GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL)
2544 manage_window_focus_in(mainwin->window, NULL, NULL);
2547 app_will_exit(widget, mainwin);
2550 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2553 summary_search(mainwin->summaryview);
2555 message_search(mainwin->messageview);
2558 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
2560 prefs_common.show_searchbar = TRUE;
2561 summaryview_activate_quicksearch(mainwin->summaryview);
2564 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2569 active = GTK_CHECK_MENU_ITEM(widget)->active;
2571 switch (mainwin->type) {
2573 case SEPARATE_MESSAGE:
2576 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2578 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2581 case SEPARATE_FOLDER:
2582 debug_print("separate folder\n");
2584 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2586 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2590 gtk_widget_show(mainwin->win.sep_both.folderwin);
2592 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2596 prefs_common.folderview_visible = active;
2599 static void toggle_message_cb(MainWindow *mainwin, guint action,
2604 active = GTK_CHECK_MENU_ITEM(widget)->active;
2606 if (active != messageview_is_visible(mainwin->messageview))
2607 summary_toggle_view(mainwin->summaryview);
2610 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2613 toolbar_toggle(action, mainwin);
2616 void main_window_reply_cb(MainWindow *mainwin, guint action,
2619 MessageView *msgview = (MessageView*)mainwin->messageview;
2620 GSList *msginfo_list = NULL;
2622 g_return_if_fail(msgview != NULL);
2624 msginfo_list = summary_get_selection(mainwin->summaryview);
2625 g_return_if_fail(msginfo_list != NULL);
2626 compose_reply_from_messageview(msgview, msginfo_list, action);
2627 g_slist_free(msginfo_list);
2631 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2634 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2635 gtk_widget_show(mainwin->hbox_stat);
2636 prefs_common.show_statusbar = TRUE;
2638 gtk_widget_hide(mainwin->hbox_stat);
2639 prefs_common.show_statusbar = FALSE;
2643 static void separate_widget_cb(MainWindow *mainwin, guint action,
2648 if (GTK_CHECK_MENU_ITEM(widget)->active)
2649 type = mainwin->type | action;
2651 type = mainwin->type & ~action;
2653 main_window_separation_change(mainwin, type);
2655 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2656 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2659 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
2662 offline_ask_sync = ask_sync;
2664 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2666 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2667 offline_ask_sync = TRUE;
2670 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2672 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
2675 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
2677 GList *folderlist = folder_get_list();
2678 gboolean found = FALSE;
2680 /* see if there are synchronised folders */
2681 for (; folderlist; folderlist = folderlist->next) {
2682 Folder *folder = (Folder *)folderlist->data;
2683 if (folder_want_synchronise(folder)) {
2692 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
2693 _("Do you want to synchronise your folders now?"),
2694 GTK_STOCK_YES, GTK_STOCK_NO, NULL) != G_ALERTDEFAULT)
2697 folder_synchronise(NULL);
2700 static void online_switch_clicked (GtkButton *btn, gpointer data)
2702 MainWindow *mainwin;
2703 GtkItemFactory *ifactory;
2704 GtkCheckMenuItem *menuitem;
2706 mainwin = (MainWindow *) data;
2708 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2709 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2711 g_return_if_fail(mainwin != NULL);
2712 g_return_if_fail(menuitem != NULL);
2714 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2716 mainwindow_check_synchronise(mainwin, TRUE);
2717 gtk_widget_hide (mainwin->online_switch);
2718 gtk_widget_show (mainwin->offline_switch);
2719 menuitem->active = TRUE;
2720 prefs_common.work_offline = TRUE;
2721 inc_autocheck_timer_remove();
2724 gtk_widget_hide (mainwin->offline_switch);
2725 gtk_widget_show (mainwin->online_switch);
2726 menuitem->active = FALSE;
2727 prefs_common.work_offline = FALSE;
2728 inc_autocheck_timer_set();
2732 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2735 addressbook_open(NULL);
2738 static void log_window_show_cb(MainWindow *mainwin, guint action,
2741 log_window_show(mainwin->logwin);
2744 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2749 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2751 summary_move_to(mainwin->summaryview);
2754 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2756 summary_copy_to(mainwin->summaryview);
2759 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2761 summary_delete(mainwin->summaryview);
2764 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2766 summary_delete_trash(mainwin->summaryview);
2769 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2771 summary_cancel(mainwin->summaryview);
2774 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2776 summary_open_msg(mainwin->summaryview);
2779 static void view_source_cb(MainWindow *mainwin, guint action,
2782 summary_view_source(mainwin->summaryview);
2785 static void show_all_header_cb(MainWindow *mainwin, guint action,
2788 if (mainwin->menu_lock_count) return;
2789 mainwin->summaryview->messageview->all_headers =
2790 GTK_CHECK_MENU_ITEM(widget)->active;
2791 summary_display_msg_selected(mainwin->summaryview,
2792 GTK_CHECK_MENU_ITEM(widget)->active);
2795 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2797 summary_mark(mainwin->summaryview);
2800 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2802 summary_unmark(mainwin->summaryview);
2805 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2808 summary_mark_as_unread(mainwin->summaryview);
2811 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2814 summary_mark_as_read(mainwin->summaryview);
2817 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2820 summary_mark_all_read(mainwin->summaryview);
2823 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2825 summary_reedit(mainwin->summaryview);
2828 static void add_address_cb(MainWindow *mainwin, guint action,
2831 summary_add_address(mainwin->summaryview);
2834 static void set_charset_cb(MainWindow *mainwin, guint action,
2839 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2840 str = conv_get_charset_str((CharSet)action);
2842 g_free(mainwin->messageview->forced_charset);
2843 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
2844 procmime_force_charset(str);
2846 summary_redisplay_msg(mainwin->summaryview);
2848 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2852 static void set_decode_cb(MainWindow *mainwin, guint action,
2855 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2856 mainwin->messageview->forced_encoding = (EncodingType)action;
2858 summary_redisplay_msg(mainwin->summaryview);
2860 debug_print("forced encoding: %d\n", action);
2864 static void hide_read_messages (MainWindow *mainwin, guint action,
2867 if (!mainwin->summaryview->folder_item
2868 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
2870 summary_toggle_show_read_messages(mainwin->summaryview);
2873 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2875 if (mainwin->menu_lock_count) return;
2876 if (!mainwin->summaryview->folder_item) return;
2878 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2879 summary_thread_build(mainwin->summaryview);
2880 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2882 summary_unthread(mainwin->summaryview);
2883 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2887 static void expand_threads_cb(MainWindow *mainwin, guint action,
2890 summary_expand_threads(mainwin->summaryview);
2893 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2896 summary_collapse_threads(mainwin->summaryview);
2899 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
2902 prefs_summary_column_open();
2905 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
2908 prefs_folder_column_open();
2911 static void sort_summary_cb(MainWindow *mainwin, guint action,
2914 FolderItem *item = mainwin->summaryview->folder_item;
2915 GtkWidget *menuitem;
2917 if (mainwin->menu_lock_count) return;
2919 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2920 menuitem = gtk_item_factory_get_item
2921 (mainwin->menu_factory, "/View/Sort/Ascending");
2922 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2923 GTK_CHECK_MENU_ITEM(menuitem)->active
2924 ? SORT_ASCENDING : SORT_DESCENDING);
2925 item->sort_key = action;
2929 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2932 FolderItem *item = mainwin->summaryview->folder_item;
2934 if (mainwin->menu_lock_count) return;
2936 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2937 summary_sort(mainwin->summaryview,
2938 item->sort_key, (FolderSortType)action);
2941 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2944 summary_attract_by_subject(mainwin->summaryview);
2947 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2952 item = folderview_get_selected_item(mainwin->folderview);
2954 main_window_cursor_wait(mainwin);
2955 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
2957 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
2958 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
2960 STATUSBAR_POP(mainwin);
2961 main_window_cursor_normal(mainwin);
2971 static void deldup_all(FolderItem *item, gpointer _data)
2973 struct DelDupsData *data = _data;
2976 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
2978 data->dups += result;
2983 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
2986 struct DelDupsData data = {0, 0};
2988 folder_func_to_all_folders(deldup_all, &data);
2989 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
2990 "Deleted %d duplicate messages in %d folders.\n",
2992 data.dups, data.folders);
2995 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2997 summary_filter(mainwin->summaryview, (gboolean)action);
3000 static void execute_summary_cb(MainWindow *mainwin, guint action,
3003 summary_execute(mainwin->summaryview);
3006 static void update_summary_cb(MainWindow *mainwin, guint action,
3010 FolderView *folderview = mainwin->folderview;
3012 if (!mainwin->summaryview->folder_item) return;
3013 if (!folderview->opened) return;
3015 folder_update_op_count();
3017 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
3018 folderview->opened);
3021 folder_item_scan(fitem);
3022 summary_show(mainwin->summaryview, fitem);
3025 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3027 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
3030 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3032 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
3035 static void prev_unread_cb(MainWindow *mainwin, guint action,
3038 summary_select_prev_unread(mainwin->summaryview);
3041 static void next_unread_cb(MainWindow *mainwin, guint action,
3044 summary_select_next_unread(mainwin->summaryview);
3047 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3049 summary_select_prev_new(mainwin->summaryview);
3052 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3054 summary_select_next_new(mainwin->summaryview);
3057 static void prev_marked_cb(MainWindow *mainwin, guint action,
3060 summary_select_prev_marked(mainwin->summaryview);
3063 static void next_marked_cb(MainWindow *mainwin, guint action,
3066 summary_select_next_marked(mainwin->summaryview);
3069 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3072 summary_select_prev_labeled(mainwin->summaryview);
3075 static void next_labeled_cb(MainWindow *mainwin, guint action,
3078 summary_select_next_labeled(mainwin->summaryview);
3081 static void goto_folder_cb(MainWindow *mainwin, guint action,
3084 FolderItem *to_folder;
3086 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3089 folderview_select(mainwin->folderview, to_folder);
3092 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3094 messageview_copy_clipboard(mainwin->messageview);
3097 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3099 MessageView *msgview = mainwin->messageview;
3101 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3102 summary_select_all(mainwin->summaryview);
3103 else if (messageview_is_visible(msgview) &&
3104 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3105 messageview_select_all(mainwin->messageview);
3108 static void select_thread_cb(MainWindow *mainwin, guint action,
3111 summary_select_thread(mainwin->summaryview);
3114 static void create_filter_cb(MainWindow *mainwin, guint action,
3117 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3120 static void create_processing_cb(MainWindow *mainwin, guint action,
3123 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3126 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3129 prefs_filtering_open(&pre_global_processing,
3130 _("Processing rules to apply before folder rules"),
3134 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3137 prefs_filtering_open(&post_global_processing,
3138 _("Processing rules to apply after folder rules"),
3142 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3145 prefs_filtering_open(&filtering_rules,
3146 _("Filtering configuration"),
3150 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3153 prefs_template_open();
3156 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3159 prefs_actions_open(mainwin);
3162 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3165 ssl_manager_open(mainwin);
3168 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3172 new_account_cb(mainwin, 0, widget);
3174 account_open(cur_account);
3178 static void new_account_cb(MainWindow *mainwin, guint action,
3181 account_edit_open();
3182 if (!compose_get_compose_list()) account_add();
3185 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3187 FolderItem *item = NULL;
3188 cur_account = (PrefsAccount *)data;
3190 if (!mainwindow_get_mainwindow())
3192 main_window_show_cur_account(mainwindow_get_mainwindow());
3193 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
3194 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
3195 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
3196 item = folderview_get_selected_item(
3197 mainwindow_get_mainwindow()->folderview);
3199 toolbar_set_compose_button
3200 (mainwindow_get_mainwindow()->toolbar,
3201 FOLDER_TYPE(item->folder) == F_NEWS ?
3202 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
3206 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3208 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3209 PrefsAccount *account = (PrefsAccount *)data;
3211 inc_account_mail(mainwin, account);
3214 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3219 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3221 pluginwindow_create();
3224 static void manual_open_cb(MainWindow *mainwin, guint action,
3227 manual_open((ManualType)action);
3230 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
3235 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3237 MainWindow *mainwin = (MainWindow *)data;
3241 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3242 LOCAL_FOLDER(folder)->rootpath,
3246 str = g_strdup_printf(_("Scanning folder %s ..."),
3247 LOCAL_FOLDER(folder)->rootpath);
3249 STATUSBAR_PUSH(mainwin, str);
3250 STATUSBAR_POP(mainwin);
3254 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3257 SummaryView *summary;
3259 g_return_val_if_fail(data, FALSE);
3260 summary = ((MainWindow *)data)->summaryview;
3261 g_return_val_if_fail(summary, FALSE);
3263 if (GTK_CLIST(summary->ctree)->selection &&
3264 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3267 if (summary->selected != summary->displayed)
3268 summary_select_node(summary, summary->displayed, FALSE, TRUE);
3272 #define BREAK_ON_MODIFIER_KEY() \
3273 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3275 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3278 MainWindow *mainwin = (MainWindow*) data;
3280 if (!mainwin || !event)
3283 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3286 switch (event->keyval) {
3287 case GDK_Q: /* Quit */
3288 BREAK_ON_MODIFIER_KEY();
3290 app_exit_cb(mainwin, 0, NULL);
3293 if (mainwin->folderview && mainwin->summaryview
3294 && !mainwin->summaryview->displayed) {
3295 summary_lock(mainwin->summaryview);
3296 folderview_select_next_unread(mainwin->folderview);
3297 summary_unlock(mainwin->summaryview);
3306 #undef BREAK_ON_MODIFIER_KEY
3309 * Harvest addresses for selected folder.
3311 static void addr_harvest_cb( MainWindow *mainwin,