2 Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail team
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 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, see <http://www.gnu.org/licenses/>.
22 #include <glib/gi18n.h>
23 #include <gdk/gdkkeysyms.h>
24 #include <gtk/gtkmain.h>
25 #include <gtk/gtkwindow.h>
26 #include <gtk/gtkwidget.h>
27 #include <gtk/gtksignal.h>
28 #include <gtk/gtkvbox.h>
29 #include <gtk/gtkcontainer.h>
30 #include <gtk/gtkstatusbar.h>
31 #include <gtk/gtkprogressbar.h>
32 #include <gtk/gtkhpaned.h>
33 #include <gtk/gtkvpaned.h>
34 #include <gtk/gtkcheckmenuitem.h>
35 #include <gtk/gtkitemfactory.h>
36 #include <gtk/gtkeditable.h>
37 #include <gtk/gtkmenu.h>
38 #include <gtk/gtkmenuitem.h>
39 #include <gtk/gtkhandlebox.h>
40 #include <gtk/gtktoolbar.h>
41 #include <gtk/gtkbutton.h>
42 #include <gtk/gtktooltips.h>
46 #include "mainwindow.h"
47 #include "folderview.h"
48 #include "foldersel.h"
49 #include "summaryview.h"
50 #include "summary_search.h"
51 #include "messageview.h"
52 #include "message_search.h"
53 #include "headerview.h"
55 #include "stock_pixmap.h"
64 #include "prefs_common.h"
65 #include "prefs_actions.h"
66 #include "prefs_filtering.h"
67 #include "prefs_account.h"
68 #include "prefs_summary_column.h"
69 #include "prefs_folder_column.h"
70 #include "prefs_template.h"
73 #include "addressbook.h"
74 #include "logwindow.h"
75 #include "manage_window.h"
76 #include "alertpanel.h"
77 #include "statusbar.h"
78 #include "inputdialog.h"
85 #include "ssl_manager.h"
86 #include "sslcertwindow.h"
87 #include "prefs_gtk.h"
88 #include "pluginwindow.h"
90 #include "progressindicator.h"
91 #include "localfolder.h"
92 #include "filtering.h"
93 #include "folderutils.h"
94 #include "foldersort.h"
95 #include "icon_legend.h"
96 #include "colorlabel.h"
102 #define AC_LABEL_WIDTH 240
104 /* list of all instantiated MainWindow */
105 static GList *mainwin_list = NULL;
107 static GdkCursor *watch_cursor = NULL;
108 static GdkCursor *hand_cursor = NULL;
110 static gint iconified_count = 0;
112 static void main_window_menu_callback_block (MainWindow *mainwin);
113 static void main_window_menu_callback_unblock (MainWindow *mainwin);
115 static void main_window_show_cur_account (MainWindow *mainwin);
117 static void main_window_separation_change (MainWindow *mainwin,
118 LayoutType layout_mode);
120 static void main_window_set_widgets (MainWindow *mainwin,
121 LayoutType layout_mode);
123 static void toolbar_child_attached (GtkWidget *widget,
126 static void toolbar_child_detached (GtkWidget *widget,
130 static gboolean ac_label_button_pressed (GtkWidget *widget,
131 GdkEventButton *event,
134 static gint main_window_close_cb (GtkWidget *widget,
138 static void main_window_size_allocate_cb (GtkWidget *widget,
139 GtkAllocation *allocation,
141 static void folder_window_size_allocate_cb (GtkWidget *widget,
142 GtkAllocation *allocation,
144 static void message_window_size_allocate_cb (GtkWidget *widget,
145 GtkAllocation *allocation,
148 static void update_folderview_cb (MainWindow *mainwin,
151 static void add_mailbox_cb (MainWindow *mainwin,
154 static void foldersort_cb (MainWindow *mainwin,
157 static void import_mbox_cb (MainWindow *mainwin,
160 static void export_mbox_cb (MainWindow *mainwin,
163 static void export_list_mbox_cb (MainWindow *mainwin,
166 static void empty_trash_cb (MainWindow *mainwin,
170 static void save_as_cb (MainWindow *mainwin,
173 static void print_cb (MainWindow *mainwin,
176 static void app_exit_cb (MainWindow *mainwin,
180 static void search_cb (MainWindow *mainwin,
184 static void toggle_message_cb (MainWindow *mainwin,
187 static void toggle_toolbar_cb (MainWindow *mainwin,
190 static void toggle_col_headers_cb(MainWindow *mainwin,
194 static void toggle_statusbar_cb (MainWindow *mainwin,
197 static void set_layout_cb (MainWindow *mainwin,
201 static void addressbook_open_cb (MainWindow *mainwin,
204 static void log_window_show_cb (MainWindow *mainwin,
207 static void filtering_debug_window_show_cb (MainWindow *mainwin,
211 static void inc_cancel_cb (MainWindow *mainwin,
215 static void open_msg_cb (MainWindow *mainwin,
219 static void view_source_cb (MainWindow *mainwin,
223 static void show_all_header_cb (MainWindow *mainwin,
227 static void hide_quotes_cb(MainWindow *mainwin,
231 static void move_to_cb (MainWindow *mainwin,
234 static void copy_to_cb (MainWindow *mainwin,
237 static void delete_cb (MainWindow *mainwin,
240 static void delete_trash_cb (MainWindow *mainwin,
244 static void cancel_cb (MainWindow *mainwin,
248 static void mark_cb (MainWindow *mainwin,
251 static void unmark_cb (MainWindow *mainwin,
255 static void mark_as_unread_cb (MainWindow *mainwin,
258 static void mark_as_read_cb (MainWindow *mainwin,
261 static void mark_all_read_cb (MainWindow *mainwin,
264 static void mark_as_spam_cb (MainWindow *mainwin,
268 static void ignore_thread_cb (MainWindow *mainwin,
271 static void unignore_thread_cb (MainWindow *mainwin,
274 static void watch_thread_cb (MainWindow *mainwin,
277 static void unwatch_thread_cb (MainWindow *mainwin,
280 static void lock_msgs_cb (MainWindow *mainwin,
283 static void unlock_msgs_cb (MainWindow *mainwin,
287 static void reedit_cb (MainWindow *mainwin,
291 static void add_address_cb (MainWindow *mainwin,
295 static void set_charset_cb (MainWindow *mainwin,
299 static void set_decode_cb (MainWindow *mainwin,
303 static void hide_read_messages (MainWindow *mainwin,
307 static void thread_cb (MainWindow *mainwin,
310 static void expand_threads_cb (MainWindow *mainwin,
313 static void collapse_threads_cb (MainWindow *mainwin,
317 static void set_summary_display_item_cb (MainWindow *mainwin,
320 static void set_folder_display_item_cb (MainWindow *mainwin,
323 static void sort_summary_cb (MainWindow *mainwin,
326 static void sort_summary_type_cb (MainWindow *mainwin,
329 static void attract_by_subject_cb(MainWindow *mainwin,
333 static void delete_duplicated_cb (MainWindow *mainwin,
336 static void delete_duplicated_all_cb (MainWindow *mainwin,
339 static void filter_cb (MainWindow *mainwin,
342 static void execute_summary_cb (MainWindow *mainwin,
345 static void update_summary_cb (MainWindow *mainwin,
349 static void prev_cb (MainWindow *mainwin,
352 static void next_cb (MainWindow *mainwin,
355 static void next_unread_cb (MainWindow *mainwin,
358 static void prev_unread_cb (MainWindow *mainwin,
362 static void prev_new_cb (MainWindow *mainwin,
365 static void next_new_cb (MainWindow *mainwin,
368 static void prev_marked_cb (MainWindow *mainwin,
371 static void next_marked_cb (MainWindow *mainwin,
374 static void prev_labeled_cb (MainWindow *mainwin,
377 static void next_labeled_cb (MainWindow *mainwin,
380 static void last_read_cb (MainWindow *mainwin,
383 static void parent_cb (MainWindow *mainwin,
387 static void goto_folder_cb (MainWindow *mainwin,
390 static void goto_unread_folder_cb(MainWindow *mainwin,
394 static void copy_cb (MainWindow *mainwin,
397 static void allsel_cb (MainWindow *mainwin,
400 static void select_thread_cb (MainWindow *mainwin,
403 static void delete_thread_cb (MainWindow *mainwin,
407 static void create_filter_cb (MainWindow *mainwin,
410 static void create_processing_cb (MainWindow *mainwin,
413 static void open_urls_cb (MainWindow *mainwin,
417 static void prefs_template_open_cb (MainWindow *mainwin,
420 static void prefs_actions_open_cb (MainWindow *mainwin,
423 static void prefs_tags_open_cb (MainWindow *mainwin,
426 static void prefs_account_open_cb (MainWindow *mainwin,
430 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
434 static void prefs_post_processing_open_cb (MainWindow *mainwin,
438 static void prefs_filtering_open_cb (MainWindow *mainwin,
442 static void ssl_manager_open_cb (MainWindow *mainwin,
446 static void new_account_cb (MainWindow *mainwin,
450 static void account_selector_menu_cb (GtkMenuItem *menuitem,
452 static void account_receive_menu_cb (GtkMenuItem *menuitem,
454 static void account_compose_menu_cb (GtkMenuItem *menuitem,
457 static void prefs_open_cb (GtkMenuItem *menuitem,
459 static void plugins_open_cb (GtkMenuItem *menuitem,
462 static void online_switch_clicked(GtkButton *btn,
465 static void manual_open_cb (MainWindow *mainwin,
469 static void legend_open_cb (GtkMenuItem *menuitem,
472 static void scan_tree_func (Folder *folder,
476 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
478 static void addr_harvest_cb ( MainWindow *mainwin,
482 static void addr_harvest_msg_cb ( MainWindow *mainwin,
485 static void sync_cb ( MainWindow *mainwin,
489 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
490 GdkEventFocus *focus,
492 static gboolean mainwindow_visibility_event_cb (GtkWidget *widget,
493 GdkEventVisibility *state,
495 static gboolean mainwindow_state_event_cb (GtkWidget *widget,
496 GdkEventWindowState *state,
498 static void main_window_reply_cb (MainWindow *mainwin,
501 static gboolean mainwindow_progressindicator_hook (gpointer source,
504 static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
507 static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
509 static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
511 static void mailing_list_compose(GtkWidget *w, gpointer *data);
513 static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
514 #define SEPARATE_ACTION 500
515 static void mainwindow_quicksearch (MainWindow *mainwin,
518 static gboolean any_folder_want_synchronise(void);
520 static GtkItemFactoryEntry mainwin_entries[] =
522 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
523 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
524 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
525 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
526 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
527 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
528 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
529 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
530 {N_("/_File/Exp_ort selected to mbox file..."),
531 NULL, export_list_mbox_cb, 0, NULL},
532 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
533 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
534 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
535 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
536 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
537 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
538 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
539 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
540 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
541 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
542 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
544 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
545 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
546 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
547 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
548 {N_("/_Edit/_Delete thread"), NULL, delete_thread_cb, 0, NULL},
549 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
550 {N_("/_Edit/_Find in current message..."),
551 "<control>F", search_cb, 0, NULL},
552 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
553 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
554 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
555 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
556 {N_("/_View/Show or hi_de/_Message view"),
557 "V", toggle_message_cb, 0, "<ToggleItem>"},
558 {N_("/_View/Show or hi_de/_Toolbar"),
559 NULL, NULL, 0, "<Branch>"},
560 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
561 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
562 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
563 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
564 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
565 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
566 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
567 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
568 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
569 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
571 {N_("/_View/Show or hi_de/Status _bar"),
572 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
574 {N_("/_View/Show or hi_de/Column headers"),
575 NULL, toggle_col_headers_cb, 0, "<ToggleItem>"},
576 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
577 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
578 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
580 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
582 {N_("/_View/La_yout"), NULL, NULL, 0, "<Branch>"},
583 {N_("/_View/Layout/_Standard"), NULL, set_layout_cb, NORMAL_LAYOUT, "<RadioItem>"},
584 {N_("/_View/Layout/_Three columns"), NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
585 {N_("/_View/Layout/_Wide message"), NULL, set_layout_cb, WIDE_LAYOUT, "/View/Layout/Standard"},
586 {N_("/_View/Layout/W_ide message list"),NULL, set_layout_cb, WIDE_MSGLIST_LAYOUT, "/View/Layout/Standard"},
587 {N_("/_View/Layout/S_mall screen"), NULL, set_layout_cb, SMALL_LAYOUT, "/View/Layout/Standard"},
588 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
590 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
591 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
592 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
593 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
594 {N_("/_View/_Sort/by Thread date"), NULL, sort_summary_cb, SORT_BY_THREAD_DATE, "/View/Sort/by number"},
595 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
596 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
597 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
598 {N_("/_View/_Sort/by _color label"), NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
599 {N_("/_View/_Sort/by tag"), NULL, sort_summary_cb, SORT_BY_TAGS, "/View/Sort/by number"},
600 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
601 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
602 {N_("/_View/_Sort/by a_ttachment"),
603 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
604 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
605 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
606 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
607 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
608 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
609 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
610 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
611 {N_("/_View/_Sort/_Attract by subject"),
612 NULL, attract_by_subject_cb, 0, NULL},
613 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
614 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
615 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
616 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
618 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
619 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
620 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
621 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
622 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
623 {N_("/_View/_Go to/P_revious unread message"),
624 "<shift>P", prev_unread_cb, 0, NULL},
625 {N_("/_View/_Go to/N_ext unread message"),
626 "<shift>N", next_unread_cb, 0, NULL},
627 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
628 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
629 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
630 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
631 {N_("/_View/_Go to/Previous _marked message"),
632 NULL, prev_marked_cb, 0, NULL},
633 {N_("/_View/_Go to/Next m_arked message"),
634 NULL, next_marked_cb, 0, NULL},
635 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
636 {N_("/_View/_Go to/Previous _labeled message"),
637 NULL, prev_labeled_cb, 0, NULL},
638 {N_("/_View/_Go to/Next la_beled message"),
639 NULL, next_labeled_cb, 0, NULL},
640 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
641 {N_("/_View/_Go to/Last read message"),
642 NULL, last_read_cb, 0, NULL},
643 {N_("/_View/_Go to/Parent message"),
644 "<control>Up", parent_cb, 0, NULL},
645 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
646 {N_("/_View/_Go to/Next unread _folder"), "<shift>G", goto_unread_folder_cb, 0, NULL},
647 {N_("/_View/_Go to/_Other folder..."), "G", goto_folder_cb, 0, NULL},
648 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
650 #define ENC_SEPARATOR \
651 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
652 #define ENC_ACTION(action) \
653 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
655 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
656 {N_("/_View/Character _encoding/_Auto detect"),
657 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
658 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
659 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
660 ENC_ACTION(C_US_ASCII)},
661 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
662 ENC_ACTION(C_UTF_8)},
665 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
666 ENC_ACTION(C_ISO_8859_1)},
667 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
668 ENC_ACTION(C_ISO_8859_15)},
669 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
670 ENC_ACTION(C_WINDOWS_1252)},
673 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
674 ENC_ACTION(C_ISO_8859_2)},
677 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
678 ENC_ACTION(C_ISO_8859_13)},
679 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
680 ENC_ACTION(C_ISO_8859_4)},
683 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
684 ENC_ACTION(C_ISO_8859_7)},
687 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
688 ENC_ACTION(C_ISO_8859_8)},
689 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
690 ENC_ACTION(C_CP1255)},
693 {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"),
694 ENC_ACTION(C_ISO_8859_6)},
695 {N_("/_View/Character _encoding/Arabic (Windows-1256)"),
696 ENC_ACTION(C_CP1256)},
699 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
700 ENC_ACTION(C_ISO_8859_9)},
703 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
704 ENC_ACTION(C_ISO_8859_5)},
705 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
706 ENC_ACTION(C_KOI8_R)},
707 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
708 ENC_ACTION(C_KOI8_U)},
709 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
710 ENC_ACTION(C_CP1251)},
713 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
714 ENC_ACTION(C_ISO_2022_JP)},
715 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
716 ENC_ACTION(C_ISO_2022_JP_2)},
717 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
718 ENC_ACTION(C_EUC_JP)},
719 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
720 ENC_ACTION(C_SHIFT_JIS)},
723 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
724 ENC_ACTION(C_GB2312)},
725 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
727 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
729 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
730 ENC_ACTION(C_EUC_TW)},
731 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
732 ENC_ACTION(C_ISO_2022_CN)},
735 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
736 ENC_ACTION(C_EUC_KR)},
737 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
738 ENC_ACTION(C_ISO_2022_KR)},
741 {N_("/_View/Character _encoding/Thai (TIS-620)"),
742 ENC_ACTION(C_TIS_620)},
743 {N_("/_View/Character _encoding/Thai (Windows-874)"),
744 ENC_ACTION(C_WINDOWS_874)},
749 #define DEC_SEPARATOR \
750 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
751 #define DEC_ACTION(action) \
752 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
753 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
754 {N_("/_View/Decode/_Auto detect"),
755 NULL, set_decode_cb, 0, "<RadioItem>"},
756 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
757 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
758 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
759 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
760 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
765 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
766 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
767 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
768 {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
769 {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
770 {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
771 {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
772 {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
773 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
774 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
776 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
777 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
778 {N_("/_Message/Recei_ve/Get from _current account"),
779 "<control>I", inc_mail_cb, 0, NULL},
780 {N_("/_Message/Recei_ve/Get from _all accounts"),
781 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
782 {N_("/_Message/Recei_ve/Cancel receivin_g"),
783 NULL, inc_cancel_cb, 0, NULL},
784 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
785 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
786 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
787 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
788 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
789 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
790 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
791 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
792 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
793 {N_("/_Message/Repl_y to/mailing _list"),
794 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
795 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
796 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
797 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
798 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
799 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
801 {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
802 {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
803 {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
804 {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
805 {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
806 {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
807 {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
809 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
810 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
811 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
812 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
813 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
814 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
815 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
816 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
817 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
818 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
819 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
820 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
821 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
822 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
823 {N_("/_Message/_Mark/Ignore thread"), NULL, ignore_thread_cb, 0, NULL},
824 {N_("/_Message/_Mark/Unignore thread"), NULL, unignore_thread_cb, 0, NULL},
825 {N_("/_Message/_Mark/Watch thread"), NULL, watch_thread_cb, 0, NULL},
826 {N_("/_Message/_Mark/Unwatch thread"), NULL, unwatch_thread_cb, 0, NULL},
827 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
828 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
829 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
830 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
831 {N_("/_Message/_Mark/Lock"), NULL, lock_msgs_cb, 0, NULL},
832 {N_("/_Message/_Mark/Unlock"), NULL, unlock_msgs_cb, 0, NULL},
833 {N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
834 {N_("/_Message/T_ags"), NULL, NULL, 0, NULL},
835 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
836 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
838 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
839 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
840 {N_("/_Tools/Add sender to address boo_k"),
841 NULL, add_address_cb, 0, NULL},
842 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
843 {N_("/_Tools/_Harvest addresses/from _Folder..."),
844 NULL, addr_harvest_cb, 0, NULL},
845 {N_("/_Tools/_Harvest addresses/from _Messages..."),
846 NULL, addr_harvest_msg_cb, 0, NULL},
847 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
848 {N_("/_Tools/_Filter all messages in folder"),
849 NULL, filter_cb, 0, NULL},
850 {N_("/_Tools/Filter _selected messages"),
851 NULL, filter_cb, 1, NULL},
852 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
853 {N_("/_Tools/_Create filter rule/_Automatically"),
854 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
855 {N_("/_Tools/_Create filter rule/by _From"),
856 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
857 {N_("/_Tools/_Create filter rule/by _To"),
858 NULL, create_filter_cb, FILTER_BY_TO, NULL},
859 {N_("/_Tools/_Create filter rule/by _Subject"),
860 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
861 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
862 {N_("/_Tools/C_reate processing rule/_Automatically"),
863 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
864 {N_("/_Tools/C_reate processing rule/by _From"),
865 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
866 {N_("/_Tools/C_reate processing rule/by _To"),
867 NULL, create_processing_cb, FILTER_BY_TO, NULL},
868 {N_("/_Tools/C_reate processing rule/by _Subject"),
869 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
870 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
871 {N_("/_Tools/List _URLs..."), "<shift><control>U", open_urls_cb, 0, NULL},
872 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
873 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
874 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
875 {N_("/_Tools/Ch_eck for new messages in all folders"),
876 NULL, update_folderview_cb, 0, NULL},
877 {N_("/_Tools/Delete du_plicated messages"),
878 NULL, NULL, 0, "<Branch>"},
879 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
880 NULL, delete_duplicated_cb, 0, NULL},
881 {N_("/_Tools/Delete du_plicated messages/In all folders"),
882 NULL, delete_duplicated_all_cb, 0, NULL},
883 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
884 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
886 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
887 {N_("/_Tools/SSL cer_tificates..."),
888 NULL, ssl_manager_open_cb, 0, NULL},
890 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
891 {N_("/_Tools/Filtering Log"), NULL, filtering_debug_window_show_cb, 0, NULL},
892 {N_("/_Tools/Network _Log"), "<shift><control>L", log_window_show_cb, 0, NULL},
894 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
895 {N_("/_Configuration/C_hange current account"),
896 NULL, NULL, 0, "<Branch>"},
897 {N_("/_Configuration/_Preferences for current account..."),
898 NULL, prefs_account_open_cb, 0, NULL},
899 {N_("/_Configuration/Create _new account..."),
900 NULL, new_account_cb, 0, NULL},
901 {N_("/_Configuration/_Edit accounts..."),
902 NULL, account_edit_open, 0, NULL},
903 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
904 {N_("/_Configuration/P_references..."),
905 NULL, prefs_open_cb, 0, NULL},
906 {N_("/_Configuration/Pre-pr_ocessing..."),
907 NULL, prefs_pre_processing_open_cb, 0, NULL},
908 {N_("/_Configuration/Post-pro_cessing..."),
909 NULL, prefs_post_processing_open_cb, 0, NULL},
910 {N_("/_Configuration/_Filtering..."),
911 NULL, prefs_filtering_open_cb, 0, NULL},
912 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
913 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
914 {N_("/_Configuration/Tag_s..."), NULL, prefs_tags_open_cb, 0, NULL},
915 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
916 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
918 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
919 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_CLAWS, NULL},
920 {N_("/_Help/_Online User-contributed FAQ"),
921 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
922 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
923 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
924 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
927 static gboolean offline_ask_sync = TRUE;
928 static guint lastkey;
929 static gboolean is_obscured = FALSE;
931 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
937 MainWindow *mainwin = (MainWindow *)user_data;
939 if (mainwin->summaryview &&
940 mainwin->summaryview->quicksearch &&
941 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
942 (mod == 0 || mod == GDK_SHIFT_MASK)) {
943 quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
949 #define N_COLOR_LABELS colorlabel_get_color_count()
951 static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
956 GtkCheckMenuItem **items;
961 mainwin = (MainWindow *)data;
962 g_return_if_fail(mainwin != NULL);
964 sel = summary_get_selection(mainwin->summaryview);
967 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
968 g_return_if_fail(menu != NULL);
970 Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
972 /* NOTE: don't return prematurely because we set the "dont_toggle"
973 * state for check menu items */
974 g_object_set_data(G_OBJECT(menu), "dont_toggle",
977 /* clear items. get item pointers. */
978 for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
979 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
980 gtk_check_menu_item_set_active
981 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
982 items[n] = GTK_CHECK_MENU_ITEM(cur->data);
987 if (n == (N_COLOR_LABELS + 1)) {
988 /* iterate all messages and set the state of the appropriate
990 for (; sel != NULL; sel = sel->next) {
994 msginfo = (MsgInfo *)sel->data;
996 clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
997 if (!items[clabel]->active)
998 gtk_check_menu_item_set_active
999 (items[clabel], TRUE);
1003 g_warning("invalid number of color elements (%d)\n", n);
1006 /* reset "dont_toggle" state */
1007 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1008 GINT_TO_POINTER(0));
1011 static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
1014 guint color = GPOINTER_TO_UINT(data);
1015 MainWindow *mainwin;
1017 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1018 g_return_if_fail(mainwin != NULL);
1020 /* "dont_toggle" state set? */
1021 if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
1025 summary_set_colorlabel(mainwin->summaryview, color, NULL);
1028 static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
1031 MainWindow *mainwin;
1035 GHashTable *menu_table = g_hash_table_new_full(
1039 GHashTable *menu_allsel_table = g_hash_table_new_full(
1044 mainwin = (MainWindow *)data;
1045 g_return_if_fail(mainwin != NULL);
1047 sel = summary_get_selection(mainwin->summaryview);
1050 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1051 g_return_if_fail(menu != NULL);
1053 /* NOTE: don't return prematurely because we set the "dont_toggle"
1054 * state for check menu items */
1055 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1056 GINT_TO_POINTER(1));
1058 /* clear items. get item pointers. */
1059 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1060 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
1061 gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
1063 gtk_check_menu_item_set_active
1064 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
1066 g_hash_table_insert(menu_table, GINT_TO_POINTER(id), GTK_CHECK_MENU_ITEM(cur->data));
1067 g_hash_table_insert(menu_allsel_table, GINT_TO_POINTER(id), GINT_TO_POINTER(0));
1071 /* iterate all messages and set the state of the appropriate
1074 for (; sel != NULL; sel = sel->next) {
1076 GSList *tags = NULL;
1078 GtkCheckMenuItem *item;
1079 msginfo = (MsgInfo *)sel->data;
1082 tags = msginfo->tags;
1086 for (; tags; tags = tags->next) {
1087 gint num_checked = GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table, tags->data));
1088 id = GPOINTER_TO_INT(tags->data);
1089 item = g_hash_table_lookup(menu_table, GINT_TO_POINTER(tags->data));
1090 if (item && !item->active) {
1091 gtk_check_menu_item_set_active
1095 g_hash_table_replace(menu_allsel_table, tags->data, GINT_TO_POINTER(num_checked));
1100 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1101 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
1102 gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
1104 gint num_checked = GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table, GINT_TO_POINTER(id)));
1105 if (num_checked < sel_len && num_checked > 0)
1106 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur->data), TRUE);
1108 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur->data), FALSE);
1112 g_hash_table_destroy(menu_table);
1113 g_hash_table_destroy(menu_allsel_table);
1114 /* reset "dont_toggle" state */
1115 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1116 GINT_TO_POINTER(0));
1119 static void mainwindow_tags_menu_item_activate_cb(GtkWidget *widget,
1122 gint id = GPOINTER_TO_INT(data);
1123 gboolean set = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
1124 MainWindow *mainwin;
1126 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1127 g_return_if_fail(mainwin != NULL);
1129 /* "dont_toggle" state set? */
1130 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1136 summary_set_tag(mainwin->summaryview, id, NULL);
1139 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
1141 GtkWidget *label_menuitem;
1146 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1147 "/Message/Color label");
1148 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1149 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_item_cb),
1151 gtk_widget_show(label_menuitem);
1153 menu = gtk_menu_new();
1155 /* create sub items. for the menu item activation callback we pass the
1156 * index of label_colors[] as data parameter. for the None color we
1157 * pass an invalid (high) value. also we attach a data pointer so we
1158 * can always get back the Mainwindow pointer. */
1160 item = gtk_check_menu_item_new_with_label(_("None"));
1161 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1162 g_signal_connect(G_OBJECT(item), "activate",
1163 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1164 GUINT_TO_POINTER(0));
1165 g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
1166 gtk_widget_show(item);
1168 gtk_widget_add_accelerator(item, "activate",
1169 mainwin->menu_factory->accel_group,
1170 GDK_0, GDK_CONTROL_MASK,
1171 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1173 item = gtk_menu_item_new();
1174 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1175 gtk_widget_show(item);
1177 /* create pixmap/label menu items */
1178 for (i = 0; i < N_COLOR_LABELS; i++) {
1179 item = colorlabel_create_check_color_menu_item(
1180 i, refresh, MAINWIN_COLORMENU);
1181 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1182 g_signal_connect(G_OBJECT(item), "activate",
1183 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1184 GUINT_TO_POINTER(i + 1));
1185 g_object_set_data(G_OBJECT(item), "mainwin",
1187 gtk_widget_show(item);
1189 gtk_widget_add_accelerator(item, "activate",
1190 mainwin->menu_factory->accel_group,
1191 GDK_1+i, GDK_CONTROL_MASK,
1192 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1194 gtk_widget_show(menu);
1195 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1196 mainwin->colorlabel_menu = menu;
1199 static void mainwindow_tags_menu_item_apply_tags_activate_cb(GtkWidget *widget,
1202 MainWindow *mainwin;
1204 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1205 g_return_if_fail(mainwin != NULL);
1207 /* "dont_toggle" state set? */
1208 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1212 tag_apply_open(summary_get_selection(mainwin->summaryview));
1215 static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
1217 GtkWidget *label_menuitem;
1220 GSList *cur = tags_get_list();
1222 gboolean existing_tags = FALSE;
1224 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1226 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1227 G_CALLBACK(mainwindow_tags_menu_item_activate_item_cb),
1230 gtk_widget_show(label_menuitem);
1232 menu = gtk_menu_new();
1234 /* create tags menu items */
1235 for (; cur; cur = cur->next) {
1236 gint id = GPOINTER_TO_INT(cur->data);
1237 const gchar *tag = tags_get_tag(id);
1239 item = gtk_check_menu_item_new_with_label(tag);
1240 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1241 g_signal_connect(G_OBJECT(item), "activate",
1242 G_CALLBACK(mainwindow_tags_menu_item_activate_cb),
1243 GINT_TO_POINTER(id));
1244 g_object_set_data(G_OBJECT(item), "mainwin",
1246 g_object_set_data(G_OBJECT(item), "tag_id",
1247 GINT_TO_POINTER(id));
1248 gtk_widget_show(item);
1249 existing_tags = TRUE;
1251 if (existing_tags) {
1253 item = gtk_menu_item_new();
1254 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1255 gtk_widget_show(item);
1258 item = gtk_menu_item_new_with_label(_("Apply tags..."));
1259 gtk_widget_add_accelerator(item, "activate",
1260 mainwin->menu_factory->accel_group,
1261 GDK_T, GDK_CONTROL_MASK|GDK_SHIFT_MASK,
1262 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1263 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1264 g_signal_connect(G_OBJECT(item), "activate",
1265 G_CALLBACK(mainwindow_tags_menu_item_apply_tags_activate_cb),
1267 g_object_set_data(G_OBJECT(item), "mainwin",
1269 gtk_widget_show(item);
1272 gtk_widget_show(menu);
1273 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1274 mainwin->tags_menu = menu;
1277 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
1278 MainWindow *mainwindow)
1280 if (evt && evt->button == 1) {
1281 log_window_show_error(mainwindow->logwin);
1282 gtk_widget_hide(mainwindow->warning_btn);
1287 static gboolean warning_visi_notify(GtkWidget *widget,
1288 GdkEventVisibility *event,
1289 MainWindow *mainwindow)
1291 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1295 static gboolean warning_leave_notify(GtkWidget *widget,
1296 GdkEventCrossing *event,
1297 MainWindow *mainwindow)
1299 gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
1303 static gboolean warning_enter_notify(GtkWidget *widget,
1304 GdkEventCrossing *event,
1305 MainWindow *mainwindow)
1307 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1311 void mainwindow_show_error(void)
1313 MainWindow *mainwin = mainwindow_get_mainwindow();
1314 gtk_widget_show(mainwin->warning_btn);
1317 void mainwindow_clear_error(MainWindow *mainwin)
1319 gtk_widget_hide(mainwin->warning_btn);
1322 MainWindow *main_window_create()
1324 MainWindow *mainwin;
1328 GtkWidget *handlebox;
1329 GtkWidget *vbox_body;
1331 GtkWidget *hbox_stat;
1332 GtkWidget *statusbar;
1333 GtkWidget *progressbar;
1334 GtkWidget *statuslabel;
1335 GtkWidget *ac_button;
1336 GtkWidget *ac_label;
1337 GtkWidget *online_pixmap;
1338 GtkWidget *offline_pixmap;
1340 GtkWidget *warning_icon;
1341 GtkWidget *warning_btn;
1343 GtkWidget *online_switch;
1344 GtkWidget *offline_switch;
1345 FolderView *folderview;
1346 SummaryView *summaryview;
1347 MessageView *messageview;
1348 GdkColormap *colormap;
1350 gboolean success[4];
1351 GtkItemFactory *ifactory;
1353 GtkWidget *menuitem;
1355 guint n_menu_entries;
1357 static GdkGeometry geometry;
1359 debug_print("Creating main window...\n");
1360 mainwin = g_new0(MainWindow, 1);
1363 window = GTK_WIDGET(gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow"));
1364 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1365 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1367 prefs_common.layout_mode = SMALL_LAYOUT;
1369 if (!geometry.min_height) {
1370 geometry.min_width = 320;
1371 geometry.min_height = 200;
1373 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1376 g_signal_connect(G_OBJECT(window), "delete_event",
1377 G_CALLBACK(main_window_close_cb), mainwin);
1378 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1379 g_signal_connect(G_OBJECT(window), "focus_in_event",
1380 G_CALLBACK(mainwindow_focus_in_event),
1382 g_signal_connect(G_OBJECT(window), "key_press_event",
1383 G_CALLBACK(mainwindow_key_pressed), mainwin);
1385 gtk_widget_realize(window);
1386 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1389 gtkut_widget_set_app_icon(window);
1391 vbox = gtk_vbox_new(FALSE, 0);
1392 gtk_widget_show(vbox);
1393 gtk_container_add(GTK_CONTAINER(window), vbox);
1396 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1397 menubar = menubar_create(window, mainwin_entries,
1398 n_menu_entries, "<Main>", mainwin);
1399 gtk_widget_show(menubar);
1402 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1405 ifactory = gtk_item_factory_from_widget(menubar);
1407 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1408 main_create_mailing_list_menu (mainwin, NULL); */
1410 if (prefs_common.toolbar_detachable) {
1411 handlebox = gtk_handle_box_new();
1412 gtk_widget_show(handlebox);
1413 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1414 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1415 G_CALLBACK(toolbar_child_attached), mainwin);
1416 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1417 G_CALLBACK(toolbar_child_detached), mainwin);
1419 handlebox = gtk_hbox_new(FALSE, 0);
1420 gtk_widget_show(handlebox);
1421 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1423 /* link window to mainwin->window to avoid gdk warnings */
1424 mainwin->window = window;
1425 mainwin_list = g_list_append(mainwin_list, mainwin);
1428 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1432 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1436 toolbar_set_learn_button
1440 /* vbox that contains body */
1441 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1442 gtk_widget_show(vbox_body);
1443 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1444 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1447 hbox_stat = gtk_hbox_new(FALSE, 2);
1448 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1450 tips = gtk_tooltips_new();
1452 warning_icon = gtk_image_new_from_stock
1453 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1454 warning_btn = gtk_event_box_new();
1455 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1457 mainwin->warning_btn = warning_btn;
1459 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1460 G_CALLBACK(warning_icon_pressed),
1461 (gpointer) mainwin);
1462 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1463 G_CALLBACK(warning_visi_notify), mainwin);
1464 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1465 G_CALLBACK(warning_visi_notify), mainwin);
1466 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1467 G_CALLBACK(warning_leave_notify), mainwin);
1468 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1469 G_CALLBACK(warning_enter_notify), mainwin);
1471 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1473 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1474 _("Some error(s) happened. Click here to view log."), NULL);
1475 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1477 statusbar = statusbar_create();
1478 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1480 progressbar = gtk_progress_bar_new();
1481 gtk_widget_set_size_request(progressbar, 120, 1);
1482 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1484 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1485 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1486 online_switch = gtk_button_new ();
1487 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1488 _("You are online. Click the icon to go offline"), NULL);
1489 offline_switch = gtk_button_new ();
1490 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1491 _("You are offline. Click the icon to go online"),
1493 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1494 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1495 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1496 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1497 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1498 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1499 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1500 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1502 statuslabel = gtk_label_new("");
1503 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1505 ac_button = gtk_button_new();
1506 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1507 ac_button, _("Select account"), NULL);
1508 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1509 gtk_widget_set_size_request(ac_button, -1, 0);
1510 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1511 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1512 G_CALLBACK(ac_label_button_pressed), mainwin);
1514 ac_label = gtk_label_new("");
1515 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1517 gtk_widget_show_all(hbox_stat);
1519 gtk_widget_hide(offline_switch);
1520 gtk_widget_hide(warning_btn);
1522 online_switch = gtk_button_new ();
1523 offline_switch = gtk_button_new ();
1524 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1525 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1528 mainwin->folderview = folderview = folderview_create();
1529 mainwin->summaryview = summaryview = summary_create();
1530 mainwin->messageview = messageview = messageview_create(mainwin);
1532 /* init log instances data before creating log views */
1533 set_log_title(LOG_PROTOCOL, _("Network log"));
1534 set_log_prefs(LOG_PROTOCOL,
1535 &prefs_common.logwin_width,
1536 &prefs_common.logwin_height);
1537 set_log_title(LOG_DEBUG_FILTERING, _("Filtering/processing debug log"));
1538 set_log_prefs(LOG_DEBUG_FILTERING,
1539 &prefs_common.filtering_debugwin_width,
1540 &prefs_common.filtering_debugwin_height);
1542 /* setup log windows */
1543 mainwin->logwin = log_window_create(LOG_PROTOCOL);
1544 log_window_init(mainwin->logwin);
1546 mainwin->filtering_debugwin = log_window_create(LOG_DEBUG_FILTERING);
1547 log_window_set_clipping(mainwin->logwin,
1548 prefs_common.cliplog,
1549 prefs_common.loglength);
1551 log_window_init(mainwin->filtering_debugwin);
1552 log_window_set_clipping(mainwin->filtering_debugwin,
1553 prefs_common.filtering_debug_cliplog,
1554 prefs_common.filtering_debug_loglength);
1555 if (prefs_common.enable_filtering_debug)
1556 log_message(LOG_DEBUG_FILTERING, _("filtering log enabled\n"));
1558 log_message(LOG_DEBUG_FILTERING, _("filtering log disabled\n"));
1560 folderview->mainwin = mainwin;
1561 folderview->summaryview = summaryview;
1563 summaryview->mainwin = mainwin;
1564 summaryview->folderview = folderview;
1565 summaryview->messageview = messageview;
1566 summaryview->window = window;
1568 mainwin->vbox = vbox;
1569 mainwin->menubar = menubar;
1570 mainwin->menu_factory = ifactory;
1571 mainwin->handlebox = handlebox;
1572 mainwin->vbox_body = vbox_body;
1573 mainwin->online_switch = online_switch;
1574 mainwin->offline_switch = offline_switch;
1576 messageview->statusbar = statusbar;
1577 mainwin->statusbar = statusbar;
1578 mainwin->hbox_stat = hbox_stat;
1579 mainwin->progressbar = progressbar;
1580 mainwin->statuslabel = statuslabel;
1581 mainwin->online_pixmap = online_pixmap;
1582 mainwin->offline_pixmap = offline_pixmap;
1583 mainwin->ac_button = ac_button;
1584 mainwin->ac_label = ac_label;
1585 /* set context IDs for status bar */
1586 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1587 (GTK_STATUSBAR(statusbar), "Main Window");
1588 mainwin->folderview_cid = gtk_statusbar_get_context_id
1589 (GTK_STATUSBAR(statusbar), "Folder View");
1590 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1591 (GTK_STATUSBAR(statusbar), "Summary View");
1592 mainwin->messageview_cid = gtk_statusbar_get_context_id
1593 (GTK_STATUSBAR(statusbar), "Message View");
1594 messageview->statusbar_cid = mainwin->messageview_cid;
1597 messageview->statusbar = NULL;
1598 mainwin->statusbar = NULL;
1599 mainwin->hbox_stat = NULL;
1600 /* mainwin->progressbar is set in toolbar.c */
1601 mainwin->statuslabel = NULL;
1602 mainwin->online_pixmap = NULL;
1603 mainwin->offline_pixmap = NULL;
1604 mainwin->ac_button = NULL;
1605 mainwin->ac_label = NULL;
1608 /* allocate colors for summary view and folder view */
1609 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1610 summaryview->color_marked.blue = (guint16)65535;
1612 summaryview->color_dim.red = summaryview->color_dim.green =
1613 summaryview->color_dim.blue = COLOR_DIM;
1615 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1616 &folderview->color_new);
1618 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1619 &folderview->color_op);
1621 summaryview->color_important.red = 0;
1622 summaryview->color_important.green = 0;
1623 summaryview->color_important.blue = (guint16)65535;
1625 color[0] = summaryview->color_marked;
1626 color[1] = summaryview->color_dim;
1627 color[2] = folderview->color_new;
1628 color[3] = folderview->color_op;
1630 colormap = gdk_drawable_get_colormap(window->window);
1631 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1632 for (i = 0; i < 4; i++) {
1633 if (success[i] == FALSE)
1634 g_warning("MainWindow: color allocation %d failed\n", i);
1637 debug_print("done.\n");
1639 messageview->visible = prefs_common.msgview_visible;
1641 main_window_set_widgets(mainwin, prefs_common.layout_mode);
1643 g_signal_connect(G_OBJECT(window), "size_allocate",
1644 G_CALLBACK(main_window_size_allocate_cb),
1647 /* set menu items */
1648 menuitem = gtk_item_factory_get_item
1649 (ifactory, "/View/Character encoding/Auto detect");
1650 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1652 switch (prefs_common.toolbar_style) {
1654 menuitem = gtk_item_factory_get_item
1655 (ifactory, "/View/Show or hide/Toolbar/Hide");
1658 menuitem = gtk_item_factory_get_item
1659 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1662 menuitem = gtk_item_factory_get_item
1663 (ifactory, "/View/Show or hide/Toolbar/Text only");
1666 menuitem = gtk_item_factory_get_item
1667 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1669 case TOOLBAR_BOTH_HORIZ:
1670 menuitem = gtk_item_factory_get_item
1672 "/View/Show or hide/Toolbar/Text beside icons");
1674 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1677 gtk_widget_hide(mainwin->hbox_stat);
1678 menuitem = gtk_item_factory_get_item
1679 (ifactory, "/View/Show or hide/Status bar");
1680 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1681 prefs_common.show_statusbar);
1683 menuitem = gtk_item_factory_get_item
1684 (ifactory, "/View/Show or hide/Column headers");
1685 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1686 prefs_common.show_col_headers);
1687 /* set account selection menu */
1688 ac_menu = gtk_item_factory_get_widget
1689 (ifactory, "/Configuration/Change current account");
1690 mainwin->ac_menu = ac_menu;
1692 toolbar_main_set_sensitive(mainwin);
1694 /* create actions menu */
1695 main_window_update_actions_menu(mainwin);
1697 main_create_mailing_list_menu (mainwin, NULL);
1699 /* attach accel groups to main window */
1700 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1701 gtk_window_add_accel_group \
1703 gtk_item_factory_from_widget(menu)->accel_group); \
1704 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1706 G_CALLBACK(main_window_accel_activate), mainwin);
1709 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1711 /* connect the accelerators for equivalent
1712 menu items in different menus */
1713 menu_connect_identical_items();
1716 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1719 g_signal_connect(G_OBJECT(window), "window_state_event",
1720 G_CALLBACK(mainwindow_state_event_cb), mainwin);
1721 g_signal_connect(G_OBJECT(window), "visibility_notify_event",
1722 G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
1723 gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
1725 if (prefs_common.layout_mode == VERTICAL_LAYOUT ||
1726 prefs_common.layout_mode == SMALL_LAYOUT) {
1727 summary_relayout(mainwin->summaryview);
1729 summary_update_unread(mainwin->summaryview, NULL);
1731 gtk_widget_show(mainwin->window);
1733 /* initialize views */
1734 folderview_init(folderview);
1735 summary_init(summaryview);
1736 messageview_init(messageview);
1738 sslcertwindow_register_hook();
1740 mainwin->lock_count = 0;
1741 mainwin->menu_lock_count = 0;
1742 mainwin->cursor_count = 0;
1744 mainwin->progressindicator_hook =
1745 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1748 watch_cursor = gdk_cursor_new(GDK_WATCH);
1750 hand_cursor = gdk_cursor_new(GDK_HAND2);
1752 /* init work_offline */
1753 if (prefs_common.work_offline)
1754 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1756 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1757 mainwindow_tags_menu_create(mainwin, FALSE);
1762 void main_window_destroy(MainWindow *mainwin)
1764 /* TODO : destroy other component */
1765 messageview_destroy(mainwin->messageview);
1766 mainwin->messageview = NULL;
1769 void main_window_update_actions_menu(MainWindow *mainwin)
1771 GtkItemFactory *ifactory;
1773 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1774 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1777 void main_window_cursor_wait(MainWindow *mainwin)
1780 if (mainwin->cursor_count == 0) {
1781 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1782 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1785 mainwin->cursor_count++;
1790 void main_window_cursor_normal(MainWindow *mainwin)
1792 if (mainwin->cursor_count)
1793 mainwin->cursor_count--;
1795 if (mainwin->cursor_count == 0) {
1796 gdk_window_set_cursor(mainwin->window->window, NULL);
1797 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1802 /* lock / unlock the user-interface */
1803 void main_window_lock(MainWindow *mainwin)
1805 if (mainwin->lock_count == 0 && mainwin->ac_button)
1806 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1808 mainwin->lock_count++;
1810 main_window_set_menu_sensitive(mainwin);
1811 toolbar_main_set_sensitive(mainwin);
1814 void main_window_unlock(MainWindow *mainwin)
1816 if (mainwin->lock_count)
1817 mainwin->lock_count--;
1819 main_window_set_menu_sensitive(mainwin);
1820 toolbar_main_set_sensitive(mainwin);
1822 if (mainwin->lock_count == 0 && mainwin->ac_button)
1823 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1826 static void main_window_menu_callback_block(MainWindow *mainwin)
1828 mainwin->menu_lock_count++;
1831 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1833 if (mainwin->menu_lock_count)
1834 mainwin->menu_lock_count--;
1837 static guint prefs_tag = 0;
1839 void main_window_reflect_prefs_all(void)
1841 main_window_reflect_prefs_all_real(FALSE);
1844 static gboolean reflect_prefs_timeout_cb(gpointer data)
1846 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1848 MainWindow *mainwin;
1851 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1852 mainwin = (MainWindow *)cur->data;
1854 main_window_show_cur_account(mainwin);
1855 main_window_set_menu_sensitive(mainwin);
1856 toolbar_main_set_sensitive(mainwin);
1859 if (pixmap_theme_changed) {
1860 toolbar_update(TOOLBAR_MAIN, mainwin);
1861 messageview_reflect_prefs_pixmap_theme();
1862 compose_reflect_prefs_pixmap_theme();
1863 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1864 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1866 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1867 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1868 mainwin->online_pixmap);
1869 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1870 gtk_widget_show(pixmap);
1871 mainwin->online_pixmap = pixmap;
1872 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1873 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1874 mainwin->offline_pixmap);
1875 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1876 gtk_widget_show(pixmap);
1877 mainwin->offline_pixmap = pixmap;
1881 headerview_set_font(mainwin->messageview->headerview);
1882 headerview_set_visibility(mainwin->messageview->headerview,
1883 prefs_common.display_header_pane);
1884 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1885 folderview_reflect_prefs();
1886 summary_reflect_prefs();
1888 summary_redisplay_msg(mainwin->summaryview);
1890 if (prefs_common.layout_mode == SMALL_LAYOUT) {
1891 if (mainwin->in_folder) {
1892 mainwindow_enter_folder(mainwin);
1894 mainwindow_exit_folder(mainwin);
1902 void main_window_reflect_prefs_all_now(void)
1904 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1907 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1912 /* re-create colorlabel submenu */
1913 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1914 g_return_if_fail(menu != NULL);
1916 /* clear items. get item pointers. */
1917 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1918 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1920 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1921 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1925 void main_window_reflect_tags_changes(MainWindow *mainwin)
1930 /* re-create tags submenu */
1931 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1932 g_return_if_fail(menu != NULL);
1934 /* clear items. get item pointers. */
1935 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1936 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1938 mainwindow_tags_menu_create(mainwin, TRUE);
1939 summary_reflect_tags_changes(mainwin->summaryview);
1943 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1945 if (prefs_tag == 0 || pixmap_theme_changed) {
1946 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1947 GINT_TO_POINTER(pixmap_theme_changed));
1951 void main_window_set_summary_column(void)
1954 MainWindow *mainwin;
1956 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1957 mainwin = (MainWindow *)cur->data;
1958 summary_set_column_order(mainwin->summaryview);
1962 void main_window_set_folder_column(void)
1965 MainWindow *mainwin;
1967 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1968 mainwin = (MainWindow *)cur->data;
1969 folderview_set_column_order(mainwin->folderview);
1973 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1974 GList *account_list)
1976 GList *cur_ac, *cur_item;
1977 GtkWidget *menuitem;
1978 PrefsAccount *ac_prefs;
1980 /* destroy all previous menu item */
1981 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1982 while (cur_item != NULL) {
1983 GList *next = cur_item->next;
1984 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1988 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1989 ac_prefs = (PrefsAccount *)cur_ac->data;
1991 menuitem = gtk_menu_item_new_with_label
1992 (ac_prefs->account_name
1993 ? ac_prefs->account_name : _("Untitled"));
1994 gtk_widget_show(menuitem);
1995 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1996 g_signal_connect(G_OBJECT(menuitem), "activate",
1997 G_CALLBACK(account_selector_menu_cb),
2002 static void main_window_set_account_receive_menu(MainWindow *mainwin,
2003 GList *account_list)
2005 GList *cur_ac, *cur_item;
2007 GtkWidget *menuitem;
2008 PrefsAccount *ac_prefs;
2010 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
2011 "/Message/Receive");
2013 /* search for separator */
2014 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2015 cur_item = cur_item->next) {
2016 if (GTK_BIN(cur_item->data)->child == NULL) {
2017 cur_item = cur_item->next;
2022 /* destroy all previous menu item */
2023 while (cur_item != NULL) {
2024 GList *next = cur_item->next;
2025 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
2029 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2030 ac_prefs = (PrefsAccount *)cur_ac->data;
2032 menuitem = gtk_menu_item_new_with_label
2033 (ac_prefs->account_name ? ac_prefs->account_name
2035 gtk_widget_show(menuitem);
2036 gtk_menu_append(GTK_MENU(menu), menuitem);
2037 g_signal_connect(G_OBJECT(menuitem), "activate",
2038 G_CALLBACK(account_receive_menu_cb),
2043 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
2044 GList *account_list)
2047 GtkWidget *menuitem;
2048 PrefsAccount *ac_prefs;
2049 GtkWidget *menu = NULL;
2051 if (mainwin->toolbar->getall_btn == NULL) /* button doesn't exist */
2054 menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn));
2056 gtk_widget_destroy(menu);
2057 menu = gtk_menu_new();
2059 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2060 ac_prefs = (PrefsAccount *)cur_ac->data;
2062 menuitem = gtk_menu_item_new_with_label
2063 (ac_prefs->account_name
2064 ? ac_prefs->account_name : _("Untitled"));
2065 gtk_widget_show(menuitem);
2066 gtk_menu_append(GTK_MENU(menu), menuitem);
2067 g_signal_connect(G_OBJECT(menuitem), "activate",
2068 G_CALLBACK(account_receive_menu_cb),
2071 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn), menu);
2074 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
2075 GList *account_list)
2079 GtkWidget *menuitem;
2080 PrefsAccount *ac_prefs;
2081 GtkWidget *menu = NULL;
2083 if (mainwin->toolbar->compose_mail_btn == NULL) /* button doesn't exist */
2086 menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn));
2088 gtk_widget_destroy(menu);
2089 menu = gtk_menu_new();
2091 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2092 ac_prefs = (PrefsAccount *)cur_ac->data;
2094 menuitem = gtk_menu_item_new_with_label
2095 (ac_prefs->account_name
2096 ? ac_prefs->account_name : _("Untitled"));
2097 gtk_widget_show(menuitem);
2098 gtk_menu_append(GTK_MENU(menu), menuitem);
2099 g_signal_connect(G_OBJECT(menuitem), "activate",
2100 G_CALLBACK(account_compose_menu_cb),
2103 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn), menu);
2107 void main_window_set_account_menu(GList *account_list)
2110 MainWindow *mainwin;
2112 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2113 mainwin = (MainWindow *)cur->data;
2114 main_window_set_account_selector_menu(mainwin, account_list);
2115 main_window_set_account_receive_menu(mainwin, account_list);
2116 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2117 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2119 hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
2122 void main_window_set_account_menu_only_toolbar(GList *account_list)
2125 MainWindow *mainwin;
2127 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2128 mainwin = (MainWindow *)cur->data;
2129 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2130 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2134 static void main_window_show_cur_account(MainWindow *mainwin)
2139 ac_name = g_strdup(cur_account
2140 ? (cur_account->account_name
2141 ? cur_account->account_name : _("Untitled"))
2145 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
2147 buf = g_strdup(PROG_VERSION);
2148 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
2151 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
2152 if (mainwin->ac_button)
2153 gtk_widget_queue_resize(mainwin->ac_button);
2158 static void main_window_separation_change(MainWindow *mainwin, LayoutType layout_mode)
2160 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
2161 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
2162 GtkWidget *message_wid = mainwin->messageview->vbox;
2164 if (layout_mode == prefs_common.layout_mode)
2167 debug_print("Changing window separation type from %d to %d\n",
2168 prefs_common.layout_mode, layout_mode);
2170 /* remove widgets from those containers */
2171 gtk_widget_ref(folder_wid);
2172 gtk_widget_ref(summary_wid);
2173 gtk_widget_ref(message_wid);
2174 gtkut_container_remove
2175 (GTK_CONTAINER(folder_wid->parent), folder_wid);
2176 gtkut_container_remove
2177 (GTK_CONTAINER(summary_wid->parent), summary_wid);
2178 gtkut_container_remove
2179 (GTK_CONTAINER(message_wid->parent), message_wid);
2181 gtk_widget_hide(mainwin->window);
2182 main_window_set_widgets(mainwin, layout_mode);
2183 gtk_widget_show(mainwin->window);
2185 gtk_widget_unref(folder_wid);
2186 gtk_widget_unref(summary_wid);
2187 gtk_widget_unref(message_wid);
2190 void mainwindow_reset_paned(GtkPaned *paned)
2194 if (gtk_paned_get_child1(GTK_PANED(paned)))
2195 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2196 if (gtk_paned_get_child2(GTK_PANED(paned)))
2197 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2200 g_object_get (G_OBJECT(paned),
2203 g_object_get (G_OBJECT(paned),
2207 gtk_paned_set_position(GTK_PANED(paned), mid);
2210 static void mainwin_paned_show_first(GtkPaned *paned)
2213 g_object_get (G_OBJECT(paned),
2217 if (gtk_paned_get_child1(GTK_PANED(paned)))
2218 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2219 if (gtk_paned_get_child2(GTK_PANED(paned)))
2220 gtk_widget_hide(gtk_paned_get_child2(GTK_PANED(paned)));
2221 gtk_paned_set_position(GTK_PANED(paned), max);
2224 static void mainwin_paned_show_last(GtkPaned *paned)
2227 g_object_get (G_OBJECT(paned),
2231 if (gtk_paned_get_child1(GTK_PANED(paned)))
2232 gtk_widget_hide(gtk_paned_get_child1(GTK_PANED(paned)));
2233 if (gtk_paned_get_child2(GTK_PANED(paned)))
2234 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2235 gtk_paned_set_position(GTK_PANED(paned), min);
2238 void main_window_toggle_message_view(MainWindow *mainwin)
2240 SummaryView *summaryview = mainwin->summaryview;
2241 GtkWidget *ppaned = NULL;
2242 GtkWidget *container = NULL;
2244 switch (prefs_common.layout_mode) {
2246 case VERTICAL_LAYOUT:
2248 ppaned = mainwin->vpaned;
2249 container = mainwin->hpaned;
2250 if (ppaned->parent != NULL) {
2251 mainwin->messageview->visible = FALSE;
2252 summaryview->displayed = NULL;
2253 gtk_widget_ref(ppaned);
2254 gtkut_container_remove(GTK_CONTAINER(container), ppaned);
2255 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
2257 mainwin->messageview->visible = TRUE;
2258 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), ppaned);
2259 gtk_container_add(GTK_CONTAINER(container), ppaned);
2260 gtk_widget_unref(ppaned);
2264 ppaned = mainwin->hpaned;
2265 container = mainwin->vpaned;
2266 if (mainwin->messageview->vbox->parent != NULL) {
2267 mainwin->messageview->visible = FALSE;
2268 summaryview->displayed = NULL;
2269 gtk_widget_ref(mainwin->messageview->vbox);
2270 gtkut_container_remove(GTK_CONTAINER(container), mainwin->messageview->vbox);
2272 mainwin->messageview->visible = TRUE;
2273 gtk_container_add(GTK_CONTAINER(container), mainwin->messageview->vbox);
2274 gtk_widget_unref(mainwin->messageview->vbox);
2277 case WIDE_MSGLIST_LAYOUT:
2278 g_warning("can't hide messageview in this wide msglist layout");
2282 if (messageview_is_visible(mainwin->messageview))
2283 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2284 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2286 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2287 GTK_ARROW_UP, GTK_SHADOW_OUT);
2289 if (mainwin->messageview->visible == FALSE)
2290 messageview_clear(mainwin->messageview);
2292 main_window_set_menu_sensitive(mainwin);
2294 prefs_common.msgview_visible = mainwin->messageview->visible;
2296 if (messageview_is_visible(mainwin->messageview)) {
2297 gtk_widget_queue_resize(mainwin->hpaned);
2298 gtk_widget_queue_resize(mainwin->vpaned);
2300 summary_grab_focus(summaryview);
2303 void main_window_get_size(MainWindow *mainwin)
2305 GtkAllocation *allocation;
2307 if (mainwin_list == NULL || mainwin->messageview == NULL) {
2308 debug_print("called after messageview "
2309 "has been deallocated!\n");
2313 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
2315 if (allocation->width > 1 && allocation->height > 1) {
2316 prefs_common.summaryview_width = allocation->width;
2318 if (messageview_is_visible(mainwin->messageview))
2319 prefs_common.summaryview_height = allocation->height;
2321 prefs_common.mainview_width = allocation->width;
2324 allocation = &mainwin->window->allocation;
2325 if (allocation->width > 1 && allocation->height > 1) {
2326 prefs_common.mainview_height = allocation->height;
2327 prefs_common.mainwin_width = allocation->width;
2328 prefs_common.mainwin_height = allocation->height;
2331 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
2332 if (allocation->width > 1 && allocation->height > 1) {
2333 prefs_common.folderview_width = allocation->width;
2334 prefs_common.folderview_height = allocation->height;
2337 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
2338 if (allocation->width > 1 && allocation->height > 1) {
2339 prefs_common.msgview_width = allocation->width;
2340 prefs_common.msgview_height = allocation->height;
2343 /* debug_print("summaryview size: %d x %d\n",
2344 prefs_common.summaryview_width,
2345 prefs_common.summaryview_height);
2346 debug_print("folderview size: %d x %d\n",
2347 prefs_common.folderview_width,
2348 prefs_common.folderview_height);
2349 debug_print("messageview size: %d x %d\n",
2350 prefs_common.msgview_width,
2351 prefs_common.msgview_height); */
2354 void main_window_get_position(MainWindow *mainwin)
2358 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2360 prefs_common.mainview_x = x;
2361 prefs_common.mainview_y = y;
2362 prefs_common.mainwin_x = x;
2363 prefs_common.mainwin_y = y;
2365 debug_print("main window position: %d, %d\n", x, y);
2368 void main_window_progress_on(MainWindow *mainwin)
2370 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2373 void main_window_progress_off(MainWindow *mainwin)
2375 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2376 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2379 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
2383 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
2384 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
2385 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
2386 (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
2389 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2391 if (confirm && procmsg_have_trashed_mails_fast()) {
2392 if (alertpanel(_("Empty trash"),
2393 _("Delete all messages in trash folders?"),
2394 GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL)
2395 != G_ALERTALTERNATE)
2397 manage_window_focus_in(mainwin->window, NULL, NULL);
2400 procmsg_empty_all_trash();
2402 if (mainwin->summaryview->folder_item &&
2403 mainwin->summaryview->folder_item->stype == F_TRASH)
2404 gtk_widget_grab_focus(mainwin->folderview->ctree);
2407 void main_window_add_mailbox(MainWindow *mainwin)
2412 path = input_dialog(_("Add mailbox"),
2413 _("Input the location of mailbox.\n"
2414 "If an existing mailbox is specified, it will be\n"
2415 "scanned automatically."),
2418 if (folder_find_from_path(path)) {
2419 alertpanel_error(_("The mailbox '%s' already exists."), path);
2423 folder = folder_new(folder_get_class_from_string("mh"),
2424 !strcmp(path, "Mail") ? _("Mailbox") :
2425 g_path_get_basename(path), path);
2428 if (folder->klass->create_tree(folder) < 0) {
2429 alertpanel_error(_("Creation of the mailbox failed.\n"
2430 "Maybe some files already exist, or you don't have the permission to write there."));
2431 folder_destroy(folder);
2436 folder_set_ui_func(folder, scan_tree_func, mainwin);
2437 folder_scan_tree(folder, TRUE);
2438 folder_set_ui_func(folder, NULL, NULL);
2441 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2443 SensitiveCond state = 0;
2444 SummarySelection selection;
2445 FolderItem *item = mainwin->summaryview->folder_item;
2446 GList *account_list = account_get_list();
2449 selection = summary_get_selection_type(mainwin->summaryview);
2451 if (mainwin->lock_count == 0)
2452 state |= M_UNLOCKED;
2453 if (selection != SUMMARY_NONE)
2454 state |= M_MSG_EXIST;
2455 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2457 /* if (item->folder->type != F_NEWS) */
2458 state |= M_ALLOW_DELETE;
2460 if (prefs_common.immediate_exec == 0
2461 && mainwin->lock_count == 0)
2462 state |= M_DELAY_EXEC;
2464 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2465 || selection != SUMMARY_NONE)
2466 state |= M_HIDE_READ_MSG;
2468 if (mainwin->summaryview->threaded)
2469 state |= M_THREADED;
2471 state |= M_UNTHREADED;
2472 if (selection == SUMMARY_SELECTED_SINGLE ||
2473 selection == SUMMARY_SELECTED_MULTIPLE)
2474 state |= M_TARGET_EXIST;
2475 if (selection == SUMMARY_SELECTED_SINGLE)
2476 state |= M_SINGLE_TARGET_EXIST;
2477 if (mainwin->summaryview->folder_item &&
2478 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2481 state |= M_NOT_NEWS;
2482 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2483 state |= M_ACTIONS_EXIST;
2485 tmp = tags_get_list();
2486 if (tmp && g_slist_length(tmp))
2487 state |= M_TAGS_EXIST;
2490 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2491 state |= M_HAVE_QUEUED_MAILS;
2493 if (selection == SUMMARY_SELECTED_SINGLE &&
2495 (folder_has_parent_of_type(item, F_DRAFT) ||
2496 folder_has_parent_of_type(item, F_OUTBOX) ||
2497 folder_has_parent_of_type(item, F_QUEUE))))
2498 state |= M_ALLOW_REEDIT;
2500 state |= M_HAVE_ACCOUNT;
2502 if (any_folder_want_synchronise())
2503 state |= M_WANT_SYNC;
2505 for ( ; account_list != NULL; account_list = account_list->next) {
2506 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2507 state |= M_HAVE_NEWS_ACCOUNT;
2512 if (procmsg_spam_can_learn() &&
2513 (mainwin->summaryview->folder_item &&
2514 mainwin->summaryview->folder_item->folder->klass->type != F_UNKNOWN &&
2515 mainwin->summaryview->folder_item->folder->klass->type != F_NEWS)) {
2516 state |= M_CAN_LEARN_SPAM;
2519 if (inc_is_active())
2520 state |= M_INC_ACTIVE;
2521 if (imap_cancel_all_enabled())
2522 state |= M_INC_ACTIVE;
2524 if (mainwin->summaryview->deleted > 0 ||
2525 mainwin->summaryview->moved > 0 ||
2526 mainwin->summaryview->copied > 0)
2527 state |= M_DELAY_EXEC;
2534 void main_window_set_menu_sensitive(MainWindow *mainwin)
2536 GtkItemFactory *ifactory = mainwin->menu_factory;
2537 SensitiveCond state;
2540 GtkWidget *menuitem;
2541 SummaryView *summaryview;
2546 static const struct {
2550 {"/File/Save as...", M_TARGET_EXIST},
2551 {"/File/Print..." , M_TARGET_EXIST},
2552 {"/File/Synchronise folders", M_WANT_SYNC},
2553 {"/File/Exit" , M_UNLOCKED},
2555 {"/Edit/Select thread" , M_TARGET_EXIST},
2556 {"/Edit/Delete thread" , M_TARGET_EXIST},
2557 {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
2559 {"/View/Set displayed columns/in Folder list..."
2561 {"/View/Sort" , M_EXEC},
2562 {"/View/Thread view" , M_EXEC},
2563 {"/View/Expand all threads" , M_MSG_EXIST},
2564 {"/View/Collapse all threads" , M_MSG_EXIST},
2565 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2566 {"/View/Go to/Previous message" , M_MSG_EXIST},
2567 {"/View/Go to/Next message" , M_MSG_EXIST},
2568 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2569 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2570 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2571 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2572 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2573 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2574 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2575 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2576 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2577 {"/View/All headers" , M_SINGLE_TARGET_EXIST},
2578 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2580 {"/Message/Receive/Get from current account"
2581 , M_HAVE_ACCOUNT|M_UNLOCKED},
2582 {"/Message/Receive/Get from all accounts"
2583 , M_HAVE_ACCOUNT|M_UNLOCKED},
2584 {"/Message/Receive/Cancel receiving"
2586 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2587 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2588 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2589 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2590 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2591 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2592 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2593 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2594 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2595 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2596 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2597 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2598 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2599 {"/Message/Mark" , M_TARGET_EXIST},
2600 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2601 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2602 {"/Message/Mark/Ignore thread" , M_TARGET_EXIST},
2603 {"/Message/Mark/Unignore thread" , M_TARGET_EXIST},
2604 {"/Message/Mark/Lock" , M_TARGET_EXIST},
2605 {"/Message/Mark/Unlock" , M_TARGET_EXIST},
2606 {"/Message/Color label" , M_TARGET_EXIST},
2607 {"/Message/Tags" , M_TARGET_EXIST},
2608 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2610 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2611 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2612 {"/Tools/Harvest addresses/from Messages..."
2614 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2615 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2616 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2617 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2618 {"/Tools/List URLs..." , M_TARGET_EXIST},
2619 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2620 {"/Tools/Execute" , M_DELAY_EXEC},
2621 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2623 {"/Configuration", M_UNLOCKED},
2624 {"/Configuration/Preferences for current account...", M_UNLOCKED},
2625 {"/Configuration/Create new account...", M_UNLOCKED},
2626 {"/Configuration/Edit accounts...", M_UNLOCKED},
2631 state = main_window_get_current_state(mainwin);
2633 for (i = 0; entry[i].entry != NULL; i++) {
2634 sensitive = ((entry[i].cond & state) == entry[i].cond);
2635 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2638 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2640 /* search for separator */
2641 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2642 cur_item = cur_item->next) {
2643 if (GTK_BIN(cur_item->data)->child == NULL) {
2644 cur_item = cur_item->next;
2649 for (; cur_item != NULL; cur_item = cur_item->next) {
2650 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2651 (M_UNLOCKED & state) != 0);
2654 main_window_menu_callback_block(mainwin);
2656 #define SET_CHECK_MENU_ACTIVE(path, active) \
2658 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2659 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2662 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2663 messageview_is_visible(mainwin->messageview));
2665 summaryview = mainwin->summaryview;
2666 menu_path = "/View/Sort/Don't sort";
2668 switch (summaryview->sort_key) {
2669 case SORT_BY_NUMBER:
2670 menu_path = "/View/Sort/by number"; break;
2672 menu_path = "/View/Sort/by Size"; break;
2674 menu_path = "/View/Sort/by Date"; break;
2675 case SORT_BY_THREAD_DATE:
2676 menu_path = "/View/Sort/by Thread date"; break;
2678 menu_path = "/View/Sort/by From"; break;
2680 menu_path = "/View/Sort/by To"; break;
2681 case SORT_BY_SUBJECT:
2682 menu_path = "/View/Sort/by Subject"; break;
2684 menu_path = "/View/Sort/by color label"; break;
2686 menu_path = "/View/Sort/by mark"; break;
2687 case SORT_BY_STATUS:
2688 menu_path = "/View/Sort/by status"; break;
2690 menu_path = "/View/Sort/by attachment"; break;
2692 menu_path = "/View/Sort/by score"; break;
2693 case SORT_BY_LOCKED:
2694 menu_path = "/View/Sort/by locked"; break;
2696 menu_path = "/View/Sort/by tag"; break;
2699 menu_path = "/View/Sort/Don't sort"; break;
2701 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2703 if (summaryview->sort_type == SORT_ASCENDING) {
2704 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2706 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2709 if (summaryview->sort_key != SORT_BY_NONE) {
2710 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2711 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2713 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2714 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2717 if (mainwin->messageview
2718 && mainwin->messageview->mimeview
2719 && mainwin->messageview->mimeview->textview)
2720 SET_CHECK_MENU_ACTIVE("/View/All headers",
2721 mainwin->messageview->mimeview->textview->show_all_headers);
2722 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2723 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2724 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2725 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2726 if (prefs_common.hide_quotes == 1)
2727 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2728 if (prefs_common.hide_quotes == 2)
2729 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2730 if (prefs_common.hide_quotes == 3)
2731 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2733 #undef SET_CHECK_MENU_ACTIVE
2735 main_window_menu_callback_unblock(mainwin);
2738 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2740 GtkItemFactory *ifactory;
2742 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2745 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2747 gtk_widget_set_sensitive (gtk_item_factory_get_item
2748 (ifactory,"/Message/Mailing-List"), TRUE);
2750 gtk_widget_set_sensitive (gtk_item_factory_get_item
2751 (ifactory,"/Message/Mailing-List"), FALSE);
2754 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2757 GtkWidget *menuitem;
2759 if (!msginfo || !msginfo->extradata) {
2760 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2761 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2762 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2763 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2764 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2765 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2769 /* Mailing list post */
2770 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2771 g_free(msginfo->extradata->list_post);
2772 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2774 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2776 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2778 /* Mailing list help */
2779 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2781 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2783 /* Mailing list subscribe */
2784 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2786 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2788 /* Mailing list unsubscribe */
2789 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2791 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2793 /* Mailing list view archive */
2794 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2796 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2798 /* Mailing list contact owner */
2799 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2801 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2806 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2808 GtkWidget *item, *menu;
2809 const gchar *url_pt ;
2810 gchar url_decoded[BUFFSIZE];
2811 GList *amenu, *alist;
2814 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2816 /* First delete old submenu */
2817 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2818 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2819 alist = amenu->next;
2820 item = GTK_WIDGET (amenu->data);
2821 gtk_widget_destroy (item);
2825 for (url_pt = list_header; url_pt && *url_pt;) {
2826 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2828 if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
2829 item = gtk_menu_item_new_with_label ((url_decoded));
2830 g_signal_connect(G_OBJECT(item), "activate",
2831 G_CALLBACK(mailing_list_compose),
2834 else if (!g_strncasecmp (url_decoded, "http:", 5) ||
2835 !g_strncasecmp (url_decoded, "https:",6)) {
2837 item = gtk_menu_item_new_with_label ((url_decoded));
2838 g_signal_connect(G_OBJECT(item), "activate",
2839 G_CALLBACK(mailing_list_open_uri),
2843 gtk_menu_append (GTK_MENU(menu), item);
2844 gtk_widget_show (item);
2850 gtk_widget_set_sensitive (menuitem, TRUE);
2852 gtk_widget_set_sensitive (menuitem, FALSE);
2858 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2860 gchar tmp[BUFFSIZE];
2864 gboolean with_plus = TRUE;
2867 *url_decoded = '\0';
2871 /* Ignore spaces, comments and tabs () */
2872 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2874 for (;*buf != ')' && *buf != 0x00; buf++);
2876 /* First non space and non comment must be a < */
2879 if (!strncmp(buf, "mailto:", strlen("mailto:")))
2881 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2886 *url_decoded = '\0';
2891 *url_decoded = '\0';
2897 decode_uri_with_plus (url_decoded, (const gchar *)tmp, with_plus);
2899 /* Prepare the work for the next url in the list */
2900 /* after the closing bracket >, ignore space, comments and tabs */
2901 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2903 for (;*buf != ')' && *buf != 0x00; buf++);
2905 if (!buf || !*buf) {
2910 /* now first non space, non comment must be a comma */
2912 for (;*buf != 0x00; buf++);
2918 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2922 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2923 compose_new(NULL, mailto+7, NULL);
2926 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2931 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2932 open_uri (mailto, prefs_common.uri_cmd);
2935 void main_window_popup(MainWindow *mainwin)
2937 if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
2938 main_window_show(mainwin);
2940 gtkut_window_popup(mainwin->window);
2941 if (prefs_common.layout_mode == SMALL_LAYOUT) {
2942 if (mainwin->in_folder) {
2943 mainwindow_enter_folder(mainwin);
2945 mainwindow_exit_folder(mainwin);
2950 void main_window_show(MainWindow *mainwin)
2952 gtk_widget_show(mainwin->window);
2953 gtk_widget_show(mainwin->vbox_body);
2955 gtk_widget_set_uposition(mainwin->window,
2956 prefs_common.mainwin_x,
2957 prefs_common.mainwin_y);
2959 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2960 prefs_common.folderview_width,
2961 prefs_common.folderview_height);
2962 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2963 prefs_common.summaryview_width,
2964 prefs_common.summaryview_height);
2965 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2966 prefs_common.msgview_width,
2967 prefs_common.msgview_height);
2970 void main_window_hide(MainWindow *mainwin)
2972 main_window_get_size(mainwin);
2973 main_window_get_position(mainwin);
2975 gtk_widget_hide(mainwin->window);
2976 gtk_widget_hide(mainwin->vbox_body);
2979 static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
2981 GtkWidget *folderwin = NULL;
2982 GtkWidget *messagewin = NULL;
2985 GtkWidget *vbox_body = mainwin->vbox_body;
2986 GtkItemFactory *ifactory = mainwin->menu_factory;
2987 GtkWidget *menuitem;
2988 gboolean first_set = (mainwin->hpaned == NULL);
2989 debug_print("Setting widgets... ");
2991 if (layout_mode == SMALL_LAYOUT && first_set) {
2992 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2993 prefs_common.folderview_width,
2994 prefs_common.folderview_height);
2995 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2997 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3000 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3001 prefs_common.folderview_width,
3002 prefs_common.folderview_height);
3003 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3004 prefs_common.summaryview_width,
3005 prefs_common.summaryview_height);
3006 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3007 prefs_common.msgview_width,
3008 prefs_common.msgview_height);
3012 mainwin->messageview->statusbar = mainwin->statusbar;
3013 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
3015 /* clean top-most container */
3016 if (mainwin->hpaned) {
3017 if (mainwin->hpaned->parent == mainwin->vpaned)
3018 gtk_widget_destroy(mainwin->vpaned);
3020 gtk_widget_destroy(mainwin->hpaned);
3023 menu_set_sensitive(ifactory, "/View/Show or hide/Message view",
3024 (layout_mode != WIDE_MSGLIST_LAYOUT && layout_mode != SMALL_LAYOUT));
3025 switch (layout_mode) {
3026 case VERTICAL_LAYOUT:
3029 hpaned = gtk_hpaned_new();
3030 if (layout_mode == VERTICAL_LAYOUT)
3031 vpaned = gtk_hpaned_new();
3033 vpaned = gtk_vpaned_new();
3034 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
3035 gtk_paned_add1(GTK_PANED(hpaned),
3036 GTK_WIDGET_PTR(mainwin->folderview));
3037 gtk_widget_show(hpaned);
3038 gtk_widget_queue_resize(hpaned);
3040 if (messageview_is_visible(mainwin->messageview)) {
3041 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
3042 gtk_paned_add1(GTK_PANED(vpaned),
3043 GTK_WIDGET_PTR(mainwin->summaryview));
3045 gtk_paned_add2(GTK_PANED(hpaned),
3046 GTK_WIDGET_PTR(mainwin->summaryview));
3047 gtk_widget_ref(vpaned);
3049 gtk_paned_add2(GTK_PANED(vpaned),
3050 GTK_WIDGET_PTR(mainwin->messageview));
3051 gtk_widget_show(vpaned);
3052 if (layout_mode == SMALL_LAYOUT && first_set) {
3053 mainwin_paned_show_first(GTK_PANED(hpaned));
3055 gtk_widget_queue_resize(vpaned);
3058 vpaned = gtk_vpaned_new();
3059 hpaned = gtk_hpaned_new();
3060 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3061 gtk_paned_add1(GTK_PANED(vpaned), hpaned);
3063 gtk_paned_add1(GTK_PANED(hpaned),
3064 GTK_WIDGET_PTR(mainwin->folderview));
3065 gtk_paned_add2(GTK_PANED(hpaned),
3066 GTK_WIDGET_PTR(mainwin->summaryview));
3068 gtk_widget_show(hpaned);
3069 gtk_widget_queue_resize(hpaned);
3071 if (messageview_is_visible(mainwin->messageview)) {
3072 gtk_paned_add2(GTK_PANED(vpaned),
3073 GTK_WIDGET_PTR(mainwin->messageview));
3075 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3077 gtk_widget_show(vpaned);
3078 gtk_widget_queue_resize(vpaned);
3080 case WIDE_MSGLIST_LAYOUT:
3081 vpaned = gtk_vpaned_new();
3082 hpaned = gtk_hpaned_new();
3083 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3085 gtk_paned_add1(GTK_PANED(vpaned),
3086 GTK_WIDGET_PTR(mainwin->summaryview));
3087 gtk_paned_add1(GTK_PANED(hpaned),
3088 GTK_WIDGET_PTR(mainwin->folderview));
3090 gtk_widget_show(hpaned);
3091 gtk_widget_queue_resize(hpaned);
3093 if (messageview_is_visible(mainwin->messageview)) {
3094 gtk_paned_add2(GTK_PANED(hpaned),
3095 GTK_WIDGET_PTR(mainwin->messageview));
3097 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3099 gtk_paned_add2(GTK_PANED(vpaned), hpaned);
3101 gtk_widget_show(vpaned);
3102 gtk_widget_queue_resize(vpaned);
3105 g_warning("Unknown layout");
3109 mainwin->hpaned = hpaned;
3110 mainwin->vpaned = vpaned;
3112 if (layout_mode == SMALL_LAYOUT) {
3113 if (mainwin->messageview->visible)
3114 main_window_toggle_message_view(mainwin);
3117 if (layout_mode == SMALL_LAYOUT && first_set) {
3118 gtk_widget_realize(mainwin->window);
3119 gtk_widget_realize(mainwin->folderview->ctree);
3120 gtk_widget_realize(mainwin->summaryview->hbox);
3121 gtk_widget_realize(mainwin->summaryview->hbox_l);
3122 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3123 prefs_common.folderview_width,
3124 prefs_common.folderview_height);
3125 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3127 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3129 gtk_widget_set_size_request(GTK_WIDGET(mainwin->window),
3130 prefs_common.mainwin_width,
3131 prefs_common.mainwin_height);
3132 gtk_paned_set_position(GTK_PANED(mainwin->hpaned), 800);
3134 /* remove headerview if not in prefs */
3135 headerview_set_visibility(mainwin->messageview->headerview,
3136 prefs_common.display_header_pane);
3138 if (messageview_is_visible(mainwin->messageview))
3139 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3140 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
3142 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3143 GTK_ARROW_UP, GTK_SHADOW_OUT);
3145 gtk_window_move(GTK_WINDOW(mainwin->window),
3146 prefs_common.mainwin_x,
3147 prefs_common.mainwin_y);
3149 gtk_widget_queue_resize(vbox_body);
3150 gtk_widget_queue_resize(mainwin->vbox);
3151 gtk_widget_queue_resize(mainwin->window);
3152 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
3153 * and mimeview icon list/ctree lose track of their visibility states */
3154 if (!noticeview_is_visible(mainwin->messageview->noticeview))
3155 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
3156 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
3157 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
3158 if (mainwin->messageview->mimeview->ctree_mode)
3159 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
3161 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
3163 prefs_common.layout_mode = layout_mode;
3165 menuitem = gtk_item_factory_get_item
3166 (ifactory, "/View/Show or hide/Message view");
3167 gtk_check_menu_item_set_active
3168 (GTK_CHECK_MENU_ITEM(menuitem),
3169 messageview_is_visible(mainwin->messageview));
3171 #define SET_CHECK_MENU_ACTIVE(path, active) \
3173 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3174 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3178 switch (prefs_common.layout_mode) {
3180 SET_CHECK_MENU_ACTIVE("/View/Layout/Standard", TRUE);
3182 case VERTICAL_LAYOUT:
3183 SET_CHECK_MENU_ACTIVE("/View/Layout/Three columns", TRUE);
3186 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message", TRUE);
3188 case WIDE_MSGLIST_LAYOUT: