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 process_cb (MainWindow *mainwin,
345 static void execute_summary_cb (MainWindow *mainwin,
348 static void update_summary_cb (MainWindow *mainwin,
352 static void prev_cb (MainWindow *mainwin,
355 static void next_cb (MainWindow *mainwin,
358 static void next_unread_cb (MainWindow *mainwin,
361 static void prev_unread_cb (MainWindow *mainwin,
365 static void prev_new_cb (MainWindow *mainwin,
368 static void next_new_cb (MainWindow *mainwin,
371 static void prev_marked_cb (MainWindow *mainwin,
374 static void next_marked_cb (MainWindow *mainwin,
377 static void prev_labeled_cb (MainWindow *mainwin,
380 static void next_labeled_cb (MainWindow *mainwin,
383 static void last_read_cb (MainWindow *mainwin,
386 static void parent_cb (MainWindow *mainwin,
390 static void goto_folder_cb (MainWindow *mainwin,
393 static void goto_unread_folder_cb(MainWindow *mainwin,
397 static void copy_cb (MainWindow *mainwin,
400 static void allsel_cb (MainWindow *mainwin,
403 static void select_thread_cb (MainWindow *mainwin,
406 static void delete_thread_cb (MainWindow *mainwin,
410 static void create_filter_cb (MainWindow *mainwin,
413 static void create_processing_cb (MainWindow *mainwin,
416 static void open_urls_cb (MainWindow *mainwin,
420 static void prefs_template_open_cb (MainWindow *mainwin,
423 static void prefs_actions_open_cb (MainWindow *mainwin,
426 static void prefs_tags_open_cb (MainWindow *mainwin,
429 static void prefs_account_open_cb (MainWindow *mainwin,
433 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
437 static void prefs_post_processing_open_cb (MainWindow *mainwin,
441 static void prefs_filtering_open_cb (MainWindow *mainwin,
445 static void ssl_manager_open_cb (MainWindow *mainwin,
449 static void new_account_cb (MainWindow *mainwin,
453 static void account_selector_menu_cb (GtkMenuItem *menuitem,
455 static void account_receive_menu_cb (GtkMenuItem *menuitem,
457 static void account_compose_menu_cb (GtkMenuItem *menuitem,
460 static void prefs_open_cb (GtkMenuItem *menuitem,
462 static void plugins_open_cb (GtkMenuItem *menuitem,
465 static void online_switch_clicked(GtkButton *btn,
468 static void manual_open_cb (MainWindow *mainwin,
472 static void legend_open_cb (GtkMenuItem *menuitem,
475 static void scan_tree_func (Folder *folder,
479 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
481 static void addr_harvest_cb ( MainWindow *mainwin,
485 static void addr_harvest_msg_cb ( MainWindow *mainwin,
488 static void sync_cb ( MainWindow *mainwin,
492 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
493 GdkEventFocus *focus,
495 static gboolean mainwindow_visibility_event_cb (GtkWidget *widget,
496 GdkEventVisibility *state,
498 static gboolean mainwindow_state_event_cb (GtkWidget *widget,
499 GdkEventWindowState *state,
501 static void main_window_reply_cb (MainWindow *mainwin,
504 static gboolean mainwindow_progressindicator_hook (gpointer source,
507 static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
510 static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
512 static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
514 static void mailing_list_compose(GtkWidget *w, gpointer *data);
516 static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
517 #define SEPARATE_ACTION 500
518 static void mainwindow_quicksearch (MainWindow *mainwin,
521 static gboolean any_folder_want_synchronise(void);
523 static GtkItemFactoryEntry mainwin_entries[] =
525 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
526 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
527 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
528 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
529 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
530 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
531 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
532 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
533 {N_("/_File/Exp_ort selected to mbox file..."),
534 NULL, export_list_mbox_cb, 0, NULL},
535 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
536 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
537 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
538 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
539 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
540 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
541 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
542 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
543 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
544 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
545 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
547 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
548 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
549 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
550 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
551 {N_("/_Edit/_Delete thread"), NULL, delete_thread_cb, 0, NULL},
552 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
553 {N_("/_Edit/_Find in current message..."),
554 "<control>F", search_cb, 0, NULL},
555 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
556 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
557 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
558 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
559 {N_("/_View/Show or hi_de/_Message view"),
560 "V", toggle_message_cb, 0, "<ToggleItem>"},
561 {N_("/_View/Show or hi_de/_Toolbar"),
562 NULL, NULL, 0, "<Branch>"},
563 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
564 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
565 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
566 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
567 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
568 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
569 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
570 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
571 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
572 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
574 {N_("/_View/Show or hi_de/Status _bar"),
575 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
577 {N_("/_View/Show or hi_de/Column headers"),
578 NULL, toggle_col_headers_cb, 0, "<ToggleItem>"},
579 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
580 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
581 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
583 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
585 {N_("/_View/La_yout"), NULL, NULL, 0, "<Branch>"},
586 {N_("/_View/Layout/_Standard"), NULL, set_layout_cb, NORMAL_LAYOUT, "<RadioItem>"},
587 {N_("/_View/Layout/_Three columns"), NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
588 {N_("/_View/Layout/_Wide message"), NULL, set_layout_cb, WIDE_LAYOUT, "/View/Layout/Standard"},
589 {N_("/_View/Layout/W_ide message list"),NULL, set_layout_cb, WIDE_MSGLIST_LAYOUT, "/View/Layout/Standard"},
590 {N_("/_View/Layout/S_mall screen"), NULL, set_layout_cb, SMALL_LAYOUT, "/View/Layout/Standard"},
591 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
593 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
594 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
595 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
596 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
597 {N_("/_View/_Sort/by Thread date"), NULL, sort_summary_cb, SORT_BY_THREAD_DATE, "/View/Sort/by number"},
598 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
599 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
600 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
601 {N_("/_View/_Sort/by _color label"), NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
602 {N_("/_View/_Sort/by tag"), NULL, sort_summary_cb, SORT_BY_TAGS, "/View/Sort/by number"},
603 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
604 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
605 {N_("/_View/_Sort/by a_ttachment"),
606 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
607 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
608 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
609 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
610 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
611 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
612 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
613 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
614 {N_("/_View/_Sort/_Attract by subject"),
615 NULL, attract_by_subject_cb, 0, NULL},
616 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
617 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
618 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
619 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
621 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
622 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
623 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
624 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
625 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
626 {N_("/_View/_Go to/P_revious unread message"),
627 "<shift>P", prev_unread_cb, 0, NULL},
628 {N_("/_View/_Go to/N_ext unread message"),
629 "<shift>N", next_unread_cb, 0, NULL},
630 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
631 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
632 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
633 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
634 {N_("/_View/_Go to/Previous _marked message"),
635 NULL, prev_marked_cb, 0, NULL},
636 {N_("/_View/_Go to/Next m_arked message"),
637 NULL, next_marked_cb, 0, NULL},
638 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
639 {N_("/_View/_Go to/Previous _labeled message"),
640 NULL, prev_labeled_cb, 0, NULL},
641 {N_("/_View/_Go to/Next la_beled message"),
642 NULL, next_labeled_cb, 0, NULL},
643 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
644 {N_("/_View/_Go to/Last read message"),
645 NULL, last_read_cb, 0, NULL},
646 {N_("/_View/_Go to/Parent message"),
647 "<control>Up", parent_cb, 0, NULL},
648 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
649 {N_("/_View/_Go to/Next unread _folder"), "<shift>G", goto_unread_folder_cb, 0, NULL},
650 {N_("/_View/_Go to/_Other folder..."), "G", goto_folder_cb, 0, NULL},
651 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
653 #define ENC_SEPARATOR \
654 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
655 #define ENC_ACTION(action) \
656 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
658 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
659 {N_("/_View/Character _encoding/_Auto detect"),
660 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
661 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
662 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
663 ENC_ACTION(C_US_ASCII)},
664 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
665 ENC_ACTION(C_UTF_8)},
668 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
669 ENC_ACTION(C_ISO_8859_1)},
670 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
671 ENC_ACTION(C_ISO_8859_15)},
672 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
673 ENC_ACTION(C_WINDOWS_1252)},
676 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
677 ENC_ACTION(C_ISO_8859_2)},
680 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
681 ENC_ACTION(C_ISO_8859_13)},
682 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
683 ENC_ACTION(C_ISO_8859_4)},
686 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
687 ENC_ACTION(C_ISO_8859_7)},
690 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
691 ENC_ACTION(C_ISO_8859_8)},
692 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
693 ENC_ACTION(C_CP1255)},
696 {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"),
697 ENC_ACTION(C_ISO_8859_6)},
698 {N_("/_View/Character _encoding/Arabic (Windows-1256)"),
699 ENC_ACTION(C_CP1256)},
702 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
703 ENC_ACTION(C_ISO_8859_9)},
706 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
707 ENC_ACTION(C_ISO_8859_5)},
708 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
709 ENC_ACTION(C_KOI8_R)},
710 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
711 ENC_ACTION(C_KOI8_U)},
712 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
713 ENC_ACTION(C_CP1251)},
716 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
717 ENC_ACTION(C_ISO_2022_JP)},
718 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
719 ENC_ACTION(C_ISO_2022_JP_2)},
720 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
721 ENC_ACTION(C_EUC_JP)},
722 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
723 ENC_ACTION(C_SHIFT_JIS)},
726 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
727 ENC_ACTION(C_GB2312)},
728 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
730 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
732 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
733 ENC_ACTION(C_EUC_TW)},
734 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
735 ENC_ACTION(C_ISO_2022_CN)},
738 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
739 ENC_ACTION(C_EUC_KR)},
740 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
741 ENC_ACTION(C_ISO_2022_KR)},
744 {N_("/_View/Character _encoding/Thai (TIS-620)"),
745 ENC_ACTION(C_TIS_620)},
746 {N_("/_View/Character _encoding/Thai (Windows-874)"),
747 ENC_ACTION(C_WINDOWS_874)},
752 #define DEC_SEPARATOR \
753 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
754 #define DEC_ACTION(action) \
755 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
756 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
757 {N_("/_View/Decode/_Auto detect"),
758 NULL, set_decode_cb, 0, "<RadioItem>"},
759 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
760 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
761 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
762 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
763 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
768 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
769 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
770 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
771 {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
772 {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
773 {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
774 {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
775 {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
776 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
777 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
779 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
780 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
781 {N_("/_Message/Recei_ve/Get from _current account"),
782 "<control>I", inc_mail_cb, 0, NULL},
783 {N_("/_Message/Recei_ve/Get from _all accounts"),
784 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
785 {N_("/_Message/Recei_ve/Cancel receivin_g"),
786 NULL, inc_cancel_cb, 0, NULL},
787 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
788 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
789 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
790 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
791 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
792 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
793 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
794 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
795 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
796 {N_("/_Message/Repl_y to/mailing _list"),
797 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
798 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
799 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
800 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
801 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
802 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
804 {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
805 {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
806 {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
807 {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
808 {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
809 {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
810 {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
812 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
813 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
814 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
815 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
816 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
817 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
818 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
819 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
820 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
821 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
822 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
823 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
824 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
825 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
826 {N_("/_Message/_Mark/Ignore thread"), NULL, ignore_thread_cb, 0, NULL},
827 {N_("/_Message/_Mark/Unignore thread"), NULL, unignore_thread_cb, 0, NULL},
828 {N_("/_Message/_Mark/Watch thread"), NULL, watch_thread_cb, 0, NULL},
829 {N_("/_Message/_Mark/Unwatch thread"), NULL, unwatch_thread_cb, 0, NULL},
830 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
831 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
832 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
833 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
834 {N_("/_Message/_Mark/Lock"), NULL, lock_msgs_cb, 0, NULL},
835 {N_("/_Message/_Mark/Unlock"), NULL, unlock_msgs_cb, 0, NULL},
836 {N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
837 {N_("/_Message/T_ags"), NULL, NULL, 0, NULL},
838 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
839 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
841 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
842 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
843 {N_("/_Tools/Add sender to address boo_k"),
844 NULL, add_address_cb, 0, NULL},
845 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
846 {N_("/_Tools/_Harvest addresses/from _Folder..."),
847 NULL, addr_harvest_cb, 0, NULL},
848 {N_("/_Tools/_Harvest addresses/from _Messages..."),
849 NULL, addr_harvest_msg_cb, 0, NULL},
850 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
851 {N_("/_Tools/_Filter all messages in folder"),
852 NULL, filter_cb, 0, NULL},
853 {N_("/_Tools/Filter _selected messages"),
854 NULL, filter_cb, 1, NULL},
855 {N_("/_Tools/Run folder processing rules"),
856 NULL, process_cb, 0, NULL},
857 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
858 {N_("/_Tools/_Create filter rule/_Automatically"),
859 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
860 {N_("/_Tools/_Create filter rule/by _From"),
861 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
862 {N_("/_Tools/_Create filter rule/by _To"),
863 NULL, create_filter_cb, FILTER_BY_TO, NULL},
864 {N_("/_Tools/_Create filter rule/by _Subject"),
865 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
866 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
867 {N_("/_Tools/C_reate processing rule/_Automatically"),
868 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
869 {N_("/_Tools/C_reate processing rule/by _From"),
870 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
871 {N_("/_Tools/C_reate processing rule/by _To"),
872 NULL, create_processing_cb, FILTER_BY_TO, NULL},
873 {N_("/_Tools/C_reate processing rule/by _Subject"),
874 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
875 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
876 {N_("/_Tools/List _URLs..."), "<shift><control>U", open_urls_cb, 0, NULL},
877 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
878 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
879 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
880 {N_("/_Tools/Ch_eck for new messages in all folders"),
881 NULL, update_folderview_cb, 0, NULL},
882 {N_("/_Tools/Delete du_plicated messages"),
883 NULL, NULL, 0, "<Branch>"},
884 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
885 NULL, delete_duplicated_cb, 0, NULL},
886 {N_("/_Tools/Delete du_plicated messages/In all folders"),
887 NULL, delete_duplicated_all_cb, 0, NULL},
888 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
889 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
891 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
892 {N_("/_Tools/SSL cer_tificates..."),
893 NULL, ssl_manager_open_cb, 0, NULL},
895 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
896 {N_("/_Tools/Filtering Log"), NULL, filtering_debug_window_show_cb, 0, NULL},
897 {N_("/_Tools/Network _Log"), "<shift><control>L", log_window_show_cb, 0, NULL},
899 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
900 {N_("/_Configuration/C_hange current account"),
901 NULL, NULL, 0, "<Branch>"},
902 {N_("/_Configuration/_Preferences for current account..."),
903 NULL, prefs_account_open_cb, 0, NULL},
904 {N_("/_Configuration/Create _new account..."),
905 NULL, new_account_cb, 0, NULL},
906 {N_("/_Configuration/_Edit accounts..."),
907 NULL, account_edit_open, 0, NULL},
908 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
909 {N_("/_Configuration/P_references..."),
910 NULL, prefs_open_cb, 0, NULL},
911 {N_("/_Configuration/Pre-pr_ocessing..."),
912 NULL, prefs_pre_processing_open_cb, 0, NULL},
913 {N_("/_Configuration/Post-pro_cessing..."),
914 NULL, prefs_post_processing_open_cb, 0, NULL},
915 {N_("/_Configuration/_Filtering..."),
916 NULL, prefs_filtering_open_cb, 0, NULL},
917 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
918 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
919 {N_("/_Configuration/Tag_s..."), NULL, prefs_tags_open_cb, 0, NULL},
920 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
921 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
923 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
924 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_CLAWS, NULL},
925 {N_("/_Help/_Online User-contributed FAQ"),
926 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
927 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
928 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
929 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
932 static gboolean offline_ask_sync = TRUE;
933 static guint lastkey;
934 static gboolean is_obscured = FALSE;
936 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
942 MainWindow *mainwin = (MainWindow *)user_data;
944 if (mainwin->summaryview &&
945 mainwin->summaryview->quicksearch &&
946 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
947 (mod == 0 || mod == GDK_SHIFT_MASK)) {
948 quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
954 #define N_COLOR_LABELS colorlabel_get_color_count()
956 static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
961 GtkCheckMenuItem **items;
966 mainwin = (MainWindow *)data;
967 g_return_if_fail(mainwin != NULL);
969 sel = summary_get_selection(mainwin->summaryview);
972 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
973 g_return_if_fail(menu != NULL);
975 Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
977 /* NOTE: don't return prematurely because we set the "dont_toggle"
978 * state for check menu items */
979 g_object_set_data(G_OBJECT(menu), "dont_toggle",
982 /* clear items. get item pointers. */
983 for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
984 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
985 gtk_check_menu_item_set_active
986 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
987 items[n] = GTK_CHECK_MENU_ITEM(cur->data);
992 if (n == (N_COLOR_LABELS + 1)) {
993 /* iterate all messages and set the state of the appropriate
995 for (; sel != NULL; sel = sel->next) {
999 msginfo = (MsgInfo *)sel->data;
1001 clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
1002 if (!items[clabel]->active)
1003 gtk_check_menu_item_set_active
1004 (items[clabel], TRUE);
1008 g_warning("invalid number of color elements (%d)\n", n);
1011 /* reset "dont_toggle" state */
1012 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1013 GINT_TO_POINTER(0));
1016 static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
1019 guint color = GPOINTER_TO_UINT(data);
1020 MainWindow *mainwin;
1022 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1023 g_return_if_fail(mainwin != NULL);
1025 /* "dont_toggle" state set? */
1026 if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
1030 summary_set_colorlabel(mainwin->summaryview, color, NULL);
1033 static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
1036 MainWindow *mainwin;
1040 GHashTable *menu_table = g_hash_table_new_full(
1044 GHashTable *menu_allsel_table = g_hash_table_new_full(
1049 mainwin = (MainWindow *)data;
1050 g_return_if_fail(mainwin != NULL);
1052 sel = summary_get_selection(mainwin->summaryview);
1055 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1056 g_return_if_fail(menu != NULL);
1058 /* NOTE: don't return prematurely because we set the "dont_toggle"
1059 * state for check menu items */
1060 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1061 GINT_TO_POINTER(1));
1063 /* clear items. get item pointers. */
1064 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1065 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
1066 gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
1068 gtk_check_menu_item_set_active
1069 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
1071 g_hash_table_insert(menu_table, GINT_TO_POINTER(id), GTK_CHECK_MENU_ITEM(cur->data));
1072 g_hash_table_insert(menu_allsel_table, GINT_TO_POINTER(id), GINT_TO_POINTER(0));
1076 /* iterate all messages and set the state of the appropriate
1079 for (; sel != NULL; sel = sel->next) {
1081 GSList *tags = NULL;
1083 GtkCheckMenuItem *item;
1084 msginfo = (MsgInfo *)sel->data;
1087 tags = msginfo->tags;
1091 for (; tags; tags = tags->next) {
1092 gint num_checked = GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table, tags->data));
1093 id = GPOINTER_TO_INT(tags->data);
1094 item = g_hash_table_lookup(menu_table, GINT_TO_POINTER(tags->data));
1095 if (item && !item->active) {
1096 gtk_check_menu_item_set_active
1100 g_hash_table_replace(menu_allsel_table, tags->data, GINT_TO_POINTER(num_checked));
1105 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1106 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
1107 gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
1109 gint num_checked = GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table, GINT_TO_POINTER(id)));
1110 if (num_checked < sel_len && num_checked > 0)
1111 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur->data), TRUE);
1113 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur->data), FALSE);
1117 g_hash_table_destroy(menu_table);
1118 g_hash_table_destroy(menu_allsel_table);
1119 /* reset "dont_toggle" state */
1120 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1121 GINT_TO_POINTER(0));
1124 static void mainwindow_tags_menu_item_activate_cb(GtkWidget *widget,
1127 gint id = GPOINTER_TO_INT(data);
1128 gboolean set = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
1129 MainWindow *mainwin;
1131 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1132 g_return_if_fail(mainwin != NULL);
1134 /* "dont_toggle" state set? */
1135 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1141 summary_set_tag(mainwin->summaryview, id, NULL);
1144 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
1146 GtkWidget *label_menuitem;
1151 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1152 "/Message/Color label");
1153 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1154 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_item_cb),
1156 gtk_widget_show(label_menuitem);
1158 menu = gtk_menu_new();
1160 /* create sub items. for the menu item activation callback we pass the
1161 * index of label_colors[] as data parameter. for the None color we
1162 * pass an invalid (high) value. also we attach a data pointer so we
1163 * can always get back the Mainwindow pointer. */
1165 item = gtk_check_menu_item_new_with_label(_("None"));
1166 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1167 g_signal_connect(G_OBJECT(item), "activate",
1168 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1169 GUINT_TO_POINTER(0));
1170 g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
1171 gtk_widget_show(item);
1173 gtk_widget_add_accelerator(item, "activate",
1174 mainwin->menu_factory->accel_group,
1175 GDK_0, GDK_CONTROL_MASK,
1176 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1178 item = gtk_menu_item_new();
1179 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1180 gtk_widget_show(item);
1182 /* create pixmap/label menu items */
1183 for (i = 0; i < N_COLOR_LABELS; i++) {
1184 item = colorlabel_create_check_color_menu_item(
1185 i, refresh, MAINWIN_COLORMENU);
1186 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1187 g_signal_connect(G_OBJECT(item), "activate",
1188 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1189 GUINT_TO_POINTER(i + 1));
1190 g_object_set_data(G_OBJECT(item), "mainwin",
1192 gtk_widget_show(item);
1194 gtk_widget_add_accelerator(item, "activate",
1195 mainwin->menu_factory->accel_group,
1196 GDK_1+i, GDK_CONTROL_MASK,
1197 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1199 gtk_widget_show(menu);
1200 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1201 mainwin->colorlabel_menu = menu;
1204 static void mainwindow_tags_menu_item_apply_tags_activate_cb(GtkWidget *widget,
1207 MainWindow *mainwin;
1209 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1210 g_return_if_fail(mainwin != NULL);
1212 /* "dont_toggle" state set? */
1213 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1217 tag_apply_open(summary_get_selection(mainwin->summaryview));
1220 static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
1222 GtkWidget *label_menuitem;
1225 GSList *cur = tags_get_list();
1227 gboolean existing_tags = FALSE;
1229 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1231 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1232 G_CALLBACK(mainwindow_tags_menu_item_activate_item_cb),
1235 gtk_widget_show(label_menuitem);
1237 menu = gtk_menu_new();
1239 /* create tags menu items */
1240 for (; cur; cur = cur->next) {
1241 gint id = GPOINTER_TO_INT(cur->data);
1242 const gchar *tag = tags_get_tag(id);
1244 item = gtk_check_menu_item_new_with_label(tag);
1245 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1246 g_signal_connect(G_OBJECT(item), "activate",
1247 G_CALLBACK(mainwindow_tags_menu_item_activate_cb),
1248 GINT_TO_POINTER(id));
1249 g_object_set_data(G_OBJECT(item), "mainwin",
1251 g_object_set_data(G_OBJECT(item), "tag_id",
1252 GINT_TO_POINTER(id));
1253 gtk_widget_show(item);
1254 existing_tags = TRUE;
1256 if (existing_tags) {
1258 item = gtk_menu_item_new();
1259 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1260 gtk_widget_show(item);
1263 item = gtk_menu_item_new_with_label(_("Apply tags..."));
1264 gtk_widget_add_accelerator(item, "activate",
1265 mainwin->menu_factory->accel_group,
1266 GDK_T, GDK_CONTROL_MASK|GDK_SHIFT_MASK,
1267 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1268 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1269 g_signal_connect(G_OBJECT(item), "activate",
1270 G_CALLBACK(mainwindow_tags_menu_item_apply_tags_activate_cb),
1272 g_object_set_data(G_OBJECT(item), "mainwin",
1274 gtk_widget_show(item);
1277 gtk_widget_show(menu);
1278 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1279 mainwin->tags_menu = menu;
1282 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
1283 MainWindow *mainwindow)
1285 if (evt && evt->button == 1) {
1286 log_window_show_error(mainwindow->logwin);
1287 gtk_widget_hide(mainwindow->warning_btn);
1292 static gboolean warning_visi_notify(GtkWidget *widget,
1293 GdkEventVisibility *event,
1294 MainWindow *mainwindow)
1296 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1300 static gboolean warning_leave_notify(GtkWidget *widget,
1301 GdkEventCrossing *event,
1302 MainWindow *mainwindow)
1304 gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
1308 static gboolean warning_enter_notify(GtkWidget *widget,
1309 GdkEventCrossing *event,
1310 MainWindow *mainwindow)
1312 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1316 void mainwindow_show_error(void)
1318 MainWindow *mainwin = mainwindow_get_mainwindow();
1319 gtk_widget_show(mainwin->warning_btn);
1322 void mainwindow_clear_error(MainWindow *mainwin)
1324 gtk_widget_hide(mainwin->warning_btn);
1327 MainWindow *main_window_create()
1329 MainWindow *mainwin;
1333 GtkWidget *handlebox;
1334 GtkWidget *vbox_body;
1336 GtkWidget *hbox_stat;
1337 GtkWidget *statusbar;
1338 GtkWidget *progressbar;
1339 GtkWidget *statuslabel;
1340 GtkWidget *ac_button;
1341 GtkWidget *ac_label;
1342 GtkWidget *online_pixmap;
1343 GtkWidget *offline_pixmap;
1345 GtkWidget *warning_icon;
1346 GtkWidget *warning_btn;
1348 GtkWidget *online_switch;
1349 GtkWidget *offline_switch;
1350 FolderView *folderview;
1351 SummaryView *summaryview;
1352 MessageView *messageview;
1353 GdkColormap *colormap;
1355 gboolean success[4];
1356 GtkItemFactory *ifactory;
1358 GtkWidget *menuitem;
1360 guint n_menu_entries;
1362 static GdkGeometry geometry;
1364 debug_print("Creating main window...\n");
1365 mainwin = g_new0(MainWindow, 1);
1368 window = GTK_WIDGET(gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow"));
1369 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1370 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1372 prefs_common.layout_mode = SMALL_LAYOUT;
1374 if (!geometry.min_height) {
1375 geometry.min_width = 320;
1376 geometry.min_height = 200;
1378 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1381 g_signal_connect(G_OBJECT(window), "delete_event",
1382 G_CALLBACK(main_window_close_cb), mainwin);
1383 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1384 g_signal_connect(G_OBJECT(window), "focus_in_event",
1385 G_CALLBACK(mainwindow_focus_in_event),
1387 g_signal_connect(G_OBJECT(window), "key_press_event",
1388 G_CALLBACK(mainwindow_key_pressed), mainwin);
1390 gtk_widget_realize(window);
1391 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1394 gtkut_widget_set_app_icon(window);
1396 vbox = gtk_vbox_new(FALSE, 0);
1397 gtk_widget_show(vbox);
1398 gtk_container_add(GTK_CONTAINER(window), vbox);
1401 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1402 menubar = menubar_create(window, mainwin_entries,
1403 n_menu_entries, "<Main>", mainwin);
1404 gtk_widget_show(menubar);
1407 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1410 ifactory = gtk_item_factory_from_widget(menubar);
1412 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1413 main_create_mailing_list_menu (mainwin, NULL); */
1415 if (prefs_common.toolbar_detachable) {
1416 handlebox = gtk_handle_box_new();
1417 gtk_widget_show(handlebox);
1418 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1419 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1420 G_CALLBACK(toolbar_child_attached), mainwin);
1421 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1422 G_CALLBACK(toolbar_child_detached), mainwin);
1424 handlebox = gtk_hbox_new(FALSE, 0);
1425 gtk_widget_show(handlebox);
1426 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1428 /* link window to mainwin->window to avoid gdk warnings */
1429 mainwin->window = window;
1430 mainwin_list = g_list_append(mainwin_list, mainwin);
1433 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1437 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1441 toolbar_set_learn_button
1445 /* vbox that contains body */
1446 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1447 gtk_widget_show(vbox_body);
1448 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1449 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1452 hbox_stat = gtk_hbox_new(FALSE, 2);
1453 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1455 tips = gtk_tooltips_new();
1457 warning_icon = gtk_image_new_from_stock
1458 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1459 warning_btn = gtk_event_box_new();
1460 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1462 mainwin->warning_btn = warning_btn;
1464 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1465 G_CALLBACK(warning_icon_pressed),
1466 (gpointer) mainwin);
1467 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1468 G_CALLBACK(warning_visi_notify), mainwin);
1469 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1470 G_CALLBACK(warning_visi_notify), mainwin);
1471 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1472 G_CALLBACK(warning_leave_notify), mainwin);
1473 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1474 G_CALLBACK(warning_enter_notify), mainwin);
1476 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1478 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1479 _("Some error(s) happened. Click here to view log."), NULL);
1480 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1482 statusbar = statusbar_create();
1483 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1485 progressbar = gtk_progress_bar_new();
1486 gtk_widget_set_size_request(progressbar, 120, 1);
1487 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1489 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1490 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1491 online_switch = gtk_button_new ();
1492 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1493 _("You are online. Click the icon to go offline"), NULL);
1494 offline_switch = gtk_button_new ();
1495 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1496 _("You are offline. Click the icon to go online"),
1498 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1499 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1500 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1501 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1502 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1503 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1504 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1505 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1507 statuslabel = gtk_label_new("");
1508 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1510 ac_button = gtk_button_new();
1511 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1512 ac_button, _("Select account"), NULL);
1513 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1514 gtk_widget_set_size_request(ac_button, -1, 0);
1515 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1516 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1517 G_CALLBACK(ac_label_button_pressed), mainwin);
1519 ac_label = gtk_label_new("");
1520 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1522 gtk_widget_show_all(hbox_stat);
1524 gtk_widget_hide(offline_switch);
1525 gtk_widget_hide(warning_btn);
1527 online_switch = gtk_button_new ();
1528 offline_switch = gtk_button_new ();
1529 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1530 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1533 mainwin->folderview = folderview = folderview_create();
1534 mainwin->summaryview = summaryview = summary_create();
1535 mainwin->messageview = messageview = messageview_create(mainwin);
1537 /* init log instances data before creating log views */
1538 set_log_title(LOG_PROTOCOL, _("Network log"));
1539 set_log_prefs(LOG_PROTOCOL,
1540 &prefs_common.logwin_width,
1541 &prefs_common.logwin_height);
1542 set_log_title(LOG_DEBUG_FILTERING, _("Filtering/processing debug log"));
1543 set_log_prefs(LOG_DEBUG_FILTERING,
1544 &prefs_common.filtering_debugwin_width,
1545 &prefs_common.filtering_debugwin_height);
1547 /* setup log windows */
1548 mainwin->logwin = log_window_create(LOG_PROTOCOL);
1549 log_window_init(mainwin->logwin);
1551 mainwin->filtering_debugwin = log_window_create(LOG_DEBUG_FILTERING);
1552 log_window_set_clipping(mainwin->logwin,
1553 prefs_common.cliplog,
1554 prefs_common.loglength);
1556 log_window_init(mainwin->filtering_debugwin);
1557 log_window_set_clipping(mainwin->filtering_debugwin,
1558 prefs_common.filtering_debug_cliplog,
1559 prefs_common.filtering_debug_loglength);
1560 if (prefs_common.enable_filtering_debug)
1561 log_message(LOG_DEBUG_FILTERING, _("filtering log enabled\n"));
1563 log_message(LOG_DEBUG_FILTERING, _("filtering log disabled\n"));
1565 folderview->mainwin = mainwin;
1566 folderview->summaryview = summaryview;
1568 summaryview->mainwin = mainwin;
1569 summaryview->folderview = folderview;
1570 summaryview->messageview = messageview;
1571 summaryview->window = window;
1573 mainwin->vbox = vbox;
1574 mainwin->menubar = menubar;
1575 mainwin->menu_factory = ifactory;
1576 mainwin->handlebox = handlebox;
1577 mainwin->vbox_body = vbox_body;
1578 mainwin->online_switch = online_switch;
1579 mainwin->offline_switch = offline_switch;
1581 messageview->statusbar = statusbar;
1582 mainwin->statusbar = statusbar;
1583 mainwin->hbox_stat = hbox_stat;
1584 mainwin->progressbar = progressbar;
1585 mainwin->statuslabel = statuslabel;
1586 mainwin->online_pixmap = online_pixmap;
1587 mainwin->offline_pixmap = offline_pixmap;
1588 mainwin->ac_button = ac_button;
1589 mainwin->ac_label = ac_label;
1590 /* set context IDs for status bar */
1591 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1592 (GTK_STATUSBAR(statusbar), "Main Window");
1593 mainwin->folderview_cid = gtk_statusbar_get_context_id
1594 (GTK_STATUSBAR(statusbar), "Folder View");
1595 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1596 (GTK_STATUSBAR(statusbar), "Summary View");
1597 mainwin->messageview_cid = gtk_statusbar_get_context_id
1598 (GTK_STATUSBAR(statusbar), "Message View");
1599 messageview->statusbar_cid = mainwin->messageview_cid;
1602 messageview->statusbar = NULL;
1603 mainwin->statusbar = NULL;
1604 mainwin->hbox_stat = NULL;
1605 /* mainwin->progressbar is set in toolbar.c */
1606 mainwin->statuslabel = NULL;
1607 mainwin->online_pixmap = NULL;
1608 mainwin->offline_pixmap = NULL;
1609 mainwin->ac_button = NULL;
1610 mainwin->ac_label = NULL;
1613 /* allocate colors for summary view and folder view */
1614 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1615 summaryview->color_marked.blue = (guint16)65535;
1617 summaryview->color_dim.red = summaryview->color_dim.green =
1618 summaryview->color_dim.blue = COLOR_DIM;
1620 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1621 &folderview->color_new);
1623 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1624 &folderview->color_op);
1626 summaryview->color_important.red = 0;
1627 summaryview->color_important.green = 0;
1628 summaryview->color_important.blue = (guint16)65535;
1630 color[0] = summaryview->color_marked;
1631 color[1] = summaryview->color_dim;
1632 color[2] = folderview->color_new;
1633 color[3] = folderview->color_op;
1635 colormap = gdk_drawable_get_colormap(window->window);
1636 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1637 for (i = 0; i < 4; i++) {
1638 if (success[i] == FALSE)
1639 g_warning("MainWindow: color allocation %d failed\n", i);
1642 debug_print("done.\n");
1644 messageview->visible = prefs_common.msgview_visible;
1646 main_window_set_widgets(mainwin, prefs_common.layout_mode);
1648 g_signal_connect(G_OBJECT(window), "size_allocate",
1649 G_CALLBACK(main_window_size_allocate_cb),
1652 /* set menu items */
1653 menuitem = gtk_item_factory_get_item
1654 (ifactory, "/View/Character encoding/Auto detect");
1655 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1657 switch (prefs_common.toolbar_style) {
1659 menuitem = gtk_item_factory_get_item
1660 (ifactory, "/View/Show or hide/Toolbar/Hide");
1663 menuitem = gtk_item_factory_get_item
1664 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1667 menuitem = gtk_item_factory_get_item
1668 (ifactory, "/View/Show or hide/Toolbar/Text only");
1671 menuitem = gtk_item_factory_get_item
1672 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1674 case TOOLBAR_BOTH_HORIZ:
1675 menuitem = gtk_item_factory_get_item
1677 "/View/Show or hide/Toolbar/Text beside icons");
1679 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1682 gtk_widget_hide(mainwin->hbox_stat);
1683 menuitem = gtk_item_factory_get_item
1684 (ifactory, "/View/Show or hide/Status bar");
1685 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1686 prefs_common.show_statusbar);
1688 menuitem = gtk_item_factory_get_item
1689 (ifactory, "/View/Show or hide/Column headers");
1690 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1691 prefs_common.show_col_headers);
1692 /* set account selection menu */
1693 ac_menu = gtk_item_factory_get_widget
1694 (ifactory, "/Configuration/Change current account");
1695 mainwin->ac_menu = ac_menu;
1697 toolbar_main_set_sensitive(mainwin);
1699 /* create actions menu */
1700 main_window_update_actions_menu(mainwin);
1702 main_create_mailing_list_menu (mainwin, NULL);
1704 /* attach accel groups to main window */
1705 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1706 gtk_window_add_accel_group \
1708 gtk_item_factory_from_widget(menu)->accel_group); \
1709 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1711 G_CALLBACK(main_window_accel_activate), mainwin);
1714 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1716 /* connect the accelerators for equivalent
1717 menu items in different menus */
1718 menu_connect_identical_items();
1721 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1724 g_signal_connect(G_OBJECT(window), "window_state_event",
1725 G_CALLBACK(mainwindow_state_event_cb), mainwin);
1726 g_signal_connect(G_OBJECT(window), "visibility_notify_event",
1727 G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
1728 gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
1730 if (prefs_common.layout_mode == VERTICAL_LAYOUT ||
1731 prefs_common.layout_mode == SMALL_LAYOUT) {
1732 summary_relayout(mainwin->summaryview);
1734 summary_update_unread(mainwin->summaryview, NULL);
1736 gtk_widget_show(mainwin->window);
1738 /* initialize views */
1739 folderview_init(folderview);
1740 summary_init(summaryview);
1741 messageview_init(messageview);
1743 sslcertwindow_register_hook();
1745 mainwin->lock_count = 0;
1746 mainwin->menu_lock_count = 0;
1747 mainwin->cursor_count = 0;
1749 mainwin->progressindicator_hook =
1750 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1753 watch_cursor = gdk_cursor_new(GDK_WATCH);
1755 hand_cursor = gdk_cursor_new(GDK_HAND2);
1757 /* init work_offline */
1758 if (prefs_common.work_offline)
1759 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1761 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1762 mainwindow_tags_menu_create(mainwin, FALSE);
1767 void main_window_destroy(MainWindow *mainwin)
1769 /* TODO : destroy other component */
1770 messageview_destroy(mainwin->messageview);
1771 mainwin->messageview = NULL;
1774 void main_window_update_actions_menu(MainWindow *mainwin)
1776 GtkItemFactory *ifactory;
1778 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1779 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1782 void main_window_cursor_wait(MainWindow *mainwin)
1785 if (mainwin->cursor_count == 0) {
1786 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1787 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1790 mainwin->cursor_count++;
1795 void main_window_cursor_normal(MainWindow *mainwin)
1797 if (mainwin->cursor_count)
1798 mainwin->cursor_count--;
1800 if (mainwin->cursor_count == 0) {
1801 gdk_window_set_cursor(mainwin->window->window, NULL);
1802 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1807 /* lock / unlock the user-interface */
1808 void main_window_lock(MainWindow *mainwin)
1810 if (mainwin->lock_count == 0 && mainwin->ac_button)
1811 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1813 mainwin->lock_count++;
1815 main_window_set_menu_sensitive(mainwin);
1816 toolbar_main_set_sensitive(mainwin);
1819 void main_window_unlock(MainWindow *mainwin)
1821 if (mainwin->lock_count)
1822 mainwin->lock_count--;
1824 main_window_set_menu_sensitive(mainwin);
1825 toolbar_main_set_sensitive(mainwin);
1827 if (mainwin->lock_count == 0 && mainwin->ac_button)
1828 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1831 static void main_window_menu_callback_block(MainWindow *mainwin)
1833 mainwin->menu_lock_count++;
1836 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1838 if (mainwin->menu_lock_count)
1839 mainwin->menu_lock_count--;
1842 static guint prefs_tag = 0;
1844 void main_window_reflect_prefs_all(void)
1846 main_window_reflect_prefs_all_real(FALSE);
1849 static gboolean reflect_prefs_timeout_cb(gpointer data)
1851 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1853 MainWindow *mainwin;
1856 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1857 mainwin = (MainWindow *)cur->data;
1859 main_window_show_cur_account(mainwin);
1860 main_window_set_menu_sensitive(mainwin);
1861 toolbar_main_set_sensitive(mainwin);
1864 if (pixmap_theme_changed) {
1865 toolbar_update(TOOLBAR_MAIN, mainwin);
1866 messageview_reflect_prefs_pixmap_theme();
1867 compose_reflect_prefs_pixmap_theme();
1868 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1869 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1871 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1872 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1873 mainwin->online_pixmap);
1874 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1875 gtk_widget_show(pixmap);
1876 mainwin->online_pixmap = pixmap;
1877 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1878 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1879 mainwin->offline_pixmap);
1880 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1881 gtk_widget_show(pixmap);
1882 mainwin->offline_pixmap = pixmap;
1886 headerview_set_font(mainwin->messageview->headerview);
1887 headerview_set_visibility(mainwin->messageview->headerview,
1888 prefs_common.display_header_pane);
1889 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1890 folderview_reflect_prefs();
1891 summary_reflect_prefs();
1893 summary_redisplay_msg(mainwin->summaryview);
1895 if (prefs_common.layout_mode == SMALL_LAYOUT) {
1896 if (mainwin->in_folder) {
1897 mainwindow_enter_folder(mainwin);
1899 mainwindow_exit_folder(mainwin);
1907 void main_window_reflect_prefs_all_now(void)
1909 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1912 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1917 /* re-create colorlabel submenu */
1918 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1919 g_return_if_fail(menu != NULL);
1921 /* clear items. get item pointers. */
1922 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1923 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1925 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1926 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1930 void main_window_reflect_tags_changes(MainWindow *mainwin)
1935 /* re-create tags submenu */
1936 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1937 g_return_if_fail(menu != NULL);
1939 /* clear items. get item pointers. */
1940 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1941 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1943 mainwindow_tags_menu_create(mainwin, TRUE);
1944 summary_reflect_tags_changes(mainwin->summaryview);
1948 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1950 if (prefs_tag == 0 || pixmap_theme_changed) {
1951 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1952 GINT_TO_POINTER(pixmap_theme_changed));
1956 void main_window_set_summary_column(void)
1959 MainWindow *mainwin;
1961 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1962 mainwin = (MainWindow *)cur->data;
1963 summary_set_column_order(mainwin->summaryview);
1967 void main_window_set_folder_column(void)
1970 MainWindow *mainwin;
1972 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1973 mainwin = (MainWindow *)cur->data;
1974 folderview_set_column_order(mainwin->folderview);
1978 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1979 GList *account_list)
1981 GList *cur_ac, *cur_item;
1982 GtkWidget *menuitem;
1983 PrefsAccount *ac_prefs;
1985 /* destroy all previous menu item */
1986 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1987 while (cur_item != NULL) {
1988 GList *next = cur_item->next;
1989 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1993 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1994 ac_prefs = (PrefsAccount *)cur_ac->data;
1996 menuitem = gtk_menu_item_new_with_label
1997 (ac_prefs->account_name
1998 ? ac_prefs->account_name : _("Untitled"));
1999 gtk_widget_show(menuitem);
2000 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
2001 g_signal_connect(G_OBJECT(menuitem), "activate",
2002 G_CALLBACK(account_selector_menu_cb),
2007 static void main_window_set_account_receive_menu(MainWindow *mainwin,
2008 GList *account_list)
2010 GList *cur_ac, *cur_item;
2012 GtkWidget *menuitem;
2013 PrefsAccount *ac_prefs;
2015 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
2016 "/Message/Receive");
2018 /* search for separator */
2019 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2020 cur_item = cur_item->next) {
2021 if (GTK_BIN(cur_item->data)->child == NULL) {
2022 cur_item = cur_item->next;
2027 /* destroy all previous menu item */
2028 while (cur_item != NULL) {
2029 GList *next = cur_item->next;
2030 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
2034 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2035 ac_prefs = (PrefsAccount *)cur_ac->data;
2037 menuitem = gtk_menu_item_new_with_label
2038 (ac_prefs->account_name ? ac_prefs->account_name
2040 gtk_widget_show(menuitem);
2041 gtk_menu_append(GTK_MENU(menu), menuitem);
2042 g_signal_connect(G_OBJECT(menuitem), "activate",
2043 G_CALLBACK(account_receive_menu_cb),
2048 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
2049 GList *account_list)
2052 GtkWidget *menuitem;
2053 PrefsAccount *ac_prefs;
2054 GtkWidget *menu = NULL;
2056 if (mainwin->toolbar->getall_btn == NULL) /* button doesn't exist */
2059 menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn));
2061 gtk_widget_destroy(menu);
2062 menu = gtk_menu_new();
2064 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2065 ac_prefs = (PrefsAccount *)cur_ac->data;
2067 menuitem = gtk_menu_item_new_with_label
2068 (ac_prefs->account_name
2069 ? ac_prefs->account_name : _("Untitled"));
2070 gtk_widget_show(menuitem);
2071 gtk_menu_append(GTK_MENU(menu), menuitem);
2072 g_signal_connect(G_OBJECT(menuitem), "activate",
2073 G_CALLBACK(account_receive_menu_cb),
2076 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn), menu);
2079 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
2080 GList *account_list)
2084 GtkWidget *menuitem;
2085 PrefsAccount *ac_prefs;
2086 GtkWidget *menu = NULL;
2088 if (mainwin->toolbar->compose_mail_btn == NULL) /* button doesn't exist */
2091 menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn));
2093 gtk_widget_destroy(menu);
2094 menu = gtk_menu_new();
2096 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2097 ac_prefs = (PrefsAccount *)cur_ac->data;
2099 menuitem = gtk_menu_item_new_with_label
2100 (ac_prefs->account_name
2101 ? ac_prefs->account_name : _("Untitled"));
2102 gtk_widget_show(menuitem);
2103 gtk_menu_append(GTK_MENU(menu), menuitem);
2104 g_signal_connect(G_OBJECT(menuitem), "activate",
2105 G_CALLBACK(account_compose_menu_cb),
2108 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn), menu);
2112 void main_window_set_account_menu(GList *account_list)
2115 MainWindow *mainwin;
2117 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2118 mainwin = (MainWindow *)cur->data;
2119 main_window_set_account_selector_menu(mainwin, account_list);
2120 main_window_set_account_receive_menu(mainwin, account_list);
2121 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2122 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2124 hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
2127 void main_window_set_account_menu_only_toolbar(GList *account_list)
2130 MainWindow *mainwin;
2132 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2133 mainwin = (MainWindow *)cur->data;
2134 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2135 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2139 static void main_window_show_cur_account(MainWindow *mainwin)
2144 ac_name = g_strdup(cur_account
2145 ? (cur_account->account_name
2146 ? cur_account->account_name : _("Untitled"))
2150 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
2152 buf = g_strdup(PROG_VERSION);
2153 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
2156 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
2157 if (mainwin->ac_button)
2158 gtk_widget_queue_resize(mainwin->ac_button);
2163 static void main_window_separation_change(MainWindow *mainwin, LayoutType layout_mode)
2165 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
2166 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
2167 GtkWidget *message_wid = mainwin->messageview->vbox;
2169 if (layout_mode == prefs_common.layout_mode)
2172 debug_print("Changing window separation type from %d to %d\n",
2173 prefs_common.layout_mode, layout_mode);
2175 /* remove widgets from those containers */
2176 gtk_widget_ref(folder_wid);
2177 gtk_widget_ref(summary_wid);
2178 gtk_widget_ref(message_wid);
2179 gtkut_container_remove
2180 (GTK_CONTAINER(folder_wid->parent), folder_wid);
2181 gtkut_container_remove
2182 (GTK_CONTAINER(summary_wid->parent), summary_wid);
2183 gtkut_container_remove
2184 (GTK_CONTAINER(message_wid->parent), message_wid);
2186 gtk_widget_hide(mainwin->window);
2187 main_window_set_widgets(mainwin, layout_mode);
2188 gtk_widget_show(mainwin->window);
2190 gtk_widget_unref(folder_wid);
2191 gtk_widget_unref(summary_wid);
2192 gtk_widget_unref(message_wid);
2195 void mainwindow_reset_paned(GtkPaned *paned)
2199 if (gtk_paned_get_child1(GTK_PANED(paned)))
2200 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2201 if (gtk_paned_get_child2(GTK_PANED(paned)))
2202 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2205 g_object_get (G_OBJECT(paned),
2208 g_object_get (G_OBJECT(paned),
2212 gtk_paned_set_position(GTK_PANED(paned), mid);
2215 static void mainwin_paned_show_first(GtkPaned *paned)
2218 g_object_get (G_OBJECT(paned),
2222 if (gtk_paned_get_child1(GTK_PANED(paned)))
2223 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2224 if (gtk_paned_get_child2(GTK_PANED(paned)))
2225 gtk_widget_hide(gtk_paned_get_child2(GTK_PANED(paned)));
2226 gtk_paned_set_position(GTK_PANED(paned), max);
2229 static void mainwin_paned_show_last(GtkPaned *paned)
2232 g_object_get (G_OBJECT(paned),
2236 if (gtk_paned_get_child1(GTK_PANED(paned)))
2237 gtk_widget_hide(gtk_paned_get_child1(GTK_PANED(paned)));
2238 if (gtk_paned_get_child2(GTK_PANED(paned)))
2239 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2240 gtk_paned_set_position(GTK_PANED(paned), min);
2243 void main_window_toggle_message_view(MainWindow *mainwin)
2245 SummaryView *summaryview = mainwin->summaryview;
2246 GtkWidget *ppaned = NULL;
2247 GtkWidget *container = NULL;
2249 switch (prefs_common.layout_mode) {
2251 case VERTICAL_LAYOUT:
2253 ppaned = mainwin->vpaned;
2254 container = mainwin->hpaned;
2255 if (ppaned->parent != NULL) {
2256 mainwin->messageview->visible = FALSE;
2257 summaryview->displayed = NULL;
2258 gtk_widget_ref(ppaned);
2259 gtkut_container_remove(GTK_CONTAINER(container), ppaned);
2260 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
2262 mainwin->messageview->visible = TRUE;
2263 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), ppaned);
2264 gtk_container_add(GTK_CONTAINER(container), ppaned);
2265 gtk_widget_unref(ppaned);
2269 ppaned = mainwin->hpaned;
2270 container = mainwin->vpaned;
2271 if (mainwin->messageview->vbox->parent != NULL) {
2272 mainwin->messageview->visible = FALSE;
2273 summaryview->displayed = NULL;
2274 gtk_widget_ref(mainwin->messageview->vbox);
2275 gtkut_container_remove(GTK_CONTAINER(container), mainwin->messageview->vbox);
2277 mainwin->messageview->visible = TRUE;
2278 gtk_container_add(GTK_CONTAINER(container), mainwin->messageview->vbox);
2279 gtk_widget_unref(mainwin->messageview->vbox);
2282 case WIDE_MSGLIST_LAYOUT:
2283 g_warning("can't hide messageview in this wide msglist layout");
2287 if (messageview_is_visible(mainwin->messageview))
2288 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2289 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2291 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2292 GTK_ARROW_UP, GTK_SHADOW_OUT);
2294 if (mainwin->messageview->visible == FALSE)
2295 messageview_clear(mainwin->messageview);
2297 main_window_set_menu_sensitive(mainwin);
2299 prefs_common.msgview_visible = mainwin->messageview->visible;
2301 if (messageview_is_visible(mainwin->messageview)) {
2302 gtk_widget_queue_resize(mainwin->hpaned);
2303 gtk_widget_queue_resize(mainwin->vpaned);
2305 summary_grab_focus(summaryview);
2308 void main_window_get_size(MainWindow *mainwin)
2310 GtkAllocation *allocation;
2312 if (mainwin_list == NULL || mainwin->messageview == NULL) {
2313 debug_print("called after messageview "
2314 "has been deallocated!\n");
2318 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
2320 if (allocation->width > 1 && allocation->height > 1) {
2321 prefs_common.summaryview_width = allocation->width;
2323 if (messageview_is_visible(mainwin->messageview))
2324 prefs_common.summaryview_height = allocation->height;
2326 prefs_common.mainview_width = allocation->width;
2329 allocation = &mainwin->window->allocation;
2330 if (allocation->width > 1 && allocation->height > 1) {
2331 prefs_common.mainview_height = allocation->height;
2332 prefs_common.mainwin_width = allocation->width;
2333 prefs_common.mainwin_height = allocation->height;
2336 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
2337 if (allocation->width > 1 && allocation->height > 1) {
2338 prefs_common.folderview_width = allocation->width;
2339 prefs_common.folderview_height = allocation->height;
2342 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
2343 if (allocation->width > 1 && allocation->height > 1) {
2344 prefs_common.msgview_width = allocation->width;
2345 prefs_common.msgview_height = allocation->height;
2348 /* debug_print("summaryview size: %d x %d\n",
2349 prefs_common.summaryview_width,
2350 prefs_common.summaryview_height);
2351 debug_print("folderview size: %d x %d\n",
2352 prefs_common.folderview_width,
2353 prefs_common.folderview_height);
2354 debug_print("messageview size: %d x %d\n",
2355 prefs_common.msgview_width,
2356 prefs_common.msgview_height); */
2359 void main_window_get_position(MainWindow *mainwin)
2363 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2365 prefs_common.mainview_x = x;
2366 prefs_common.mainview_y = y;
2367 prefs_common.mainwin_x = x;
2368 prefs_common.mainwin_y = y;
2370 debug_print("main window position: %d, %d\n", x, y);
2373 void main_window_progress_on(MainWindow *mainwin)
2375 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2378 void main_window_progress_off(MainWindow *mainwin)
2380 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2381 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2384 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
2388 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
2389 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
2390 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
2391 (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
2394 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2396 if (confirm && procmsg_have_trashed_mails_fast()) {
2397 if (alertpanel(_("Empty trash"),
2398 _("Delete all messages in trash folders?"),
2399 GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL)
2400 != G_ALERTALTERNATE)
2402 manage_window_focus_in(mainwin->window, NULL, NULL);
2405 procmsg_empty_all_trash();
2407 if (mainwin->summaryview->folder_item &&
2408 mainwin->summaryview->folder_item->stype == F_TRASH)
2409 gtk_widget_grab_focus(mainwin->folderview->ctree);
2412 void main_window_add_mailbox(MainWindow *mainwin)
2417 path = input_dialog(_("Add mailbox"),
2418 _("Input the location of mailbox.\n"
2419 "If an existing mailbox is specified, it will be\n"
2420 "scanned automatically."),
2423 if (folder_find_from_path(path)) {
2424 alertpanel_error(_("The mailbox '%s' already exists."), path);
2428 folder = folder_new(folder_get_class_from_string("mh"),
2429 !strcmp(path, "Mail") ? _("Mailbox") :
2430 g_path_get_basename(path), path);
2433 if (folder->klass->create_tree(folder) < 0) {
2434 alertpanel_error(_("Creation of the mailbox failed.\n"
2435 "Maybe some files already exist, or you don't have the permission to write there."));
2436 folder_destroy(folder);
2441 folder_set_ui_func(folder, scan_tree_func, mainwin);
2442 folder_scan_tree(folder, TRUE);
2443 folder_set_ui_func(folder, NULL, NULL);
2446 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2448 SensitiveCond state = 0;
2449 SummarySelection selection;
2450 FolderItem *item = mainwin->summaryview->folder_item;
2451 GList *account_list = account_get_list();
2454 selection = summary_get_selection_type(mainwin->summaryview);
2456 if (mainwin->lock_count == 0)
2457 state |= M_UNLOCKED;
2458 if (selection != SUMMARY_NONE)
2459 state |= M_MSG_EXIST;
2460 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2462 /* if (item->folder->type != F_NEWS) */
2463 state |= M_ALLOW_DELETE;
2465 if (prefs_common.immediate_exec == 0
2466 && mainwin->lock_count == 0)
2467 state |= M_DELAY_EXEC;
2469 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2470 || selection != SUMMARY_NONE)
2471 state |= M_HIDE_READ_MSG;
2473 if (mainwin->summaryview->threaded)
2474 state |= M_THREADED;
2476 state |= M_UNTHREADED;
2477 if (selection == SUMMARY_SELECTED_SINGLE ||
2478 selection == SUMMARY_SELECTED_MULTIPLE)
2479 state |= M_TARGET_EXIST;
2480 if (selection == SUMMARY_SELECTED_SINGLE)
2481 state |= M_SINGLE_TARGET_EXIST;
2482 if (mainwin->summaryview->folder_item &&
2483 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2486 state |= M_NOT_NEWS;
2487 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2488 state |= M_ACTIONS_EXIST;
2490 tmp = tags_get_list();
2491 if (tmp && g_slist_length(tmp))
2492 state |= M_TAGS_EXIST;
2495 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2496 state |= M_HAVE_QUEUED_MAILS;
2498 if (selection == SUMMARY_SELECTED_SINGLE &&
2500 (folder_has_parent_of_type(item, F_DRAFT) ||
2501 folder_has_parent_of_type(item, F_OUTBOX) ||
2502 folder_has_parent_of_type(item, F_QUEUE))))
2503 state |= M_ALLOW_REEDIT;
2505 state |= M_HAVE_ACCOUNT;
2507 if (any_folder_want_synchronise())
2508 state |= M_WANT_SYNC;
2510 if (item && item->prefs->processing && selection != SUMMARY_NONE)
2511 state |= M_HAVE_PROCESSING;
2513 for ( ; account_list != NULL; account_list = account_list->next) {
2514 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2515 state |= M_HAVE_NEWS_ACCOUNT;
2520 if (procmsg_spam_can_learn() &&
2521 (mainwin->summaryview->folder_item &&
2522 mainwin->summaryview->folder_item->folder->klass->type != F_UNKNOWN &&
2523 mainwin->summaryview->folder_item->folder->klass->type != F_NEWS)) {
2524 state |= M_CAN_LEARN_SPAM;
2527 if (inc_is_active())
2528 state |= M_INC_ACTIVE;
2529 if (imap_cancel_all_enabled())
2530 state |= M_INC_ACTIVE;
2532 if (mainwin->summaryview->deleted > 0 ||
2533 mainwin->summaryview->moved > 0 ||
2534 mainwin->summaryview->copied > 0)
2535 state |= M_DELAY_EXEC;
2542 void main_window_set_menu_sensitive(MainWindow *mainwin)
2544 GtkItemFactory *ifactory = mainwin->menu_factory;
2545 SensitiveCond state;
2548 GtkWidget *menuitem;
2549 SummaryView *summaryview;
2554 static const struct {
2558 {"/File/Save as...", M_TARGET_EXIST},
2559 {"/File/Print..." , M_TARGET_EXIST},
2560 {"/File/Synchronise folders", M_WANT_SYNC},
2561 {"/File/Exit" , M_UNLOCKED},
2563 {"/Edit/Select thread" , M_TARGET_EXIST},
2564 {"/Edit/Delete thread" , M_TARGET_EXIST},
2565 {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
2567 {"/View/Set displayed columns/in Folder list..."
2569 {"/View/Sort" , M_EXEC},
2570 {"/View/Thread view" , M_EXEC},
2571 {"/View/Expand all threads" , M_MSG_EXIST},
2572 {"/View/Collapse all threads" , M_MSG_EXIST},
2573 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2574 {"/View/Go to/Previous message" , M_MSG_EXIST},
2575 {"/View/Go to/Next message" , M_MSG_EXIST},
2576 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2577 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2578 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2579 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2580 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2581 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2582 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2583 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2584 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2585 {"/View/All headers" , M_SINGLE_TARGET_EXIST},
2586 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2588 {"/Message/Receive/Get from current account"
2589 , M_HAVE_ACCOUNT|M_UNLOCKED},
2590 {"/Message/Receive/Get from all accounts"
2591 , M_HAVE_ACCOUNT|M_UNLOCKED},
2592 {"/Message/Receive/Cancel receiving"
2594 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2595 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2596 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2597 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2598 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2599 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2600 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2601 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2602 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2603 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2604 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2605 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2606 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2607 {"/Message/Mark" , M_TARGET_EXIST},
2608 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2609 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2610 {"/Message/Mark/Ignore thread" , M_TARGET_EXIST},
2611 {"/Message/Mark/Unignore thread" , M_TARGET_EXIST},
2612 {"/Message/Mark/Lock" , M_TARGET_EXIST},
2613 {"/Message/Mark/Unlock" , M_TARGET_EXIST},
2614 {"/Message/Color label" , M_TARGET_EXIST},
2615 {"/Message/Tags" , M_TARGET_EXIST},
2616 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2618 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2619 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2620 {"/Tools/Harvest addresses/from Messages..."
2622 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2623 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2624 {"/Tools/Run folder processing rules" , M_HAVE_PROCESSING},
2625 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2626 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2627 {"/Tools/List URLs..." , M_TARGET_EXIST},
2628 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2629 {"/Tools/Execute" , M_DELAY_EXEC},
2630 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2632 {"/Configuration", M_UNLOCKED},
2633 {"/Configuration/Preferences for current account...", M_UNLOCKED},
2634 {"/Configuration/Create new account...", M_UNLOCKED},
2635 {"/Configuration/Edit accounts...", M_UNLOCKED},
2640 state = main_window_get_current_state(mainwin);
2642 for (i = 0; entry[i].entry != NULL; i++) {
2643 sensitive = ((entry[i].cond & state) == entry[i].cond);
2644 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2647 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2649 /* search for separator */
2650 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2651 cur_item = cur_item->next) {
2652 if (GTK_BIN(cur_item->data)->child == NULL) {
2653 cur_item = cur_item->next;
2658 for (; cur_item != NULL; cur_item = cur_item->next) {
2659 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2660 (M_UNLOCKED & state) != 0);
2663 main_window_menu_callback_block(mainwin);
2665 #define SET_CHECK_MENU_ACTIVE(path, active) \
2667 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2668 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2671 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2672 messageview_is_visible(mainwin->messageview));
2674 summaryview = mainwin->summaryview;
2675 menu_path = "/View/Sort/Don't sort";
2677 switch (summaryview->sort_key) {
2678 case SORT_BY_NUMBER:
2679 menu_path = "/View/Sort/by number"; break;
2681 menu_path = "/View/Sort/by Size"; break;
2683 menu_path = "/View/Sort/by Date"; break;
2684 case SORT_BY_THREAD_DATE:
2685 menu_path = "/View/Sort/by Thread date"; break;
2687 menu_path = "/View/Sort/by From"; break;
2689 menu_path = "/View/Sort/by To"; break;
2690 case SORT_BY_SUBJECT:
2691 menu_path = "/View/Sort/by Subject"; break;
2693 menu_path = "/View/Sort/by color label"; break;
2695 menu_path = "/View/Sort/by mark"; break;
2696 case SORT_BY_STATUS:
2697 menu_path = "/View/Sort/by status"; break;
2699 menu_path = "/View/Sort/by attachment"; break;
2701 menu_path = "/View/Sort/by score"; break;
2702 case SORT_BY_LOCKED:
2703 menu_path = "/View/Sort/by locked"; break;
2705 menu_path = "/View/Sort/by tag"; break;
2708 menu_path = "/View/Sort/Don't sort"; break;
2710 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2712 if (summaryview->sort_type == SORT_ASCENDING) {
2713 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2715 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2718 if (summaryview->sort_key != SORT_BY_NONE) {
2719 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2720 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2722 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2723 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2726 if (mainwin->messageview
2727 && mainwin->messageview->mimeview
2728 && mainwin->messageview->mimeview->textview)
2729 SET_CHECK_MENU_ACTIVE("/View/All headers",
2730 mainwin->messageview->mimeview->textview->show_all_headers);
2731 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2732 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2733 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2734 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2735 if (prefs_common.hide_quotes == 1)
2736 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2737 if (prefs_common.hide_quotes == 2)
2738 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2739 if (prefs_common.hide_quotes == 3)
2740 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2742 #undef SET_CHECK_MENU_ACTIVE
2744 main_window_menu_callback_unblock(mainwin);
2747 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2749 GtkItemFactory *ifactory;
2751 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2754 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2756 gtk_widget_set_sensitive (gtk_item_factory_get_item
2757 (ifactory,"/Message/Mailing-List"), TRUE);
2759 gtk_widget_set_sensitive (gtk_item_factory_get_item
2760 (ifactory,"/Message/Mailing-List"), FALSE);
2763 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2766 GtkWidget *menuitem;
2768 if (!msginfo || !msginfo->extradata) {
2769 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2770 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2771 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2772 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2773 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2774 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2778 /* Mailing list post */
2779 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2780 g_free(msginfo->extradata->list_post);
2781 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2783 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2785 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2787 /* Mailing list help */
2788 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2790 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2792 /* Mailing list subscribe */
2793 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2795 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2797 /* Mailing list unsubscribe */
2798 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2800 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2802 /* Mailing list view archive */
2803 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2805 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2807 /* Mailing list contact owner */
2808 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2810 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2815 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2817 GtkWidget *item, *menu;
2818 const gchar *url_pt ;
2819 gchar url_decoded[BUFFSIZE];
2820 GList *amenu, *alist;
2823 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2825 /* First delete old submenu */
2826 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2827 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2828 alist = amenu->next;
2829 item = GTK_WIDGET (amenu->data);
2830 gtk_widget_destroy (item);
2834 for (url_pt = list_header; url_pt && *url_pt;) {
2835 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2837 if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
2838 item = gtk_menu_item_new_with_label ((url_decoded));
2839 g_signal_connect(G_OBJECT(item), "activate",
2840 G_CALLBACK(mailing_list_compose),
2843 else if (!g_strncasecmp (url_decoded, "http:", 5) ||
2844 !g_strncasecmp (url_decoded, "https:",6)) {
2846 item = gtk_menu_item_new_with_label ((url_decoded));
2847 g_signal_connect(G_OBJECT(item), "activate",
2848 G_CALLBACK(mailing_list_open_uri),
2852 gtk_menu_append (GTK_MENU(menu), item);
2853 gtk_widget_show (item);
2859 gtk_widget_set_sensitive (menuitem, TRUE);
2861 gtk_widget_set_sensitive (menuitem, FALSE);
2867 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2869 gchar tmp[BUFFSIZE];
2873 gboolean with_plus = TRUE;
2876 *url_decoded = '\0';
2880 /* Ignore spaces, comments and tabs () */
2881 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2883 for (;*buf != ')' && *buf != 0x00; buf++);
2885 /* First non space and non comment must be a < */
2888 if (!strncmp(buf, "mailto:", strlen("mailto:")))
2890 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2895 *url_decoded = '\0';
2900 *url_decoded = '\0';
2906 decode_uri_with_plus (url_decoded, (const gchar *)tmp, with_plus);
2908 /* Prepare the work for the next url in the list */
2909 /* after the closing bracket >, ignore space, comments and tabs */
2910 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2912 for (;*buf != ')' && *buf != 0x00; buf++);
2914 if (!buf || !*buf) {
2919 /* now first non space, non comment must be a comma */
2921 for (;*buf != 0x00; buf++);
2927 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2931 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2932 compose_new(NULL, mailto+7, NULL);
2935 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2940 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2941 open_uri (mailto, prefs_common.uri_cmd);
2944 void main_window_popup(MainWindow *mainwin)
2946 if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
2947 main_window_show(mainwin);
2949 gtkut_window_popup(mainwin->window);
2950 if (prefs_common.layout_mode == SMALL_LAYOUT) {
2951 if (mainwin->in_folder) {
2952 mainwindow_enter_folder(mainwin);
2954 mainwindow_exit_folder(mainwin);
2959 void main_window_show(MainWindow *mainwin)
2961 gtk_widget_show(mainwin->window);
2962 gtk_widget_show(mainwin->vbox_body);
2964 gtk_widget_set_uposition(mainwin->window,
2965 prefs_common.mainwin_x,
2966 prefs_common.mainwin_y);
2968 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2969 prefs_common.folderview_width,
2970 prefs_common.folderview_height);
2971 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2972 prefs_common.summaryview_width,
2973 prefs_common.summaryview_height);
2974 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2975 prefs_common.msgview_width,
2976 prefs_common.msgview_height);
2979 void main_window_hide(MainWindow *mainwin)
2981 main_window_get_size(mainwin);
2982 main_window_get_position(mainwin);
2984 gtk_widget_hide(mainwin->window);
2985 gtk_widget_hide(mainwin->vbox_body);
2988 static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
2990 GtkWidget *folderwin = NULL;
2991 GtkWidget *messagewin = NULL;
2994 GtkWidget *vbox_body = mainwin->vbox_body;
2995 GtkItemFactory *ifactory = mainwin->menu_factory;
2996 GtkWidget *menuitem;
2997 gboolean first_set = (mainwin->hpaned == NULL);
2998 debug_print("Setting widgets... ");
3000 if (layout_mode == SMALL_LAYOUT && first_set) {
3001 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3002 prefs_common.folderview_width,
3003 prefs_common.folderview_height);
3004 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3006 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3009 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3010 prefs_common.folderview_width,
3011 prefs_common.folderview_height);
3012 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3013 prefs_common.summaryview_width,
3014 prefs_common.summaryview_height);
3015 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3016 prefs_common.msgview_width,
3017 prefs_common.msgview_height);
3021 mainwin->messageview->statusbar = mainwin->statusbar;
3022 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
3024 /* clean top-most container */
3025 if (mainwin->hpaned) {
3026 if (mainwin->hpaned->parent == mainwin->vpaned)
3027 gtk_widget_destroy(mainwin->vpaned);
3029 gtk_widget_destroy(mainwin->hpaned);
3032 menu_set_sensitive(ifactory, "/View/Show or hide/Message view",
3033 (layout_mode != WIDE_MSGLIST_LAYOUT && layout_mode != SMALL_LAYOUT));
3034 switch (layout_mode) {
3035 case VERTICAL_LAYOUT:
3038 hpaned = gtk_hpaned_new();
3039 if (layout_mode == VERTICAL_LAYOUT)
3040 vpaned = gtk_hpaned_new();
3042 vpaned = gtk_vpaned_new();
3043 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
3044 gtk_paned_add1(GTK_PANED(hpaned),
3045 GTK_WIDGET_PTR(mainwin->folderview));
3046 gtk_widget_show(hpaned);
3047 gtk_widget_queue_resize(hpaned);
3049 if (messageview_is_visible(mainwin->messageview)) {
3050 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
3051 gtk_paned_add1(GTK_PANED(vpaned),
3052 GTK_WIDGET_PTR(mainwin->summaryview));
3054 gtk_paned_add2(GTK_PANED(hpaned),
3055 GTK_WIDGET_PTR(mainwin->summaryview));
3056 gtk_widget_ref(vpaned);
3058 gtk_paned_add2(GTK_PANED(vpaned),
3059 GTK_WIDGET_PTR(mainwin->messageview));
3060 gtk_widget_show(vpaned);
3061 if (layout_mode == SMALL_LAYOUT && first_set) {
3062 mainwin_paned_show_first(GTK_PANED(hpaned));
3064 gtk_widget_queue_resize(vpaned);
3067 vpaned = gtk_vpaned_new();
3068 hpaned = gtk_hpaned_new();
3069 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3070 gtk_paned_add1(GTK_PANED(vpaned), hpaned);
3072 gtk_paned_add1(GTK_PANED(hpaned),
3073 GTK_WIDGET_PTR(mainwin->folderview));
3074 gtk_paned_add2(GTK_PANED(hpaned),
3075 GTK_WIDGET_PTR(mainwin->summaryview));
3077 gtk_widget_show(hpaned);
3078 gtk_widget_queue_resize(hpaned);
3080 if (messageview_is_visible(mainwin->messageview)) {
3081 gtk_paned_add2(GTK_PANED(vpaned),
3082 GTK_WIDGET_PTR(mainwin->messageview));
3084 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3086 gtk_widget_show(vpaned);
3087 gtk_widget_queue_resize(vpaned);
3089 case WIDE_MSGLIST_LAYOUT:
3090 vpaned = gtk_vpaned_new();
3091 hpaned = gtk_hpaned_new();
3092 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3094 gtk_paned_add1(GTK_PANED(vpaned),
3095 GTK_WIDGET_PTR(mainwin->summaryview));
3096 gtk_paned_add1(GTK_PANED(hpaned),
3097 GTK_WIDGET_PTR(mainwin->folderview));
3099 gtk_widget_show(hpaned);
3100 gtk_widget_queue_resize(hpaned);
3102 if (messageview_is_visible(mainwin->messageview)) {
3103 gtk_paned_add2(GTK_PANED(hpaned),
3104 GTK_WIDGET_PTR(mainwin->messageview));
3106 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3108 gtk_paned_add2(GTK_PANED(vpaned), hpaned);
3110 gtk_widget_show(vpaned);
3111 gtk_widget_queue_resize(vpaned);
3114 g_warning("Unknown layout");
3118 mainwin->hpaned = hpaned;
3119 mainwin->vpaned = vpaned;
3121 if (layout_mode == SMALL_LAYOUT) {
3122 if (mainwin->messageview->visible)
3123 main_window_toggle_message_view(mainwin);
3126 if (layout_mode == SMALL_LAYOUT && first_set) {
3127 gtk_widget_realize(mainwin->window);
3128 gtk_widget_realize(mainwin->folderview->ctree);
3129 gtk_widget_realize(mainwin->summaryview->hbox);
3130 gtk_widget_realize(mainwin->summaryview->hbox_l);
3131 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3132 prefs_common.folderview_width,
3133 prefs_common.folderview_height);
3134 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3136 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3138 gtk_widget_set_size_request(GTK_WIDGET(mainwin->window),
3139 prefs_common.mainwin_width,
3140 prefs_common.mainwin_height);
3141 gtk_paned_set_position(GTK_PANED(mainwin->hpaned), 800);
3143 /* remove headerview if not in prefs */
3144 headerview_set_visibility(mainwin->messageview->headerview,
3145 prefs_common.display_header_pane);
3147 if (messageview_is_visible(mainwin->messageview))
3148 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3149 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
3151 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3152 GTK_ARROW_UP, GTK_SHADOW_OUT);
3154 gtk_window_move(GTK_WINDOW(mainwin->window),
3155 prefs_common.mainwin_x,
3156 prefs_common.mainwin_y);
3158 gtk_widget_queue_resize(vbox_body);
3159 gtk_widget_queue_resize(mainwin->vbox);
3160 gtk_widget_queue_resize(mainwin->window);
3161 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
3162 * and mimeview icon list/ctree lose track of their visibility states */
3163 if (!noticeview_is_visible(mainwin->messageview->noticeview))
3164 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
3165 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
3166 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
3167 if (mainwin->messageview->mimeview->ctree_mode)
3168 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
3170 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
3172 prefs_common.layout_mode = layout_mode;
3174 menuitem = gtk_item_factory_get_item
3175 (ifactory, "/View/Show or hide/Message view");
3176 gtk_check_menu_item_set_active
3177 (GTK_CHECK_MENU_ITEM(menuitem),
3178 messageview_is_visible(mainwin->messageview));
3180 #define SET_CHECK_MENU_ACTIVE(path, active) \
3182 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3183 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \