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_statusbar_cb (MainWindow *mainwin,
193 static void set_layout_cb (MainWindow *mainwin,
197 static void addressbook_open_cb (MainWindow *mainwin,
200 static void log_window_show_cb (MainWindow *mainwin,
203 static void filtering_debug_window_show_cb (MainWindow *mainwin,
207 static void inc_cancel_cb (MainWindow *mainwin,
211 static void open_msg_cb (MainWindow *mainwin,
215 static void view_source_cb (MainWindow *mainwin,
219 static void show_all_header_cb (MainWindow *mainwin,
223 static void hide_quotes_cb(MainWindow *mainwin,
227 static void move_to_cb (MainWindow *mainwin,
230 static void copy_to_cb (MainWindow *mainwin,
233 static void delete_cb (MainWindow *mainwin,
236 static void delete_trash_cb (MainWindow *mainwin,
240 static void cancel_cb (MainWindow *mainwin,
244 static void mark_cb (MainWindow *mainwin,
247 static void unmark_cb (MainWindow *mainwin,
251 static void mark_as_unread_cb (MainWindow *mainwin,
254 static void mark_as_read_cb (MainWindow *mainwin,
257 static void mark_all_read_cb (MainWindow *mainwin,
260 static void mark_as_spam_cb (MainWindow *mainwin,
264 static void ignore_thread_cb (MainWindow *mainwin,
267 static void unignore_thread_cb (MainWindow *mainwin,
270 static void lock_msgs_cb (MainWindow *mainwin,
273 static void unlock_msgs_cb (MainWindow *mainwin,
277 static void reedit_cb (MainWindow *mainwin,
281 static void add_address_cb (MainWindow *mainwin,
285 static void set_charset_cb (MainWindow *mainwin,
289 static void set_decode_cb (MainWindow *mainwin,
293 static void hide_read_messages (MainWindow *mainwin,
297 static void thread_cb (MainWindow *mainwin,
300 static void expand_threads_cb (MainWindow *mainwin,
303 static void collapse_threads_cb (MainWindow *mainwin,
307 static void set_summary_display_item_cb (MainWindow *mainwin,
310 static void set_folder_display_item_cb (MainWindow *mainwin,
313 static void sort_summary_cb (MainWindow *mainwin,
316 static void sort_summary_type_cb (MainWindow *mainwin,
319 static void attract_by_subject_cb(MainWindow *mainwin,
323 static void delete_duplicated_cb (MainWindow *mainwin,
326 static void delete_duplicated_all_cb (MainWindow *mainwin,
329 static void filter_cb (MainWindow *mainwin,
332 static void execute_summary_cb (MainWindow *mainwin,
335 static void update_summary_cb (MainWindow *mainwin,
339 static void prev_cb (MainWindow *mainwin,
342 static void next_cb (MainWindow *mainwin,
345 static void next_unread_cb (MainWindow *mainwin,
348 static void prev_unread_cb (MainWindow *mainwin,
352 static void prev_new_cb (MainWindow *mainwin,
355 static void next_new_cb (MainWindow *mainwin,
358 static void prev_marked_cb (MainWindow *mainwin,
361 static void next_marked_cb (MainWindow *mainwin,
364 static void prev_labeled_cb (MainWindow *mainwin,
367 static void next_labeled_cb (MainWindow *mainwin,
370 static void last_read_cb (MainWindow *mainwin,
373 static void parent_cb (MainWindow *mainwin,
377 static void goto_folder_cb (MainWindow *mainwin,
380 static void goto_unread_folder_cb(MainWindow *mainwin,
384 static void copy_cb (MainWindow *mainwin,
387 static void allsel_cb (MainWindow *mainwin,
390 static void select_thread_cb (MainWindow *mainwin,
393 static void delete_thread_cb (MainWindow *mainwin,
397 static void create_filter_cb (MainWindow *mainwin,
400 static void create_processing_cb (MainWindow *mainwin,
403 static void open_urls_cb (MainWindow *mainwin,
407 static void prefs_template_open_cb (MainWindow *mainwin,
410 static void prefs_actions_open_cb (MainWindow *mainwin,
413 static void prefs_tags_open_cb (MainWindow *mainwin,
416 static void prefs_account_open_cb (MainWindow *mainwin,
420 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
424 static void prefs_post_processing_open_cb (MainWindow *mainwin,
428 static void prefs_filtering_open_cb (MainWindow *mainwin,
432 static void ssl_manager_open_cb (MainWindow *mainwin,
436 static void new_account_cb (MainWindow *mainwin,
440 static void account_selector_menu_cb (GtkMenuItem *menuitem,
442 static void account_receive_menu_cb (GtkMenuItem *menuitem,
444 static void account_compose_menu_cb (GtkMenuItem *menuitem,
447 static void prefs_open_cb (GtkMenuItem *menuitem,
449 static void plugins_open_cb (GtkMenuItem *menuitem,
452 static void online_switch_clicked(GtkButton *btn,
455 static void manual_open_cb (MainWindow *mainwin,
459 static void legend_open_cb (GtkMenuItem *menuitem,
462 static void scan_tree_func (Folder *folder,
466 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
468 static void addr_harvest_cb ( MainWindow *mainwin,
472 static void addr_harvest_msg_cb ( MainWindow *mainwin,
475 static void sync_cb ( MainWindow *mainwin,
479 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
480 GdkEventFocus *focus,
482 static gboolean mainwindow_visibility_event_cb (GtkWidget *widget,
483 GdkEventVisibility *state,
485 static gboolean mainwindow_state_event_cb (GtkWidget *widget,
486 GdkEventWindowState *state,
488 static void main_window_reply_cb (MainWindow *mainwin,
491 static gboolean mainwindow_progressindicator_hook (gpointer source,
494 static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
497 static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
499 static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
501 static void mailing_list_compose(GtkWidget *w, gpointer *data);
503 static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
504 #define SEPARATE_ACTION 500
505 static void mainwindow_quicksearch (MainWindow *mainwin,
508 static gboolean any_folder_want_synchronise(void);
510 static GtkItemFactoryEntry mainwin_entries[] =
512 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
513 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
514 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
515 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
516 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
517 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
518 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
519 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
520 {N_("/_File/Exp_ort selected to mbox file..."),
521 NULL, export_list_mbox_cb, 0, NULL},
522 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
523 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
524 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
525 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
526 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
527 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
528 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
529 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
530 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
531 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
532 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
534 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
535 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
536 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
537 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
538 {N_("/_Edit/_Delete thread"), NULL, delete_thread_cb, 0, NULL},
539 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
540 {N_("/_Edit/_Find in current message..."),
541 "<control>F", search_cb, 0, NULL},
542 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
543 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
544 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
545 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
546 {N_("/_View/Show or hi_de/_Message view"),
547 "V", toggle_message_cb, 0, "<ToggleItem>"},
548 {N_("/_View/Show or hi_de/_Toolbar"),
549 NULL, NULL, 0, "<Branch>"},
550 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
551 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
552 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
553 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
554 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
555 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
556 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
557 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
558 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
559 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
560 {N_("/_View/Show or hi_de/Status _bar"),
561 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
562 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
563 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
564 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
566 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
567 {N_("/_View/La_yout"), NULL, NULL, 0, "<Branch>"},
568 {N_("/_View/Layout/_Standard"), NULL, set_layout_cb, NORMAL_LAYOUT, "<RadioItem>"},
569 {N_("/_View/Layout/_Three columns"), NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
570 {N_("/_View/Layout/_Wide message"), NULL, set_layout_cb, WIDE_LAYOUT, "/View/Layout/Standard"},
571 {N_("/_View/Layout/W_ide message list"),NULL, set_layout_cb, WIDE_MSGLIST_LAYOUT, "/View/Layout/Standard"},
572 {N_("/_View/Layout/S_mall screen"), NULL, set_layout_cb, SMALL_LAYOUT, "/View/Layout/Standard"},
573 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
574 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
575 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
576 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
577 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
578 {N_("/_View/_Sort/by Thread date"), NULL, sort_summary_cb, SORT_BY_THREAD_DATE, "/View/Sort/by number"},
579 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
580 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
581 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
582 {N_("/_View/_Sort/by _color label"), NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
583 {N_("/_View/_Sort/by tag"), NULL, sort_summary_cb, SORT_BY_TAGS, "/View/Sort/by number"},
584 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
585 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
586 {N_("/_View/_Sort/by a_ttachment"),
587 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
588 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
589 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
590 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
591 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
592 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
593 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
594 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
595 {N_("/_View/_Sort/_Attract by subject"),
596 NULL, attract_by_subject_cb, 0, NULL},
597 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
598 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
599 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
600 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
602 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
603 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
604 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
605 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
606 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
607 {N_("/_View/_Go to/P_revious unread message"),
608 "<shift>P", prev_unread_cb, 0, NULL},
609 {N_("/_View/_Go to/N_ext unread message"),
610 "<shift>N", next_unread_cb, 0, NULL},
611 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
612 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
613 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
614 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
615 {N_("/_View/_Go to/Previous _marked message"),
616 NULL, prev_marked_cb, 0, NULL},
617 {N_("/_View/_Go to/Next m_arked message"),
618 NULL, next_marked_cb, 0, NULL},
619 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
620 {N_("/_View/_Go to/Previous _labeled message"),
621 NULL, prev_labeled_cb, 0, NULL},
622 {N_("/_View/_Go to/Next la_beled message"),
623 NULL, next_labeled_cb, 0, NULL},
624 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
625 {N_("/_View/_Go to/Last read message"),
626 NULL, last_read_cb, 0, NULL},
627 {N_("/_View/_Go to/Parent message"),
628 "<control>Up", parent_cb, 0, NULL},
629 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
630 {N_("/_View/_Go to/Next unread _folder"), "<shift>G", goto_unread_folder_cb, 0, NULL},
631 {N_("/_View/_Go to/_Other folder..."), "G", goto_folder_cb, 0, NULL},
632 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
634 #define ENC_SEPARATOR \
635 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
636 #define ENC_ACTION(action) \
637 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
639 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
640 {N_("/_View/Character _encoding/_Auto detect"),
641 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
642 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
643 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
644 ENC_ACTION(C_US_ASCII)},
645 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
646 ENC_ACTION(C_UTF_8)},
649 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
650 ENC_ACTION(C_ISO_8859_1)},
651 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
652 ENC_ACTION(C_ISO_8859_15)},
653 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
654 ENC_ACTION(C_WINDOWS_1252)},
657 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
658 ENC_ACTION(C_ISO_8859_2)},
661 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
662 ENC_ACTION(C_ISO_8859_13)},
663 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
664 ENC_ACTION(C_ISO_8859_4)},
667 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
668 ENC_ACTION(C_ISO_8859_7)},
671 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
672 ENC_ACTION(C_ISO_8859_8)},
673 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
674 ENC_ACTION(C_CP1255)},
677 {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"),
678 ENC_ACTION(C_ISO_8859_6)},
679 {N_("/_View/Character _encoding/Arabic (Windows-1256)"),
680 ENC_ACTION(C_CP1256)},
683 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
684 ENC_ACTION(C_ISO_8859_9)},
687 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
688 ENC_ACTION(C_ISO_8859_5)},
689 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
690 ENC_ACTION(C_KOI8_R)},
691 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
692 ENC_ACTION(C_KOI8_U)},
693 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
694 ENC_ACTION(C_CP1251)},
697 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
698 ENC_ACTION(C_ISO_2022_JP)},
699 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
700 ENC_ACTION(C_ISO_2022_JP_2)},
701 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
702 ENC_ACTION(C_EUC_JP)},
703 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
704 ENC_ACTION(C_SHIFT_JIS)},
707 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
708 ENC_ACTION(C_GB2312)},
709 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
711 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
713 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
714 ENC_ACTION(C_EUC_TW)},
715 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
716 ENC_ACTION(C_ISO_2022_CN)},
719 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
720 ENC_ACTION(C_EUC_KR)},
721 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
722 ENC_ACTION(C_ISO_2022_KR)},
725 {N_("/_View/Character _encoding/Thai (TIS-620)"),
726 ENC_ACTION(C_TIS_620)},
727 {N_("/_View/Character _encoding/Thai (Windows-874)"),
728 ENC_ACTION(C_WINDOWS_874)},
733 #define DEC_SEPARATOR \
734 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
735 #define DEC_ACTION(action) \
736 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
737 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
738 {N_("/_View/Decode/_Auto detect"),
739 NULL, set_decode_cb, 0, "<RadioItem>"},
740 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
741 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
742 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
743 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
744 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
749 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
750 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
751 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
752 {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
753 {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
754 {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
755 {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
756 {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
757 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
758 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
760 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
761 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
762 {N_("/_Message/Recei_ve/Get from _current account"),
763 "<control>I", inc_mail_cb, 0, NULL},
764 {N_("/_Message/Recei_ve/Get from _all accounts"),
765 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
766 {N_("/_Message/Recei_ve/Cancel receivin_g"),
767 NULL, inc_cancel_cb, 0, NULL},
768 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
769 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
770 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
771 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
772 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
773 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
774 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
775 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
776 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
777 {N_("/_Message/Repl_y to/mailing _list"),
778 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
779 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
780 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
781 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
782 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
783 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
785 {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
786 {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
787 {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
788 {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
789 {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
790 {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
791 {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
793 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
794 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
795 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
796 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
797 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
798 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
799 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
800 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
801 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
802 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
803 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
804 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
805 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
806 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
807 {N_("/_Message/_Mark/Ignore thread"), NULL, ignore_thread_cb, 0, NULL},
808 {N_("/_Message/_Mark/Unignore thread"), NULL, unignore_thread_cb, 0, NULL},
809 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
810 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
811 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
812 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
813 {N_("/_Message/_Mark/Lock"), NULL, lock_msgs_cb, 0, NULL},
814 {N_("/_Message/_Mark/Unlock"), NULL, unlock_msgs_cb, 0, NULL},
815 {N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
816 {N_("/_Message/T_ags"), NULL, NULL, 0, NULL},
817 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
818 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
820 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
821 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
822 {N_("/_Tools/Add sender to address boo_k"),
823 NULL, add_address_cb, 0, NULL},
824 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
825 {N_("/_Tools/_Harvest addresses/from _Folder..."),
826 NULL, addr_harvest_cb, 0, NULL},
827 {N_("/_Tools/_Harvest addresses/from _Messages..."),
828 NULL, addr_harvest_msg_cb, 0, NULL},
829 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
830 {N_("/_Tools/_Filter all messages in folder"),
831 NULL, filter_cb, 0, NULL},
832 {N_("/_Tools/Filter _selected messages"),
833 NULL, filter_cb, 1, NULL},
834 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
835 {N_("/_Tools/_Create filter rule/_Automatically"),
836 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
837 {N_("/_Tools/_Create filter rule/by _From"),
838 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
839 {N_("/_Tools/_Create filter rule/by _To"),
840 NULL, create_filter_cb, FILTER_BY_TO, NULL},
841 {N_("/_Tools/_Create filter rule/by _Subject"),
842 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
843 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
844 {N_("/_Tools/C_reate processing rule/_Automatically"),
845 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
846 {N_("/_Tools/C_reate processing rule/by _From"),
847 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
848 {N_("/_Tools/C_reate processing rule/by _To"),
849 NULL, create_processing_cb, FILTER_BY_TO, NULL},
850 {N_("/_Tools/C_reate processing rule/by _Subject"),
851 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
852 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
853 {N_("/_Tools/List _URLs..."), "<shift><control>U", open_urls_cb, 0, NULL},
854 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
855 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
856 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
857 {N_("/_Tools/Ch_eck for new messages in all folders"),
858 NULL, update_folderview_cb, 0, NULL},
859 {N_("/_Tools/Delete du_plicated messages"),
860 NULL, NULL, 0, "<Branch>"},
861 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
862 NULL, delete_duplicated_cb, 0, NULL},
863 {N_("/_Tools/Delete du_plicated messages/In all folders"),
864 NULL, delete_duplicated_all_cb, 0, NULL},
865 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
866 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
868 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
869 {N_("/_Tools/SSL cer_tificates..."),
870 NULL, ssl_manager_open_cb, 0, NULL},
872 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
873 {N_("/_Tools/Filtering Log"), NULL, filtering_debug_window_show_cb, 0, NULL},
874 {N_("/_Tools/Network _Log"), "<shift><control>L", log_window_show_cb, 0, NULL},
876 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
877 {N_("/_Configuration/C_hange current account"),
878 NULL, NULL, 0, "<Branch>"},
879 {N_("/_Configuration/_Preferences for current account..."),
880 NULL, prefs_account_open_cb, 0, NULL},
881 {N_("/_Configuration/Create _new account..."),
882 NULL, new_account_cb, 0, NULL},
883 {N_("/_Configuration/_Edit accounts..."),
884 NULL, account_edit_open, 0, NULL},
885 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
886 {N_("/_Configuration/P_references..."),
887 NULL, prefs_open_cb, 0, NULL},
888 {N_("/_Configuration/Pre-pr_ocessing..."),
889 NULL, prefs_pre_processing_open_cb, 0, NULL},
890 {N_("/_Configuration/Post-pro_cessing..."),
891 NULL, prefs_post_processing_open_cb, 0, NULL},
892 {N_("/_Configuration/_Filtering..."),
893 NULL, prefs_filtering_open_cb, 0, NULL},
894 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
895 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
896 {N_("/_Configuration/Tag_s..."), NULL, prefs_tags_open_cb, 0, NULL},
897 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
898 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
900 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
901 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_LOCAL, NULL},
902 {N_("/_Help/_Online User-contributed FAQ"),
903 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
904 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
905 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
906 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
909 static gboolean offline_ask_sync = TRUE;
910 static guint lastkey;
911 static gboolean is_obscured = FALSE;
913 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
919 MainWindow *mainwin = (MainWindow *)user_data;
921 if (mainwin->summaryview &&
922 mainwin->summaryview->quicksearch &&
923 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
924 (mod == 0 || mod == GDK_SHIFT_MASK)) {
925 quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
931 #define N_COLOR_LABELS colorlabel_get_color_count()
933 static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
938 GtkCheckMenuItem **items;
943 mainwin = (MainWindow *)data;
944 g_return_if_fail(mainwin != NULL);
946 sel = summary_get_selection(mainwin->summaryview);
949 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
950 g_return_if_fail(menu != NULL);
952 Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
954 /* NOTE: don't return prematurely because we set the "dont_toggle"
955 * state for check menu items */
956 g_object_set_data(G_OBJECT(menu), "dont_toggle",
959 /* clear items. get item pointers. */
960 for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
961 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
962 gtk_check_menu_item_set_active
963 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
964 items[n] = GTK_CHECK_MENU_ITEM(cur->data);
969 if (n == (N_COLOR_LABELS + 1)) {
970 /* iterate all messages and set the state of the appropriate
972 for (; sel != NULL; sel = sel->next) {
976 msginfo = (MsgInfo *)sel->data;
978 clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
979 if (!items[clabel]->active)
980 gtk_check_menu_item_set_active
981 (items[clabel], TRUE);
985 g_warning("invalid number of color elements (%d)\n", n);
988 /* reset "dont_toggle" state */
989 g_object_set_data(G_OBJECT(menu), "dont_toggle",
993 static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
996 guint color = GPOINTER_TO_UINT(data);
999 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1000 g_return_if_fail(mainwin != NULL);
1002 /* "dont_toggle" state set? */
1003 if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
1007 summary_set_colorlabel(mainwin->summaryview, color, NULL);
1010 static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
1013 MainWindow *mainwin;
1017 GHashTable *menu_table = g_hash_table_new_full(
1022 mainwin = (MainWindow *)data;
1023 g_return_if_fail(mainwin != NULL);
1025 sel = summary_get_selection(mainwin->summaryview);
1028 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1029 g_return_if_fail(menu != NULL);
1031 /* NOTE: don't return prematurely because we set the "dont_toggle"
1032 * state for check menu items */
1033 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1034 GINT_TO_POINTER(1));
1036 /* clear items. get item pointers. */
1037 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1038 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
1039 gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
1041 gtk_check_menu_item_set_active
1042 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
1044 g_hash_table_insert(menu_table, GINT_TO_POINTER(id), GTK_CHECK_MENU_ITEM(cur->data));
1048 /* iterate all messages and set the state of the appropriate
1050 for (; sel != NULL; sel = sel->next) {
1052 GSList *tags = NULL;
1054 GtkCheckMenuItem *item;
1055 msginfo = (MsgInfo *)sel->data;
1057 tags = msginfo->tags;
1061 for (; tags; tags = tags->next) {
1062 id = GPOINTER_TO_INT(tags->data);
1063 item = g_hash_table_lookup(menu_table, GINT_TO_POINTER(tags->data));
1064 if (item && !item->active)
1065 gtk_check_menu_item_set_active
1072 g_hash_table_destroy(menu_table);
1073 /* reset "dont_toggle" state */
1074 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1075 GINT_TO_POINTER(0));
1078 static void mainwindow_tags_menu_item_activate_cb(GtkWidget *widget,
1081 gint id = GPOINTER_TO_INT(data);
1082 gboolean set = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
1083 MainWindow *mainwin;
1085 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1086 g_return_if_fail(mainwin != NULL);
1088 /* "dont_toggle" state set? */
1089 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1095 summary_set_tag(mainwin->summaryview, id, NULL);
1098 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
1100 GtkWidget *label_menuitem;
1105 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1106 "/Message/Color label");
1107 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1108 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_item_cb),
1110 gtk_widget_show(label_menuitem);
1112 menu = gtk_menu_new();
1114 /* create sub items. for the menu item activation callback we pass the
1115 * index of label_colors[] as data parameter. for the None color we
1116 * pass an invalid (high) value. also we attach a data pointer so we
1117 * can always get back the Mainwindow pointer. */
1119 item = gtk_check_menu_item_new_with_label(_("None"));
1120 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1121 g_signal_connect(G_OBJECT(item), "activate",
1122 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1123 GUINT_TO_POINTER(0));
1124 g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
1125 gtk_widget_show(item);
1127 gtk_widget_add_accelerator(item, "activate",
1128 mainwin->menu_factory->accel_group,
1129 GDK_0, GDK_CONTROL_MASK,
1130 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1132 item = gtk_menu_item_new();
1133 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1134 gtk_widget_show(item);
1136 /* create pixmap/label menu items */
1137 for (i = 0; i < N_COLOR_LABELS; i++) {
1138 item = colorlabel_create_check_color_menu_item(
1139 i, refresh, MAINWIN_COLORMENU);
1140 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1141 g_signal_connect(G_OBJECT(item), "activate",
1142 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1143 GUINT_TO_POINTER(i + 1));
1144 g_object_set_data(G_OBJECT(item), "mainwin",
1146 gtk_widget_show(item);
1148 gtk_widget_add_accelerator(item, "activate",
1149 mainwin->menu_factory->accel_group,
1150 GDK_1+i, GDK_CONTROL_MASK,
1151 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1153 gtk_widget_show(menu);
1154 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1155 mainwin->colorlabel_menu = menu;
1158 static void mainwindow_tags_menu_item_new_tag_activate_cb(GtkWidget *widget,
1161 MainWindow *mainwin;
1163 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1164 g_return_if_fail(mainwin != NULL);
1166 /* "dont_toggle" state set? */
1167 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1171 id = prefs_tags_create_new(mainwin);
1173 summary_set_tag(mainwin->summaryview, id, NULL);
1174 main_window_reflect_tags_changes(mainwindow_get_mainwindow());
1178 static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
1180 GtkWidget *label_menuitem;
1183 GSList *cur = tags_get_list();
1185 gboolean existing_tags = FALSE;
1187 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1189 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1190 G_CALLBACK(mainwindow_tags_menu_item_activate_item_cb),
1193 gtk_widget_show(label_menuitem);
1195 menu = gtk_menu_new();
1197 /* create tags menu items */
1198 for (; cur; cur = cur->next) {
1199 gint id = GPOINTER_TO_INT(cur->data);
1200 const gchar *tag = tags_get_tag(id);
1202 item = gtk_check_menu_item_new_with_label(tag);
1203 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1204 g_signal_connect(G_OBJECT(item), "activate",
1205 G_CALLBACK(mainwindow_tags_menu_item_activate_cb),
1206 GINT_TO_POINTER(id));
1207 g_object_set_data(G_OBJECT(item), "mainwin",
1209 g_object_set_data(G_OBJECT(item), "tag_id",
1210 GINT_TO_POINTER(id));
1211 gtk_widget_show(item);
1212 existing_tags = TRUE;
1214 if (existing_tags) {
1216 item = gtk_menu_item_new();
1217 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1218 gtk_widget_show(item);
1220 item = gtk_menu_item_new_with_label(_("New tag..."));
1221 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1222 g_signal_connect(G_OBJECT(item), "activate",
1223 G_CALLBACK(mainwindow_tags_menu_item_new_tag_activate_cb),
1225 g_object_set_data(G_OBJECT(item), "mainwin",
1227 gtk_widget_show(item);
1229 gtk_widget_show(menu);
1230 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1231 mainwin->tags_menu = menu;
1234 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
1235 MainWindow *mainwindow)
1237 if (evt && evt->button == 1) {
1238 log_window_show_error(mainwindow->logwin);
1239 gtk_widget_hide(mainwindow->warning_btn);
1244 static gboolean warning_visi_notify(GtkWidget *widget,
1245 GdkEventVisibility *event,
1246 MainWindow *mainwindow)
1248 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1252 static gboolean warning_leave_notify(GtkWidget *widget,
1253 GdkEventCrossing *event,
1254 MainWindow *mainwindow)
1256 gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
1260 static gboolean warning_enter_notify(GtkWidget *widget,
1261 GdkEventCrossing *event,
1262 MainWindow *mainwindow)
1264 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1268 void mainwindow_show_error(void)
1270 MainWindow *mainwin = mainwindow_get_mainwindow();
1271 gtk_widget_show(mainwin->warning_btn);
1274 void mainwindow_clear_error(MainWindow *mainwin)
1276 gtk_widget_hide(mainwin->warning_btn);
1279 MainWindow *main_window_create()
1281 MainWindow *mainwin;
1285 GtkWidget *handlebox;
1286 GtkWidget *vbox_body;
1287 GtkWidget *hbox_stat;
1288 GtkWidget *statusbar;
1289 GtkWidget *progressbar;
1290 GtkWidget *statuslabel;
1291 GtkWidget *ac_button;
1292 GtkWidget *ac_label;
1293 GtkWidget *online_pixmap;
1294 GtkWidget *offline_pixmap;
1295 GtkWidget *online_switch;
1296 GtkWidget *offline_switch;
1298 GtkWidget *warning_icon;
1299 GtkWidget *warning_btn;
1301 FolderView *folderview;
1302 SummaryView *summaryview;
1303 MessageView *messageview;
1304 GdkColormap *colormap;
1306 gboolean success[4];
1307 GtkItemFactory *ifactory;
1309 GtkWidget *menuitem;
1311 guint n_menu_entries;
1313 static GdkGeometry geometry;
1315 debug_print("Creating main window...\n");
1316 mainwin = g_new0(MainWindow, 1);
1319 window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow");
1320 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1321 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1323 if (!geometry.min_height) {
1324 geometry.min_width = 320;
1325 geometry.min_height = 200;
1327 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1330 g_signal_connect(G_OBJECT(window), "delete_event",
1331 G_CALLBACK(main_window_close_cb), mainwin);
1332 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1333 g_signal_connect(G_OBJECT(window), "focus_in_event",
1334 G_CALLBACK(mainwindow_focus_in_event),
1336 g_signal_connect(G_OBJECT(window), "key_press_event",
1337 G_CALLBACK(mainwindow_key_pressed), mainwin);
1339 gtk_widget_realize(window);
1340 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1343 gtkut_widget_set_app_icon(window);
1345 vbox = gtk_vbox_new(FALSE, 0);
1346 gtk_widget_show(vbox);
1347 gtk_container_add(GTK_CONTAINER(window), vbox);
1350 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1351 menubar = menubar_create(window, mainwin_entries,
1352 n_menu_entries, "<Main>", mainwin);
1353 gtk_widget_show(menubar);
1356 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1359 ifactory = gtk_item_factory_from_widget(menubar);
1361 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1362 main_create_mailing_list_menu (mainwin, NULL); */
1364 menu_set_sensitive(ifactory, "/Help/Manual", manual_available(MANUAL_MANUAL_LOCAL));
1366 if (prefs_common.toolbar_detachable) {
1367 handlebox = gtk_handle_box_new();
1368 gtk_widget_show(handlebox);
1369 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1370 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1371 G_CALLBACK(toolbar_child_attached), mainwin);
1372 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1373 G_CALLBACK(toolbar_child_detached), mainwin);
1375 handlebox = gtk_hbox_new(FALSE, 0);
1376 gtk_widget_show(handlebox);
1377 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1379 /* link window to mainwin->window to avoid gdk warnings */
1380 mainwin->window = window;
1381 mainwin_list = g_list_append(mainwin_list, mainwin);
1384 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1388 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1392 toolbar_set_learn_button
1396 /* vbox that contains body */
1397 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1398 gtk_widget_show(vbox_body);
1399 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1400 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1402 hbox_stat = gtk_hbox_new(FALSE, 2);
1403 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1405 tips = gtk_tooltips_new();
1407 warning_icon = gtk_image_new_from_stock
1408 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1409 warning_btn = gtk_event_box_new();
1410 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1412 mainwin->warning_btn = warning_btn;
1414 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1415 G_CALLBACK(warning_icon_pressed),
1416 (gpointer) mainwin);
1417 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1418 G_CALLBACK(warning_visi_notify), mainwin);
1419 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1420 G_CALLBACK(warning_visi_notify), mainwin);
1421 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1422 G_CALLBACK(warning_leave_notify), mainwin);
1423 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1424 G_CALLBACK(warning_enter_notify), mainwin);
1426 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1428 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1429 _("Some error(s) happened. Click here to view log."), NULL);
1430 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1432 statusbar = statusbar_create();
1433 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1436 progressbar = gtk_progress_bar_new();
1437 gtk_widget_set_size_request(progressbar, 120, 1);
1438 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1440 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1441 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1442 online_switch = gtk_button_new ();
1443 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1444 _("You are online. Click the icon to go offline"), NULL);
1445 offline_switch = gtk_button_new ();
1446 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1447 _("You are offline. Click the icon to go online"),
1449 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1450 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1451 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1452 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1453 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1454 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1455 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1456 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1458 statuslabel = gtk_label_new("");
1459 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1461 ac_button = gtk_button_new();
1462 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1463 ac_button, _("Select account"), NULL);
1464 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1465 gtk_widget_set_size_request(ac_button, -1, 0);
1466 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1467 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1468 G_CALLBACK(ac_label_button_pressed), mainwin);
1470 ac_label = gtk_label_new("");
1471 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1473 gtk_widget_show_all(hbox_stat);
1475 gtk_widget_hide(offline_switch);
1476 gtk_widget_hide(warning_btn);
1479 mainwin->folderview = folderview = folderview_create();
1480 mainwin->summaryview = summaryview = summary_create();
1481 mainwin->messageview = messageview = messageview_create(mainwin);
1483 /* init log instances data before creating log views */
1484 set_log_title(LOG_PROTOCOL, _("Network log"));
1485 set_log_prefs(LOG_PROTOCOL,
1486 &prefs_common.logwin_width,
1487 &prefs_common.logwin_height);
1488 set_log_title(LOG_DEBUG_FILTERING, _("Filtering/processing debug log"));
1489 set_log_prefs(LOG_DEBUG_FILTERING,
1490 &prefs_common.filtering_debugwin_width,
1491 &prefs_common.filtering_debugwin_height);
1493 /* setup log windows */
1494 mainwin->logwin = log_window_create(LOG_PROTOCOL);
1495 log_window_init(mainwin->logwin);
1497 mainwin->filtering_debugwin = log_window_create(LOG_DEBUG_FILTERING);
1498 log_window_set_clipping(mainwin->logwin,
1499 prefs_common.cliplog,
1500 prefs_common.loglength);
1502 log_window_init(mainwin->filtering_debugwin);
1503 log_window_set_clipping(mainwin->filtering_debugwin,
1504 prefs_common.filtering_debug_cliplog,
1505 prefs_common.filtering_debug_loglength);
1506 if (prefs_common.enable_filtering_debug)
1507 log_message(LOG_DEBUG_FILTERING, _("filtering log enabled\n"));
1509 log_message(LOG_DEBUG_FILTERING, _("filtering log disabled\n"));
1511 folderview->mainwin = mainwin;
1512 folderview->summaryview = summaryview;
1514 summaryview->mainwin = mainwin;
1515 summaryview->folderview = folderview;
1516 summaryview->messageview = messageview;
1517 summaryview->window = window;
1519 messageview->statusbar = statusbar;
1520 mainwin->vbox = vbox;
1521 mainwin->menubar = menubar;
1522 mainwin->menu_factory = ifactory;
1523 mainwin->handlebox = handlebox;
1524 mainwin->vbox_body = vbox_body;
1525 mainwin->hbox_stat = hbox_stat;
1526 mainwin->statusbar = statusbar;
1528 mainwin->progressbar = progressbar;
1530 mainwin->statuslabel = statuslabel;
1531 mainwin->online_switch = online_switch;
1532 mainwin->online_pixmap = online_pixmap;
1533 mainwin->offline_pixmap = offline_pixmap;
1534 mainwin->ac_button = ac_button;
1535 mainwin->ac_label = ac_label;
1536 mainwin->offline_switch = offline_switch;
1538 /* set context IDs for status bar */
1539 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1540 (GTK_STATUSBAR(statusbar), "Main Window");
1541 mainwin->folderview_cid = gtk_statusbar_get_context_id
1542 (GTK_STATUSBAR(statusbar), "Folder View");
1543 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1544 (GTK_STATUSBAR(statusbar), "Summary View");
1545 mainwin->messageview_cid = gtk_statusbar_get_context_id
1546 (GTK_STATUSBAR(statusbar), "Message View");
1548 messageview->statusbar_cid = mainwin->messageview_cid;
1550 /* allocate colors for summary view and folder view */
1551 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1552 summaryview->color_marked.blue = (guint16)65535;
1554 summaryview->color_dim.red = summaryview->color_dim.green =
1555 summaryview->color_dim.blue = COLOR_DIM;
1557 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1558 &folderview->color_new);
1560 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1561 &folderview->color_op);
1563 summaryview->color_important.red = 0;
1564 summaryview->color_important.green = 0;
1565 summaryview->color_important.blue = (guint16)65535;
1567 color[0] = summaryview->color_marked;
1568 color[1] = summaryview->color_dim;
1569 color[2] = folderview->color_new;
1570 color[3] = folderview->color_op;
1572 colormap = gdk_drawable_get_colormap(window->window);
1573 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1574 for (i = 0; i < 4; i++) {
1575 if (success[i] == FALSE)
1576 g_warning("MainWindow: color allocation %d failed\n", i);
1579 debug_print("done.\n");
1581 messageview->visible = prefs_common.msgview_visible;
1583 main_window_set_widgets(mainwin, prefs_common.layout_mode);
1585 g_signal_connect(G_OBJECT(window), "size_allocate",
1586 G_CALLBACK(main_window_size_allocate_cb),
1589 /* set menu items */
1590 menuitem = gtk_item_factory_get_item
1591 (ifactory, "/View/Character encoding/Auto detect");
1592 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1594 switch (prefs_common.toolbar_style) {
1596 menuitem = gtk_item_factory_get_item
1597 (ifactory, "/View/Show or hide/Toolbar/Hide");
1600 menuitem = gtk_item_factory_get_item
1601 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1604 menuitem = gtk_item_factory_get_item
1605 (ifactory, "/View/Show or hide/Toolbar/Text only");
1608 menuitem = gtk_item_factory_get_item
1609 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1611 case TOOLBAR_BOTH_HORIZ:
1612 menuitem = gtk_item_factory_get_item
1614 "/View/Show or hide/Toolbar/Text beside icons");
1616 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1618 gtk_widget_hide(mainwin->hbox_stat);
1619 menuitem = gtk_item_factory_get_item
1620 (ifactory, "/View/Show or hide/Status bar");
1621 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1622 prefs_common.show_statusbar);
1624 /* set account selection menu */
1625 ac_menu = gtk_item_factory_get_widget
1626 (ifactory, "/Configuration/Change current account");
1627 mainwin->ac_menu = ac_menu;
1629 toolbar_main_set_sensitive(mainwin);
1631 /* create actions menu */
1632 main_window_update_actions_menu(mainwin);
1634 main_create_mailing_list_menu (mainwin, NULL);
1636 /* attach accel groups to main window */
1637 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1638 gtk_window_add_accel_group \
1640 gtk_item_factory_from_widget(menu)->accel_group); \
1641 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1643 G_CALLBACK(main_window_accel_activate), mainwin);
1646 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1648 /* connect the accelerators for equivalent
1649 menu items in different menus */
1650 menu_connect_identical_items();
1653 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1656 g_signal_connect(G_OBJECT(window), "window_state_event",
1657 G_CALLBACK(mainwindow_state_event_cb), mainwin);
1658 g_signal_connect(G_OBJECT(window), "visibility_notify_event",
1659 G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
1660 gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
1662 if (prefs_common.layout_mode == VERTICAL_LAYOUT ||
1663 prefs_common.layout_mode == SMALL_LAYOUT) {
1664 summary_relayout(mainwin->summaryview);
1666 summary_update_unread(mainwin->summaryview, NULL);
1668 gtk_widget_show(mainwin->window);
1670 /* initialize views */
1671 folderview_init(folderview);
1672 summary_init(summaryview);
1673 messageview_init(messageview);
1675 sslcertwindow_register_hook();
1677 mainwin->lock_count = 0;
1678 mainwin->menu_lock_count = 0;
1679 mainwin->cursor_count = 0;
1681 mainwin->progressindicator_hook =
1682 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1685 watch_cursor = gdk_cursor_new(GDK_WATCH);
1687 hand_cursor = gdk_cursor_new(GDK_HAND2);
1689 /* init work_offline */
1690 if (prefs_common.work_offline)
1691 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1693 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1694 mainwindow_tags_menu_create(mainwin, FALSE);
1699 void main_window_destroy(MainWindow *mainwin)
1701 /* TODO : destroy other component */
1702 messageview_destroy(mainwin->messageview);
1703 mainwin->messageview = NULL;
1706 void main_window_update_actions_menu(MainWindow *mainwin)
1708 GtkItemFactory *ifactory;
1710 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1711 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1714 void main_window_cursor_wait(MainWindow *mainwin)
1717 if (mainwin->cursor_count == 0) {
1718 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1719 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1722 mainwin->cursor_count++;
1727 void main_window_cursor_normal(MainWindow *mainwin)
1729 if (mainwin->cursor_count)
1730 mainwin->cursor_count--;
1732 if (mainwin->cursor_count == 0) {
1733 gdk_window_set_cursor(mainwin->window->window, NULL);
1734 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1739 /* lock / unlock the user-interface */
1740 void main_window_lock(MainWindow *mainwin)
1742 if (mainwin->lock_count == 0)
1743 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1745 mainwin->lock_count++;
1747 main_window_set_menu_sensitive(mainwin);
1748 toolbar_main_set_sensitive(mainwin);
1751 void main_window_unlock(MainWindow *mainwin)
1753 if (mainwin->lock_count)
1754 mainwin->lock_count--;
1756 main_window_set_menu_sensitive(mainwin);
1757 toolbar_main_set_sensitive(mainwin);
1759 if (mainwin->lock_count == 0)
1760 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1763 static void main_window_menu_callback_block(MainWindow *mainwin)
1765 mainwin->menu_lock_count++;
1768 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1770 if (mainwin->menu_lock_count)
1771 mainwin->menu_lock_count--;
1774 static guint prefs_tag = 0;
1776 void main_window_reflect_prefs_all(void)
1778 main_window_reflect_prefs_all_real(FALSE);
1781 static gboolean reflect_prefs_timeout_cb(gpointer data)
1783 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1785 MainWindow *mainwin;
1788 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1789 mainwin = (MainWindow *)cur->data;
1791 main_window_show_cur_account(mainwin);
1792 main_window_set_menu_sensitive(mainwin);
1793 toolbar_main_set_sensitive(mainwin);
1796 if (pixmap_theme_changed) {
1797 toolbar_update(TOOLBAR_MAIN, mainwin);
1798 messageview_reflect_prefs_pixmap_theme();
1799 compose_reflect_prefs_pixmap_theme();
1800 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1801 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1803 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1804 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1805 mainwin->online_pixmap);
1806 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1807 gtk_widget_show(pixmap);
1808 mainwin->online_pixmap = pixmap;
1809 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1810 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1811 mainwin->offline_pixmap);
1812 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1813 gtk_widget_show(pixmap);
1814 mainwin->offline_pixmap = pixmap;
1817 headerview_set_font(mainwin->messageview->headerview);
1818 headerview_set_visibility(mainwin->messageview->headerview,
1819 prefs_common.display_header_pane);
1820 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1821 folderview_reflect_prefs();
1822 summary_reflect_prefs();
1823 summary_redisplay_msg(mainwin->summaryview);
1829 void main_window_reflect_prefs_all_now(void)
1831 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1834 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1839 /* re-create colorlabel submenu */
1840 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1841 g_return_if_fail(menu != NULL);
1843 /* clear items. get item pointers. */
1844 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1845 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1847 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1848 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1852 void main_window_reflect_tags_changes(MainWindow *mainwin)
1857 /* re-create tags submenu */
1858 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1859 g_return_if_fail(menu != NULL);
1861 /* clear items. get item pointers. */
1862 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1863 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1865 mainwindow_tags_menu_create(mainwin, TRUE);
1866 summary_reflect_tags_changes(mainwin->summaryview);
1870 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1872 if (prefs_tag == 0 || pixmap_theme_changed) {
1873 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1874 GINT_TO_POINTER(pixmap_theme_changed));
1878 void main_window_set_summary_column(void)
1881 MainWindow *mainwin;
1883 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1884 mainwin = (MainWindow *)cur->data;
1885 summary_set_column_order(mainwin->summaryview);
1889 void main_window_set_folder_column(void)
1892 MainWindow *mainwin;
1894 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1895 mainwin = (MainWindow *)cur->data;
1896 folderview_set_column_order(mainwin->folderview);
1900 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1901 GList *account_list)
1903 GList *cur_ac, *cur_item;
1904 GtkWidget *menuitem;
1905 PrefsAccount *ac_prefs;
1907 /* destroy all previous menu item */
1908 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1909 while (cur_item != NULL) {
1910 GList *next = cur_item->next;
1911 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1915 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1916 ac_prefs = (PrefsAccount *)cur_ac->data;
1918 menuitem = gtk_menu_item_new_with_label
1919 (ac_prefs->account_name
1920 ? ac_prefs->account_name : _("Untitled"));
1921 gtk_widget_show(menuitem);
1922 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
1923 g_signal_connect(G_OBJECT(menuitem), "activate",
1924 G_CALLBACK(account_selector_menu_cb),
1929 static void main_window_set_account_receive_menu(MainWindow *mainwin,
1930 GList *account_list)
1932 GList *cur_ac, *cur_item;
1934 GtkWidget *menuitem;
1935 PrefsAccount *ac_prefs;
1937 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
1938 "/Message/Receive");
1940 /* search for separator */
1941 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
1942 cur_item = cur_item->next) {
1943 if (GTK_BIN(cur_item->data)->child == NULL) {
1944 cur_item = cur_item->next;
1949 /* destroy all previous menu item */
1950 while (cur_item != NULL) {
1951 GList *next = cur_item->next;
1952 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
1956 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1957 ac_prefs = (PrefsAccount *)cur_ac->data;
1959 menuitem = gtk_menu_item_new_with_label
1960 (ac_prefs->account_name ? ac_prefs->account_name
1962 gtk_widget_show(menuitem);
1963 gtk_menu_append(GTK_MENU(menu), menuitem);
1964 g_signal_connect(G_OBJECT(menuitem), "activate",
1965 G_CALLBACK(account_receive_menu_cb),
1970 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
1971 GList *account_list)
1974 GtkWidget *menuitem;
1975 PrefsAccount *ac_prefs;
1976 GtkWidget *menu = NULL;
1978 if (mainwin->toolbar->getall_btn == NULL) /* button doesn't exist */
1981 menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn));
1983 gtk_widget_destroy(menu);
1984 menu = gtk_menu_new();
1986 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
1987 ac_prefs = (PrefsAccount *)cur_ac->data;
1989 menuitem = gtk_menu_item_new_with_label
1990 (ac_prefs->account_name
1991 ? ac_prefs->account_name : _("Untitled"));
1992 gtk_widget_show(menuitem);
1993 gtk_menu_append(GTK_MENU(menu), menuitem);
1994 g_signal_connect(G_OBJECT(menuitem), "activate",
1995 G_CALLBACK(account_receive_menu_cb),
1998 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn), menu);
2001 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
2002 GList *account_list)
2006 GtkWidget *menuitem;
2007 PrefsAccount *ac_prefs;
2008 GtkWidget *menu = NULL;
2010 if (mainwin->toolbar->compose_mail_btn == NULL) /* button doesn't exist */
2013 menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn));
2015 gtk_widget_destroy(menu);
2016 menu = gtk_menu_new();
2018 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2019 ac_prefs = (PrefsAccount *)cur_ac->data;
2021 menuitem = gtk_menu_item_new_with_label
2022 (ac_prefs->account_name
2023 ? ac_prefs->account_name : _("Untitled"));
2024 gtk_widget_show(menuitem);
2025 gtk_menu_append(GTK_MENU(menu), menuitem);
2026 g_signal_connect(G_OBJECT(menuitem), "activate",
2027 G_CALLBACK(account_compose_menu_cb),
2030 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn), menu);
2031 menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_news_btn));
2033 gtk_widget_destroy(menu);
2034 menu = gtk_menu_new();
2036 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2037 ac_prefs = (PrefsAccount *)cur_ac->data;
2039 menuitem = gtk_menu_item_new_with_label
2040 (ac_prefs->account_name
2041 ? ac_prefs->account_name : _("Untitled"));
2042 gtk_widget_show(menuitem);
2043 gtk_menu_append(GTK_MENU(menu), menuitem);
2044 g_signal_connect(G_OBJECT(menuitem), "activate",
2045 G_CALLBACK(account_compose_menu_cb),
2048 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_news_btn), menu);
2052 void main_window_set_account_menu(GList *account_list)
2055 MainWindow *mainwin;
2057 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2058 mainwin = (MainWindow *)cur->data;
2059 main_window_set_account_selector_menu(mainwin, account_list);
2060 main_window_set_account_receive_menu(mainwin, account_list);
2061 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2062 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2064 hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
2067 void main_window_set_account_menu_only_toolbar(GList *account_list)
2070 MainWindow *mainwin;
2072 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2073 mainwin = (MainWindow *)cur->data;
2074 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2075 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2079 static void main_window_show_cur_account(MainWindow *mainwin)
2084 ac_name = g_strdup(cur_account
2085 ? (cur_account->account_name
2086 ? cur_account->account_name : _("Untitled"))
2090 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
2092 buf = g_strdup(PROG_VERSION);
2093 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
2096 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
2097 gtk_widget_queue_resize(mainwin->ac_button);
2102 static void main_window_separation_change(MainWindow *mainwin, LayoutType layout_mode)
2104 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
2105 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
2106 GtkWidget *message_wid = mainwin->messageview->vbox;
2108 if (layout_mode == prefs_common.layout_mode)
2111 debug_print("Changing window separation type from %d to %d\n",
2112 prefs_common.layout_mode, layout_mode);
2114 /* remove widgets from those containers */
2115 gtk_widget_ref(folder_wid);
2116 gtk_widget_ref(summary_wid);
2117 gtk_widget_ref(message_wid);
2118 gtkut_container_remove
2119 (GTK_CONTAINER(folder_wid->parent), folder_wid);
2120 gtkut_container_remove
2121 (GTK_CONTAINER(summary_wid->parent), summary_wid);
2122 gtkut_container_remove
2123 (GTK_CONTAINER(message_wid->parent), message_wid);
2125 gtk_widget_hide(mainwin->window);
2126 main_window_set_widgets(mainwin, layout_mode);
2127 gtk_widget_show(mainwin->window);
2129 gtk_widget_unref(folder_wid);
2130 gtk_widget_unref(summary_wid);
2131 gtk_widget_unref(message_wid);
2134 void mainwindow_reset_paned(GtkPaned *paned)
2138 if (gtk_paned_get_child1(GTK_PANED(paned)))
2139 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2140 if (gtk_paned_get_child2(GTK_PANED(paned)))
2141 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2144 g_object_get (G_OBJECT(paned),
2147 g_object_get (G_OBJECT(paned),
2151 gtk_paned_set_position(GTK_PANED(paned), mid);
2154 static void mainwin_paned_show_first(GtkPaned *paned)
2157 g_object_get (G_OBJECT(paned),
2161 if (gtk_paned_get_child1(GTK_PANED(paned)))
2162 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2163 if (gtk_paned_get_child2(GTK_PANED(paned)))
2164 gtk_widget_hide(gtk_paned_get_child2(GTK_PANED(paned)));
2165 gtk_paned_set_position(GTK_PANED(paned), max);
2168 static void mainwin_paned_show_last(GtkPaned *paned)
2171 g_object_get (G_OBJECT(paned),
2175 if (gtk_paned_get_child1(GTK_PANED(paned)))
2176 gtk_widget_hide(gtk_paned_get_child1(GTK_PANED(paned)));
2177 if (gtk_paned_get_child2(GTK_PANED(paned)))
2178 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2179 gtk_paned_set_position(GTK_PANED(paned), min);
2182 void main_window_toggle_message_view(MainWindow *mainwin)
2184 SummaryView *summaryview = mainwin->summaryview;
2185 GtkWidget *ppaned = NULL;
2186 GtkWidget *container = NULL;
2188 switch (prefs_common.layout_mode) {
2190 case VERTICAL_LAYOUT:
2192 ppaned = mainwin->vpaned;
2193 container = mainwin->hpaned;
2194 if (ppaned->parent != NULL) {
2195 mainwin->messageview->visible = FALSE;
2196 summaryview->displayed = NULL;
2197 gtk_widget_ref(ppaned);
2198 gtkut_container_remove(GTK_CONTAINER(container), ppaned);
2199 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
2201 mainwin->messageview->visible = TRUE;
2202 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), ppaned);
2203 gtk_container_add(GTK_CONTAINER(container), ppaned);
2204 gtk_widget_unref(ppaned);
2208 ppaned = mainwin->hpaned;
2209 container = mainwin->vpaned;
2210 if (mainwin->messageview->vbox->parent != NULL) {
2211 mainwin->messageview->visible = FALSE;
2212 summaryview->displayed = NULL;
2213 gtk_widget_ref(mainwin->messageview->vbox);
2214 gtkut_container_remove(GTK_CONTAINER(container), mainwin->messageview->vbox);
2216 mainwin->messageview->visible = TRUE;
2217 gtk_container_add(GTK_CONTAINER(container), mainwin->messageview->vbox);
2218 gtk_widget_unref(mainwin->messageview->vbox);
2221 case WIDE_MSGLIST_LAYOUT:
2222 g_warning("can't hide messageview in this wide msglist layout");
2226 if (messageview_is_visible(mainwin->messageview))
2227 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2228 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2230 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2231 GTK_ARROW_UP, GTK_SHADOW_OUT);
2233 if (mainwin->messageview->visible == FALSE)
2234 messageview_clear(mainwin->messageview);
2236 main_window_set_menu_sensitive(mainwin);
2238 prefs_common.msgview_visible = mainwin->messageview->visible;
2240 if (messageview_is_visible(mainwin->messageview)) {
2241 gtk_widget_queue_resize(mainwin->hpaned);
2242 gtk_widget_queue_resize(mainwin->vpaned);
2244 summary_grab_focus(summaryview);
2247 void main_window_get_size(MainWindow *mainwin)
2249 GtkAllocation *allocation;
2251 if (mainwin_list == NULL || mainwin->messageview == NULL) {
2252 debug_print("called after messageview "
2253 "has been deallocated!\n");
2257 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
2259 if (allocation->width > 1 && allocation->height > 1) {
2260 prefs_common.summaryview_width = allocation->width;
2262 if (messageview_is_visible(mainwin->messageview))
2263 prefs_common.summaryview_height = allocation->height;
2265 prefs_common.mainview_width = allocation->width;
2268 allocation = &mainwin->window->allocation;
2269 if (allocation->width > 1 && allocation->height > 1) {
2270 prefs_common.mainview_height = allocation->height;
2271 prefs_common.mainwin_width = allocation->width;
2272 prefs_common.mainwin_height = allocation->height;
2275 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
2276 if (allocation->width > 1 && allocation->height > 1) {
2277 prefs_common.folderview_width = allocation->width;
2278 prefs_common.folderview_height = allocation->height;
2281 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
2282 if (allocation->width > 1 && allocation->height > 1) {
2283 prefs_common.msgview_width = allocation->width;
2284 prefs_common.msgview_height = allocation->height;
2287 /* debug_print("summaryview size: %d x %d\n",
2288 prefs_common.summaryview_width,
2289 prefs_common.summaryview_height);
2290 debug_print("folderview size: %d x %d\n",
2291 prefs_common.folderview_width,
2292 prefs_common.folderview_height);
2293 debug_print("messageview size: %d x %d\n",
2294 prefs_common.msgview_width,
2295 prefs_common.msgview_height); */
2298 void main_window_get_position(MainWindow *mainwin)
2302 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2304 prefs_common.mainview_x = x;
2305 prefs_common.mainview_y = y;
2306 prefs_common.mainwin_x = x;
2307 prefs_common.mainwin_y = y;
2309 debug_print("main window position: %d, %d\n", x, y);
2312 void main_window_progress_on(MainWindow *mainwin)
2314 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2317 void main_window_progress_off(MainWindow *mainwin)
2319 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2320 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2323 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
2327 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
2328 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
2329 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
2330 (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
2333 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2335 if (confirm && procmsg_have_trashed_mails_fast()) {
2336 if (alertpanel(_("Empty trash"),
2337 _("Delete all messages in trash folders?"),
2338 GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL)
2339 != G_ALERTALTERNATE)
2341 manage_window_focus_in(mainwin->window, NULL, NULL);
2344 procmsg_empty_all_trash();
2346 if (mainwin->summaryview->folder_item &&
2347 mainwin->summaryview->folder_item->stype == F_TRASH)
2348 gtk_widget_grab_focus(mainwin->folderview->ctree);
2351 void main_window_add_mailbox(MainWindow *mainwin)
2356 path = input_dialog(_("Add mailbox"),
2357 _("Input the location of mailbox.\n"
2358 "If an existing mailbox is specified, it will be\n"
2359 "scanned automatically."),
2362 if (folder_find_from_path(path)) {
2363 alertpanel_error(_("The mailbox '%s' already exists."), path);
2367 folder = folder_new(folder_get_class_from_string("mh"),
2368 !strcmp(path, "Mail") ? _("Mailbox") :
2369 g_path_get_basename(path), path);
2372 if (folder->klass->create_tree(folder) < 0) {
2373 alertpanel_error(_("Creation of the mailbox failed.\n"
2374 "Maybe some files already exist, or you don't have the permission to write there."));
2375 folder_destroy(folder);
2380 folder_set_ui_func(folder, scan_tree_func, mainwin);
2381 folder_scan_tree(folder, TRUE);
2382 folder_set_ui_func(folder, NULL, NULL);
2385 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2387 SensitiveCond state = 0;
2388 SummarySelection selection;
2389 FolderItem *item = mainwin->summaryview->folder_item;
2390 GList *account_list = account_get_list();
2393 selection = summary_get_selection_type(mainwin->summaryview);
2395 if (mainwin->lock_count == 0)
2396 state |= M_UNLOCKED;
2397 if (selection != SUMMARY_NONE)
2398 state |= M_MSG_EXIST;
2399 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2401 /* if (item->folder->type != F_NEWS) */
2402 state |= M_ALLOW_DELETE;
2404 if (prefs_common.immediate_exec == 0
2405 && mainwin->lock_count == 0)
2406 state |= M_DELAY_EXEC;
2408 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2409 || selection != SUMMARY_NONE)
2410 state |= M_HIDE_READ_MSG;
2412 if (mainwin->summaryview->threaded)
2413 state |= M_THREADED;
2415 state |= M_UNTHREADED;
2416 if (selection == SUMMARY_SELECTED_SINGLE ||
2417 selection == SUMMARY_SELECTED_MULTIPLE)
2418 state |= M_TARGET_EXIST;
2419 if (selection == SUMMARY_SELECTED_SINGLE)
2420 state |= M_SINGLE_TARGET_EXIST;
2421 if (mainwin->summaryview->folder_item &&
2422 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2425 state |= M_NOT_NEWS;
2426 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2427 state |= M_ACTIONS_EXIST;
2429 tmp = tags_get_list();
2430 if (tmp && g_slist_length(tmp))
2431 state |= M_TAGS_EXIST;
2434 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2435 state |= M_HAVE_QUEUED_MAILS;
2437 if (selection == SUMMARY_SELECTED_SINGLE &&
2439 (folder_has_parent_of_type(item, F_DRAFT) ||
2440 folder_has_parent_of_type(item, F_OUTBOX) ||
2441 folder_has_parent_of_type(item, F_QUEUE))))
2442 state |= M_ALLOW_REEDIT;
2444 state |= M_HAVE_ACCOUNT;
2446 if (any_folder_want_synchronise())
2447 state |= M_WANT_SYNC;
2449 for ( ; account_list != NULL; account_list = account_list->next) {
2450 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2451 state |= M_HAVE_NEWS_ACCOUNT;
2456 if (procmsg_spam_can_learn() &&
2457 (mainwin->summaryview->folder_item &&
2458 mainwin->summaryview->folder_item->folder->klass->type != F_UNKNOWN &&
2459 mainwin->summaryview->folder_item->folder->klass->type != F_NEWS)) {
2460 state |= M_CAN_LEARN_SPAM;
2463 if (inc_is_active())
2464 state |= M_INC_ACTIVE;
2465 if (imap_cancel_all_enabled())
2466 state |= M_INC_ACTIVE;
2468 if (mainwin->summaryview->deleted > 0 ||
2469 mainwin->summaryview->moved > 0 ||
2470 mainwin->summaryview->copied > 0)
2471 state |= M_DELAY_EXEC;
2478 void main_window_set_menu_sensitive(MainWindow *mainwin)
2480 GtkItemFactory *ifactory = mainwin->menu_factory;
2481 SensitiveCond state;
2484 GtkWidget *menuitem;
2485 SummaryView *summaryview;
2490 static const struct {
2494 {"/File/Save as...", M_TARGET_EXIST},
2495 {"/File/Print..." , M_TARGET_EXIST},
2496 {"/File/Synchronise folders", M_WANT_SYNC},
2497 {"/File/Exit" , M_UNLOCKED},
2499 {"/Edit/Select thread" , M_TARGET_EXIST},
2500 {"/Edit/Delete thread" , M_TARGET_EXIST},
2501 {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
2503 {"/View/Set displayed columns/in Folder list..."
2505 {"/View/Sort" , M_EXEC},
2506 {"/View/Thread view" , M_EXEC},
2507 {"/View/Expand all threads" , M_MSG_EXIST},
2508 {"/View/Collapse all threads" , M_MSG_EXIST},
2509 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2510 {"/View/Go to/Previous message" , M_MSG_EXIST},
2511 {"/View/Go to/Next message" , M_MSG_EXIST},
2512 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2513 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2514 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2515 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2516 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2517 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2518 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2519 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2520 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2521 {"/View/All headers" , M_SINGLE_TARGET_EXIST},
2522 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2524 {"/Message/Receive/Get from current account"
2525 , M_HAVE_ACCOUNT|M_UNLOCKED},
2526 {"/Message/Receive/Get from all accounts"
2527 , M_HAVE_ACCOUNT|M_UNLOCKED},
2528 {"/Message/Receive/Cancel receiving"
2530 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2531 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2532 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2533 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2534 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2535 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2536 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2537 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2538 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2539 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2540 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2541 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2542 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2543 {"/Message/Mark" , M_TARGET_EXIST},
2544 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2545 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2546 {"/Message/Mark/Ignore thread" , M_TARGET_EXIST},
2547 {"/Message/Mark/Unignore thread" , M_TARGET_EXIST},
2548 {"/Message/Mark/Lock" , M_TARGET_EXIST},
2549 {"/Message/Mark/Unlock" , M_TARGET_EXIST},
2550 {"/Message/Color label" , M_TARGET_EXIST},
2551 {"/Message/Tags" , M_TARGET_EXIST},
2552 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2554 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2555 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2556 {"/Tools/Harvest addresses/from Messages..."
2558 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2559 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2560 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2561 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2562 {"/Tools/List URLs..." , M_TARGET_EXIST},
2563 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2564 {"/Tools/Execute" , M_DELAY_EXEC},
2565 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2567 {"/Configuration", M_UNLOCKED},
2568 {"/Configuration/Preferences for current account...", M_UNLOCKED},
2569 {"/Configuration/Create new account...", M_UNLOCKED},
2570 {"/Configuration/Edit accounts...", M_UNLOCKED},
2575 state = main_window_get_current_state(mainwin);
2577 for (i = 0; entry[i].entry != NULL; i++) {
2578 sensitive = ((entry[i].cond & state) == entry[i].cond);
2579 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2582 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2584 /* search for separator */
2585 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2586 cur_item = cur_item->next) {
2587 if (GTK_BIN(cur_item->data)->child == NULL) {
2588 cur_item = cur_item->next;
2593 for (; cur_item != NULL; cur_item = cur_item->next) {
2594 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2595 (M_UNLOCKED & state) != 0);
2598 main_window_menu_callback_block(mainwin);
2600 #define SET_CHECK_MENU_ACTIVE(path, active) \
2602 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2603 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2606 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2607 messageview_is_visible(mainwin->messageview));
2609 summaryview = mainwin->summaryview;
2610 menu_path = "/View/Sort/Don't sort";
2612 switch (summaryview->sort_key) {
2613 case SORT_BY_NUMBER:
2614 menu_path = "/View/Sort/by number"; break;
2616 menu_path = "/View/Sort/by Size"; break;
2618 menu_path = "/View/Sort/by Date"; break;
2619 case SORT_BY_THREAD_DATE:
2620 menu_path = "/View/Sort/by Thread date"; break;
2622 menu_path = "/View/Sort/by From"; break;
2624 menu_path = "/View/Sort/by To"; break;
2625 case SORT_BY_SUBJECT:
2626 menu_path = "/View/Sort/by Subject"; break;
2628 menu_path = "/View/Sort/by color label"; break;
2630 menu_path = "/View/Sort/by mark"; break;
2631 case SORT_BY_STATUS:
2632 menu_path = "/View/Sort/by status"; break;
2634 menu_path = "/View/Sort/by attachment"; break;
2636 menu_path = "/View/Sort/by score"; break;
2637 case SORT_BY_LOCKED:
2638 menu_path = "/View/Sort/by locked"; break;
2640 menu_path = "/View/Sort/by tag"; break;
2643 menu_path = "/View/Sort/Don't sort"; break;
2645 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2647 if (summaryview->sort_type == SORT_ASCENDING) {
2648 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2650 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2653 if (summaryview->sort_key != SORT_BY_NONE) {
2654 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2655 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2657 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2658 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2661 if (mainwin->messageview
2662 && mainwin->messageview->mimeview
2663 && mainwin->messageview->mimeview->textview)
2664 SET_CHECK_MENU_ACTIVE("/View/All headers",
2665 mainwin->messageview->mimeview->textview->show_all_headers);
2666 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2667 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2668 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2669 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2670 if (prefs_common.hide_quotes == 1)
2671 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2672 if (prefs_common.hide_quotes == 2)
2673 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2674 if (prefs_common.hide_quotes == 3)
2675 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2677 #undef SET_CHECK_MENU_ACTIVE
2679 main_window_menu_callback_unblock(mainwin);
2682 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2684 GtkItemFactory *ifactory;
2686 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2689 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2691 gtk_widget_set_sensitive (gtk_item_factory_get_item
2692 (ifactory,"/Message/Mailing-List"), TRUE);
2694 gtk_widget_set_sensitive (gtk_item_factory_get_item
2695 (ifactory,"/Message/Mailing-List"), FALSE);
2698 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2701 GtkWidget *menuitem;
2703 if (!msginfo || !msginfo->extradata) {
2704 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2705 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2706 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2707 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2708 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2709 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2713 /* Mailing list post */
2714 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2715 g_free(msginfo->extradata->list_post);
2716 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2718 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2720 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2722 /* Mailing list help */
2723 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2725 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2727 /* Mailing list subscribe */
2728 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2730 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2732 /* Mailing list unsubscribe */
2733 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2735 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2737 /* Mailing list view archive */
2738 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2740 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2742 /* Mailing list contact owner */
2743 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2745 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2750 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2752 GtkWidget *item, *menu;
2753 const gchar *url_pt ;
2754 gchar url_decoded[BUFFSIZE];
2755 GList *amenu, *alist;
2758 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2760 /* First delete old submenu */
2761 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2762 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2763 alist = amenu->next;
2764 item = GTK_WIDGET (amenu->data);
2765 gtk_widget_destroy (item);
2769 for (url_pt = list_header; url_pt && *url_pt;) {
2770 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2772 if (!g_strncasecmp(url_decoded, "mailto:", 7)) {
2773 item = gtk_menu_item_new_with_label ((url_decoded));
2774 g_signal_connect(G_OBJECT(item), "activate",
2775 G_CALLBACK(mailing_list_compose),
2778 else if (!g_strncasecmp (url_decoded, "http:", 5) ||
2779 !g_strncasecmp (url_decoded, "https:",6)) {
2781 item = gtk_menu_item_new_with_label ((url_decoded));
2782 g_signal_connect(G_OBJECT(item), "activate",
2783 G_CALLBACK(mailing_list_open_uri),
2787 gtk_menu_append (GTK_MENU(menu), item);
2788 gtk_widget_show (item);
2794 gtk_widget_set_sensitive (menuitem, TRUE);
2796 gtk_widget_set_sensitive (menuitem, FALSE);
2802 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2804 gchar tmp[BUFFSIZE];
2808 gboolean with_plus = TRUE;
2811 *url_decoded = '\0';
2815 /* Ignore spaces, comments and tabs () */
2816 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2818 for (;*buf != ')' && *buf != 0x00; buf++);
2820 /* First non space and non comment must be a < */
2823 if (!strncmp(buf, "mailto:", strlen("mailto:")))
2825 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2830 *url_decoded = '\0';
2835 *url_decoded = '\0';
2841 decode_uri_with_plus (url_decoded, (const gchar *)tmp, with_plus);
2843 /* Prepare the work for the next url in the list */
2844 /* after the closing bracket >, ignore space, comments and tabs */
2845 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2847 for (;*buf != ')' && *buf != 0x00; buf++);
2849 if (!buf || !*buf) {
2854 /* now first non space, non comment must be a comma */
2856 for (;*buf != 0x00; buf++);
2862 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2866 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2867 compose_new(NULL, mailto+7, NULL);
2870 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2875 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2876 open_uri (mailto, prefs_common.uri_cmd);
2879 void main_window_popup(MainWindow *mainwin)
2881 if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
2882 main_window_show(mainwin);
2884 gtkut_window_popup(mainwin->window);
2885 if (prefs_common.layout_mode == SMALL_LAYOUT) {
2886 if (mainwin->in_folder) {
2887 mainwindow_enter_folder(mainwin);
2889 mainwindow_exit_folder(mainwin);
2894 void main_window_show(MainWindow *mainwin)
2896 gtk_widget_show(mainwin->window);
2897 gtk_widget_show(mainwin->vbox_body);
2899 gtk_widget_set_uposition(mainwin->window,
2900 prefs_common.mainwin_x,
2901 prefs_common.mainwin_y);
2903 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2904 prefs_common.folderview_width,
2905 prefs_common.folderview_height);
2906 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2907 prefs_common.summaryview_width,
2908 prefs_common.summaryview_height);
2909 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2910 prefs_common.msgview_width,
2911 prefs_common.msgview_height);
2914 void main_window_hide(MainWindow *mainwin)
2916 main_window_get_size(mainwin);
2917 main_window_get_position(mainwin);
2919 gtk_widget_hide(mainwin->window);
2920 gtk_widget_hide(mainwin->vbox_body);
2923 static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
2925 GtkWidget *folderwin = NULL;
2926 GtkWidget *messagewin = NULL;
2929 GtkWidget *vbox_body = mainwin->vbox_body;
2930 GtkItemFactory *ifactory = mainwin->menu_factory;
2931 GtkWidget *menuitem;
2932 gboolean first_set = (mainwin->hpaned == NULL);
2933 debug_print("Setting widgets... ");
2935 if (layout_mode == SMALL_LAYOUT && first_set) {
2936 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2937 prefs_common.folderview_width,
2938 prefs_common.folderview_height);
2939 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2941 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2944 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2945 prefs_common.folderview_width,
2946 prefs_common.folderview_height);
2947 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2948 prefs_common.summaryview_width,
2949 prefs_common.summaryview_height);
2950 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2951 prefs_common.msgview_width,
2952 prefs_common.msgview_height);
2955 mainwin->messageview->statusbar = mainwin->statusbar;
2956 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
2958 /* clean top-most container */
2959 if (mainwin->hpaned) {
2960 if (mainwin->hpaned->parent == mainwin->vpaned)
2961 gtk_widget_destroy(mainwin->vpaned);
2963 gtk_widget_destroy(mainwin->hpaned);
2966 menu_set_sensitive(ifactory, "/View/Show or hide/Message view",
2967 (layout_mode != WIDE_MSGLIST_LAYOUT && layout_mode != SMALL_LAYOUT));
2968 switch (layout_mode) {
2969 case VERTICAL_LAYOUT:
2972 hpaned = gtk_hpaned_new();
2973 if (layout_mode == VERTICAL_LAYOUT)
2974 vpaned = gtk_hpaned_new();
2976 vpaned = gtk_vpaned_new();
2977 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
2978 gtk_paned_add1(GTK_PANED(hpaned),
2979 GTK_WIDGET_PTR(mainwin->folderview));
2980 gtk_widget_show(hpaned);
2981 gtk_widget_queue_resize(hpaned);
2983 if (messageview_is_visible(mainwin->messageview)) {
2984 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
2985 gtk_paned_add1(GTK_PANED(vpaned),
2986 GTK_WIDGET_PTR(mainwin->summaryview));
2988 gtk_paned_add2(GTK_PANED(hpaned),
2989 GTK_WIDGET_PTR(mainwin->summaryview));
2990 gtk_widget_ref(vpaned);
2992 gtk_paned_add2(GTK_PANED(vpaned),
2993 GTK_WIDGET_PTR(mainwin->messageview));
2994 gtk_widget_show(vpaned);
2995 if (layout_mode == SMALL_LAYOUT && first_set) {
2996 mainwin_paned_show_first(GTK_PANED(hpaned));
2998 gtk_widget_queue_resize(vpaned);
3001 vpaned = gtk_vpaned_new();
3002 hpaned = gtk_hpaned_new();
3003 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3004 gtk_paned_add1(GTK_PANED(vpaned), hpaned);
3006 gtk_paned_add1(GTK_PANED(hpaned),
3007 GTK_WIDGET_PTR(mainwin->folderview));
3008 gtk_paned_add2(GTK_PANED(hpaned),
3009 GTK_WIDGET_PTR(mainwin->summaryview));
3011 gtk_widget_show(hpaned);
3012 gtk_widget_queue_resize(hpaned);
3014 if (messageview_is_visible(mainwin->messageview)) {
3015 gtk_paned_add2(GTK_PANED(vpaned),
3016 GTK_WIDGET_PTR(mainwin->messageview));
3018 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3020 gtk_widget_show(vpaned);
3021 gtk_widget_queue_resize(vpaned);
3023 case WIDE_MSGLIST_LAYOUT:
3024 vpaned = gtk_vpaned_new();
3025 hpaned = gtk_hpaned_new();
3026 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3028 gtk_paned_add1(GTK_PANED(vpaned),
3029 GTK_WIDGET_PTR(mainwin->summaryview));
3030 gtk_paned_add1(GTK_PANED(hpaned),
3031 GTK_WIDGET_PTR(mainwin->folderview));
3033 gtk_widget_show(hpaned);
3034 gtk_widget_queue_resize(hpaned);
3036 if (messageview_is_visible(mainwin->messageview)) {
3037 gtk_paned_add2(GTK_PANED(hpaned),
3038 GTK_WIDGET_PTR(mainwin->messageview));
3040 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3042 gtk_paned_add2(GTK_PANED(vpaned), hpaned);
3044 gtk_widget_show(vpaned);
3045 gtk_widget_queue_resize(vpaned);
3048 g_warning("Unknown layout");
3052 mainwin->hpaned = hpaned;
3053 mainwin->vpaned = vpaned;
3055 if (layout_mode == SMALL_LAYOUT) {
3056 if (mainwin->messageview->visible)
3057 main_window_toggle_message_view(mainwin);
3060 if (layout_mode == SMALL_LAYOUT && first_set) {
3061 gtk_widget_realize(mainwin->window);
3062 gtk_widget_realize(mainwin->folderview->ctree);
3063 gtk_widget_realize(mainwin->summaryview->hbox);
3064 gtk_widget_realize(mainwin->summaryview->hbox_l);
3065 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3066 prefs_common.folderview_width,
3067 prefs_common.folderview_height);
3068 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3070 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3072 gtk_widget_set_size_request(GTK_WIDGET(mainwin->window),
3073 prefs_common.mainwin_width,
3074 prefs_common.mainwin_height);
3075 gtk_paned_set_position(GTK_PANED(mainwin->hpaned), 800);
3077 /* remove headerview if not in prefs */
3078 headerview_set_visibility(mainwin->messageview->headerview,
3079 prefs_common.display_header_pane);
3081 if (messageview_is_visible(mainwin->messageview))
3082 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3083 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
3085 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3086 GTK_ARROW_UP, GTK_SHADOW_OUT);
3088 gtk_window_move(GTK_WINDOW(mainwin->window),
3089 prefs_common.mainwin_x,
3090 prefs_common.mainwin_y);
3092 gtk_widget_queue_resize(vbox_body);
3093 gtk_widget_queue_resize(mainwin->vbox);
3094 gtk_widget_queue_resize(mainwin->window);
3095 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
3096 * and mimeview icon list/ctree lose track of their visibility states */
3097 if (!noticeview_is_visible(mainwin->messageview->noticeview))
3098 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
3099 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
3100 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
3101 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainwin->messageview->mimeview->mime_toggle)))
3102 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
3104 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
3106 prefs_common.layout_mode = layout_mode;
3108 menuitem = gtk_item_factory_get_item
3109 (ifactory, "/View/Show or hide/Message view");
3110 gtk_check_menu_item_set_active
3111 (GTK_CHECK_MENU_ITEM(menuitem),
3112 messageview_is_visible(mainwin->messageview));
3114 #define SET_CHECK_MENU_ACTIVE(path, active) \
3116 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3117 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3120 switch (prefs_common.layout_mode) {
3122 SET_CHECK_MENU_ACTIVE("/View/Layout/Standard", TRUE);
3124 case VERTICAL_LAYOUT:
3125 SET_CHECK_MENU_ACTIVE("/View/Layout/Three columns", TRUE);
3128 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message", TRUE);
3130 case WIDE_MSGLIST_LAYOUT:
3131 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message list", TRUE);
3134 SET_CHECK_MENU_ACTIVE("/View/Layout/Small screen", TRUE);
3137 #undef SET_CHECK_MENU_ACTIVE
3141 (G_OBJECT(folderwin), "size_allocate",
3142 G_CALLBACK(folder_window_size_allocate_cb),
3147 (G_OBJECT(messagewin), "size_allocate",
3148 G_CALLBACK(message_window_size_allocate_cb),
3152 debug_print("done.\n");
3155 void main_window_destroy_all(void)
3157 while (mainwin_list != NULL) {
3158 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
3160 /* free toolbar stuff */
3161 toolbar_clear_list(TOOLBAR_MAIN);
3162 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
3163 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
3165 mainwin->folderview->mainwin = NULL;
3166 mainwin->summaryview->mainwin = NULL;
3167 mainwin->messageview->mainwin = NULL;
3169 g_free(mainwin->toolbar);
3172 mainwin_list = g_list_remove(mainwin_list, mainwin);
3174 g_list_free(mainwin_list);
3175 mainwin_list = NULL;
3178 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
3181 gtk_widget_set_size_request(child, 1, -1);
3184 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
3187 gtk_widget_set_size_request(child, -1, -1);
3190 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
3193 MainWindow *mainwin = (MainWindow *)data;
3195 if (!event) return FALSE;
3197 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
3198 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",