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"
95 #define AC_LABEL_WIDTH 240
97 /* list of all instantiated MainWindow */
98 static GList *mainwin_list = NULL;
100 static GdkCursor *watch_cursor;
102 static void main_window_menu_callback_block (MainWindow *mainwin);
103 static void main_window_menu_callback_unblock (MainWindow *mainwin);
105 static void main_window_show_cur_account (MainWindow *mainwin);
107 static void main_window_set_widgets (MainWindow *mainwin,
111 static gboolean toolbar_account_button_pressed (GtkWidget *widget,
112 GdkEventButton *event,
116 static void toolbar_child_attached (GtkWidget *widget,
119 static void toolbar_child_detached (GtkWidget *widget,
123 static gboolean ac_label_button_pressed (GtkWidget *widget,
124 GdkEventButton *event,
127 static gint main_window_close_cb (GtkWidget *widget,
130 static gint folder_window_close_cb (GtkWidget *widget,
133 static gint message_window_close_cb (GtkWidget *widget,
137 static void main_window_size_allocate_cb (GtkWidget *widget,
138 GtkAllocation *allocation,
140 static void folder_window_size_allocate_cb (GtkWidget *widget,
141 GtkAllocation *allocation,
143 static void message_window_size_allocate_cb (GtkWidget *widget,
144 GtkAllocation *allocation,
147 static void update_folderview_cb (MainWindow *mainwin,
150 static void add_mailbox_cb (MainWindow *mainwin,
153 static void foldersort_cb (MainWindow *mainwin,
156 static void import_mbox_cb (MainWindow *mainwin,
159 static void export_mbox_cb (MainWindow *mainwin,
162 static void export_list_mbox_cb (MainWindow *mainwin,
165 static void empty_trash_cb (MainWindow *mainwin,
169 static void save_as_cb (MainWindow *mainwin,
172 static void print_cb (MainWindow *mainwin,
175 static void app_exit_cb (MainWindow *mainwin,
179 static void search_cb (MainWindow *mainwin,
183 static void toggle_folder_cb (MainWindow *mainwin,
186 static void toggle_message_cb (MainWindow *mainwin,
189 static void toggle_toolbar_cb (MainWindow *mainwin,
192 static void toggle_statusbar_cb (MainWindow *mainwin,
195 static void separate_widget_cb (MainWindow *mainwin,
199 static void addressbook_open_cb (MainWindow *mainwin,
202 static void log_window_show_cb (MainWindow *mainwin,
206 static void inc_cancel_cb (MainWindow *mainwin,
210 static void open_msg_cb (MainWindow *mainwin,
214 static void view_source_cb (MainWindow *mainwin,
218 static void show_all_header_cb (MainWindow *mainwin,
222 static void move_to_cb (MainWindow *mainwin,
225 static void copy_to_cb (MainWindow *mainwin,
228 static void delete_cb (MainWindow *mainwin,
231 static void delete_trash_cb (MainWindow *mainwin,
235 static void cancel_cb (MainWindow *mainwin,
239 static void mark_cb (MainWindow *mainwin,
242 static void unmark_cb (MainWindow *mainwin,
246 static void mark_as_unread_cb (MainWindow *mainwin,
249 static void mark_as_read_cb (MainWindow *mainwin,
252 static void mark_all_read_cb (MainWindow *mainwin,
256 static void reedit_cb (MainWindow *mainwin,
260 static void add_address_cb (MainWindow *mainwin,
264 static void set_charset_cb (MainWindow *mainwin,
268 static void set_decode_cb (MainWindow *mainwin,
272 static void hide_read_messages (MainWindow *mainwin,
276 static void thread_cb (MainWindow *mainwin,
279 static void expand_threads_cb (MainWindow *mainwin,
282 static void collapse_threads_cb (MainWindow *mainwin,
286 static void set_summary_display_item_cb (MainWindow *mainwin,
289 static void set_folder_display_item_cb (MainWindow *mainwin,
292 static void sort_summary_cb (MainWindow *mainwin,
295 static void sort_summary_type_cb (MainWindow *mainwin,
298 static void attract_by_subject_cb(MainWindow *mainwin,
302 static void delete_duplicated_cb (MainWindow *mainwin,
305 static void delete_duplicated_all_cb (MainWindow *mainwin,
308 static void filter_cb (MainWindow *mainwin,
311 static void execute_summary_cb (MainWindow *mainwin,
314 static void update_summary_cb (MainWindow *mainwin,
318 static void prev_cb (MainWindow *mainwin,
321 static void next_cb (MainWindow *mainwin,
324 static void next_unread_cb (MainWindow *mainwin,
327 static void prev_unread_cb (MainWindow *mainwin,
331 static void prev_new_cb (MainWindow *mainwin,
334 static void next_new_cb (MainWindow *mainwin,
337 static void prev_marked_cb (MainWindow *mainwin,
340 static void next_marked_cb (MainWindow *mainwin,
343 static void prev_labeled_cb (MainWindow *mainwin,
346 static void next_labeled_cb (MainWindow *mainwin,
350 static void goto_folder_cb (MainWindow *mainwin,
354 static void copy_cb (MainWindow *mainwin,
357 static void allsel_cb (MainWindow *mainwin,
360 static void select_thread_cb (MainWindow *mainwin,
364 static void create_filter_cb (MainWindow *mainwin,
367 static void create_processing_cb (MainWindow *mainwin,
371 static void prefs_template_open_cb (MainWindow *mainwin,
374 static void prefs_actions_open_cb (MainWindow *mainwin,
377 static void prefs_account_open_cb (MainWindow *mainwin,
381 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
385 static void prefs_post_processing_open_cb (MainWindow *mainwin,
389 static void prefs_filtering_open_cb (MainWindow *mainwin,
393 static void ssl_manager_open_cb (MainWindow *mainwin,
397 static void new_account_cb (MainWindow *mainwin,
401 static void account_selector_menu_cb (GtkMenuItem *menuitem,
403 static void account_receive_menu_cb (GtkMenuItem *menuitem,
406 static void prefs_open_cb (GtkMenuItem *menuitem,
408 static void plugins_open_cb (GtkMenuItem *menuitem,
411 static void online_switch_clicked(GtkButton *btn,
414 static void manual_open_cb (MainWindow *mainwin,
418 static void scan_tree_func (Folder *folder,
422 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
424 static void addr_harvest_cb ( MainWindow *mainwin,
428 static void addr_harvest_msg_cb ( MainWindow *mainwin,
431 static void sync_cb ( MainWindow *mainwin,
435 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
436 GdkEventFocus *focus,
438 void main_window_reply_cb (MainWindow *mainwin,
441 gboolean mainwindow_progressindicator_hook (gpointer source,
443 #define SEPARATE_ACTION 500
444 static void mainwindow_quicksearch (MainWindow *mainwin,
448 static GtkItemFactoryEntry mainwin_entries[] =
450 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
451 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
452 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
453 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
454 {N_("/_File/Change folder order"), NULL, foldersort_cb, 0, NULL},
455 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
456 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
457 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
458 {N_("/_File/Exp_ort selected to mbox file..."),
459 NULL, export_list_mbox_cb, 0, NULL},
460 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
461 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
462 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
463 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
464 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
465 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
466 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
467 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
468 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
469 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
470 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
472 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
473 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
474 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
475 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
476 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
477 {N_("/_Edit/_Find in current message..."),
478 "<control>F", search_cb, 0, NULL},
479 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
480 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
481 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
482 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
483 {N_("/_View/Show or hi_de/_Folder tree"),
484 NULL, toggle_folder_cb, 0, "<ToggleItem>"},
485 {N_("/_View/Show or hi_de/_Message view"),
486 "V", toggle_message_cb, 0, "<ToggleItem>"},
487 {N_("/_View/Show or hi_de/_Toolbar"),
488 NULL, NULL, 0, "<Branch>"},
489 {N_("/_View/Show or hi_de/_Toolbar/Icon _and text"),
490 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
491 {N_("/_View/Show or hi_de/_Toolbar/_Icon"),
492 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Icon and text"},
493 {N_("/_View/Show or hi_de/_Toolbar/_Text"),
494 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Icon and text"},
495 {N_("/_View/Show or hi_de/_Toolbar/_None"),
496 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Icon and text"},
497 {N_("/_View/Show or hi_de/Status _bar"),
498 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
499 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
500 {N_("/_View/Separate f_older tree"), NULL, separate_widget_cb, SEPARATE_FOLDER, "<ToggleItem>"},
501 {N_("/_View/Separate _message view"), NULL, separate_widget_cb, SEPARATE_MESSAGE, "<ToggleItem>"},
502 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
503 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
504 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
505 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
506 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
507 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
508 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
509 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
510 {N_("/_View/_Sort/by _color label"),
511 NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
512 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
513 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
514 {N_("/_View/_Sort/by a_ttachment"),
515 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
516 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
517 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
518 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
519 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
520 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
521 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
522 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
523 {N_("/_View/_Sort/_Attract by subject"),
524 NULL, attract_by_subject_cb, 0, NULL},
525 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
526 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
527 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
528 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
529 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
530 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
531 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
533 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
534 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
535 {N_("/_View/_Go to/_Prev message"), "P", prev_cb, 0, NULL},
536 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
537 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
538 {N_("/_View/_Go to/P_rev unread message"),
539 "<shift>P", prev_unread_cb, 0, NULL},
540 {N_("/_View/_Go to/N_ext unread message"),
541 "<shift>N", next_unread_cb, 0, NULL},
542 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
543 {N_("/_View/_Go to/Prev ne_w message"), NULL, prev_new_cb, 0, NULL},
544 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
545 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
546 {N_("/_View/_Go to/Prev _marked message"),
547 NULL, prev_marked_cb, 0, NULL},
548 {N_("/_View/_Go to/Next m_arked message"),
549 NULL, next_marked_cb, 0, NULL},
550 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
551 {N_("/_View/_Go to/Prev _labeled message"),
552 NULL, prev_labeled_cb, 0, NULL},
553 {N_("/_View/_Go to/Next la_beled message"),
554 NULL, next_labeled_cb, 0, NULL},
555 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
556 {N_("/_View/_Go to/Other _folder..."), "G", goto_folder_cb, 0, NULL},
557 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
559 #define ENC_SEPARATOR \
560 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
561 #define ENC_ACTION(action) \
562 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
564 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
565 {N_("/_View/Character _encoding/_Auto detect"),
566 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
567 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
568 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
569 ENC_ACTION(C_US_ASCII)},
570 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
571 ENC_ACTION(C_UTF_8)},
574 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
575 ENC_ACTION(C_ISO_8859_1)},
576 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
577 ENC_ACTION(C_ISO_8859_15)},
578 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
579 ENC_ACTION(C_WINDOWS_1252)},
582 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
583 ENC_ACTION(C_ISO_8859_2)},
586 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
587 ENC_ACTION(C_ISO_8859_13)},
588 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
589 ENC_ACTION(C_ISO_8859_4)},
592 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
593 ENC_ACTION(C_ISO_8859_7)},
596 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
597 ENC_ACTION(C_ISO_8859_8)},
598 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
599 ENC_ACTION(C_CP1255)},
602 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
603 ENC_ACTION(C_ISO_8859_9)},
606 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
607 ENC_ACTION(C_ISO_8859_5)},
608 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
609 ENC_ACTION(C_KOI8_R)},
610 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
611 ENC_ACTION(C_KOI8_U)},
612 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
613 ENC_ACTION(C_CP1251)},
616 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
617 ENC_ACTION(C_ISO_2022_JP)},
618 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
619 ENC_ACTION(C_ISO_2022_JP_2)},
620 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
621 ENC_ACTION(C_EUC_JP)},
622 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
623 ENC_ACTION(C_SHIFT_JIS)},
626 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
627 ENC_ACTION(C_GB2312)},
628 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
630 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
632 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
633 ENC_ACTION(C_EUC_TW)},
634 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
635 ENC_ACTION(C_ISO_2022_CN)},
638 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
639 ENC_ACTION(C_EUC_KR)},
640 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
641 ENC_ACTION(C_ISO_2022_KR)},
644 {N_("/_View/Character _encoding/Thai (TIS-620)"),
645 ENC_ACTION(C_TIS_620)},
646 {N_("/_View/Character _encoding/Thai (Windows-874)"),
647 ENC_ACTION(C_WINDOWS_874)},
652 #define DEC_SEPARATOR \
653 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
654 #define DEC_ACTION(action) \
655 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
656 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
657 {N_("/_View/Decode/_Auto detect"),
658 NULL, set_decode_cb, 0, "<RadioItem>"},
659 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
660 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
661 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
662 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
663 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
668 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
669 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
670 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
671 {N_("/_View/Show all headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
672 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
673 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
675 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
676 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
677 {N_("/_Message/Recei_ve/Get from _current account"),
678 "<control>I", inc_mail_cb, 0, NULL},
679 {N_("/_Message/Recei_ve/Get from _all accounts"),
680 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
681 {N_("/_Message/Recei_ve/Cancel receivin_g"),
682 NULL, inc_cancel_cb, 0, NULL},
683 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
684 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
685 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
686 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
687 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
688 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
689 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
690 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
691 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
692 {N_("/_Message/Repl_y to/mailing _list"),
693 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
694 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
695 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
696 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
697 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
698 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
699 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
700 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
701 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
702 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
703 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
704 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
705 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
706 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
707 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
708 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
709 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
710 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
711 {N_("/_Message/_Mark/Mark as rea_d"),
712 NULL, mark_as_read_cb, 0, NULL},
713 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
714 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
715 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
717 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
718 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
719 {N_("/_Tools/Add sender to address boo_k"),
720 NULL, add_address_cb, 0, NULL},
721 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
722 {N_("/_Tools/_Harvest addresses/from _Folder..."),
723 NULL, addr_harvest_cb, 0, NULL},
724 {N_("/_Tools/_Harvest addresses/from _Messages..."),
725 NULL, addr_harvest_msg_cb, 0, NULL},
726 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
727 {N_("/_Tools/_Filter all messages in folder"),
728 NULL, filter_cb, 0, NULL},
729 {N_("/_Tools/Filter _selected messages"),
730 NULL, filter_cb, 1, NULL},
731 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
732 {N_("/_Tools/_Create filter rule/_Automatically"),
733 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
734 {N_("/_Tools/_Create filter rule/by _From"),
735 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
736 {N_("/_Tools/_Create filter rule/by _To"),
737 NULL, create_filter_cb, FILTER_BY_TO, NULL},
738 {N_("/_Tools/_Create filter rule/by _Subject"),
739 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
740 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
741 {N_("/_Tools/C_reate processing rule/_Automatically"),
742 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
743 {N_("/_Tools/C_reate processing rule/by _From"),
744 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
745 {N_("/_Tools/C_reate processing rule/by _To"),
746 NULL, create_processing_cb, FILTER_BY_TO, NULL},
747 {N_("/_Tools/C_reate processing rule/by _Subject"),
748 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
749 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
750 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
751 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
752 {N_("/_Tools/Ch_eck for new messages in all folders"),
753 NULL, update_folderview_cb, 0, NULL},
754 {N_("/_Tools/Delete du_plicated messages"),
755 NULL, NULL, 0, "<Branch>"},
756 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
757 NULL, delete_duplicated_cb, 0, NULL},
758 {N_("/_Tools/Delete du_plicated messages/In all folders"),
759 NULL, delete_duplicated_all_cb, 0, NULL},
760 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
761 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
763 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
764 {N_("/_Tools/SSL cer_tificates..."),
765 NULL, ssl_manager_open_cb, 0, NULL},
767 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
768 {N_("/_Tools/_Log window"), "<shift><control>L", log_window_show_cb, 0, NULL},
770 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
771 {N_("/_Configuration/C_hange current account"),
772 NULL, NULL, 0, "<Branch>"},
773 {N_("/_Configuration/_Preferences for current account..."),
774 NULL, prefs_account_open_cb, 0, NULL},
775 {N_("/_Configuration/Create _new account..."),
776 NULL, new_account_cb, 0, NULL},
777 {N_("/_Configuration/_Edit accounts..."),
778 NULL, account_edit_open, 0, NULL},
779 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
780 {N_("/_Configuration/P_references..."),
781 NULL, prefs_open_cb, 0, NULL},
782 {N_("/_Configuration/Pre-pr_ocessing..."),
783 NULL, prefs_pre_processing_open_cb, 0, NULL},
784 {N_("/_Configuration/Post-pro_cessing..."),
785 NULL, prefs_post_processing_open_cb, 0, NULL},
786 {N_("/_Configuration/_Filtering..."),
787 NULL, prefs_filtering_open_cb, 0, NULL},
788 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
789 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
790 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
792 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
793 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
794 {N_("/_Help/_FAQ"), NULL, manual_open_cb, MANUAL_FAQ_LOCAL, NULL},
795 {N_("/_Help/_Online User-contributed FAQ"),
796 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
797 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
798 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
801 static gboolean offline_ask_sync = TRUE;
803 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
809 MainWindow *mainwin = (MainWindow *)user_data;
811 if (mainwin->summaryview &&
812 mainwin->summaryview->quicksearch &&
813 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
814 (mod == 0 || mod == GDK_SHIFT_MASK)) {
815 quicksearch_pass_key(mainwin->summaryview->quicksearch, value, mod);
821 MainWindow *main_window_create(SeparateType type)
827 GtkWidget *handlebox;
828 GtkWidget *vbox_body;
829 GtkWidget *hbox_stat;
830 GtkWidget *statusbar;
831 GtkWidget *progressbar;
832 GtkWidget *statuslabel;
833 GtkWidget *ac_button;
835 GtkWidget *online_pixmap;
836 GtkWidget *offline_pixmap;
837 GtkWidget *online_switch;
838 GtkWidget *offline_switch;
839 GtkTooltips *offline_tip;
840 GtkTooltips *online_tip;
841 GtkTooltips *sel_ac_tip;
843 FolderView *folderview;
844 SummaryView *summaryview;
845 MessageView *messageview;
846 GdkColormap *colormap;
849 GtkItemFactory *ifactory;
853 guint n_menu_entries;
855 static GdkGeometry geometry;
857 debug_print("Creating main window...\n");
858 mainwin = g_new0(MainWindow, 1);
861 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
862 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
863 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
865 if (!geometry.min_height) {
866 geometry.min_width = 320;
867 geometry.min_height = 200;
869 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
872 g_signal_connect(G_OBJECT(window), "delete_event",
873 G_CALLBACK(main_window_close_cb), mainwin);
874 MANAGE_WINDOW_SIGNALS_CONNECT(window);
875 g_signal_connect(G_OBJECT(window), "focus_in_event",
876 G_CALLBACK(mainwindow_focus_in_event),
878 g_signal_connect(G_OBJECT(window), "key_press_event",
879 G_CALLBACK(mainwindow_key_pressed), mainwin);
881 gtk_widget_realize(window);
882 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
885 gtkut_widget_set_app_icon(window);
887 vbox = gtk_vbox_new(FALSE, 0);
888 gtk_widget_show(vbox);
889 gtk_container_add(GTK_CONTAINER(window), vbox);
892 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
893 menubar = menubar_create(window, mainwin_entries,
894 n_menu_entries, "<Main>", mainwin);
895 gtk_widget_show(menubar);
896 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
897 ifactory = gtk_item_factory_from_widget(menubar);
899 menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
900 menu_set_sensitive(ifactory, "/Help/FAQ", manual_available(MANUAL_FAQ_LOCAL));
902 if (prefs_common.toolbar_detachable) {
903 handlebox = gtk_handle_box_new();
904 gtk_widget_show(handlebox);
905 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
906 g_signal_connect(G_OBJECT(handlebox), "child_attached",
907 G_CALLBACK(toolbar_child_attached), mainwin);
908 g_signal_connect(G_OBJECT(handlebox), "child_detached",
909 G_CALLBACK(toolbar_child_detached), mainwin);
911 handlebox = gtk_hbox_new(FALSE, 0);
912 gtk_widget_show(handlebox);
913 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
915 /* link window to mainwin->window to avoid gdk warnings */
916 mainwin->window = window;
919 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
923 /* vbox that contains body */
924 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
925 gtk_widget_show(vbox_body);
926 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
927 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
929 hbox_stat = gtk_hbox_new(FALSE, 2);
930 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
932 statusbar = statusbar_create();
933 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
935 progressbar = gtk_progress_bar_new();
936 gtk_widget_set_size_request(progressbar, 120, 1);
937 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
939 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
940 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
941 online_tip = gtk_tooltips_new();
942 online_switch = gtk_button_new ();
943 gtk_tooltips_set_tip(GTK_TOOLTIPS(online_tip),online_switch,
944 _("You are online. Click the icon to go offline"), NULL);
945 offline_tip = gtk_tooltips_new();
946 offline_switch = gtk_button_new ();
947 gtk_tooltips_set_tip(GTK_TOOLTIPS(offline_tip),offline_switch,
948 _("You are offline. Click the icon to go online"),
950 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
951 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
952 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
953 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
954 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
955 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
956 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
957 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
959 statuslabel = gtk_label_new("");
960 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
962 sel_ac_tip = gtk_tooltips_new();
963 ac_button = gtk_button_new();
964 gtk_tooltips_set_tip(GTK_TOOLTIPS(sel_ac_tip),
965 ac_button, _("Select account"), NULL);
966 gtk_button_set_relief(GTK_BUTTON(ac_button), GTK_RELIEF_NONE);
967 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
968 gtk_widget_set_size_request(ac_button, -1, 0);
969 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
970 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
971 G_CALLBACK(ac_label_button_pressed), mainwin);
973 ac_label = gtk_label_new("");
974 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
976 gtk_widget_show_all(hbox_stat);
978 gtk_widget_hide(offline_switch);
980 mainwin->folderview = folderview = folderview_create();
981 mainwin->summaryview = summaryview = summary_create();
982 mainwin->messageview = messageview = messageview_create(mainwin);
983 mainwin->logwin = log_window_create();
985 folderview->mainwin = mainwin;
986 folderview->summaryview = summaryview;
988 summaryview->mainwin = mainwin;
989 summaryview->folderview = folderview;
990 summaryview->messageview = messageview;
991 summaryview->window = window;
993 messageview->statusbar = statusbar;
994 mainwin->vbox = vbox;
995 mainwin->menubar = menubar;
996 mainwin->menu_factory = ifactory;
997 mainwin->handlebox = handlebox;
998 mainwin->vbox_body = vbox_body;
999 mainwin->hbox_stat = hbox_stat;
1000 mainwin->statusbar = statusbar;
1001 mainwin->progressbar = progressbar;
1002 mainwin->statuslabel = statuslabel;
1003 mainwin->online_switch = online_switch;
1004 mainwin->online_pixmap = online_pixmap;
1005 mainwin->offline_pixmap = offline_pixmap;
1006 mainwin->ac_button = ac_button;
1007 mainwin->ac_label = ac_label;
1008 mainwin->offline_switch = offline_switch;
1010 /* set context IDs for status bar */
1011 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1012 (GTK_STATUSBAR(statusbar), "Main Window");
1013 mainwin->folderview_cid = gtk_statusbar_get_context_id
1014 (GTK_STATUSBAR(statusbar), "Folder View");
1015 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1016 (GTK_STATUSBAR(statusbar), "Summary View");
1017 mainwin->messageview_cid = gtk_statusbar_get_context_id
1018 (GTK_STATUSBAR(statusbar), "Message View");
1020 messageview->statusbar_cid = mainwin->messageview_cid;
1022 /* allocate colors for summary view and folder view */
1023 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1024 summaryview->color_marked.blue = (guint16)65535;
1026 summaryview->color_dim.red = summaryview->color_dim.green =
1027 summaryview->color_dim.blue = COLOR_DIM;
1029 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1030 &folderview->color_new);
1032 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1033 &folderview->color_op);
1035 summaryview->color_important.red = 0;
1036 summaryview->color_important.green = 0;
1037 summaryview->color_important.blue = (guint16)65535;
1039 color[0] = summaryview->color_marked;
1040 color[1] = summaryview->color_dim;
1041 color[2] = folderview->color_new;
1042 color[3] = folderview->color_op;
1044 colormap = gdk_drawable_get_colormap(window->window);
1045 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1046 for (i = 0; i < 4; i++) {
1047 if (success[i] == FALSE)
1048 g_warning("MainWindow: color allocation %d failed\n", i);
1051 debug_print("done.\n");
1053 messageview->visible = prefs_common.msgview_visible;
1055 main_window_set_widgets(mainwin, type);
1057 g_signal_connect(G_OBJECT(window), "size_allocate",
1058 G_CALLBACK(main_window_size_allocate_cb),
1061 /* set menu items */
1062 menuitem = gtk_item_factory_get_item
1063 (ifactory, "/View/Character encoding/Auto detect");
1064 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1066 switch (prefs_common.toolbar_style) {
1068 menuitem = gtk_item_factory_get_item
1069 (ifactory, "/View/Show or hide/Toolbar/None");
1072 menuitem = gtk_item_factory_get_item
1073 (ifactory, "/View/Show or hide/Toolbar/Icon");
1076 menuitem = gtk_item_factory_get_item
1077 (ifactory, "/View/Show or hide/Toolbar/Text");
1080 menuitem = gtk_item_factory_get_item
1081 (ifactory, "/View/Show or hide/Toolbar/Icon and text");
1083 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1085 gtk_widget_hide(mainwin->hbox_stat);
1086 menuitem = gtk_item_factory_get_item
1087 (ifactory, "/View/Show or hide/Status bar");
1088 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1089 prefs_common.show_statusbar);
1091 /* set account selection menu */
1092 ac_menu = gtk_item_factory_get_widget
1093 (ifactory, "/Configuration/Change current account");
1094 mainwin->ac_menu = ac_menu;
1096 toolbar_main_set_sensitive(mainwin);
1098 /* create actions menu */
1099 main_window_update_actions_menu(mainwin);
1101 /* attach accel groups to main window */
1102 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1103 gtk_window_add_accel_group \
1105 gtk_item_factory_from_widget(menu)->accel_group); \
1106 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1108 G_CALLBACK(main_window_accel_activate), mainwin);
1111 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1113 /* connect the accelerators for equivalent
1114 menu items in different menus */
1115 menu_connect_identical_items();
1119 /* show main window */
1120 gtk_widget_show(mainwin->window);
1122 /* initialize views */
1123 folderview_init(folderview);
1124 summary_init(summaryview);
1125 messageview_init(messageview);
1126 log_window_init(mainwin->logwin);
1127 log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
1128 prefs_common.loglength);
1130 sslcertwindow_register_hook();
1132 mainwin->lock_count = 0;
1133 mainwin->menu_lock_count = 0;
1134 mainwin->cursor_count = 0;
1136 mainwin->progressindicator_hook =
1137 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1140 watch_cursor = gdk_cursor_new(GDK_WATCH);
1142 mainwin_list = g_list_append(mainwin_list, mainwin);
1144 /* init work_offline */
1145 if (prefs_common.work_offline)
1146 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1151 void main_window_destroy(MainWindow *mainwin)
1153 /* TODO : destroy other component */
1154 messageview_destroy(mainwin->messageview);
1155 mainwin->messageview = NULL;
1158 void main_window_update_actions_menu(MainWindow *mainwin)
1160 GtkItemFactory *ifactory;
1162 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1163 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1166 void main_window_cursor_wait(MainWindow *mainwin)
1169 if (mainwin->cursor_count == 0)
1170 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1172 mainwin->cursor_count++;
1177 void main_window_cursor_normal(MainWindow *mainwin)
1179 if (mainwin->cursor_count)
1180 mainwin->cursor_count--;
1182 if (mainwin->cursor_count == 0)
1183 gdk_window_set_cursor(mainwin->window->window, NULL);
1188 /* lock / unlock the user-interface */
1189 void main_window_lock(MainWindow *mainwin)
1191 if (mainwin->lock_count == 0)
1192 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1194 mainwin->lock_count++;
1196 main_window_set_menu_sensitive(mainwin);
1197 toolbar_main_set_sensitive(mainwin);
1200 void main_window_unlock(MainWindow *mainwin)
1202 if (mainwin->lock_count)
1203 mainwin->lock_count--;
1205 main_window_set_menu_sensitive(mainwin);
1206 toolbar_main_set_sensitive(mainwin);
1208 if (mainwin->lock_count == 0)
1209 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1212 static void main_window_menu_callback_block(MainWindow *mainwin)
1214 mainwin->menu_lock_count++;
1217 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1219 if (mainwin->menu_lock_count)
1220 mainwin->menu_lock_count--;
1223 static guint prefs_tag = 0;
1225 void main_window_reflect_prefs_all(void)
1227 main_window_reflect_prefs_all_real(FALSE);
1230 static gboolean reflect_prefs_timeout_cb(gpointer data)
1232 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1234 MainWindow *mainwin;
1237 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1238 mainwin = (MainWindow *)cur->data;
1240 main_window_show_cur_account(mainwin);
1241 main_window_set_menu_sensitive(mainwin);
1242 toolbar_main_set_sensitive(mainwin);
1245 if (pixmap_theme_changed) {
1246 toolbar_update(TOOLBAR_MAIN, mainwin);
1247 messageview_reflect_prefs_pixmap_theme();
1248 compose_reflect_prefs_pixmap_theme();
1249 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1250 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1252 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1253 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1254 mainwin->online_pixmap);
1255 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1256 gtk_widget_show(pixmap);
1257 mainwin->online_pixmap = pixmap;
1258 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1259 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1260 mainwin->offline_pixmap);
1261 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1262 gtk_widget_show(pixmap);
1263 mainwin->offline_pixmap = pixmap;
1266 headerview_set_font(mainwin->messageview->headerview);
1267 headerview_set_visibility(mainwin->messageview->headerview,
1268 prefs_common.display_header_pane);
1269 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1270 folderview_reflect_prefs();
1271 summary_reflect_prefs();
1272 summary_redisplay_msg(mainwin->summaryview);
1278 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1280 if (prefs_tag == 0 || pixmap_theme_changed) {
1281 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1282 GINT_TO_POINTER(pixmap_theme_changed));
1286 void main_window_set_summary_column(void)
1289 MainWindow *mainwin;
1291 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1292 mainwin = (MainWindow *)cur->data;
1293 summary_set_column_order(mainwin->summaryview);
1297 void main_window_set_folder_column(void)
1300 MainWindow *mainwin;
1302 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1303 mainwin = (MainWindow *)cur->data;
1304 folderview_set_column_order(mainwin->folderview);
1308 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1309 GList *account_list)
1311 GList *cur_ac, *cur_item;
1312 GtkWidget *menuitem;
1313 PrefsAccount *ac_prefs;
1315 /* destroy all previous menu item */
1316 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1317 while (cur_item != NULL) {
1318 GList *next = cur_item->next;
1319 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1323 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1324 ac_prefs = (PrefsAccount *)cur_ac->data;
1326 menuitem = gtk_menu_item_new_with_label
1327 (ac_prefs->account_name
1328 ? ac_prefs->account_name : _("Untitled"));
1329 gtk_widget_show(menuitem);
1330 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1331 g_signal_connect(G_OBJECT(menuitem), "activate",
1332 G_CALLBACK(account_selector_menu_cb),
1337 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1338 GList *account_list)
1340 GList *cur_ac, *cur_item;
1342 GtkWidget *menuitem;
1343 PrefsAccount *ac_prefs;
1345 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1346 "/Message/Receive");
1348 /* search for separator */
1349 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1350 cur_item = cur_item->next) {
1351 if (GTK_BIN(cur_item->data)->child == NULL) {
1352 cur_item = cur_item->next;
1357 /* destroy all previous menu item */
1358 while (cur_item != NULL) {
1359 GList *next = cur_item->next;
1360 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1364 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1365 ac_prefs = (PrefsAccount *)cur_ac->data;
1367 menuitem = gtk_menu_item_new_with_label
1368 (ac_prefs->account_name ? ac_prefs->account_name
1370 gtk_widget_show(menuitem);
1371 gtk_menu_append(GTK_MENU(menu), menuitem);
1372 g_signal_connect(G_OBJECT(menuitem), "activate",
1373 G_CALLBACK(account_receive_menu_cb),
1378 void main_window_set_account_menu(GList *account_list)
1381 MainWindow *mainwin;
1383 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1384 mainwin = (MainWindow *)cur->data;
1385 main_window_set_account_selector_menu(mainwin, account_list);
1386 main_window_set_account_receive_menu(mainwin, account_list);
1390 static void main_window_show_cur_account(MainWindow *mainwin)
1395 ac_name = g_strdup(cur_account
1396 ? (cur_account->account_name
1397 ? cur_account->account_name : _("Untitled"))
1401 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
1403 buf = g_strdup(PROG_VERSION);
1404 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
1407 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
1408 gtk_widget_queue_resize(mainwin->ac_button);
1413 GtkWidget *main_window_get_folder_window(MainWindow *mainwin)
1415 switch (mainwin->type) {
1416 case SEPARATE_FOLDER:
1417 return mainwin->win.sep_folder.folderwin;
1419 return mainwin->win.sep_both.folderwin;
1425 GtkWidget *main_window_get_message_window(MainWindow *mainwin)
1427 switch (mainwin->type) {
1428 case SEPARATE_MESSAGE:
1429 return mainwin->win.sep_message.messagewin;
1431 return mainwin->win.sep_both.messagewin;
1437 void main_window_separation_change(MainWindow *mainwin, SeparateType type)
1439 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
1440 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
1441 /* GtkWidget *message_wid = GTK_WIDGET_PTR(mainwin->messageview); */
1442 GtkWidget *message_wid = mainwin->messageview->vbox;
1444 debug_print("Changing window separation type from %d to %d\n",
1445 mainwin->type, type);
1447 if (mainwin->type == type) return;
1449 /* remove widgets from those containers */
1450 gtk_widget_ref(folder_wid);
1451 gtk_widget_ref(summary_wid);
1452 gtk_widget_ref(message_wid);
1453 gtkut_container_remove
1454 (GTK_CONTAINER(folder_wid->parent), folder_wid);
1455 gtkut_container_remove
1456 (GTK_CONTAINER(summary_wid->parent), summary_wid);
1457 gtkut_container_remove
1458 (GTK_CONTAINER(message_wid->parent), message_wid);
1460 /* clean containers */
1461 switch (mainwin->type) {
1463 gtk_widget_destroy(mainwin->win.sep_none.hpaned);
1465 case SEPARATE_FOLDER:
1466 gtk_widget_destroy(mainwin->win.sep_folder.vpaned);
1467 gtk_widget_destroy(mainwin->win.sep_folder.folderwin);
1469 case SEPARATE_MESSAGE:
1470 gtk_widget_destroy(mainwin->win.sep_message.hpaned);
1471 gtk_widget_destroy(mainwin->win.sep_message.messagewin);
1474 gtk_widget_destroy(mainwin->win.sep_both.messagewin);
1475 gtk_widget_destroy(mainwin->win.sep_both.folderwin);
1479 gtk_widget_hide(mainwin->window);
1480 main_window_set_widgets(mainwin, type);
1481 gtk_widget_show(mainwin->window);
1483 gtk_widget_unref(folder_wid);
1484 gtk_widget_unref(summary_wid);
1485 gtk_widget_unref(message_wid);
1488 void main_window_toggle_message_view(MainWindow *mainwin)
1490 SummaryView *summaryview = mainwin->summaryview;
1491 union CompositeWin *cwin = &mainwin->win;
1492 GtkWidget *vpaned = NULL;
1493 GtkWidget *container = NULL;
1494 GtkWidget *msgwin = NULL;
1496 switch (mainwin->type) {
1498 vpaned = cwin->sep_none.vpaned;
1499 container = cwin->sep_none.hpaned;
1501 case SEPARATE_FOLDER:
1502 vpaned = cwin->sep_folder.vpaned;
1503 container = mainwin->vbox_body;
1505 case SEPARATE_MESSAGE:
1506 msgwin = mainwin->win.sep_message.messagewin;
1509 msgwin = mainwin->win.sep_both.messagewin;
1514 if (GTK_WIDGET_VISIBLE(msgwin)) {
1515 gtk_widget_hide(msgwin);
1516 mainwin->messageview->visible = FALSE;
1517 summaryview->displayed = NULL;
1519 gtk_widget_show(msgwin);
1520 mainwin->messageview->visible = TRUE;
1522 } else if (vpaned->parent != NULL) {
1523 mainwin->messageview->visible = FALSE;
1524 summaryview->displayed = NULL;
1525 gtk_widget_ref(vpaned);
1526 gtkut_container_remove(GTK_CONTAINER(container), vpaned);
1527 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
1529 mainwin->messageview->visible = TRUE;
1530 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), vpaned);
1531 gtk_container_add(GTK_CONTAINER(container), vpaned);
1532 gtk_widget_unref(vpaned);
1535 if (messageview_is_visible(mainwin->messageview))
1536 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1537 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
1539 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
1540 GTK_ARROW_UP, GTK_SHADOW_OUT);
1542 if (mainwin->messageview->visible == FALSE)
1543 messageview_clear(mainwin->messageview);
1545 main_window_set_menu_sensitive(mainwin);
1547 prefs_common.msgview_visible = mainwin->messageview->visible;
1549 gtk_widget_grab_focus(summaryview->ctree);
1552 void main_window_get_size(MainWindow *mainwin)
1554 GtkAllocation *allocation;
1556 if (mainwin->messageview == NULL) {
1557 debug_print("called after messageview "
1558 "has been deallocated!\n");
1562 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
1564 if (allocation->width > 1 && allocation->height > 1) {
1565 prefs_common.summaryview_width = allocation->width;
1567 if ((mainwin->type == SEPARATE_NONE ||
1568 mainwin->type == SEPARATE_FOLDER) &&
1569 messageview_is_visible(mainwin->messageview))
1570 prefs_common.summaryview_height = allocation->height;
1572 prefs_common.mainview_width = allocation->width;
1575 allocation = &mainwin->window->allocation;
1576 if (allocation->width > 1 && allocation->height > 1) {
1577 prefs_common.mainview_height = allocation->height;
1578 prefs_common.mainwin_width = allocation->width;
1579 prefs_common.mainwin_height = allocation->height;
1582 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
1583 if (allocation->width > 1 && allocation->height > 1) {
1584 prefs_common.folderview_width = allocation->width;
1585 prefs_common.folderview_height = allocation->height;
1588 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
1589 if (allocation->width > 1 && allocation->height > 1) {
1590 prefs_common.msgview_width = allocation->width;
1591 prefs_common.msgview_height = allocation->height;
1594 /* debug_print("summaryview size: %d x %d\n",
1595 prefs_common.summaryview_width,
1596 prefs_common.summaryview_height);
1597 debug_print("folderview size: %d x %d\n",
1598 prefs_common.folderview_width,
1599 prefs_common.folderview_height);
1600 debug_print("messageview size: %d x %d\n",
1601 prefs_common.msgview_width,
1602 prefs_common.msgview_height); */
1605 void main_window_get_position(MainWindow *mainwin)
1610 gtkut_widget_get_uposition(mainwin->window, &x, &y);
1612 prefs_common.mainview_x = x;
1613 prefs_common.mainview_y = y;
1614 prefs_common.mainwin_x = x;
1615 prefs_common.mainwin_y = y;
1617 debug_print("main window position: %d, %d\n", x, y);
1619 window = main_window_get_folder_window(mainwin);
1621 gtkut_widget_get_uposition(window, &x, &y);
1622 prefs_common.folderwin_x = x;
1623 prefs_common.folderwin_y = y;
1624 debug_print("folder window position: %d, %d\n", x, y);
1626 window = main_window_get_message_window(mainwin);
1628 gtkut_widget_get_uposition(window, &x, &y);
1629 prefs_common.main_msgwin_x = x;
1630 prefs_common.main_msgwin_y = y;
1631 debug_print("message window position: %d, %d\n", x, y);
1635 void main_window_progress_on(MainWindow *mainwin)
1637 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1640 void main_window_progress_off(MainWindow *mainwin)
1642 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
1643 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
1646 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
1650 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
1651 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
1652 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
1653 (cur == 0 && total == 0) ? 0 :
1654 (gfloat)cur / (gfloat)total);
1657 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
1660 if (alertpanel(_("Empty trash"),
1661 _("Delete all messages in trash folders?"),
1662 GTK_STOCK_YES, GTK_STOCK_NO, NULL)
1665 manage_window_focus_in(mainwin->window, NULL, NULL);
1668 procmsg_empty_all_trash();
1670 if (mainwin->summaryview->folder_item &&
1671 mainwin->summaryview->folder_item->stype == F_TRASH)
1672 gtk_widget_grab_focus(mainwin->folderview->ctree);
1675 void main_window_add_mailbox(MainWindow *mainwin)
1680 path = input_dialog(_("Add mailbox"),
1681 _("Input the location of mailbox.\n"
1682 "If the existing mailbox is specified, it will be\n"
1683 "scanned automatically."),
1686 if (folder_find_from_path(path)) {
1687 alertpanel_error(_("The mailbox '%s' already exists."), path);
1691 folder = folder_new(folder_get_class_from_string("mh"),
1692 !strcmp(path, "Mail") ? _("Mailbox") :
1693 g_path_get_basename(path), path);
1696 if (folder->klass->create_tree(folder) < 0) {
1697 alertpanel_error(_("Creation of the mailbox failed.\n"
1698 "Maybe some files already exist, or you don't have the permission to write there."));
1699 folder_destroy(folder);
1704 folder_set_ui_func(folder, scan_tree_func, mainwin);
1705 folder_scan_tree(folder, TRUE);
1706 folder_set_ui_func(folder, NULL, NULL);
1709 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
1711 SensitiveCond state = 0;
1712 SummarySelection selection;
1713 FolderItem *item = mainwin->summaryview->folder_item;
1714 GList *account_list = account_get_list();
1716 selection = summary_get_selection_type(mainwin->summaryview);
1718 if (mainwin->lock_count == 0)
1719 state |= M_UNLOCKED;
1720 if (selection != SUMMARY_NONE)
1721 state |= M_MSG_EXIST;
1722 if (item && item->path && folder_item_parent(item) && !item->no_select) {
1724 /* if (item->folder->type != F_NEWS) */
1725 state |= M_ALLOW_DELETE;
1727 if (prefs_common.immediate_exec == 0
1728 && mainwin->lock_count == 0)
1729 state |= M_DELAY_EXEC;
1731 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
1732 || selection != SUMMARY_NONE)
1733 state |= M_HIDE_READ_MSG;
1735 if (mainwin->summaryview->threaded)
1736 state |= M_THREADED;
1738 state |= M_UNTHREADED;
1739 if (selection == SUMMARY_SELECTED_SINGLE ||
1740 selection == SUMMARY_SELECTED_MULTIPLE)
1741 state |= M_TARGET_EXIST;
1742 if (selection == SUMMARY_SELECTED_SINGLE)
1743 state |= M_SINGLE_TARGET_EXIST;
1744 if (mainwin->summaryview->folder_item &&
1745 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
1748 state |= M_NOT_NEWS;
1749 if (selection == SUMMARY_SELECTED_SINGLE &&
1751 (folder_has_parent_of_type(item, F_DRAFT) ||
1752 folder_has_parent_of_type(item, F_OUTBOX) ||
1753 folder_has_parent_of_type(item, F_QUEUE))))
1754 state |= M_ALLOW_REEDIT;
1756 state |= M_HAVE_ACCOUNT;
1758 for ( ; account_list != NULL; account_list = account_list->next) {
1759 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
1760 state |= M_HAVE_NEWS_ACCOUNT;
1765 if (inc_is_active())
1766 state |= M_INC_ACTIVE;
1768 if (mainwin->summaryview->deleted > 0 ||
1769 mainwin->summaryview->moved > 0 ||
1770 mainwin->summaryview->copied > 0)
1771 state |= M_DELAY_EXEC;
1778 void main_window_set_menu_sensitive(MainWindow *mainwin)
1780 GtkItemFactory *ifactory = mainwin->menu_factory;
1781 SensitiveCond state;
1784 GtkWidget *menuitem;
1785 SummaryView *summaryview;
1790 static const struct {
1794 {"/File/Add mailbox" , M_UNLOCKED},
1796 {"/File/Add mailbox/MH..." , M_UNLOCKED},
1797 {"/File/Change folder order" , M_UNLOCKED},
1798 {"/File/Export to mbox file..." , M_UNLOCKED},
1799 {"/File/Empty all Trash folders" , M_UNLOCKED},
1800 {"/File/Work offline" , M_UNLOCKED},
1802 {"/File/Save as...", M_TARGET_EXIST|M_UNLOCKED},
1803 {"/File/Print..." , M_TARGET_EXIST|M_UNLOCKED},
1804 /* {"/File/Close" , M_UNLOCKED}, */
1805 {"/File/Exit" , M_UNLOCKED},
1807 {"/Edit/Select thread" , M_SINGLE_TARGET_EXIST},
1809 {"/View/Sort" , M_EXEC},
1810 {"/View/Thread view" , M_EXEC},
1811 {"/View/Expand all threads" , M_MSG_EXIST},
1812 {"/View/Collapse all threads" , M_MSG_EXIST},
1813 {"/View/Hide read messages" , M_HIDE_READ_MSG},
1814 {"/View/Go to/Prev message" , M_MSG_EXIST},
1815 {"/View/Go to/Next message" , M_MSG_EXIST},
1816 {"/View/Go to/Prev unread message" , M_MSG_EXIST},
1817 {"/View/Go to/Prev new message" , M_MSG_EXIST},
1818 {"/View/Go to/Prev marked message" , M_MSG_EXIST},
1819 {"/View/Go to/Next marked message" , M_MSG_EXIST},
1820 {"/View/Go to/Prev labeled message", M_MSG_EXIST},
1821 {"/View/Go to/Next labeled message", M_MSG_EXIST},
1822 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
1823 {"/View/Show all headers" , M_SINGLE_TARGET_EXIST},
1824 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
1826 {"/Message/Receive/Get from current account"
1827 , M_HAVE_ACCOUNT|M_UNLOCKED},
1828 {"/Message/Receive/Get from all accounts"
1829 , M_HAVE_ACCOUNT|M_UNLOCKED},
1830 {"/Message/Receive/Cancel receiving"
1833 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
1834 {"/Message/Reply" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1835 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1836 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST|M_NEWS},
1837 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1838 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
1839 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_SINGLE_TARGET_EXIST},
1840 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1841 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1842 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NOT_NEWS},
1843 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1844 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_UNLOCKED|M_NEWS},
1845 {"/Message/Mark" , M_TARGET_EXIST},
1846 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
1848 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
1849 {"/Tools/Harvest addresses" , M_UNLOCKED},
1850 {"/Tools/Harvest addresses/from Folder..."
1851 , M_UNLOCKED|M_MSG_EXIST},
1852 {"/Tools/Harvest addresses/from Messages..."
1853 , M_UNLOCKED|M_MSG_EXIST|M_TARGET_EXIST},
1854 {"/Tools/Harvest addresses" , M_UNLOCKED},
1855 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC|M_UNLOCKED},
1856 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC|M_UNLOCKED},
1857 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
1858 {"/Tools/Actions" , M_TARGET_EXIST|M_UNLOCKED},
1859 {"/Tools/Execute" , M_DELAY_EXEC},
1860 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE|M_UNLOCKED},
1862 {"/Configuration", M_UNLOCKED},
1867 state = main_window_get_current_state(mainwin);
1869 for (i = 0; entry[i].entry != NULL; i++) {
1870 sensitive = ((entry[i].cond & state) == entry[i].cond);
1871 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
1874 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
1876 /* search for separator */
1877 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1878 cur_item = cur_item->next) {
1879 if (GTK_BIN(cur_item->data)->child == NULL) {
1880 cur_item = cur_item->next;
1885 for (; cur_item != NULL; cur_item = cur_item->next) {
1886 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
1887 (M_UNLOCKED & state) != 0);
1890 main_window_menu_callback_block(mainwin);
1892 #define SET_CHECK_MENU_ACTIVE(path, active) \
1894 menuitem = gtk_item_factory_get_widget(ifactory, path); \
1895 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
1898 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
1899 messageview_is_visible(mainwin->messageview));
1901 summaryview = mainwin->summaryview;
1902 menu_path = "/View/Sort/Don't sort";
1904 switch (summaryview->sort_key) {
1905 case SORT_BY_NUMBER:
1906 menu_path = "/View/Sort/by number"; break;
1908 menu_path = "/View/Sort/by Size"; break;
1910 menu_path = "/View/Sort/by Date"; break;
1912 menu_path = "/View/Sort/by From"; break;
1914 menu_path = "/View/Sort/by To"; break;
1915 case SORT_BY_SUBJECT:
1916 menu_path = "/View/Sort/by Subject"; break;
1918 menu_path = "/View/Sort/by color label"; break;
1920 menu_path = "/View/Sort/by mark"; break;
1921 case SORT_BY_STATUS:
1922 menu_path = "/View/Sort/by status"; break;
1924 menu_path = "/View/Sort/by attachment"; break;
1926 menu_path = "/View/Sort/by score"; break;
1927 case SORT_BY_LOCKED:
1928 menu_path = "/View/Sort/by locked"; break;
1931 menu_path = "/View/Sort/Don't sort"; break;
1933 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
1935 if (summaryview->sort_type == SORT_ASCENDING) {
1936 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
1938 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
1941 if (summaryview->sort_key != SORT_BY_NONE) {
1942 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
1943 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
1945 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
1946 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
1949 SET_CHECK_MENU_ACTIVE("/View/Show all headers",
1950 mainwin->messageview->mimeview->textview->show_all_headers);
1951 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
1953 #undef SET_CHECK_MENU_ACTIVE
1955 main_window_menu_callback_unblock(mainwin);
1958 void main_window_popup(MainWindow *mainwin)
1960 gtkut_window_popup(mainwin->window);
1962 switch (mainwin->type) {
1963 case SEPARATE_FOLDER:
1964 gtkut_window_popup(mainwin->win.sep_folder.folderwin);
1966 case SEPARATE_MESSAGE:
1967 gtkut_window_popup(mainwin->win.sep_message.messagewin);
1970 gtkut_window_popup(mainwin->win.sep_both.folderwin);
1971 gtkut_window_popup(mainwin->win.sep_both.messagewin);
1978 void main_window_show(MainWindow *mainwin)
1980 gtk_widget_show(mainwin->window);
1981 gtk_widget_show(mainwin->vbox_body);
1983 gtk_widget_set_uposition(mainwin->window,
1984 prefs_common.mainwin_x,
1985 prefs_common.mainwin_y);
1987 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
1988 prefs_common.folderview_width,
1989 prefs_common.folderview_height);
1990 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
1991 prefs_common.summaryview_width,
1992 prefs_common.summaryview_height);
1993 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
1994 prefs_common.msgview_width,
1995 prefs_common.msgview_height);
1997 if (mainwin->type & SEPARATE_FOLDER) {
1998 GtkWidget *folderwin;
2000 folderwin = main_window_get_folder_window(mainwin);
2001 gtk_widget_show(folderwin);
2002 gtk_widget_set_uposition(folderwin, prefs_common.folderwin_x,
2003 prefs_common.folderwin_y);
2006 if (mainwin->type & SEPARATE_MESSAGE) {
2007 GtkWidget *messagewin;
2009 messagewin = main_window_get_message_window(mainwin);
2010 gtk_widget_show(messagewin);
2011 gtk_widget_set_uposition(messagewin, prefs_common.main_msgwin_x,
2012 prefs_common.main_msgwin_y);
2016 void main_window_hide(MainWindow *mainwin)
2018 main_window_get_size(mainwin);
2019 main_window_get_position(mainwin);
2021 gtk_widget_hide(mainwin->window);
2022 gtk_widget_hide(mainwin->vbox_body);
2024 if (mainwin->type & SEPARATE_FOLDER) {
2025 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2028 if (mainwin->type & SEPARATE_MESSAGE) {
2029 gtk_widget_hide(mainwin->win.sep_message.messagewin);
2033 static void main_window_set_widgets(MainWindow *mainwin, SeparateType type)
2035 GtkWidget *folderwin = NULL;
2036 GtkWidget *messagewin = NULL;
2039 GtkWidget *vbox_body = mainwin->vbox_body;
2040 GtkItemFactory *ifactory = mainwin->menu_factory;
2041 GtkWidget *menuitem;
2042 GtkItemFactory *msgview_ifactory;
2044 debug_print("Setting widgets... ");
2046 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2047 prefs_common.folderview_width,
2048 prefs_common.folderview_height);
2049 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2050 prefs_common.summaryview_width,
2051 prefs_common.summaryview_height);
2052 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2053 prefs_common.msgview_width,
2054 prefs_common.msgview_height);
2056 /* create separated window(s) if needed */
2057 if (type & SEPARATE_FOLDER) {
2058 static GdkGeometry folderwin_geometry;
2060 folderwin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2061 gtk_window_set_title(GTK_WINDOW(folderwin),
2062 _("Sylpheed - Folder View"));
2064 gtk_window_move(GTK_WINDOW(folderwin),
2065 prefs_common.folderwin_x,
2066 prefs_common.folderwin_y);
2068 if (!folderwin_geometry.min_height) {
2069 folderwin_geometry.min_width = 320;
2070 folderwin_geometry.min_height = 200;
2072 gtk_window_set_geometry_hints(GTK_WINDOW(folderwin), NULL,
2073 &folderwin_geometry, GDK_HINT_MIN_SIZE);
2075 gtk_widget_set_size_request(folderwin,
2076 prefs_common.folderview_width,
2077 prefs_common.folderview_height);
2079 gtk_container_set_border_width(GTK_CONTAINER(folderwin),
2082 g_signal_connect(G_OBJECT(folderwin), "delete_event",
2083 G_CALLBACK(folder_window_close_cb),
2085 gtk_container_add(GTK_CONTAINER(folderwin),
2086 GTK_WIDGET_PTR(mainwin->folderview));
2087 gtk_widget_realize(folderwin);
2089 if (prefs_common.folderview_visible)
2090 gtk_widget_show(folderwin);
2093 if (type & SEPARATE_MESSAGE) {
2094 static GdkGeometry msgwin_geometry;
2096 messagewin = gtk_window_new(GTK_WINDOW_TOPLEVEL);
2097 gtk_window_set_title(GTK_WINDOW(messagewin),
2098 _("Sylpheed - Message View"));
2100 gtk_window_move(GTK_WINDOW(messagewin),
2101 prefs_common.main_msgwin_x,
2102 prefs_common.main_msgwin_y);
2104 if (!msgwin_geometry.min_height) {
2105 msgwin_geometry.min_width = 320;
2106 msgwin_geometry.min_height = 200;
2108 gtk_window_set_geometry_hints(GTK_WINDOW(messagewin), NULL,
2109 &msgwin_geometry, GDK_HINT_MIN_SIZE);
2111 gtk_widget_set_size_request(messagewin,
2112 prefs_common.msgwin_width,
2113 prefs_common.msgwin_height);
2115 gtk_container_set_border_width(GTK_CONTAINER(messagewin),
2117 g_signal_connect(G_OBJECT(messagewin), "delete_event",
2118 G_CALLBACK(message_window_close_cb),
2120 if (messageview_is_visible(mainwin->messageview))
2121 gtk_widget_show(messagewin);
2123 mainwin->messageview->statusbar = mainwin->statusbar;
2124 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2129 hpaned = gtk_hpaned_new();
2130 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2131 gtk_paned_add1(GTK_PANED(hpaned),
2132 GTK_WIDGET_PTR(mainwin->folderview));
2133 gtk_widget_show(hpaned);
2134 gtk_widget_queue_resize(hpaned);
2136 vpaned = gtk_vpaned_new();
2137 if (messageview_is_visible(mainwin->messageview)) {
2138 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2139 gtk_paned_add1(GTK_PANED(vpaned),
2140 GTK_WIDGET_PTR(mainwin->summaryview));
2142 gtk_paned_add2(GTK_PANED(hpaned),
2143 GTK_WIDGET_PTR(mainwin->summaryview));
2144 gtk_widget_ref(vpaned);
2146 gtk_paned_add2(GTK_PANED(vpaned),
2147 GTK_WIDGET_PTR(mainwin->messageview));
2148 gtk_widget_show(vpaned);
2149 gtk_widget_queue_resize(vpaned);
2151 mainwin->win.sep_none.hpaned = hpaned;
2152 mainwin->win.sep_none.vpaned = vpaned;
2154 /* remove headerview if not in prefs */
2155 headerview_set_visibility(mainwin->messageview->headerview,
2156 prefs_common.display_header_pane);
2158 case SEPARATE_FOLDER:
2159 vpaned = gtk_vpaned_new();
2160 if (messageview_is_visible(mainwin->messageview)) {
2161 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned,
2163 gtk_paned_add1(GTK_PANED(vpaned),
2164 GTK_WIDGET_PTR(mainwin->summaryview));
2166 gtk_box_pack_start(GTK_BOX(vbox_body),
2167 GTK_WIDGET_PTR(mainwin->summaryview),
2169 gtk_widget_ref(vpaned);
2171 gtk_paned_add2(GTK_PANED(vpaned),
2172 GTK_WIDGET_PTR(mainwin->messageview));
2173 gtk_widget_show(vpaned);
2174 gtk_widget_queue_resize(vpaned);
2176 mainwin->win.sep_folder.folderwin = folderwin;
2177 mainwin->win.sep_folder.vpaned = vpaned;
2179 /* remove headerview if not in prefs */
2180 headerview_set_visibility(mainwin->messageview->headerview,
2181 prefs_common.display_header_pane);
2184 case SEPARATE_MESSAGE:
2185 hpaned = gtk_hpaned_new();
2186 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2187 gtk_paned_add1(GTK_PANED(hpaned),
2188 GTK_WIDGET_PTR(mainwin->folderview));
2189 gtk_paned_add2(GTK_PANED(hpaned),
2190 GTK_WIDGET_PTR(mainwin->summaryview));
2191 gtk_widget_show(hpaned);
2192 gtk_widget_queue_resize(hpaned);
2193 messageview_add_toolbar(mainwin->messageview, messagewin);
2194 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2195 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2197 mainwin->win.sep_message.messagewin = messagewin;
2198 mainwin->win.sep_message.hpaned = hpaned;
2200 gtk_widget_realize(messagewin);
2201 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2202 gtk_widget_show_all(messagewin);
2203 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2204 mainwin->messageview->handlebox,
2205 prefs_common.toolbar_style);
2209 messageview_add_toolbar(mainwin->messageview, messagewin);
2210 msgview_ifactory = gtk_item_factory_from_widget(mainwin->messageview->menubar);
2211 menu_set_sensitive(msgview_ifactory, "/File/Close", FALSE);
2213 gtk_box_pack_start(GTK_BOX(vbox_body),
2214 GTK_WIDGET_PTR(mainwin->summaryview),
2217 mainwin->win.sep_both.folderwin = folderwin;
2218 mainwin->win.sep_both.messagewin = messagewin;
2220 gtk_widget_realize(messagewin);
2221 gtk_widget_show_all(GTK_WIDGET_PTR(mainwin->messageview));
2222 gtk_widget_show_all(messagewin);
2223 toolbar_set_style(mainwin->messageview->toolbar->toolbar,
2224 mainwin->messageview->handlebox,
2225 prefs_common.toolbar_style);
2230 if (messageview_is_visible(mainwin->messageview))
2231 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2232 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2234 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2235 GTK_ARROW_UP, GTK_SHADOW_OUT);
2237 gtk_window_move(GTK_WINDOW(mainwin->window),
2238 prefs_common.mainwin_x,
2239 prefs_common.mainwin_y);
2241 gtk_widget_queue_resize(vbox_body);
2242 gtk_widget_queue_resize(mainwin->vbox);
2243 gtk_widget_queue_resize(mainwin->window);
2244 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
2245 * and mimeview icon list/ctree lose track of their visibility states */
2246 if (!noticeview_is_visible(mainwin->messageview->noticeview))
2247 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
2248 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
2249 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
2250 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
2251 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
2253 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
2255 mainwin->type = type;
2258 /* toggle menu state */
2259 menuitem = gtk_item_factory_get_item
2260 (ifactory, "/View/Show or hide/Folder tree");
2261 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2262 (type & SEPARATE_FOLDER) == 0 ? TRUE :
2263 prefs_common.folderview_visible);
2264 gtk_widget_set_sensitive(menuitem, ((type & SEPARATE_FOLDER) != 0));
2265 menuitem = gtk_item_factory_get_item
2266 (ifactory, "/View/Show or hide/Message view");
2267 gtk_check_menu_item_set_active
2268 (GTK_CHECK_MENU_ITEM(menuitem),
2269 messageview_is_visible(mainwin->messageview));
2271 menuitem = gtk_item_factory_get_item
2272 (ifactory, "/View/Separate folder tree");
2273 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2274 ((type & SEPARATE_FOLDER) != 0));
2275 menuitem = gtk_item_factory_get_item
2276 (ifactory, "/View/Separate message view");
2277 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
2278 ((type & SEPARATE_MESSAGE) != 0));
2282 (G_OBJECT(folderwin), "size_allocate",
2283 G_CALLBACK(folder_window_size_allocate_cb),
2288 (G_OBJECT(messagewin), "size_allocate",
2289 G_CALLBACK(message_window_size_allocate_cb),
2293 debug_print("done.\n");
2296 void main_window_destroy_all(void)
2298 while (mainwin_list != NULL) {
2299 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
2301 /* free toolbar stuff */
2302 toolbar_clear_list(TOOLBAR_MAIN);
2303 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
2304 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
2306 g_free(mainwin->toolbar);
2309 mainwin_list = g_list_remove(mainwin_list, mainwin);
2311 g_list_free(mainwin_list);
2315 static gboolean toolbar_account_button_pressed(GtkWidget *widget,
2316 GdkEventButton *event,
2319 MainWindow *mainwin = (MainWindow *)data;
2321 if (!event) return FALSE;
2322 if (event->button != 3) return FALSE;
2324 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2325 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2328 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2329 menu_button_position, widget,
2330 event->button, event->time);
2336 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
2339 gtk_widget_set_size_request(child, 1, -1);
2342 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
2345 gtk_widget_set_size_request(child, -1, -1);
2348 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
2351 MainWindow *mainwin = (MainWindow *)data;
2353 if (!event) return FALSE;
2355 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
2356 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
2359 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
2360 menu_button_position, widget,
2361 event->button, event->time);
2366 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2369 MainWindow *mainwin = (MainWindow *)data;
2371 if (mainwin->lock_count == 0)
2372 app_exit_cb(data, 0, widget);
2377 static gint folder_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2380 MainWindow *mainwin = (MainWindow *)data;
2381 GtkWidget *menuitem;
2383 menuitem = gtk_item_factory_get_item
2384 (mainwin->menu_factory, "/View/Show or hide/Folder tree");
2385 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2390 static gint message_window_close_cb(GtkWidget *widget, GdkEventAny *event,
2393 MainWindow *mainwin = (MainWindow *)data;
2394 GtkWidget *menuitem;
2396 menuitem = gtk_item_factory_get_item
2397 (mainwin->menu_factory, "/View/Show or hide/Message view");
2398 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), FALSE);
2400 mainwin->messageview->statusbar = mainwin->statusbar;
2401 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2406 static void main_window_size_allocate_cb(GtkWidget *widget,
2407 GtkAllocation *allocation,
2410 MainWindow *mainwin = (MainWindow *)data;
2412 main_window_get_size(mainwin);
2415 static void folder_window_size_allocate_cb(GtkWidget *widget,
2416 GtkAllocation *allocation,
2419 MainWindow *mainwin = (MainWindow *)data;
2421 main_window_get_size(mainwin);
2424 static void message_window_size_allocate_cb(GtkWidget *widget,
2425 GtkAllocation *allocation,
2428 MainWindow *mainwin = (MainWindow *)data;
2430 main_window_get_size(mainwin);
2433 static void add_mailbox_cb(MainWindow *mainwin, guint action,
2436 main_window_add_mailbox(mainwin);
2439 static void update_folderview_cb(MainWindow *mainwin, guint action,
2442 summary_show(mainwin->summaryview, NULL);
2443 folderview_check_new_all();
2446 static void foldersort_cb(MainWindow *mainwin, guint action,
2452 static void import_mbox_cb(MainWindow *mainwin, guint action,
2455 import_mbox(mainwin->summaryview->folder_item);
2458 static void export_mbox_cb(MainWindow *mainwin, guint action,
2461 export_mbox(mainwin->summaryview->folder_item);
2464 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
2467 summaryview_export_mbox_list(mainwin->summaryview);
2470 static void empty_trash_cb(MainWindow *mainwin, guint action,
2473 main_window_empty_trash(mainwin, TRUE);
2476 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2478 summary_save_as(mainwin->summaryview);
2481 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2483 summary_print(mainwin->summaryview);
2486 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2488 if (prefs_common.confirm_on_exit) {
2489 if (alertpanel(_("Exit"), _("Exit this program?"),
2490 GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL)
2493 manage_window_focus_in(mainwin->window, NULL, NULL);
2496 app_will_exit(widget, mainwin);
2499 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2502 summary_search(mainwin->summaryview);
2504 message_search(mainwin->messageview);
2507 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
2509 prefs_common.show_searchbar = TRUE;
2510 summaryview_activate_quicksearch(mainwin->summaryview);
2513 static void toggle_folder_cb(MainWindow *mainwin, guint action,
2518 active = GTK_CHECK_MENU_ITEM(widget)->active;
2520 switch (mainwin->type) {
2522 case SEPARATE_MESSAGE:
2525 gtk_widget_show(GTK_WIDGET_PTR(mainwin->folderview));
2527 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->folderview));
2530 case SEPARATE_FOLDER:
2531 debug_print("separate folder\n");
2533 gtk_widget_show(mainwin->win.sep_folder.folderwin);
2535 gtk_widget_hide(mainwin->win.sep_folder.folderwin);
2539 gtk_widget_show(mainwin->win.sep_both.folderwin);
2541 gtk_widget_hide(mainwin->win.sep_both.folderwin);
2545 prefs_common.folderview_visible = active;
2548 static void toggle_message_cb(MainWindow *mainwin, guint action,
2553 active = GTK_CHECK_MENU_ITEM(widget)->active;
2555 if (active != messageview_is_visible(mainwin->messageview))
2556 summary_toggle_view(mainwin->summaryview);
2559 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
2562 toolbar_toggle(action, mainwin);
2565 void main_window_reply_cb(MainWindow *mainwin, guint action,
2568 MessageView *msgview = (MessageView*)mainwin->messageview;
2569 GSList *msginfo_list = NULL;
2571 g_return_if_fail(msgview != NULL);
2573 msginfo_list = summary_get_selection(mainwin->summaryview);
2574 g_return_if_fail(msginfo_list != NULL);
2575 compose_reply_from_messageview(msgview, msginfo_list, action);
2576 g_slist_free(msginfo_list);
2580 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
2583 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2584 gtk_widget_show(mainwin->hbox_stat);
2585 prefs_common.show_statusbar = TRUE;
2587 gtk_widget_hide(mainwin->hbox_stat);
2588 prefs_common.show_statusbar = FALSE;
2592 static void separate_widget_cb(MainWindow *mainwin, guint action,
2597 if (GTK_CHECK_MENU_ITEM(widget)->active)
2598 type = mainwin->type | action;
2600 type = mainwin->type & ~action;
2602 main_window_separation_change(mainwin, type);
2604 prefs_common.sep_folder = (type & SEPARATE_FOLDER) != 0;
2605 prefs_common.sep_msg = (type & SEPARATE_MESSAGE) != 0;
2608 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
2611 offline_ask_sync = ask_sync;
2613 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
2615 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
2616 offline_ask_sync = TRUE;
2619 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
2621 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
2624 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
2626 GList *folderlist = folder_get_list();
2627 gboolean found = FALSE;
2629 /* see if there are synchronised folders */
2630 for (; folderlist; folderlist = folderlist->next) {
2631 Folder *folder = (Folder *)folderlist->data;
2632 if (folder_want_synchronise(folder)) {
2641 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
2642 _("Do you want to synchronise your folders now?"),
2643 GTK_STOCK_YES, GTK_STOCK_NO, NULL) != G_ALERTDEFAULT)
2646 folder_synchronise(NULL);
2649 static void online_switch_clicked (GtkButton *btn, gpointer data)
2651 MainWindow *mainwin;
2652 GtkItemFactory *ifactory;
2653 GtkCheckMenuItem *menuitem;
2655 mainwin = (MainWindow *) data;
2657 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2658 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
2660 g_return_if_fail(mainwin != NULL);
2661 g_return_if_fail(menuitem != NULL);
2663 if (btn == GTK_BUTTON(mainwin->online_switch)) {
2665 mainwindow_check_synchronise(mainwin, TRUE);
2666 gtk_widget_hide (mainwin->online_switch);
2667 gtk_widget_show (mainwin->offline_switch);
2668 menuitem->active = TRUE;
2669 prefs_common.work_offline = TRUE;
2670 inc_autocheck_timer_remove();
2673 gtk_widget_hide (mainwin->offline_switch);
2674 gtk_widget_show (mainwin->online_switch);
2675 menuitem->active = FALSE;
2676 prefs_common.work_offline = FALSE;
2677 inc_autocheck_timer_set();
2681 static void addressbook_open_cb(MainWindow *mainwin, guint action,
2684 addressbook_open(NULL);
2687 static void log_window_show_cb(MainWindow *mainwin, guint action,
2690 log_window_show(mainwin->logwin);
2693 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2698 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2700 summary_move_to(mainwin->summaryview);
2703 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2705 summary_copy_to(mainwin->summaryview);
2708 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2710 summary_delete(mainwin->summaryview);
2713 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2715 summary_delete_trash(mainwin->summaryview);
2718 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2720 summary_cancel(mainwin->summaryview);
2723 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2725 summary_open_msg(mainwin->summaryview);
2728 static void view_source_cb(MainWindow *mainwin, guint action,
2731 summary_view_source(mainwin->summaryview);
2734 static void show_all_header_cb(MainWindow *mainwin, guint action,
2737 if (mainwin->menu_lock_count) return;
2738 mainwin->summaryview->messageview->all_headers =
2739 GTK_CHECK_MENU_ITEM(widget)->active;
2740 summary_display_msg_selected(mainwin->summaryview,
2741 GTK_CHECK_MENU_ITEM(widget)->active);
2744 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2746 summary_mark(mainwin->summaryview);
2749 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2751 summary_unmark(mainwin->summaryview);
2754 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
2757 summary_mark_as_unread(mainwin->summaryview);
2760 static void mark_as_read_cb(MainWindow *mainwin, guint action,
2763 summary_mark_as_read(mainwin->summaryview);
2766 static void mark_all_read_cb(MainWindow *mainwin, guint action,
2769 summary_mark_all_read(mainwin->summaryview);
2772 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2774 summary_reedit(mainwin->summaryview);
2777 static void add_address_cb(MainWindow *mainwin, guint action,
2780 summary_add_address(mainwin->summaryview);
2783 static void set_charset_cb(MainWindow *mainwin, guint action,
2788 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2789 str = conv_get_charset_str((CharSet)action);
2791 g_free(mainwin->messageview->forced_charset);
2792 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
2793 procmime_force_charset(str);
2795 summary_redisplay_msg(mainwin->summaryview);
2797 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
2801 static void set_decode_cb(MainWindow *mainwin, guint action,
2804 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2805 mainwin->messageview->forced_encoding = (EncodingType)action;
2807 summary_redisplay_msg(mainwin->summaryview);
2809 debug_print("forced encoding: %d\n", action);
2813 static void hide_read_messages (MainWindow *mainwin, guint action,
2816 if (!mainwin->summaryview->folder_item
2817 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
2819 summary_toggle_show_read_messages(mainwin->summaryview);
2822 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2824 if (mainwin->menu_lock_count) return;
2825 if (!mainwin->summaryview->folder_item) return;
2827 if (GTK_CHECK_MENU_ITEM(widget)->active) {
2828 summary_thread_build(mainwin->summaryview);
2829 /* mainwin->summaryview->folder_item->threaded = TRUE; */
2831 summary_unthread(mainwin->summaryview);
2832 /* mainwin->summaryview->folder_item->threaded = FALSE; */
2836 static void expand_threads_cb(MainWindow *mainwin, guint action,
2839 summary_expand_threads(mainwin->summaryview);
2842 static void collapse_threads_cb(MainWindow *mainwin, guint action,
2845 summary_collapse_threads(mainwin->summaryview);
2848 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
2851 prefs_summary_column_open();
2854 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
2857 prefs_folder_column_open();
2860 static void sort_summary_cb(MainWindow *mainwin, guint action,
2863 FolderItem *item = mainwin->summaryview->folder_item;
2864 GtkWidget *menuitem;
2866 if (mainwin->menu_lock_count) return;
2868 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
2869 menuitem = gtk_item_factory_get_item
2870 (mainwin->menu_factory, "/View/Sort/Ascending");
2871 summary_sort(mainwin->summaryview, (FolderSortKey)action,
2872 GTK_CHECK_MENU_ITEM(menuitem)->active
2873 ? SORT_ASCENDING : SORT_DESCENDING);
2874 item->sort_key = action;
2878 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
2881 FolderItem *item = mainwin->summaryview->folder_item;
2883 if (mainwin->menu_lock_count) return;
2885 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
2886 summary_sort(mainwin->summaryview,
2887 item->sort_key, (FolderSortType)action);
2890 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
2893 summary_attract_by_subject(mainwin->summaryview);
2896 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
2901 item = folderview_get_selected_item(mainwin->folderview);
2903 main_window_cursor_wait(mainwin);
2904 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
2906 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
2907 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
2909 STATUSBAR_POP(mainwin);
2910 main_window_cursor_normal(mainwin);
2920 static void deldup_all(FolderItem *item, gpointer _data)
2922 struct DelDupsData *data = _data;
2925 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
2927 data->dups += result;
2932 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
2935 struct DelDupsData data = {0, 0};
2937 folder_func_to_all_folders(deldup_all, &data);
2938 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
2939 "Deleted %d duplicate messages in %d folders.\n",
2941 data.dups, data.folders);
2944 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2946 summary_filter(mainwin->summaryview, (gboolean)action);
2949 static void execute_summary_cb(MainWindow *mainwin, guint action,
2952 summary_execute(mainwin->summaryview);
2955 static void update_summary_cb(MainWindow *mainwin, guint action,
2959 FolderView *folderview = mainwin->folderview;
2961 if (!mainwin->summaryview->folder_item) return;
2962 if (!folderview->opened) return;
2964 folder_update_op_count();
2966 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
2967 folderview->opened);
2970 folder_item_scan(fitem);
2971 summary_show(mainwin->summaryview, fitem);
2974 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2976 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
2979 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2981 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
2984 static void prev_unread_cb(MainWindow *mainwin, guint action,
2987 summary_select_prev_unread(mainwin->summaryview);
2990 static void next_unread_cb(MainWindow *mainwin, guint action,
2993 summary_select_next_unread(mainwin->summaryview);
2996 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
2998 summary_select_prev_new(mainwin->summaryview);
3001 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3003 summary_select_next_new(mainwin->summaryview);
3006 static void prev_marked_cb(MainWindow *mainwin, guint action,
3009 summary_select_prev_marked(mainwin->summaryview);
3012 static void next_marked_cb(MainWindow *mainwin, guint action,
3015 summary_select_next_marked(mainwin->summaryview);
3018 static void prev_labeled_cb(MainWindow *mainwin, guint action,
3021 summary_select_prev_labeled(mainwin->summaryview);
3024 static void next_labeled_cb(MainWindow *mainwin, guint action,
3027 summary_select_next_labeled(mainwin->summaryview);
3030 static void goto_folder_cb(MainWindow *mainwin, guint action,
3033 FolderItem *to_folder;
3035 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
3038 folderview_select(mainwin->folderview, to_folder);
3041 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3043 messageview_copy_clipboard(mainwin->messageview);
3046 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3048 MessageView *msgview = mainwin->messageview;
3050 if (GTK_WIDGET_HAS_FOCUS(mainwin->summaryview->ctree))
3051 summary_select_all(mainwin->summaryview);
3052 else if (messageview_is_visible(msgview) &&
3053 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
3054 messageview_select_all(mainwin->messageview);
3057 static void select_thread_cb(MainWindow *mainwin, guint action,
3060 summary_select_thread(mainwin->summaryview);
3063 static void create_filter_cb(MainWindow *mainwin, guint action,
3066 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
3069 static void create_processing_cb(MainWindow *mainwin, guint action,
3072 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
3075 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
3078 prefs_filtering_open(&pre_global_processing,
3079 _("Processing rules to apply before folder rules"),
3083 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
3086 prefs_filtering_open(&post_global_processing,
3087 _("Processing rules to apply after folder rules"),
3091 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
3094 prefs_filtering_open(&filtering_rules,
3095 _("Filtering configuration"),
3099 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
3102 prefs_template_open();
3105 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
3108 prefs_actions_open(mainwin);
3111 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
3114 ssl_manager_open(mainwin);
3117 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
3121 new_account_cb(mainwin, 0, widget);
3123 account_open(cur_account);
3127 static void new_account_cb(MainWindow *mainwin, guint action,
3130 account_edit_open();
3131 if (!compose_get_compose_list()) account_add();
3134 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
3136 FolderItem *item = NULL;
3137 cur_account = (PrefsAccount *)data;
3139 if (!mainwindow_get_mainwindow())
3141 main_window_show_cur_account(mainwindow_get_mainwindow());
3142 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
3143 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
3144 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
3145 gtk_button_set_relief(GTK_BUTTON(mainwindow_get_mainwindow()->ac_button), GTK_RELIEF_NONE);
3146 item = folderview_get_selected_item(
3147 mainwindow_get_mainwindow()->folderview);
3149 toolbar_set_compose_button
3150 (mainwindow_get_mainwindow()->toolbar,
3151 FOLDER_TYPE(item->folder) == F_NEWS ?
3152 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
3156 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
3158 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
3159 PrefsAccount *account = (PrefsAccount *)data;
3161 inc_account_mail(mainwin, account);
3164 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
3169 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
3171 pluginwindow_create();
3174 static void manual_open_cb(MainWindow *mainwin, guint action,
3177 manual_open((ManualType)action);
3180 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
3182 MainWindow *mainwin = (MainWindow *)data;
3186 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
3187 LOCAL_FOLDER(folder)->rootpath,
3191 str = g_strdup_printf(_("Scanning folder %s ..."),
3192 LOCAL_FOLDER(folder)->rootpath);
3194 STATUSBAR_PUSH(mainwin, str);
3195 STATUSBAR_POP(mainwin);
3199 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
3202 SummaryView *summary;
3204 g_return_val_if_fail(data, FALSE);
3205 summary = ((MainWindow *)data)->summaryview;
3206 g_return_val_if_fail(summary, FALSE);
3208 if (GTK_CLIST(summary->ctree)->selection &&
3209 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
3212 if (summary->selected != summary->displayed)
3213 summary_select_node(summary, summary->displayed, FALSE, TRUE);
3217 #define BREAK_ON_MODIFIER_KEY() \
3218 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
3220 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
3223 MainWindow *mainwin = (MainWindow*) data;
3225 if (!mainwin || !event)
3228 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
3231 switch (event->keyval) {
3232 case GDK_Q: /* Quit */
3233 BREAK_ON_MODIFIER_KEY();
3235 app_exit_cb(mainwin, 0, NULL);
3238 if (mainwin->folderview && mainwin->summaryview
3239 && !mainwin->summaryview->displayed) {
3240 summary_lock(mainwin->summaryview);
3241 folderview_select_next_unread(mainwin->folderview);
3242 summary_unlock(mainwin->summaryview);
3251 #undef BREAK_ON_MODIFIER_KEY
3254 * Harvest addresses for selected folder.
3256 static void addr_harvest_cb( MainWindow *mainwin,
3260 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
3264 * Harvest addresses for selected messages in summary view.
3266 static void addr_harvest_msg_cb( MainWindow *mainwin,
3270 summary_harvest_address( mainwin->summaryview );
3274 *\brief get a MainWindow
3276 *\return MainWindow * The first mainwindow in the mainwin_list
3278 MainWindow *mainwindow_get_mainwindow(void)
3280 if (mainwin_list && mainwin_list->data)
3281 return (MainWindow *)(mainwin_list->data);
3286 gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
3288 ProgressData *data = (ProgressData *) source;
3289 MainWindow *mainwin = (MainWindow *) userdata;
3291 switch (data->cmd) {
3292 case PROGRESS_COMMAND_START:
3293 case PROGRESS_COMMAND_STOP:
3294 gtk_progress_bar_set_fraction
3295 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
3297 case PROGRESS_COMMAND_SET_PERCENTAGE:
3298 gtk_progress_bar_set_fraction
3299 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
3302 while (gtk_events_pending()) gtk_main_iteration ();
3307 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3309 mainwindow_check_synchronise(mainwin, FALSE);