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"
101 #include "printing.h"
103 #define AC_LABEL_WIDTH 240
105 /* list of all instantiated MainWindow */
106 static GList *mainwin_list = NULL;
108 static GdkCursor *watch_cursor = NULL;
109 static GdkCursor *hand_cursor = NULL;
111 static gint iconified_count = 0;
113 static void main_window_menu_callback_block (MainWindow *mainwin);
114 static void main_window_menu_callback_unblock (MainWindow *mainwin);
116 static void main_window_show_cur_account (MainWindow *mainwin);
118 static void main_window_separation_change (MainWindow *mainwin,
119 LayoutType layout_mode);
121 static void main_window_set_widgets (MainWindow *mainwin,
122 LayoutType layout_mode);
124 static void toolbar_child_attached (GtkWidget *widget,
127 static void toolbar_child_detached (GtkWidget *widget,
131 static gboolean ac_label_button_pressed (GtkWidget *widget,
132 GdkEventButton *event,
135 static gint main_window_close_cb (GtkWidget *widget,
139 static void main_window_size_allocate_cb (GtkWidget *widget,
140 GtkAllocation *allocation,
142 static void folder_window_size_allocate_cb (GtkWidget *widget,
143 GtkAllocation *allocation,
145 static void message_window_size_allocate_cb (GtkWidget *widget,
146 GtkAllocation *allocation,
149 static void update_folderview_cb (MainWindow *mainwin,
152 static void add_mailbox_cb (MainWindow *mainwin,
155 static void foldersort_cb (MainWindow *mainwin,
158 static void import_mbox_cb (MainWindow *mainwin,
161 static void export_mbox_cb (MainWindow *mainwin,
164 static void export_list_mbox_cb (MainWindow *mainwin,
167 static void empty_trash_cb (MainWindow *mainwin,
171 static void save_as_cb (MainWindow *mainwin,
174 #if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
175 static void page_setup_cb (MainWindow *mainwin,
180 static void print_cb (MainWindow *mainwin,
183 static void app_exit_cb (MainWindow *mainwin,
187 static void search_cb (MainWindow *mainwin,
191 static void toggle_message_cb (MainWindow *mainwin,
194 static void toggle_toolbar_cb (MainWindow *mainwin,
197 static void toggle_col_headers_cb(MainWindow *mainwin,
201 static void toggle_statusbar_cb (MainWindow *mainwin,
204 static void set_layout_cb (MainWindow *mainwin,
208 static void addressbook_open_cb (MainWindow *mainwin,
211 static void log_window_show_cb (MainWindow *mainwin,
214 static void filtering_debug_window_show_cb (MainWindow *mainwin,
218 static void inc_cancel_cb (MainWindow *mainwin,
222 static void open_msg_cb (MainWindow *mainwin,
226 static void view_source_cb (MainWindow *mainwin,
230 static void show_all_header_cb (MainWindow *mainwin,
234 static void hide_quotes_cb(MainWindow *mainwin,
238 static void move_to_cb (MainWindow *mainwin,
241 static void copy_to_cb (MainWindow *mainwin,
244 static void delete_cb (MainWindow *mainwin,
247 static void delete_trash_cb (MainWindow *mainwin,
251 static void cancel_cb (MainWindow *mainwin,
255 static void mark_cb (MainWindow *mainwin,
258 static void unmark_cb (MainWindow *mainwin,
262 static void mark_as_unread_cb (MainWindow *mainwin,
265 static void mark_as_read_cb (MainWindow *mainwin,
268 static void mark_all_read_cb (MainWindow *mainwin,
271 static void mark_as_spam_cb (MainWindow *mainwin,
275 static void ignore_thread_cb (MainWindow *mainwin,
278 static void unignore_thread_cb (MainWindow *mainwin,
281 static void watch_thread_cb (MainWindow *mainwin,
284 static void unwatch_thread_cb (MainWindow *mainwin,
287 static void lock_msgs_cb (MainWindow *mainwin,
290 static void unlock_msgs_cb (MainWindow *mainwin,
294 static void reedit_cb (MainWindow *mainwin,
298 static void add_address_cb (MainWindow *mainwin,
302 static void set_charset_cb (MainWindow *mainwin,
306 static void set_decode_cb (MainWindow *mainwin,
310 static void hide_read_messages (MainWindow *mainwin,
314 static void thread_cb (MainWindow *mainwin,
317 static void expand_threads_cb (MainWindow *mainwin,
320 static void collapse_threads_cb (MainWindow *mainwin,
324 static void set_summary_display_item_cb (MainWindow *mainwin,
327 static void set_folder_display_item_cb (MainWindow *mainwin,
330 static void sort_summary_cb (MainWindow *mainwin,
333 static void sort_summary_type_cb (MainWindow *mainwin,
336 static void attract_by_subject_cb(MainWindow *mainwin,
340 static void delete_duplicated_cb (MainWindow *mainwin,
343 static void delete_duplicated_all_cb (MainWindow *mainwin,
346 static void filter_cb (MainWindow *mainwin,
349 static void process_cb (MainWindow *mainwin,
352 static void execute_summary_cb (MainWindow *mainwin,
355 static void update_summary_cb (MainWindow *mainwin,
359 static void prev_cb (MainWindow *mainwin,
362 static void next_cb (MainWindow *mainwin,
365 static void next_unread_cb (MainWindow *mainwin,
368 static void prev_unread_cb (MainWindow *mainwin,
372 static void prev_new_cb (MainWindow *mainwin,
375 static void next_new_cb (MainWindow *mainwin,
378 static void prev_marked_cb (MainWindow *mainwin,
381 static void next_marked_cb (MainWindow *mainwin,
384 static void prev_labeled_cb (MainWindow *mainwin,
387 static void next_labeled_cb (MainWindow *mainwin,
390 static void last_read_cb (MainWindow *mainwin,
393 static void parent_cb (MainWindow *mainwin,
397 static void goto_folder_cb (MainWindow *mainwin,
400 static void goto_unread_folder_cb(MainWindow *mainwin,
404 static void copy_cb (MainWindow *mainwin,
407 static void allsel_cb (MainWindow *mainwin,
410 static void select_thread_cb (MainWindow *mainwin,
413 static void delete_thread_cb (MainWindow *mainwin,
417 static void create_filter_cb (MainWindow *mainwin,
420 static void create_processing_cb (MainWindow *mainwin,
423 static void open_urls_cb (MainWindow *mainwin,
427 static void prefs_template_open_cb (MainWindow *mainwin,
430 static void prefs_actions_open_cb (MainWindow *mainwin,
433 static void prefs_tags_open_cb (MainWindow *mainwin,
436 static void prefs_account_open_cb (MainWindow *mainwin,
440 static void prefs_pre_processing_open_cb (MainWindow *mainwin,
444 static void prefs_post_processing_open_cb (MainWindow *mainwin,
448 static void prefs_filtering_open_cb (MainWindow *mainwin,
452 static void ssl_manager_open_cb (MainWindow *mainwin,
456 static void new_account_cb (MainWindow *mainwin,
460 static void account_selector_menu_cb (GtkMenuItem *menuitem,
462 static void account_receive_menu_cb (GtkMenuItem *menuitem,
464 static void account_compose_menu_cb (GtkMenuItem *menuitem,
467 static void prefs_open_cb (GtkMenuItem *menuitem,
469 static void plugins_open_cb (GtkMenuItem *menuitem,
472 static void online_switch_clicked(GtkButton *btn,
475 static void manual_open_cb (MainWindow *mainwin,
479 static void legend_open_cb (GtkMenuItem *menuitem,
482 static void scan_tree_func (Folder *folder,
486 static void toggle_work_offline_cb(MainWindow *mainwin, guint action, GtkWidget *widget);
488 static void addr_harvest_cb ( MainWindow *mainwin,
492 static void addr_harvest_msg_cb ( MainWindow *mainwin,
495 static void sync_cb ( MainWindow *mainwin,
499 static gboolean mainwindow_focus_in_event (GtkWidget *widget,
500 GdkEventFocus *focus,
502 static gboolean mainwindow_visibility_event_cb (GtkWidget *widget,
503 GdkEventVisibility *state,
505 static gboolean mainwindow_state_event_cb (GtkWidget *widget,
506 GdkEventWindowState *state,
508 static void main_window_reply_cb (MainWindow *mainwin,
511 static gboolean mainwindow_progressindicator_hook (gpointer source,
514 static gint mailing_list_create_submenu(GtkItemFactory *ifactory,
517 static gint mailing_list_populate_submenu(GtkWidget *menu, const gchar * list_header);
519 static void get_url_part(const gchar **buf, gchar *url_decoded, gint maxlen);
521 static void mailing_list_compose(GtkWidget *w, gpointer *data);
523 static void mailing_list_open_uri(GtkWidget *w, gpointer *data);
524 #define SEPARATE_ACTION 500
525 static void mainwindow_quicksearch (MainWindow *mainwin,
528 static gboolean any_folder_want_synchronise(void);
530 static GtkItemFactoryEntry mainwin_entries[] =
532 {N_("/_File"), NULL, NULL, 0, "<Branch>"},
533 {N_("/_File/_Add mailbox"), NULL, NULL, 0, "<Branch>"},
534 {N_("/_File/_Add mailbox/MH..."), NULL, add_mailbox_cb, 0, NULL},
535 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
536 {N_("/_File/Change folder order..."), NULL, foldersort_cb, 0, NULL},
537 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
538 {N_("/_File/_Import mbox file..."), NULL, import_mbox_cb, 0, NULL},
539 {N_("/_File/_Export to mbox file..."), NULL, export_mbox_cb, 0, NULL},
540 {N_("/_File/Exp_ort selected to mbox file..."),
541 NULL, export_list_mbox_cb, 0, NULL},
542 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
543 {N_("/_File/Empty all _Trash folders"), "<shift>D", empty_trash_cb, 0, NULL},
544 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
545 {N_("/_File/_Save as..."), "<control>S", save_as_cb, 0, NULL},
546 #if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
547 {N_("/_File/Page setup..."), NULL, page_setup_cb, 0, NULL},
549 {N_("/_File/_Print..."), "<control>P", print_cb, 0, NULL},
550 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
551 {N_("/_File/_Work offline"), "<control>W", toggle_work_offline_cb, 0, "<ToggleItem>"},
552 {N_("/_File/Synchronise folders"), "<control><shift>S", sync_cb, 0, NULL},
553 {N_("/_File/---"), NULL, NULL, 0, "<Separator>"},
554 /* {N_("/_File/_Close"), "<alt>W", app_exit_cb, 0, NULL}, */
555 {N_("/_File/E_xit"), "<control>Q", app_exit_cb, 0, NULL},
557 {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
558 {N_("/_Edit/_Copy"), "<control>C", copy_cb, 0, NULL},
559 {N_("/_Edit/Select _all"), "<control>A", allsel_cb, 0, NULL},
560 {N_("/_Edit/Select _thread"), NULL, select_thread_cb, 0, NULL},
561 {N_("/_Edit/_Delete thread"), NULL, delete_thread_cb, 0, NULL},
562 {N_("/_Edit/---"), NULL, NULL, 0, "<Separator>"},
563 {N_("/_Edit/_Find in current message..."),
564 "<control>F", search_cb, 0, NULL},
565 {N_("/_Edit/_Search folder..."), "<shift><control>F", search_cb, 1, NULL},
566 {N_("/_Edit/_Quick search"), "slash", mainwindow_quicksearch, 0, NULL},
567 {N_("/_View"), NULL, NULL, 0, "<Branch>"},
568 {N_("/_View/Show or hi_de"), NULL, NULL, 0, "<Branch>"},
569 {N_("/_View/Show or hi_de/_Message view"),
570 "V", toggle_message_cb, 0, "<ToggleItem>"},
571 {N_("/_View/Show or hi_de/_Toolbar"),
572 NULL, NULL, 0, "<Branch>"},
573 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
574 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
575 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
576 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
577 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
578 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
579 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
580 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
581 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
582 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
584 {N_("/_View/Show or hi_de/Status _bar"),
585 NULL, toggle_statusbar_cb, 0, "<ToggleItem>"},
587 {N_("/_View/Show or hi_de/Column headers"),
588 NULL, toggle_col_headers_cb, 0, "<ToggleItem>"},
589 {N_("/_View/Set displayed _columns"), NULL, NULL, 0, "<Branch>"},
590 {N_("/_View/Set displayed _columns/in _Folder list..."), NULL, set_folder_display_item_cb, 0, NULL},
591 {N_("/_View/Set displayed _columns/in _Message list..."),NULL, set_summary_display_item_cb, 0, NULL},
593 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
595 {N_("/_View/La_yout"), NULL, NULL, 0, "<Branch>"},
596 {N_("/_View/Layout/_Standard"), NULL, set_layout_cb, NORMAL_LAYOUT, "<RadioItem>"},
597 {N_("/_View/Layout/_Three columns"), NULL, set_layout_cb, VERTICAL_LAYOUT, "/View/Layout/Standard"},
598 {N_("/_View/Layout/_Wide message"), NULL, set_layout_cb, WIDE_LAYOUT, "/View/Layout/Standard"},
599 {N_("/_View/Layout/W_ide message list"),NULL, set_layout_cb, WIDE_MSGLIST_LAYOUT, "/View/Layout/Standard"},
600 {N_("/_View/Layout/S_mall screen"), NULL, set_layout_cb, SMALL_LAYOUT, "/View/Layout/Standard"},
601 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
603 {N_("/_View/_Sort"), NULL, NULL, 0, "<Branch>"},
604 {N_("/_View/_Sort/by _number"), NULL, sort_summary_cb, SORT_BY_NUMBER, "<RadioItem>"},
605 {N_("/_View/_Sort/by S_ize"), NULL, sort_summary_cb, SORT_BY_SIZE, "/View/Sort/by number"},
606 {N_("/_View/_Sort/by _Date"), NULL, sort_summary_cb, SORT_BY_DATE, "/View/Sort/by number"},
607 {N_("/_View/_Sort/by Thread date"), NULL, sort_summary_cb, SORT_BY_THREAD_DATE, "/View/Sort/by number"},
608 {N_("/_View/_Sort/by _From"), NULL, sort_summary_cb, SORT_BY_FROM, "/View/Sort/by number"},
609 {N_("/_View/_Sort/by _To"), NULL, sort_summary_cb, SORT_BY_TO, "/View/Sort/by number"},
610 {N_("/_View/_Sort/by S_ubject"), NULL, sort_summary_cb, SORT_BY_SUBJECT, "/View/Sort/by number"},
611 {N_("/_View/_Sort/by _color label"), NULL, sort_summary_cb, SORT_BY_LABEL, "/View/Sort/by number"},
612 {N_("/_View/_Sort/by tag"), NULL, sort_summary_cb, SORT_BY_TAGS, "/View/Sort/by number"},
613 {N_("/_View/_Sort/by _mark"), NULL, sort_summary_cb, SORT_BY_MARK, "/View/Sort/by number"},
614 {N_("/_View/_Sort/by _status"), NULL, sort_summary_cb, SORT_BY_STATUS, "/View/Sort/by number"},
615 {N_("/_View/_Sort/by a_ttachment"),
616 NULL, sort_summary_cb, SORT_BY_MIME, "/View/Sort/by number"},
617 {N_("/_View/_Sort/by score"), NULL, sort_summary_cb, SORT_BY_SCORE, "/View/Sort/by number"},
618 {N_("/_View/_Sort/by locked"), NULL, sort_summary_cb, SORT_BY_LOCKED, "/View/Sort/by number"},
619 {N_("/_View/_Sort/D_on't sort"), NULL, sort_summary_cb, SORT_BY_NONE, "/View/Sort/by number"},
620 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
621 {N_("/_View/_Sort/Ascending"), NULL, sort_summary_type_cb, SORT_ASCENDING, "<RadioItem>"},
622 {N_("/_View/_Sort/Descending"), NULL, sort_summary_type_cb, SORT_DESCENDING, "/View/Sort/Ascending"},
623 {N_("/_View/_Sort/---"), NULL, NULL, 0, "<Separator>"},
624 {N_("/_View/_Sort/_Attract by subject"),
625 NULL, attract_by_subject_cb, 0, NULL},
626 {N_("/_View/Th_read view"), "<control>T", thread_cb, 0, "<ToggleItem>"},
627 {N_("/_View/E_xpand all threads"), NULL, expand_threads_cb, 0, NULL},
628 {N_("/_View/Co_llapse all threads"), NULL, collapse_threads_cb, 0, NULL},
629 {N_("/_View/_Hide read messages"), NULL, hide_read_messages, 0, "<ToggleItem>"},
631 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
632 {N_("/_View/_Go to"), NULL, NULL, 0, "<Branch>"},
633 {N_("/_View/_Go to/_Previous message"), "P", prev_cb, 0, NULL},
634 {N_("/_View/_Go to/_Next message"), "N", next_cb, 0, NULL},
635 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
636 {N_("/_View/_Go to/P_revious unread message"),
637 "<shift>P", prev_unread_cb, 0, NULL},
638 {N_("/_View/_Go to/N_ext unread message"),
639 "<shift>N", next_unread_cb, 0, NULL},
640 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
641 {N_("/_View/_Go to/Previous ne_w message"), NULL, prev_new_cb, 0, NULL},
642 {N_("/_View/_Go to/Ne_xt new message"), NULL, next_new_cb, 0, NULL},
643 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
644 {N_("/_View/_Go to/Previous _marked message"),
645 NULL, prev_marked_cb, 0, NULL},
646 {N_("/_View/_Go to/Next m_arked message"),
647 NULL, next_marked_cb, 0, NULL},
648 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
649 {N_("/_View/_Go to/Previous _labeled message"),
650 NULL, prev_labeled_cb, 0, NULL},
651 {N_("/_View/_Go to/Next la_beled message"),
652 NULL, next_labeled_cb, 0, NULL},
653 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
654 {N_("/_View/_Go to/Last read message"),
655 NULL, last_read_cb, 0, NULL},
656 {N_("/_View/_Go to/Parent message"),
657 "<control>Up", parent_cb, 0, NULL},
658 {N_("/_View/_Go to/---"), NULL, NULL, 0, "<Separator>"},
659 {N_("/_View/_Go to/Next unread _folder"), "<shift>G", goto_unread_folder_cb, 0, NULL},
660 {N_("/_View/_Go to/_Other folder..."), "G", goto_folder_cb, 0, NULL},
661 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
663 #define ENC_SEPARATOR \
664 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"}
665 #define ENC_ACTION(action) \
666 NULL, set_charset_cb, action, "/View/Character encoding/Auto detect"
668 {N_("/_View/Character _encoding"), NULL, NULL, 0, "<Branch>"},
669 {N_("/_View/Character _encoding/_Auto detect"),
670 NULL, set_charset_cb, C_AUTO, "<RadioItem>"},
671 {N_("/_View/Character _encoding/---"), NULL, NULL, 0, "<Separator>"},
672 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
673 ENC_ACTION(C_US_ASCII)},
674 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
675 ENC_ACTION(C_UTF_8)},
678 {N_("/_View/Character _encoding/Western European (ISO-8859-_1)"),
679 ENC_ACTION(C_ISO_8859_1)},
680 {N_("/_View/Character _encoding/Western European (ISO-8859-15)"),
681 ENC_ACTION(C_ISO_8859_15)},
682 {N_("/_View/Character _encoding/Western European (Windows-1252)"),
683 ENC_ACTION(C_WINDOWS_1252)},
686 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
687 ENC_ACTION(C_ISO_8859_2)},
690 {N_("/_View/Character _encoding/_Baltic (ISO-8859-13)"),
691 ENC_ACTION(C_ISO_8859_13)},
692 {N_("/_View/Character _encoding/Baltic (ISO-8859-_4)"),
693 ENC_ACTION(C_ISO_8859_4)},
696 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
697 ENC_ACTION(C_ISO_8859_7)},
700 {N_("/_View/Character _encoding/Hebrew (ISO-8859-_8)"),
701 ENC_ACTION(C_ISO_8859_8)},
702 {N_("/_View/Character _encoding/Hebrew (Windows-1255)"),
703 ENC_ACTION(C_CP1255)},
706 {N_("/_View/Character _encoding/Arabic (ISO-8859-_6)"),
707 ENC_ACTION(C_ISO_8859_6)},
708 {N_("/_View/Character _encoding/Arabic (Windows-1256)"),
709 ENC_ACTION(C_CP1256)},
712 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
713 ENC_ACTION(C_ISO_8859_9)},
716 {N_("/_View/Character _encoding/Cyrillic (ISO-8859-_5)"),
717 ENC_ACTION(C_ISO_8859_5)},
718 {N_("/_View/Character _encoding/Cyrillic (KOI8-_R)"),
719 ENC_ACTION(C_KOI8_R)},
720 {N_("/_View/Character _encoding/Cyrillic (KOI8-U)"),
721 ENC_ACTION(C_KOI8_U)},
722 {N_("/_View/Character _encoding/Cyrillic (Windows-1251)"),
723 ENC_ACTION(C_CP1251)},
726 {N_("/_View/Character _encoding/Japanese (ISO-2022-_JP)"),
727 ENC_ACTION(C_ISO_2022_JP)},
728 {N_("/_View/Character _encoding/Japanese (ISO-2022-JP-2)"),
729 ENC_ACTION(C_ISO_2022_JP_2)},
730 {N_("/_View/Character _encoding/Japanese (_EUC-JP)"),
731 ENC_ACTION(C_EUC_JP)},
732 {N_("/_View/Character _encoding/Japanese (_Shift__JIS)"),
733 ENC_ACTION(C_SHIFT_JIS)},
736 {N_("/_View/Character _encoding/Simplified Chinese (_GB2312)"),
737 ENC_ACTION(C_GB2312)},
738 {N_("/_View/Character _encoding/Simplified Chinese (GBK)"),
740 {N_("/_View/Character _encoding/Traditional Chinese (_Big5)"),
742 {N_("/_View/Character _encoding/Traditional Chinese (EUC-_TW)"),
743 ENC_ACTION(C_EUC_TW)},
744 {N_("/_View/Character _encoding/Chinese (ISO-2022-_CN)"),
745 ENC_ACTION(C_ISO_2022_CN)},
748 {N_("/_View/Character _encoding/Korean (EUC-_KR)"),
749 ENC_ACTION(C_EUC_KR)},
750 {N_("/_View/Character _encoding/Korean (ISO-2022-KR)"),
751 ENC_ACTION(C_ISO_2022_KR)},
754 {N_("/_View/Character _encoding/Thai (TIS-620)"),
755 ENC_ACTION(C_TIS_620)},
756 {N_("/_View/Character _encoding/Thai (Windows-874)"),
757 ENC_ACTION(C_WINDOWS_874)},
762 #define DEC_SEPARATOR \
763 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
764 #define DEC_ACTION(action) \
765 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
766 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
767 {N_("/_View/Decode/_Auto detect"),
768 NULL, set_decode_cb, 0, "<RadioItem>"},
769 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
770 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
771 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
772 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
773 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
778 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
779 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
780 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
781 {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
782 {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
783 {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
784 {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
785 {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
786 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
787 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
789 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
790 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
791 {N_("/_Message/Recei_ve/Get from _current account"),
792 "<control>I", inc_mail_cb, 0, NULL},
793 {N_("/_Message/Recei_ve/Get from _all accounts"),
794 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
795 {N_("/_Message/Recei_ve/Cancel receivin_g"),
796 NULL, inc_cancel_cb, 0, NULL},
797 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
798 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
799 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
800 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
801 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
802 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
803 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
804 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
805 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
806 {N_("/_Message/Repl_y to/mailing _list"),
807 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
808 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
809 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
810 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
811 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
812 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
814 {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
815 {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
816 {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
817 {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
818 {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
819 {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
820 {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
822 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
823 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
824 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
825 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
826 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
827 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
828 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
829 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
830 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
831 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
832 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
833 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
834 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
835 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
836 {N_("/_Message/_Mark/Ignore thread"), NULL, ignore_thread_cb, 0, NULL},
837 {N_("/_Message/_Mark/Unignore thread"), NULL, unignore_thread_cb, 0, NULL},
838 {N_("/_Message/_Mark/Watch thread"), NULL, watch_thread_cb, 0, NULL},
839 {N_("/_Message/_Mark/Unwatch thread"), NULL, unwatch_thread_cb, 0, NULL},
840 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
841 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
842 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
843 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
844 {N_("/_Message/_Mark/Lock"), NULL, lock_msgs_cb, 0, NULL},
845 {N_("/_Message/_Mark/Unlock"), NULL, unlock_msgs_cb, 0, NULL},
846 {N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
847 {N_("/_Message/T_ags"), NULL, NULL, 0, NULL},
848 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
849 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
851 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
852 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
853 {N_("/_Tools/Add sender to address boo_k"),
854 NULL, add_address_cb, 0, NULL},
855 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
856 {N_("/_Tools/_Harvest addresses/from _Folder..."),
857 NULL, addr_harvest_cb, 0, NULL},
858 {N_("/_Tools/_Harvest addresses/from _Messages..."),
859 NULL, addr_harvest_msg_cb, 0, NULL},
860 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
861 {N_("/_Tools/_Filter all messages in folder"),
862 NULL, filter_cb, 0, NULL},
863 {N_("/_Tools/Filter _selected messages"),
864 NULL, filter_cb, 1, NULL},
865 {N_("/_Tools/Run folder processing rules"),
866 NULL, process_cb, 0, NULL},
867 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
868 {N_("/_Tools/_Create filter rule/_Automatically"),
869 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
870 {N_("/_Tools/_Create filter rule/by _From"),
871 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
872 {N_("/_Tools/_Create filter rule/by _To"),
873 NULL, create_filter_cb, FILTER_BY_TO, NULL},
874 {N_("/_Tools/_Create filter rule/by _Subject"),
875 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
876 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
877 {N_("/_Tools/C_reate processing rule/_Automatically"),
878 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
879 {N_("/_Tools/C_reate processing rule/by _From"),
880 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
881 {N_("/_Tools/C_reate processing rule/by _To"),
882 NULL, create_processing_cb, FILTER_BY_TO, NULL},
883 {N_("/_Tools/C_reate processing rule/by _Subject"),
884 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
885 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
886 {N_("/_Tools/List _URLs..."), "<shift><control>U", open_urls_cb, 0, NULL},
887 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
888 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
889 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
890 {N_("/_Tools/Ch_eck for new messages in all folders"),
891 NULL, update_folderview_cb, 0, NULL},
892 {N_("/_Tools/Delete du_plicated messages"),
893 NULL, NULL, 0, "<Branch>"},
894 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
895 NULL, delete_duplicated_cb, 0, NULL},
896 {N_("/_Tools/Delete du_plicated messages/In all folders"),
897 NULL, delete_duplicated_all_cb, 0, NULL},
898 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
899 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
901 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
902 {N_("/_Tools/SSL cer_tificates..."),
903 NULL, ssl_manager_open_cb, 0, NULL},
905 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
906 {N_("/_Tools/Filtering Log"), NULL, filtering_debug_window_show_cb, 0, NULL},
907 {N_("/_Tools/Network _Log"), "<shift><control>L", log_window_show_cb, 0, NULL},
909 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
910 {N_("/_Configuration/C_hange current account"),
911 NULL, NULL, 0, "<Branch>"},
912 {N_("/_Configuration/_Preferences for current account..."),
913 NULL, prefs_account_open_cb, 0, NULL},
914 {N_("/_Configuration/Create _new account..."),
915 NULL, new_account_cb, 0, NULL},
916 {N_("/_Configuration/_Edit accounts..."),
917 NULL, account_edit_open, 0, NULL},
918 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
919 {N_("/_Configuration/P_references..."),
920 NULL, prefs_open_cb, 0, NULL},
921 {N_("/_Configuration/Pre-pr_ocessing..."),
922 NULL, prefs_pre_processing_open_cb, 0, NULL},
923 {N_("/_Configuration/Post-pro_cessing..."),
924 NULL, prefs_post_processing_open_cb, 0, NULL},
925 {N_("/_Configuration/_Filtering..."),
926 NULL, prefs_filtering_open_cb, 0, NULL},
927 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
928 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
929 {N_("/_Configuration/Tag_s..."), NULL, prefs_tags_open_cb, 0, NULL},
930 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
931 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
933 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
934 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_CLAWS, NULL},
935 {N_("/_Help/_Online User-contributed FAQ"),
936 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
937 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
938 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
939 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
942 static gboolean offline_ask_sync = TRUE;
943 static guint lastkey;
944 static gboolean is_obscured = FALSE;
946 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
952 MainWindow *mainwin = (MainWindow *)user_data;
954 if (mainwin->summaryview &&
955 mainwin->summaryview->quicksearch &&
956 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
957 (mod == 0 || mod == GDK_SHIFT_MASK)) {
958 quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
964 #define N_COLOR_LABELS colorlabel_get_color_count()
966 static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
971 GtkCheckMenuItem **items;
976 mainwin = (MainWindow *)data;
977 g_return_if_fail(mainwin != NULL);
979 sel = summary_get_selection(mainwin->summaryview);
982 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
983 g_return_if_fail(menu != NULL);
985 Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
987 /* NOTE: don't return prematurely because we set the "dont_toggle"
988 * state for check menu items */
989 g_object_set_data(G_OBJECT(menu), "dont_toggle",
992 /* clear items. get item pointers. */
993 for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
994 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
995 gtk_check_menu_item_set_active
996 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
997 items[n] = GTK_CHECK_MENU_ITEM(cur->data);
1002 if (n == (N_COLOR_LABELS + 1)) {
1003 /* iterate all messages and set the state of the appropriate
1005 for (; sel != NULL; sel = sel->next) {
1009 msginfo = (MsgInfo *)sel->data;
1011 clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
1012 if (!items[clabel]->active)
1013 gtk_check_menu_item_set_active
1014 (items[clabel], TRUE);
1018 g_warning("invalid number of color elements (%d)\n", n);
1021 /* reset "dont_toggle" state */
1022 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1023 GINT_TO_POINTER(0));
1026 static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
1029 guint color = GPOINTER_TO_UINT(data);
1030 MainWindow *mainwin;
1032 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1033 g_return_if_fail(mainwin != NULL);
1035 /* "dont_toggle" state set? */
1036 if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
1040 summary_set_colorlabel(mainwin->summaryview, color, NULL);
1043 static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
1046 MainWindow *mainwin;
1050 GHashTable *menu_table = g_hash_table_new_full(
1054 GHashTable *menu_allsel_table = g_hash_table_new_full(
1059 mainwin = (MainWindow *)data;
1060 g_return_if_fail(mainwin != NULL);
1062 sel = summary_get_selection(mainwin->summaryview);
1065 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1066 g_return_if_fail(menu != NULL);
1068 /* NOTE: don't return prematurely because we set the "dont_toggle"
1069 * state for check menu items */
1070 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1071 GINT_TO_POINTER(1));
1073 /* clear items. get item pointers. */
1074 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1075 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
1076 gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
1078 gtk_check_menu_item_set_active
1079 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
1081 g_hash_table_insert(menu_table, GINT_TO_POINTER(id), GTK_CHECK_MENU_ITEM(cur->data));
1082 g_hash_table_insert(menu_allsel_table, GINT_TO_POINTER(id), GINT_TO_POINTER(0));
1086 /* iterate all messages and set the state of the appropriate
1089 for (; sel != NULL; sel = sel->next) {
1091 GSList *tags = NULL;
1093 GtkCheckMenuItem *item;
1094 msginfo = (MsgInfo *)sel->data;
1097 tags = msginfo->tags;
1101 for (; tags; tags = tags->next) {
1102 gint num_checked = GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table, tags->data));
1103 id = GPOINTER_TO_INT(tags->data);
1104 item = g_hash_table_lookup(menu_table, GINT_TO_POINTER(tags->data));
1105 if (item && !item->active) {
1106 gtk_check_menu_item_set_active
1110 g_hash_table_replace(menu_allsel_table, tags->data, GINT_TO_POINTER(num_checked));
1115 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1116 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
1117 gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
1119 gint num_checked = GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table, GINT_TO_POINTER(id)));
1120 if (num_checked < sel_len && num_checked > 0)
1121 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur->data), TRUE);
1123 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur->data), FALSE);
1127 g_hash_table_destroy(menu_table);
1128 g_hash_table_destroy(menu_allsel_table);
1129 /* reset "dont_toggle" state */
1130 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1131 GINT_TO_POINTER(0));
1134 static void mainwindow_tags_menu_item_activate_cb(GtkWidget *widget,
1137 gint id = GPOINTER_TO_INT(data);
1138 gboolean set = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
1139 MainWindow *mainwin;
1141 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1142 g_return_if_fail(mainwin != NULL);
1144 /* "dont_toggle" state set? */
1145 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1151 summary_set_tag(mainwin->summaryview, id, NULL);
1154 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
1156 GtkWidget *label_menuitem;
1161 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1162 "/Message/Color label");
1163 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1164 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_item_cb),
1166 gtk_widget_show(label_menuitem);
1168 menu = gtk_menu_new();
1170 /* create sub items. for the menu item activation callback we pass the
1171 * index of label_colors[] as data parameter. for the None color we
1172 * pass an invalid (high) value. also we attach a data pointer so we
1173 * can always get back the Mainwindow pointer. */
1175 item = gtk_check_menu_item_new_with_label(_("None"));
1176 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1177 g_signal_connect(G_OBJECT(item), "activate",
1178 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1179 GUINT_TO_POINTER(0));
1180 g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
1181 gtk_widget_show(item);
1183 gtk_widget_add_accelerator(item, "activate",
1184 mainwin->menu_factory->accel_group,
1185 GDK_0, GDK_CONTROL_MASK,
1186 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1188 item = gtk_menu_item_new();
1189 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1190 gtk_widget_show(item);
1192 /* create pixmap/label menu items */
1193 for (i = 0; i < N_COLOR_LABELS; i++) {
1194 item = colorlabel_create_check_color_menu_item(
1195 i, refresh, MAINWIN_COLORMENU);
1196 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1197 g_signal_connect(G_OBJECT(item), "activate",
1198 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1199 GUINT_TO_POINTER(i + 1));
1200 g_object_set_data(G_OBJECT(item), "mainwin",
1202 gtk_widget_show(item);
1204 gtk_widget_add_accelerator(item, "activate",
1205 mainwin->menu_factory->accel_group,
1206 GDK_1+i, GDK_CONTROL_MASK,
1207 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1209 gtk_widget_show(menu);
1210 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1211 mainwin->colorlabel_menu = menu;
1214 static void mainwindow_tags_menu_item_apply_tags_activate_cb(GtkWidget *widget,
1217 MainWindow *mainwin;
1219 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1220 g_return_if_fail(mainwin != NULL);
1222 /* "dont_toggle" state set? */
1223 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1227 tag_apply_open(summary_get_selection(mainwin->summaryview));
1230 static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
1232 GtkWidget *label_menuitem;
1235 GSList *cur = tags_get_list();
1237 gboolean existing_tags = FALSE;
1239 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1241 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1242 G_CALLBACK(mainwindow_tags_menu_item_activate_item_cb),
1245 gtk_widget_show(label_menuitem);
1247 menu = gtk_menu_new();
1249 /* create tags menu items */
1250 for (; cur; cur = cur->next) {
1251 gint id = GPOINTER_TO_INT(cur->data);
1252 const gchar *tag = tags_get_tag(id);
1254 item = gtk_check_menu_item_new_with_label(tag);
1255 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1256 g_signal_connect(G_OBJECT(item), "activate",
1257 G_CALLBACK(mainwindow_tags_menu_item_activate_cb),
1258 GINT_TO_POINTER(id));
1259 g_object_set_data(G_OBJECT(item), "mainwin",
1261 g_object_set_data(G_OBJECT(item), "tag_id",
1262 GINT_TO_POINTER(id));
1263 gtk_widget_show(item);
1264 existing_tags = TRUE;
1266 if (existing_tags) {
1268 item = gtk_menu_item_new();
1269 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1270 gtk_widget_show(item);
1273 item = gtk_menu_item_new_with_label(_("Apply tags..."));
1274 gtk_widget_add_accelerator(item, "activate",
1275 mainwin->menu_factory->accel_group,
1276 GDK_T, GDK_CONTROL_MASK|GDK_SHIFT_MASK,
1277 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1278 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1279 g_signal_connect(G_OBJECT(item), "activate",
1280 G_CALLBACK(mainwindow_tags_menu_item_apply_tags_activate_cb),
1282 g_object_set_data(G_OBJECT(item), "mainwin",
1284 gtk_widget_show(item);
1287 gtk_widget_show(menu);
1288 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1289 mainwin->tags_menu = menu;
1292 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
1293 MainWindow *mainwindow)
1295 if (evt && evt->button == 1) {
1296 log_window_show_error(mainwindow->logwin);
1297 gtk_widget_hide(mainwindow->warning_btn);
1302 static gboolean warning_visi_notify(GtkWidget *widget,
1303 GdkEventVisibility *event,
1304 MainWindow *mainwindow)
1306 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1310 static gboolean warning_leave_notify(GtkWidget *widget,
1311 GdkEventCrossing *event,
1312 MainWindow *mainwindow)
1314 gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
1318 static gboolean warning_enter_notify(GtkWidget *widget,
1319 GdkEventCrossing *event,
1320 MainWindow *mainwindow)
1322 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1326 void mainwindow_show_error(void)
1328 MainWindow *mainwin = mainwindow_get_mainwindow();
1329 gtk_widget_show(mainwin->warning_btn);
1332 void mainwindow_clear_error(MainWindow *mainwin)
1334 gtk_widget_hide(mainwin->warning_btn);
1337 MainWindow *main_window_create()
1339 MainWindow *mainwin;
1343 GtkWidget *handlebox;
1344 GtkWidget *vbox_body;
1346 GtkWidget *hbox_stat;
1347 GtkWidget *statusbar;
1348 GtkWidget *progressbar;
1349 GtkWidget *statuslabel;
1350 GtkWidget *ac_button;
1351 GtkWidget *ac_label;
1352 GtkWidget *online_pixmap;
1353 GtkWidget *offline_pixmap;
1355 GtkWidget *warning_icon;
1356 GtkWidget *warning_btn;
1358 GtkWidget *online_switch;
1359 GtkWidget *offline_switch;
1360 FolderView *folderview;
1361 SummaryView *summaryview;
1362 MessageView *messageview;
1363 GdkColormap *colormap;
1365 gboolean success[4];
1366 GtkItemFactory *ifactory;
1368 GtkWidget *menuitem;
1370 guint n_menu_entries;
1372 static GdkGeometry geometry;
1374 debug_print("Creating main window...\n");
1375 mainwin = g_new0(MainWindow, 1);
1378 window = GTK_WIDGET(gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow"));
1379 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1380 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1382 prefs_common.layout_mode = SMALL_LAYOUT;
1384 if (!geometry.min_height) {
1385 geometry.min_width = 320;
1386 geometry.min_height = 200;
1388 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1391 g_signal_connect(G_OBJECT(window), "delete_event",
1392 G_CALLBACK(main_window_close_cb), mainwin);
1393 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1394 g_signal_connect(G_OBJECT(window), "focus_in_event",
1395 G_CALLBACK(mainwindow_focus_in_event),
1397 g_signal_connect(G_OBJECT(window), "key_press_event",
1398 G_CALLBACK(mainwindow_key_pressed), mainwin);
1400 gtk_widget_realize(window);
1401 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1404 gtkut_widget_set_app_icon(window);
1406 vbox = gtk_vbox_new(FALSE, 0);
1407 gtk_widget_show(vbox);
1408 gtk_container_add(GTK_CONTAINER(window), vbox);
1411 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1412 menubar = menubar_create(window, mainwin_entries,
1413 n_menu_entries, "<Main>", mainwin);
1414 gtk_widget_show(menubar);
1417 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1420 ifactory = gtk_item_factory_from_widget(menubar);
1422 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1423 main_create_mailing_list_menu (mainwin, NULL); */
1425 if (prefs_common.toolbar_detachable) {
1426 handlebox = gtk_handle_box_new();
1427 gtk_widget_show(handlebox);
1428 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1429 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1430 G_CALLBACK(toolbar_child_attached), mainwin);
1431 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1432 G_CALLBACK(toolbar_child_detached), mainwin);
1434 handlebox = gtk_hbox_new(FALSE, 0);
1435 gtk_widget_show(handlebox);
1436 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1438 /* link window to mainwin->window to avoid gdk warnings */
1439 mainwin->window = window;
1440 mainwin_list = g_list_append(mainwin_list, mainwin);
1443 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1447 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1451 toolbar_set_learn_button
1455 /* vbox that contains body */
1456 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1457 gtk_widget_show(vbox_body);
1458 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1459 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1462 hbox_stat = gtk_hbox_new(FALSE, 2);
1463 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1465 tips = gtk_tooltips_new();
1467 warning_icon = gtk_image_new_from_stock
1468 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1469 warning_btn = gtk_event_box_new();
1470 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1472 mainwin->warning_btn = warning_btn;
1474 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1475 G_CALLBACK(warning_icon_pressed),
1476 (gpointer) mainwin);
1477 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1478 G_CALLBACK(warning_visi_notify), mainwin);
1479 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1480 G_CALLBACK(warning_visi_notify), mainwin);
1481 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1482 G_CALLBACK(warning_leave_notify), mainwin);
1483 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1484 G_CALLBACK(warning_enter_notify), mainwin);
1486 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1488 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1489 _("Some error(s) happened. Click here to view log."), NULL);
1490 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1492 statusbar = statusbar_create();
1493 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1495 progressbar = gtk_progress_bar_new();
1496 gtk_widget_set_size_request(progressbar, 120, 1);
1497 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1499 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1500 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1501 online_switch = gtk_button_new ();
1502 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1503 _("You are online. Click the icon to go offline"), NULL);
1504 offline_switch = gtk_button_new ();
1505 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1506 _("You are offline. Click the icon to go online"),
1508 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1509 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1510 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1511 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1512 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1513 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1514 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1515 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1517 statuslabel = gtk_label_new("");
1518 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1520 ac_button = gtk_button_new();
1521 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1522 ac_button, _("Select account"), NULL);
1523 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1524 gtk_widget_set_size_request(ac_button, -1, 0);
1525 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1526 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1527 G_CALLBACK(ac_label_button_pressed), mainwin);
1529 ac_label = gtk_label_new("");
1530 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1532 gtk_widget_show_all(hbox_stat);
1534 gtk_widget_hide(offline_switch);
1535 gtk_widget_hide(warning_btn);
1537 online_switch = gtk_button_new ();
1538 offline_switch = gtk_button_new ();
1539 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1540 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1543 mainwin->folderview = folderview = folderview_create();
1544 mainwin->summaryview = summaryview = summary_create();
1545 mainwin->messageview = messageview = messageview_create(mainwin);
1547 /* init log instances data before creating log views */
1548 set_log_title(LOG_PROTOCOL, _("Network log"));
1549 set_log_prefs(LOG_PROTOCOL,
1550 &prefs_common.logwin_width,
1551 &prefs_common.logwin_height);
1552 set_log_title(LOG_DEBUG_FILTERING, _("Filtering/processing debug log"));
1553 set_log_prefs(LOG_DEBUG_FILTERING,
1554 &prefs_common.filtering_debugwin_width,
1555 &prefs_common.filtering_debugwin_height);
1557 /* setup log windows */
1558 mainwin->logwin = log_window_create(LOG_PROTOCOL);
1559 log_window_init(mainwin->logwin);
1561 mainwin->filtering_debugwin = log_window_create(LOG_DEBUG_FILTERING);
1562 log_window_set_clipping(mainwin->logwin,
1563 prefs_common.cliplog,
1564 prefs_common.loglength);
1566 log_window_init(mainwin->filtering_debugwin);
1567 log_window_set_clipping(mainwin->filtering_debugwin,
1568 prefs_common.filtering_debug_cliplog,
1569 prefs_common.filtering_debug_loglength);
1570 if (prefs_common.enable_filtering_debug)
1571 log_message(LOG_DEBUG_FILTERING, _("filtering log enabled\n"));
1573 log_message(LOG_DEBUG_FILTERING, _("filtering log disabled\n"));
1575 folderview->mainwin = mainwin;
1576 folderview->summaryview = summaryview;
1578 summaryview->mainwin = mainwin;
1579 summaryview->folderview = folderview;
1580 summaryview->messageview = messageview;
1581 summaryview->window = window;
1583 mainwin->vbox = vbox;
1584 mainwin->menubar = menubar;
1585 mainwin->menu_factory = ifactory;
1586 mainwin->handlebox = handlebox;
1587 mainwin->vbox_body = vbox_body;
1588 mainwin->online_switch = online_switch;
1589 mainwin->offline_switch = offline_switch;
1591 messageview->statusbar = statusbar;
1592 mainwin->statusbar = statusbar;
1593 mainwin->hbox_stat = hbox_stat;
1594 mainwin->progressbar = progressbar;
1595 mainwin->statuslabel = statuslabel;
1596 mainwin->online_pixmap = online_pixmap;
1597 mainwin->offline_pixmap = offline_pixmap;
1598 mainwin->ac_button = ac_button;
1599 mainwin->ac_label = ac_label;
1600 /* set context IDs for status bar */
1601 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1602 (GTK_STATUSBAR(statusbar), "Main Window");
1603 mainwin->folderview_cid = gtk_statusbar_get_context_id
1604 (GTK_STATUSBAR(statusbar), "Folder View");
1605 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1606 (GTK_STATUSBAR(statusbar), "Summary View");
1607 mainwin->messageview_cid = gtk_statusbar_get_context_id
1608 (GTK_STATUSBAR(statusbar), "Message View");
1609 messageview->statusbar_cid = mainwin->messageview_cid;
1612 messageview->statusbar = NULL;
1613 mainwin->statusbar = NULL;
1614 mainwin->hbox_stat = NULL;
1615 /* mainwin->progressbar is set in toolbar.c */
1616 mainwin->statuslabel = NULL;
1617 mainwin->online_pixmap = NULL;
1618 mainwin->offline_pixmap = NULL;
1619 mainwin->ac_button = NULL;
1620 mainwin->ac_label = NULL;
1623 /* allocate colors for summary view and folder view */
1624 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1625 summaryview->color_marked.blue = (guint16)65535;
1627 summaryview->color_dim.red = summaryview->color_dim.green =
1628 summaryview->color_dim.blue = COLOR_DIM;
1630 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1631 &folderview->color_new);
1633 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1634 &folderview->color_op);
1636 summaryview->color_important.red = 0;
1637 summaryview->color_important.green = 0;
1638 summaryview->color_important.blue = (guint16)65535;
1640 color[0] = summaryview->color_marked;
1641 color[1] = summaryview->color_dim;
1642 color[2] = folderview->color_new;
1643 color[3] = folderview->color_op;
1645 colormap = gdk_drawable_get_colormap(window->window);
1646 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1647 for (i = 0; i < 4; i++) {
1648 if (success[i] == FALSE)
1649 g_warning("MainWindow: color allocation %d failed\n", i);
1652 debug_print("done.\n");
1654 messageview->visible = prefs_common.msgview_visible;
1656 main_window_set_widgets(mainwin, prefs_common.layout_mode);
1658 g_signal_connect(G_OBJECT(window), "size_allocate",
1659 G_CALLBACK(main_window_size_allocate_cb),
1662 /* set menu items */
1663 menuitem = gtk_item_factory_get_item
1664 (ifactory, "/View/Character encoding/Auto detect");
1665 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1667 switch (prefs_common.toolbar_style) {
1669 menuitem = gtk_item_factory_get_item
1670 (ifactory, "/View/Show or hide/Toolbar/Hide");
1673 menuitem = gtk_item_factory_get_item
1674 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1677 menuitem = gtk_item_factory_get_item
1678 (ifactory, "/View/Show or hide/Toolbar/Text only");
1681 menuitem = gtk_item_factory_get_item
1682 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1684 case TOOLBAR_BOTH_HORIZ:
1685 menuitem = gtk_item_factory_get_item
1687 "/View/Show or hide/Toolbar/Text beside icons");
1689 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1692 gtk_widget_hide(mainwin->hbox_stat);
1693 menuitem = gtk_item_factory_get_item
1694 (ifactory, "/View/Show or hide/Status bar");
1695 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1696 prefs_common.show_statusbar);
1698 menuitem = gtk_item_factory_get_item
1699 (ifactory, "/View/Show or hide/Column headers");
1700 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1701 prefs_common.show_col_headers);
1702 /* set account selection menu */
1703 ac_menu = gtk_item_factory_get_widget
1704 (ifactory, "/Configuration/Change current account");
1705 mainwin->ac_menu = ac_menu;
1707 toolbar_main_set_sensitive(mainwin);
1709 /* create actions menu */
1710 main_window_update_actions_menu(mainwin);
1712 main_create_mailing_list_menu (mainwin, NULL);
1714 /* attach accel groups to main window */
1715 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1716 gtk_window_add_accel_group \
1718 gtk_item_factory_from_widget(menu)->accel_group); \
1719 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1721 G_CALLBACK(main_window_accel_activate), mainwin);
1724 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1726 /* connect the accelerators for equivalent
1727 menu items in different menus */
1728 menu_connect_identical_items();
1731 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1734 g_signal_connect(G_OBJECT(window), "window_state_event",
1735 G_CALLBACK(mainwindow_state_event_cb), mainwin);
1736 g_signal_connect(G_OBJECT(window), "visibility_notify_event",
1737 G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
1738 gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
1740 if (prefs_common.layout_mode == VERTICAL_LAYOUT ||
1741 prefs_common.layout_mode == SMALL_LAYOUT) {
1742 summary_relayout(mainwin->summaryview);
1744 summary_update_unread(mainwin->summaryview, NULL);
1746 gtk_widget_show(mainwin->window);
1748 /* initialize views */
1749 folderview_init(folderview);
1750 summary_init(summaryview);
1751 messageview_init(messageview);
1753 sslcertwindow_register_hook();
1755 mainwin->lock_count = 0;
1756 mainwin->menu_lock_count = 0;
1757 mainwin->cursor_count = 0;
1759 mainwin->progressindicator_hook =
1760 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1763 watch_cursor = gdk_cursor_new(GDK_WATCH);
1765 hand_cursor = gdk_cursor_new(GDK_HAND2);
1767 /* init work_offline */
1768 if (prefs_common.work_offline)
1769 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1771 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1772 mainwindow_tags_menu_create(mainwin, FALSE);
1777 void main_window_destroy(MainWindow *mainwin)
1779 /* TODO : destroy other component */
1780 messageview_destroy(mainwin->messageview);
1781 mainwin->messageview = NULL;
1784 void main_window_update_actions_menu(MainWindow *mainwin)
1786 GtkItemFactory *ifactory;
1788 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1789 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1792 void main_window_cursor_wait(MainWindow *mainwin)
1795 if (mainwin->cursor_count == 0) {
1796 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1797 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1800 mainwin->cursor_count++;
1805 void main_window_cursor_normal(MainWindow *mainwin)
1807 if (mainwin->cursor_count)
1808 mainwin->cursor_count--;
1810 if (mainwin->cursor_count == 0) {
1811 gdk_window_set_cursor(mainwin->window->window, NULL);
1812 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1817 /* lock / unlock the user-interface */
1818 void main_window_lock(MainWindow *mainwin)
1820 if (mainwin->lock_count == 0 && mainwin->ac_button)
1821 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1823 mainwin->lock_count++;
1825 main_window_set_menu_sensitive(mainwin);
1826 toolbar_main_set_sensitive(mainwin);
1829 void main_window_unlock(MainWindow *mainwin)
1831 if (mainwin->lock_count)
1832 mainwin->lock_count--;
1834 main_window_set_menu_sensitive(mainwin);
1835 toolbar_main_set_sensitive(mainwin);
1837 if (mainwin->lock_count == 0 && mainwin->ac_button)
1838 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1841 static void main_window_menu_callback_block(MainWindow *mainwin)
1843 mainwin->menu_lock_count++;
1846 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1848 if (mainwin->menu_lock_count)
1849 mainwin->menu_lock_count--;
1852 static guint prefs_tag = 0;
1854 void main_window_reflect_prefs_all(void)
1856 main_window_reflect_prefs_all_real(FALSE);
1859 static gboolean reflect_prefs_timeout_cb(gpointer data)
1861 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1863 MainWindow *mainwin;
1866 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1867 mainwin = (MainWindow *)cur->data;
1869 main_window_show_cur_account(mainwin);
1870 main_window_set_menu_sensitive(mainwin);
1871 toolbar_main_set_sensitive(mainwin);
1874 if (pixmap_theme_changed) {
1875 toolbar_update(TOOLBAR_MAIN, mainwin);
1876 messageview_reflect_prefs_pixmap_theme();
1877 compose_reflect_prefs_pixmap_theme();
1878 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1879 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1881 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1882 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1883 mainwin->online_pixmap);
1884 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1885 gtk_widget_show(pixmap);
1886 mainwin->online_pixmap = pixmap;
1887 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1888 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1889 mainwin->offline_pixmap);
1890 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1891 gtk_widget_show(pixmap);
1892 mainwin->offline_pixmap = pixmap;
1896 headerview_set_font(mainwin->messageview->headerview);
1897 headerview_set_visibility(mainwin->messageview->headerview,
1898 prefs_common.display_header_pane);
1899 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1900 folderview_reflect_prefs();
1901 summary_reflect_prefs();
1903 summary_redisplay_msg(mainwin->summaryview);
1905 if (prefs_common.layout_mode == SMALL_LAYOUT) {
1906 if (mainwin->in_folder) {
1907 mainwindow_enter_folder(mainwin);
1909 mainwindow_exit_folder(mainwin);
1917 void main_window_reflect_prefs_all_now(void)
1919 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1922 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1927 /* re-create colorlabel submenu */
1928 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1929 g_return_if_fail(menu != NULL);
1931 /* clear items. get item pointers. */
1932 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1933 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1935 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1936 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1940 void main_window_reflect_tags_changes(MainWindow *mainwin)
1945 /* re-create tags submenu */
1946 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1947 g_return_if_fail(menu != NULL);
1949 /* clear items. get item pointers. */
1950 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1951 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1953 mainwindow_tags_menu_create(mainwin, TRUE);
1954 summary_reflect_tags_changes(mainwin->summaryview);
1958 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1960 if (prefs_tag == 0 || pixmap_theme_changed) {
1961 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1962 GINT_TO_POINTER(pixmap_theme_changed));
1966 void main_window_set_summary_column(void)
1969 MainWindow *mainwin;
1971 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1972 mainwin = (MainWindow *)cur->data;
1973 summary_set_column_order(mainwin->summaryview);
1977 void main_window_set_folder_column(void)
1980 MainWindow *mainwin;
1982 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1983 mainwin = (MainWindow *)cur->data;
1984 folderview_set_column_order(mainwin->folderview);
1988 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1989 GList *account_list)
1991 GList *cur_ac, *cur_item;
1992 GtkWidget *menuitem;
1993 PrefsAccount *ac_prefs;
1995 /* destroy all previous menu item */
1996 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1997 while (cur_item != NULL) {
1998 GList *next = cur_item->next;
1999 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
2003 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2004 ac_prefs = (PrefsAccount *)cur_ac->data;
2006 menuitem = gtk_menu_item_new_with_label
2007 (ac_prefs->account_name
2008 ? ac_prefs->account_name : _("Untitled"));
2009 gtk_widget_show(menuitem);
2010 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
2011 g_signal_connect(G_OBJECT(menuitem), "activate",
2012 G_CALLBACK(account_selector_menu_cb),
2017 static void main_window_set_account_receive_menu(MainWindow *mainwin,
2018 GList *account_list)
2020 GList *cur_ac, *cur_item;
2022 GtkWidget *menuitem;
2023 PrefsAccount *ac_prefs;
2025 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
2026 "/Message/Receive");
2028 /* search for separator */
2029 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2030 cur_item = cur_item->next) {
2031 if (GTK_BIN(cur_item->data)->child == NULL) {
2032 cur_item = cur_item->next;
2037 /* destroy all previous menu item */
2038 while (cur_item != NULL) {
2039 GList *next = cur_item->next;
2040 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
2044 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2045 ac_prefs = (PrefsAccount *)cur_ac->data;
2047 menuitem = gtk_menu_item_new_with_label
2048 (ac_prefs->account_name ? ac_prefs->account_name
2050 gtk_widget_show(menuitem);
2051 gtk_menu_append(GTK_MENU(menu), menuitem);
2052 g_signal_connect(G_OBJECT(menuitem), "activate",
2053 G_CALLBACK(account_receive_menu_cb),
2058 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
2059 GList *account_list)
2062 GtkWidget *menuitem;
2063 PrefsAccount *ac_prefs;
2064 GtkWidget *menu = NULL;
2066 if (mainwin->toolbar->getall_btn == NULL) /* button doesn't exist */
2069 menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn));
2071 gtk_widget_destroy(menu);
2072 menu = gtk_menu_new();
2074 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2075 ac_prefs = (PrefsAccount *)cur_ac->data;
2077 menuitem = gtk_menu_item_new_with_label
2078 (ac_prefs->account_name
2079 ? ac_prefs->account_name : _("Untitled"));
2080 gtk_widget_show(menuitem);
2081 gtk_menu_append(GTK_MENU(menu), menuitem);
2082 g_signal_connect(G_OBJECT(menuitem), "activate",
2083 G_CALLBACK(account_receive_menu_cb),
2086 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn), menu);
2089 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
2090 GList *account_list)
2094 GtkWidget *menuitem;
2095 PrefsAccount *ac_prefs;
2096 GtkWidget *menu = NULL;
2098 if (mainwin->toolbar->compose_mail_btn == NULL) /* button doesn't exist */
2101 menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn));
2103 gtk_widget_destroy(menu);
2104 menu = gtk_menu_new();
2106 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2107 ac_prefs = (PrefsAccount *)cur_ac->data;
2109 menuitem = gtk_menu_item_new_with_label
2110 (ac_prefs->account_name
2111 ? ac_prefs->account_name : _("Untitled"));
2112 gtk_widget_show(menuitem);
2113 gtk_menu_append(GTK_MENU(menu), menuitem);
2114 g_signal_connect(G_OBJECT(menuitem), "activate",
2115 G_CALLBACK(account_compose_menu_cb),
2118 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn), menu);
2122 void main_window_set_account_menu(GList *account_list)
2125 MainWindow *mainwin;
2127 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2128 mainwin = (MainWindow *)cur->data;
2129 main_window_set_account_selector_menu(mainwin, account_list);
2130 main_window_set_account_receive_menu(mainwin, account_list);
2131 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2132 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2134 hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
2137 void main_window_set_account_menu_only_toolbar(GList *account_list)
2140 MainWindow *mainwin;
2142 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2143 mainwin = (MainWindow *)cur->data;
2144 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2145 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2149 static void main_window_show_cur_account(MainWindow *mainwin)
2154 ac_name = g_strdup(cur_account
2155 ? (cur_account->account_name
2156 ? cur_account->account_name : _("Untitled"))
2160 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
2162 buf = g_strdup(PROG_VERSION);
2163 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
2166 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
2167 if (mainwin->ac_button)
2168 gtk_widget_queue_resize(mainwin->ac_button);
2173 static void main_window_separation_change(MainWindow *mainwin, LayoutType layout_mode)
2175 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
2176 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
2177 GtkWidget *message_wid = mainwin->messageview->vbox;
2179 if (layout_mode == prefs_common.layout_mode)
2182 debug_print("Changing window separation type from %d to %d\n",
2183 prefs_common.layout_mode, layout_mode);
2185 /* remove widgets from those containers */
2186 gtk_widget_ref(folder_wid);
2187 gtk_widget_ref(summary_wid);
2188 gtk_widget_ref(message_wid);
2189 gtkut_container_remove
2190 (GTK_CONTAINER(folder_wid->parent), folder_wid);
2191 gtkut_container_remove
2192 (GTK_CONTAINER(summary_wid->parent), summary_wid);
2193 gtkut_container_remove
2194 (GTK_CONTAINER(message_wid->parent), message_wid);
2196 gtk_widget_hide(mainwin->window);
2197 main_window_set_widgets(mainwin, layout_mode);
2198 gtk_widget_show(mainwin->window);
2200 gtk_widget_unref(folder_wid);
2201 gtk_widget_unref(summary_wid);
2202 gtk_widget_unref(message_wid);
2205 void mainwindow_reset_paned(GtkPaned *paned)
2209 if (gtk_paned_get_child1(GTK_PANED(paned)))
2210 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2211 if (gtk_paned_get_child2(GTK_PANED(paned)))
2212 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2215 g_object_get (G_OBJECT(paned),
2218 g_object_get (G_OBJECT(paned),
2222 gtk_paned_set_position(GTK_PANED(paned), mid);
2225 static void mainwin_paned_show_first(GtkPaned *paned)
2228 g_object_get (G_OBJECT(paned),
2232 if (gtk_paned_get_child1(GTK_PANED(paned)))
2233 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2234 if (gtk_paned_get_child2(GTK_PANED(paned)))
2235 gtk_widget_hide(gtk_paned_get_child2(GTK_PANED(paned)));
2236 gtk_paned_set_position(GTK_PANED(paned), max);
2239 static void mainwin_paned_show_last(GtkPaned *paned)
2242 g_object_get (G_OBJECT(paned),
2246 if (gtk_paned_get_child1(GTK_PANED(paned)))
2247 gtk_widget_hide(gtk_paned_get_child1(GTK_PANED(paned)));
2248 if (gtk_paned_get_child2(GTK_PANED(paned)))
2249 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2250 gtk_paned_set_position(GTK_PANED(paned), min);
2253 void main_window_toggle_message_view(MainWindow *mainwin)
2255 SummaryView *summaryview = mainwin->summaryview;
2256 GtkWidget *ppaned = NULL;
2257 GtkWidget *container = NULL;
2259 switch (prefs_common.layout_mode) {
2261 case VERTICAL_LAYOUT:
2263 ppaned = mainwin->vpaned;
2264 container = mainwin->hpaned;
2265 if (ppaned->parent != NULL) {
2266 mainwin->messageview->visible = FALSE;
2267 summaryview->displayed = NULL;
2268 gtk_widget_ref(ppaned);
2269 gtkut_container_remove(GTK_CONTAINER(container), ppaned);
2270 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
2272 mainwin->messageview->visible = TRUE;
2273 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), ppaned);
2274 gtk_container_add(GTK_CONTAINER(container), ppaned);
2275 gtk_widget_unref(ppaned);
2279 ppaned = mainwin->hpaned;
2280 container = mainwin->vpaned;
2281 if (mainwin->messageview->vbox->parent != NULL) {
2282 mainwin->messageview->visible = FALSE;
2283 summaryview->displayed = NULL;
2284 gtk_widget_ref(mainwin->messageview->vbox);
2285 gtkut_container_remove(GTK_CONTAINER(container), mainwin->messageview->vbox);
2287 mainwin->messageview->visible = TRUE;
2288 gtk_container_add(GTK_CONTAINER(container), mainwin->messageview->vbox);
2289 gtk_widget_unref(mainwin->messageview->vbox);
2292 case WIDE_MSGLIST_LAYOUT:
2293 g_warning("can't hide messageview in this wide msglist layout");
2297 if (messageview_is_visible(mainwin->messageview))
2298 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2299 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2301 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2302 GTK_ARROW_UP, GTK_SHADOW_OUT);
2304 if (mainwin->messageview->visible == FALSE)
2305 messageview_clear(mainwin->messageview);
2307 main_window_set_menu_sensitive(mainwin);
2309 prefs_common.msgview_visible = mainwin->messageview->visible;
2311 if (messageview_is_visible(mainwin->messageview)) {
2312 gtk_widget_queue_resize(mainwin->hpaned);
2313 gtk_widget_queue_resize(mainwin->vpaned);
2315 summary_grab_focus(summaryview);
2318 void main_window_get_size(MainWindow *mainwin)
2320 GtkAllocation *allocation;
2322 if (mainwin_list == NULL || mainwin->messageview == NULL) {
2323 debug_print("called after messageview "
2324 "has been deallocated!\n");
2328 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
2330 if (allocation->width > 1 && allocation->height > 1) {
2331 prefs_common.summaryview_width = allocation->width;
2333 if (messageview_is_visible(mainwin->messageview))
2334 prefs_common.summaryview_height = allocation->height;
2336 prefs_common.mainview_width = allocation->width;
2339 allocation = &mainwin->window->allocation;
2340 if (allocation->width > 1 && allocation->height > 1) {
2341 prefs_common.mainview_height = allocation->height;
2342 prefs_common.mainwin_width = allocation->width;
2343 prefs_common.mainwin_height = allocation->height;
2346 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
2347 if (allocation->width > 1 && allocation->height > 1) {
2348 prefs_common.folderview_width = allocation->width;
2349 prefs_common.folderview_height = allocation->height;
2352 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
2353 if (allocation->width > 1 && allocation->height > 1) {
2354 prefs_common.msgview_width = allocation->width;
2355 prefs_common.msgview_height = allocation->height;
2358 /* debug_print("summaryview size: %d x %d\n",
2359 prefs_common.summaryview_width,
2360 prefs_common.summaryview_height);
2361 debug_print("folderview size: %d x %d\n",
2362 prefs_common.folderview_width,
2363 prefs_common.folderview_height);
2364 debug_print("messageview size: %d x %d\n",
2365 prefs_common.msgview_width,
2366 prefs_common.msgview_height); */
2369 void main_window_get_position(MainWindow *mainwin)
2373 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2375 prefs_common.mainview_x = x;
2376 prefs_common.mainview_y = y;
2377 prefs_common.mainwin_x = x;
2378 prefs_common.mainwin_y = y;
2380 debug_print("main window position: %d, %d\n", x, y);
2383 void main_window_progress_on(MainWindow *mainwin)
2385 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2388 void main_window_progress_off(MainWindow *mainwin)
2390 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2391 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2394 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
2398 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
2399 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
2400 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
2401 (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
2404 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2406 if (confirm && procmsg_have_trashed_mails_fast()) {
2407 if (alertpanel(_("Empty trash"),
2408 _("Delete all messages in trash folders?"),
2409 GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL)
2410 != G_ALERTALTERNATE)
2412 manage_window_focus_in(mainwin->window, NULL, NULL);
2415 procmsg_empty_all_trash();
2417 if (mainwin->summaryview->folder_item &&
2418 mainwin->summaryview->folder_item->stype == F_TRASH)
2419 gtk_widget_grab_focus(mainwin->folderview->ctree);
2422 void main_window_add_mailbox(MainWindow *mainwin)
2427 path = input_dialog(_("Add mailbox"),
2428 _("Input the location of mailbox.\n"
2429 "If an existing mailbox is specified, it will be\n"
2430 "scanned automatically."),
2433 if (folder_find_from_path(path)) {
2434 alertpanel_error(_("The mailbox '%s' already exists."), path);
2438 folder = folder_new(folder_get_class_from_string("mh"),
2439 !strcmp(path, "Mail") ? _("Mailbox") :
2440 g_path_get_basename(path), path);
2443 if (folder->klass->create_tree(folder) < 0) {
2444 alertpanel_error(_("Creation of the mailbox failed.\n"
2445 "Maybe some files already exist, or you don't have the permission to write there."));
2446 folder_destroy(folder);
2451 folder_set_ui_func(folder, scan_tree_func, mainwin);
2452 folder_scan_tree(folder, TRUE);
2453 folder_set_ui_func(folder, NULL, NULL);
2456 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2458 SensitiveCond state = 0;
2459 SummarySelection selection;
2460 FolderItem *item = mainwin->summaryview->folder_item;
2461 GList *account_list = account_get_list();
2464 selection = summary_get_selection_type(mainwin->summaryview);
2466 if (mainwin->lock_count == 0 && !claws_is_starting())
2467 state |= M_UNLOCKED;
2468 if (selection != SUMMARY_NONE)
2469 state |= M_MSG_EXIST;
2470 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2472 /* if (item->folder->type != F_NEWS) */
2473 state |= M_ALLOW_DELETE;
2475 if (prefs_common.immediate_exec == 0
2476 && mainwin->lock_count == 0)
2477 state |= M_DELAY_EXEC;
2479 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2480 || selection != SUMMARY_NONE)
2481 state |= M_HIDE_READ_MSG;
2483 if (mainwin->summaryview->threaded)
2484 state |= M_THREADED;
2486 state |= M_UNTHREADED;
2487 if (selection == SUMMARY_SELECTED_SINGLE ||
2488 selection == SUMMARY_SELECTED_MULTIPLE)
2489 state |= M_TARGET_EXIST;
2490 if (selection == SUMMARY_SELECTED_SINGLE)
2491 state |= M_SINGLE_TARGET_EXIST;
2492 if (mainwin->summaryview->folder_item &&
2493 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2496 state |= M_NOT_NEWS;
2497 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2498 state |= M_ACTIONS_EXIST;
2500 tmp = tags_get_list();
2501 if (tmp && g_slist_length(tmp))
2502 state |= M_TAGS_EXIST;
2505 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2506 state |= M_HAVE_QUEUED_MAILS;
2508 if (selection == SUMMARY_SELECTED_SINGLE &&
2510 (folder_has_parent_of_type(item, F_DRAFT) ||
2511 folder_has_parent_of_type(item, F_OUTBOX) ||
2512 folder_has_parent_of_type(item, F_QUEUE))))
2513 state |= M_ALLOW_REEDIT;
2515 state |= M_HAVE_ACCOUNT;
2517 if (any_folder_want_synchronise())
2518 state |= M_WANT_SYNC;
2520 if (item && item->prefs->processing && selection != SUMMARY_NONE)
2521 state |= M_HAVE_PROCESSING;
2523 for ( ; account_list != NULL; account_list = account_list->next) {
2524 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2525 state |= M_HAVE_NEWS_ACCOUNT;
2530 if (procmsg_spam_can_learn() &&
2531 (mainwin->summaryview->folder_item &&
2532 mainwin->summaryview->folder_item->folder->klass->type != F_UNKNOWN &&
2533 mainwin->summaryview->folder_item->folder->klass->type != F_NEWS)) {
2534 state |= M_CAN_LEARN_SPAM;
2537 if (inc_is_active())
2538 state |= M_INC_ACTIVE;
2539 if (imap_cancel_all_enabled())
2540 state |= M_INC_ACTIVE;
2542 if (mainwin->summaryview->deleted > 0 ||
2543 mainwin->summaryview->moved > 0 ||
2544 mainwin->summaryview->copied > 0)
2545 state |= M_DELAY_EXEC;
2552 void main_window_set_menu_sensitive(MainWindow *mainwin)
2554 GtkItemFactory *ifactory = mainwin->menu_factory;
2555 SensitiveCond state;
2558 GtkWidget *menuitem;
2559 SummaryView *summaryview;
2564 static const struct {
2568 {"/File/Save as...", M_TARGET_EXIST},
2569 {"/File/Print..." , M_TARGET_EXIST},
2570 {"/File/Synchronise folders", M_WANT_SYNC},
2571 {"/File/Exit" , M_UNLOCKED},
2573 {"/Edit/Select thread" , M_TARGET_EXIST},
2574 {"/Edit/Delete thread" , M_TARGET_EXIST},
2575 {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
2577 {"/View/Set displayed columns/in Folder list..."
2579 {"/View/Sort" , M_EXEC},
2580 {"/View/Thread view" , M_EXEC},
2581 {"/View/Expand all threads" , M_MSG_EXIST},
2582 {"/View/Collapse all threads" , M_MSG_EXIST},
2583 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2584 {"/View/Go to/Previous message" , M_MSG_EXIST},
2585 {"/View/Go to/Next message" , M_MSG_EXIST},
2586 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2587 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2588 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2589 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2590 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2591 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2592 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2593 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2594 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2595 {"/View/All headers" , M_SINGLE_TARGET_EXIST},
2596 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2598 {"/Message/Receive/Get from current account"
2599 , M_HAVE_ACCOUNT|M_UNLOCKED},
2600 {"/Message/Receive/Get from all accounts"
2601 , M_HAVE_ACCOUNT|M_UNLOCKED},
2602 {"/Message/Receive/Cancel receiving"
2604 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2605 {"/Message/Compose an email message", M_HAVE_ACCOUNT},
2606 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2607 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2608 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2609 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2610 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2611 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2612 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2613 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2614 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2615 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2616 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2617 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2618 {"/Message/Mark" , M_TARGET_EXIST},
2619 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2620 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2621 {"/Message/Mark/Ignore thread" , M_TARGET_EXIST},
2622 {"/Message/Mark/Unignore thread" , M_TARGET_EXIST},
2623 {"/Message/Mark/Lock" , M_TARGET_EXIST},
2624 {"/Message/Mark/Unlock" , M_TARGET_EXIST},
2625 {"/Message/Color label" , M_TARGET_EXIST},
2626 {"/Message/Tags" , M_TARGET_EXIST},
2627 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2629 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2630 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2631 {"/Tools/Harvest addresses/from Messages..."
2633 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2634 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2635 {"/Tools/Run folder processing rules" , M_HAVE_PROCESSING},
2636 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2637 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2638 {"/Tools/List URLs..." , M_TARGET_EXIST},
2639 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2640 {"/Tools/Execute" , M_DELAY_EXEC},
2641 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2643 {"/Configuration", M_UNLOCKED},
2644 {"/Configuration/Preferences for current account...", M_UNLOCKED},
2645 {"/Configuration/Create new account...", M_UNLOCKED},
2646 {"/Configuration/Edit accounts...", M_UNLOCKED},
2651 state = main_window_get_current_state(mainwin);
2653 for (i = 0; entry[i].entry != NULL; i++) {
2654 sensitive = ((entry[i].cond & state) == entry[i].cond);
2655 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2658 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2660 /* search for separator */
2661 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2662 cur_item = cur_item->next) {
2663 if (GTK_BIN(cur_item->data)->child == NULL) {
2664 cur_item = cur_item->next;
2669 for (; cur_item != NULL; cur_item = cur_item->next) {
2670 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2671 (M_UNLOCKED & state) != 0);
2674 main_window_menu_callback_block(mainwin);
2676 #define SET_CHECK_MENU_ACTIVE(path, active) \
2678 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2679 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2682 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2683 messageview_is_visible(mainwin->messageview));
2685 summaryview = mainwin->summaryview;
2686 menu_path = "/View/Sort/Don't sort";
2688 switch (summaryview->sort_key) {
2689 case SORT_BY_NUMBER:
2690 menu_path = "/View/Sort/by number"; break;
2692 menu_path = "/View/Sort/by Size"; break;
2694 menu_path = "/View/Sort/by Date"; break;
2695 case SORT_BY_THREAD_DATE:
2696 menu_path = "/View/Sort/by Thread date"; break;
2698 menu_path = "/View/Sort/by From"; break;
2700 menu_path = "/View/Sort/by To"; break;
2701 case SORT_BY_SUBJECT:
2702 menu_path = "/View/Sort/by Subject"; break;
2704 menu_path = "/View/Sort/by color label"; break;
2706 menu_path = "/View/Sort/by mark"; break;
2707 case SORT_BY_STATUS:
2708 menu_path = "/View/Sort/by status"; break;
2710 menu_path = "/View/Sort/by attachment"; break;
2712 menu_path = "/View/Sort/by score"; break;
2713 case SORT_BY_LOCKED:
2714 menu_path = "/View/Sort/by locked"; break;
2716 menu_path = "/View/Sort/by tag"; break;
2719 menu_path = "/View/Sort/Don't sort"; break;
2721 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2723 if (summaryview->sort_type == SORT_ASCENDING) {
2724 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2726 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2729 if (summaryview->sort_key != SORT_BY_NONE) {
2730 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2731 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2733 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2734 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2737 if (mainwin->messageview
2738 && mainwin->messageview->mimeview
2739 && mainwin->messageview->mimeview->textview)
2740 SET_CHECK_MENU_ACTIVE("/View/All headers",
2741 mainwin->messageview->mimeview->textview->show_all_headers);
2742 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2743 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2744 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2745 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2746 if (prefs_common.hide_quotes == 1)
2747 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2748 if (prefs_common.hide_quotes == 2)
2749 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2750 if (prefs_common.hide_quotes == 3)
2751 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2753 #undef SET_CHECK_MENU_ACTIVE
2755 main_window_menu_callback_unblock(mainwin);
2758 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2760 GtkItemFactory *ifactory;
2762 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2765 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2767 gtk_widget_set_sensitive (gtk_item_factory_get_item
2768 (ifactory,"/Message/Mailing-List"), TRUE);
2770 gtk_widget_set_sensitive (gtk_item_factory_get_item
2771 (ifactory,"/Message/Mailing-List"), FALSE);
2774 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2777 GtkWidget *menuitem;
2779 if (!msginfo || !msginfo->extradata) {
2780 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2781 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2782 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2783 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2784 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2785 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2789 /* Mailing list post */
2790 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2791 g_free(msginfo->extradata->list_post);
2792 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2794 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2796 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2798 /* Mailing list help */
2799 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2801 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2803 /* Mailing list subscribe */
2804 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2806 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2808 /* Mailing list unsubscribe */
2809 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2811 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2813 /* Mailing list view archive */
2814 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2816 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2818 /* Mailing list contact owner */
2819 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2821 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2826 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2828 GtkWidget *item, *menu;
2829 const gchar *url_pt ;
2830 gchar url_decoded[BUFFSIZE];
2831 GList *amenu, *alist;
2834 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2836 /* First delete old submenu */
2837 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2838 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2839 alist = amenu->next;
2840 item = GTK_WIDGET (amenu->data);
2841 gtk_widget_destroy (item);
2845 for (url_pt = list_header; url_pt && *url_pt;) {
2846 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2848 if (!g_ascii_strncasecmp(url_decoded, "mailto:", 7)) {
2849 item = gtk_menu_item_new_with_label ((url_decoded));
2850 g_signal_connect(G_OBJECT(item), "activate",
2851 G_CALLBACK(mailing_list_compose),
2854 else if (!g_ascii_strncasecmp(url_decoded, "http:", 5) ||
2855 !g_ascii_strncasecmp(url_decoded, "https:",6)) {
2857 item = gtk_menu_item_new_with_label ((url_decoded));
2858 g_signal_connect(G_OBJECT(item), "activate",
2859 G_CALLBACK(mailing_list_open_uri),
2863 gtk_menu_append (GTK_MENU(menu), item);
2864 gtk_widget_show (item);
2870 gtk_widget_set_sensitive (menuitem, TRUE);
2872 gtk_widget_set_sensitive (menuitem, FALSE);
2878 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2880 gchar tmp[BUFFSIZE];
2884 gboolean with_plus = TRUE;
2887 *url_decoded = '\0';
2891 /* Ignore spaces, comments and tabs () */
2892 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2894 for (;*buf != ')' && *buf != 0x00; buf++);
2896 /* First non space and non comment must be a < */
2899 if (!strncmp(buf, "mailto:", strlen("mailto:")))
2901 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2906 *url_decoded = '\0';
2911 *url_decoded = '\0';
2917 decode_uri_with_plus (url_decoded, (const gchar *)tmp, with_plus);
2919 /* Prepare the work for the next url in the list */
2920 /* after the closing bracket >, ignore space, comments and tabs */
2921 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2923 for (;*buf != ')' && *buf != 0x00; buf++);
2925 if (!buf || !*buf) {
2930 /* now first non space, non comment must be a comma */
2932 for (;*buf != 0x00; buf++);
2938 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2942 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2943 compose_new(NULL, mailto+7, NULL);
2946 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2951 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2952 open_uri (mailto, prefs_common.uri_cmd);
2955 void main_window_popup(MainWindow *mainwin)
2957 if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
2958 main_window_show(mainwin);
2960 gtkut_window_popup(mainwin->window);
2961 if (prefs_common.layout_mode == SMALL_LAYOUT) {
2962 if (mainwin->in_folder) {
2963 mainwindow_enter_folder(mainwin);
2965 mainwindow_exit_folder(mainwin);
2970 void main_window_show(MainWindow *mainwin)
2972 gtk_widget_show(mainwin->window);
2973 gtk_widget_show(mainwin->vbox_body);
2975 gtk_widget_set_uposition(mainwin->window,
2976 prefs_common.mainwin_x,
2977 prefs_common.mainwin_y);
2979 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2980 prefs_common.folderview_width,
2981 prefs_common.folderview_height);
2982 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2983 prefs_common.summaryview_width,
2984 prefs_common.summaryview_height);
2985 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2986 prefs_common.msgview_width,
2987 prefs_common.msgview_height);
2990 void main_window_hide(MainWindow *mainwin)
2992 main_window_get_size(mainwin);
2993 main_window_get_position(mainwin);
2995 gtk_widget_hide(mainwin->window);
2996 gtk_widget_hide(mainwin->vbox_body);
2999 static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
3001 GtkWidget *folderwin = NULL;
3002 GtkWidget *messagewin = NULL;
3005 GtkWidget *vbox_body = mainwin->vbox_body;
3006 GtkItemFactory *ifactory = mainwin->menu_factory;
3007 GtkWidget *menuitem;
3008 gboolean first_set = (mainwin->hpaned == NULL);
3009 debug_print("Setting widgets... ");
3011 if (layout_mode == SMALL_LAYOUT && first_set) {
3012 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3013 prefs_common.folderview_width,
3014 prefs_common.folderview_height);
3015 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3017 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3020 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3021 prefs_common.folderview_width,
3022 prefs_common.folderview_height);
3023 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3024 prefs_common.summaryview_width,
3025 prefs_common.summaryview_height);
3026 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3027 prefs_common.msgview_width,
3028 prefs_common.msgview_height);
3032 mainwin->messageview->statusbar = mainwin->statusbar;
3033 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
3035 /* clean top-most container */
3036 if (mainwin->hpaned) {
3037 if (mainwin->hpaned->parent == mainwin->vpaned)
3038 gtk_widget_destroy(mainwin->vpaned);
3040 gtk_widget_destroy(mainwin->hpaned);
3043 menu_set_sensitive(ifactory, "/View/Show or hide/Message view",
3044 (layout_mode != WIDE_MSGLIST_LAYOUT && layout_mode != SMALL_LAYOUT));
3045 switch (layout_mode) {
3046 case VERTICAL_LAYOUT:
3049 hpaned = gtk_hpaned_new();
3050 if (layout_mode == VERTICAL_LAYOUT)
3051 vpaned = gtk_hpaned_new();
3053 vpaned = gtk_vpaned_new();
3054 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
3055 gtk_paned_add1(GTK_PANED(hpaned),
3056 GTK_WIDGET_PTR(mainwin->folderview));
3057 gtk_widget_show(hpaned);
3058 gtk_widget_queue_resize(hpaned);
3060 if (messageview_is_visible(mainwin->messageview)) {
3061 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
3062 gtk_paned_add1(GTK_PANED(vpaned),
3063 GTK_WIDGET_PTR(mainwin->summaryview));
3065 gtk_paned_add2(GTK_PANED(hpaned),
3066 GTK_WIDGET_PTR(mainwin->summaryview));
3067 gtk_widget_ref(vpaned);
3069 gtk_paned_add2(GTK_PANED(vpaned),
3070 GTK_WIDGET_PTR(mainwin->messageview));
3071 gtk_widget_show(vpaned);
3072 if (layout_mode == SMALL_LAYOUT && first_set) {
3073 mainwin_paned_show_first(GTK_PANED(hpaned));
3075 gtk_widget_queue_resize(vpaned);
3078 vpaned = gtk_vpaned_new();
3079 hpaned = gtk_hpaned_new();
3080 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3081 gtk_paned_add1(GTK_PANED(vpaned), hpaned);
3083 gtk_paned_add1(GTK_PANED(hpaned),
3084 GTK_WIDGET_PTR(mainwin->folderview));
3085 gtk_paned_add2(GTK_PANED(hpaned),
3086 GTK_WIDGET_PTR(mainwin->summaryview));
3088 gtk_widget_show(hpaned);
3089 gtk_widget_queue_resize(hpaned);
3091 if (messageview_is_visible(mainwin->messageview)) {
3092 gtk_paned_add2(GTK_PANED(vpaned),
3093 GTK_WIDGET_PTR(mainwin->messageview));
3095 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3097 gtk_widget_show(vpaned);
3098 gtk_widget_queue_resize(vpaned);
3100 case WIDE_MSGLIST_LAYOUT:
3101 vpaned = gtk_vpaned_new();
3102 hpaned = gtk_hpaned_new();
3103 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3105 gtk_paned_add1(GTK_PANED(vpaned),
3106 GTK_WIDGET_PTR(mainwin->summaryview));
3107 gtk_paned_add1(GTK_PANED(hpaned),
3108 GTK_WIDGET_PTR(mainwin->folderview));
3110 gtk_widget_show(hpaned);
3111 gtk_widget_queue_resize(hpaned);
3113 if (messageview_is_visible(mainwin->messageview)) {
3114 gtk_paned_add2(GTK_PANED(hpaned),
3115 GTK_WIDGET_PTR(mainwin->messageview));
3117 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3119 gtk_paned_add2(GTK_PANED(vpaned), hpaned);
3121 gtk_widget_show(vpaned);
3122 gtk_widget_queue_resize(vpaned);
3125 g_warning("Unknown layout");
3129 mainwin->hpaned = hpaned;
3130 mainwin->vpaned = vpaned;
3132 if (layout_mode == SMALL_LAYOUT) {
3133 if (mainwin->messageview->visible)
3134 main_window_toggle_message_view(mainwin);
3137 if (layout_mode == SMALL_LAYOUT && first_set) {
3138 gtk_widget_realize(mainwin->window);
3139 gtk_widget_realize(mainwin->folderview->ctree);
3140 gtk_widget_realize(mainwin->summaryview->hbox);
3141 gtk_widget_realize(mainwin->summaryview->hbox_l);
3142 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3143 prefs_common.folderview_width,
3144 prefs_common.folderview_height);
3145 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3147 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3149 gtk_widget_set_size_request(GTK_WIDGET(mainwin->window),
3150 prefs_common.mainwin_width,
3151 prefs_common.mainwin_height);
3152 gtk_paned_set_position(GTK_PANED(mainwin->hpaned), 800);
3154 /* remove headerview if not in prefs */
3155 headerview_set_visibility(mainwin->messageview->headerview,
3156 prefs_common.display_header_pane);
3158 if (messageview_is_visible(mainwin->messageview))
3159 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3160 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
3162 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3163 GTK_ARROW_UP, GTK_SHADOW_OUT);
3165 gtk_window_move(GTK_WINDOW(mainwin->window),
3166 prefs_common.mainwin_x,
3167 prefs_common.mainwin_y);
3169 gtk_widget_queue_resize(vbox_body);
3170 gtk_widget_queue_resize(mainwin->vbox);
3171 gtk_widget_queue_resize(mainwin->window);
3172 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
3173 * and mimeview icon list/ctree lose track of their visibility states */
3174 if (!noticeview_is_visible(mainwin->messageview->noticeview))
3175 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
3176 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
3177 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
3178 if (mainwin->messageview->mimeview->ctree_mode)
3179 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
3181 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
3183 prefs_common.layout_mode = layout_mode;
3185 menuitem = gtk_item_factory_get_item
3186 (ifactory, "/View/Show or hide/Message view");
3187 gtk_check_menu_item_set_active
3188 (GTK_CHECK_MENU_ITEM(menuitem),
3189 messageview_is_visible(mainwin->messageview));
3191 #define SET_CHECK_MENU_ACTIVE(path, active) \
3193 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3194 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3198 switch (prefs_common.layout_mode) {
3200 SET_CHECK_MENU_ACTIVE("/View/Layout/Standard", TRUE);
3202 case VERTICAL_LAYOUT:
3203 SET_CHECK_MENU_ACTIVE("/View/Layout/Three columns", TRUE);
3206 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message", TRUE);
3208 case WIDE_MSGLIST_LAYOUT:
3209 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message list", TRUE);
3212 SET_CHECK_MENU_ACTIVE("/View/Layout/Small screen", TRUE);
3216 #undef SET_CHECK_MENU_ACTIVE
3220 (G_OBJECT(folderwin), "size_allocate",
3221 G_CALLBACK(folder_window_size_allocate_cb),
3226 (G_OBJECT(messagewin), "size_allocate",
3227 G_CALLBACK(message_window_size_allocate_cb),
3231 debug_print("done.\n");
3234 void main_window_destroy_all(void)
3236 while (mainwin_list != NULL) {
3237 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
3239 /* free toolbar stuff */
3240 toolbar_clear_list(TOOLBAR_MAIN);
3241 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
3242 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
3244 mainwin->folderview->mainwin = NULL;
3245 mainwin->summaryview->mainwin = NULL;
3246 mainwin->messageview->mainwin = NULL;
3248 g_free(mainwin->toolbar);
3251 mainwin_list = g_list_remove(mainwin_list, mainwin);
3253 g_list_free(mainwin_list);
3254 mainwin_list = NULL;
3257 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
3260 gtk_widget_set_size_request(child, 1, -1);
3263 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
3266 gtk_widget_set_size_request(child, -1, -1);
3269 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
3272 MainWindow *mainwin = (MainWindow *)data;
3274 if (!event) return FALSE;
3276 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
3277 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
3280 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
3281 menu_button_position, widget,
3282 event->button, event->time);
3287 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
3290 MainWindow *mainwin = (MainWindow *)data;
3291 gboolean close_allowed = TRUE;
3293 hooks_invoke(MAIN_WINDOW_CLOSE, &close_allowed);
3295 if (close_allowed && mainwin->lock_count == 0)
3296 app_exit_cb(data, 0, widget);
3301 static void main_window_size_allocate_cb(GtkWidget *widget,
3302 GtkAllocation *allocation,
3305 MainWindow *mainwin = (MainWindow *)data;
3306 main_window_get_size(mainwin);
3309 static void folder_window_size_allocate_cb(GtkWidget *widget,
3310 GtkAllocation *allocation,
3313 MainWindow *mainwin = (MainWindow *)data;
3315 main_window_get_size(mainwin);
3318 static void message_window_size_allocate_cb(GtkWidget *widget,
3319 GtkAllocation *allocation,
3322 MainWindow *mainwin = (MainWindow *)data;
3324 main_window_get_size(mainwin);
3327 static void add_mailbox_cb(MainWindow *mainwin, guint action,
3330 main_window_add_mailbox(mainwin);
3333 static void update_folderview_cb(MainWindow *mainwin, guint action,
3336 summary_show(mainwin->summaryview, NULL);
3337 folderview_check_new_all();
3340 static void foldersort_cb(MainWindow *mainwin, guint action,
3346 static void import_mbox_cb(MainWindow *mainwin, guint action,
3349 /* only notify if import has failed */
3350 if (import_mbox(mainwin->summaryview->folder_item) == -1) {
3351 alertpanel_error(_("Mbox import has failed."));
3355 static void export_mbox_cb(MainWindow *mainwin, guint action,
3358 /* only notify if export has failed */
3359 if (export_mbox(mainwin->summaryview->folder_item) == -1) {
3360 alertpanel_error(_("Export to mbox has failed."));
3364 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
3367 /* only notify if export has failed */
3368 if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
3369 alertpanel_error(_("Export to mbox has failed."));
3373 static void empty_trash_cb(MainWindow *mainwin, guint action,
3376 main_window_empty_trash(mainwin, TRUE);
3379 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3381 summary_save_as(mainwin->summaryview);
3384 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3386 summary_print(mainwin->summaryview);
3389 #if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
3390 static void page_setup_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3392 MainWindow *mainwindow;
3395 mainwindow = mainwindow_get_mainwindow();
3396 win = (mainwindow ? GTK_WINDOW(mainwindow->window) : NULL);
3398 printing_page_setup(win);
3402 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3404 if (prefs_common.confirm_on_exit) {
3405 if (alertpanel(_("Exit"), _("Exit Claws Mail?"),
3406 GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
3407 != G_ALERTALTERNATE)
3409 manage_window_focus_in(mainwin->window, NULL, NULL);
3412 app_will_exit(widget, mainwin);
3415 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3418 summary_search(mainwin->summaryview);
3420 message_search(mainwin->messageview);
3423 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
3425 summaryview_activate_quicksearch(mainwin->summaryview, TRUE);
3428 static void toggle_message_cb(MainWindow *mainwin, guint action,
3433 active = GTK_CHECK_MENU_ITEM(widget)->active;
3435 if (active != messageview_is_visible(mainwin->messageview))
3436 summary_toggle_view(mainwin->summaryview);
3439 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
3442 toolbar_toggle(action, mainwin);
3445 static void main_window_reply_cb(MainWindow *mainwin, guint action,
3448 MessageView *msgview = (MessageView*)mainwin->messageview;
3449 GSList *msginfo_list = NULL;
3451 g_return_if_fail(msgview != NULL);
3453 msginfo_list = summary_get_selection(mainwin->summaryview);
3454 g_return_if_fail(msginfo_list != NULL);
3455 compose_reply_from_messageview(msgview, msginfo_list, action);
3456 g_slist_free(msginfo_list);
3459 static void toggle_col_headers_cb(MainWindow *mainwin, guint action,
3462 FolderView *folderview = mainwin->folderview;
3463 SummaryView *summaryview = mainwin->summaryview;
3465 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3466 gtk_clist_column_titles_show(GTK_CLIST(folderview->ctree));
3467 gtk_clist_column_titles_show(GTK_CLIST(summaryview->ctree));
3468 prefs_common.show_col_headers = TRUE;
3470 gtk_clist_column_titles_hide(GTK_CLIST(folderview->ctree));
3471 gtk_clist_column_titles_hide(GTK_CLIST(summaryview->ctree));
3472 prefs_common.show_col_headers = FALSE;
3477 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
3480 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3481 gtk_widget_show(mainwin->hbox_stat);
3482 prefs_common.show_statusbar = TRUE;
3484 gtk_widget_hide(mainwin->hbox_stat);
3485 prefs_common.show_statusbar = FALSE;
3489 static void set_layout_cb(MainWindow *mainwin, guint action,
3492 LayoutType layout_mode = action;
3493 LayoutType old_layout_mode = prefs_common.layout_mode;
3494 if (mainwin->menu_lock_count) {
3497 if (!GTK_CHECK_MENU_ITEM(widget)->active) {
3501 if (layout_mode == prefs_common.layout_mode) {
3505 if (!mainwin->messageview->visible && layout_mode != SMALL_LAYOUT)
3506 main_window_toggle_message_view(mainwin);
3507 else if (mainwin->messageview->visible && layout_mode == SMALL_LAYOUT)
3508 main_window_toggle_message_view(mainwin);
3510 main_window_separation_change(mainwin, layout_mode);
3511 mainwindow_reset_paned(GTK_PANED(mainwin->vpaned));
3512 if (old_layout_mode == SMALL_LAYOUT && layout_mode != SMALL_LAYOUT) {
3513 mainwindow_reset_paned(GTK_PANED(mainwin->hpaned));
3515 if (old_layout_mode != SMALL_LAYOUT && layout_mode == SMALL_LAYOUT) {
3516 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
3517 mainwindow_exit_folder(mainwin);
3519 summary_relayout(mainwin->summaryview);
3520 summary_update_unread(mainwin->summaryview, NULL);
3524 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
3527 offline_ask_sync = ask_sync;
3529 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
3531 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3532 offline_ask_sync = TRUE;
3535 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
3537 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
3540 static gboolean any_folder_want_synchronise(void)
3542 GList *folderlist = folder_get_list();
3544 /* see if there are synchronised folders */
3545 for (; folderlist; folderlist = folderlist->next) {
3546 Folder *folder = (Folder *)folderlist->data;
3547 if (folder_want_synchronise(folder)) {
3555 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
3558 if (!any_folder_want_synchronise())
3561 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
3562 _("Do you want to synchronise your folders now?"),
3563 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
3566 if (offline_ask_sync)
3567 folder_synchronise(NULL);
3570 static void online_switch_clicked (GtkButton *btn, gpointer data)
3572 MainWindow *mainwin;
3573 GtkItemFactory *ifactory;
3574 GtkCheckMenuItem *menuitem;
3576 mainwin = (MainWindow *) data;
3578 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3579 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3581 g_return_if_fail(mainwin != NULL);
3582 g_return_if_fail(menuitem != NULL);
3584 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3586 gtk_widget_hide (mainwin->online_switch);
3587 gtk_widget_show (mainwin->offline_switch);
3589 menuitem->active = TRUE;
3590 inc_autocheck_timer_remove();
3593 if (prefs_common.work_offline)
3595 mainwindow_check_synchronise(mainwin, TRUE);
3596 prefs_common.work_offline = TRUE;
3597 imap_disconnect_all();
3598 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3601 if (!prefs_common.work_offline)
3604 gtk_widget_hide (mainwin->offline_switch);
3605 gtk_widget_show (mainwin->online_switch);
3607 menuitem->active = FALSE;
3608 prefs_common.work_offline = FALSE;
3609 inc_autocheck_timer_set();
3610 refresh_resolvers();
3611 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3615 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3618 addressbook_open(NULL);
3621 static void log_window_show_cb(MainWindow *mainwin, guint action,
3624 log_window_show(mainwin->logwin);
3627 static void filtering_debug_window_show_cb(MainWindow *mainwin, guint action,
3630 log_window_show(mainwin->filtering_debugwin);
3633 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3639 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3641 summary_move_to(mainwin->summaryview);
3644 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3646 summary_copy_to(mainwin->summaryview);
3649 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3651 summary_delete(mainwin->summaryview);
3654 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3656 summary_delete_trash(mainwin->summaryview);
3659 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3661 summary_cancel(mainwin->summaryview);
3664 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3666 summary_open_msg(mainwin->summaryview);
3669 static void view_source_cb(MainWindow *mainwin, guint action,
3672 summary_view_source(mainwin->summaryview);
3675 static void show_all_header_cb(MainWindow *mainwin, guint action,
3678 if (mainwin->menu_lock_count) return;
3679 mainwin->summaryview->messageview->all_headers =
3680 GTK_CHECK_MENU_ITEM(widget)->active;
3681 summary_display_msg_selected(mainwin->summaryview,
3682 GTK_CHECK_MENU_ITEM(widget)->active);
3685 #define SET_CHECK_MENU_ACTIVE(path, active) \
3687 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3688 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3691 static void hide_quotes_cb(MainWindow *mainwin, guint action,
3694 GtkWidget *menuitem;
3695 GtkItemFactory *ifactory = mainwin->menu_factory;
3697 if (mainwin->menu_lock_count) return;
3699 prefs_common.hide_quotes =
3700 GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
3702 mainwin->menu_lock_count++;
3703 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
3704 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
3705 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
3706 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);
3707 mainwin->menu_lock_count--;
3709 summary_redisplay_msg(mainwin->summaryview);
3712 #undef SET_CHECK_MENU_ACTIVE
3713 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3715 summary_mark(mainwin->summaryview);
3718 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3720 summary_unmark(mainwin->summaryview);
3723 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3726 summary_mark_as_unread(mainwin->summaryview);
3729 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3732 summary_mark_as_read(mainwin->summaryview);
3735 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3738 summary_mark_all_read(mainwin->summaryview);
3741 static void mark_as_spam_cb(MainWindow *mainwin, guint action,
3744 summary_mark_as_spam(mainwin->summaryview, action, NULL);
3747 static void ignore_thread_cb(MainWindow *mainwin, guint action,
3750 summary_ignore_thread(mainwin->summaryview);
3753 static void unignore_thread_cb(MainWindow *mainwin, guint action,
3756 summary_unignore_thread(mainwin->summaryview);
3759 static void watch_thread_cb(MainWindow *mainwin, guint action,
3762 summary_watch_thread(mainwin->summaryview);
3765 static void unwatch_thread_cb(MainWindow *mainwin, guint action,
3768 summary_unwatch_thread(mainwin->summaryview);
3771 static void lock_msgs_cb(MainWindow *mainwin, guint action,
3774 summary_msgs_lock(mainwin->summaryview);
3777 static void unlock_msgs_cb(MainWindow *mainwin, guint action,
3780 summary_msgs_unlock(mainwin->summaryview);
3784 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3786 summary_reedit(mainwin->summaryview);
3789 static void open_urls_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3791 if (!mainwin->summaryview->displayed && mainwin->summaryview->selected) {
3792 summary_display_msg_selected(mainwin->summaryview,
3793 mainwin->messageview->mimeview->textview->show_all_headers);
3795 messageview_list_urls(mainwin->messageview);
3798 static void add_address_cb(MainWindow *mainwin, guint action,
3801 summary_add_address(mainwin->summaryview);
3804 static void set_charset_cb(MainWindow *mainwin, guint action,
3809 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3810 str = conv_get_charset_str((CharSet)action);
3812 g_free(mainwin->messageview->forced_charset);
3813 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
3814 procmime_force_charset(str);
3816 summary_redisplay_msg(mainwin->summaryview);
3818 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3822 static void set_decode_cb(MainWindow *mainwin, guint action,
3825 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3826 mainwin->messageview->forced_encoding = (EncodingType)action;
3828 summary_redisplay_msg(mainwin->summaryview);
3830 debug_print("forced encoding: %d\n", action);
3834 static void hide_read_messages (MainWindow *mainwin, guint action,
3837 if (!mainwin->summaryview->folder_item
3838 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
3840 summary_toggle_show_read_messages(mainwin->summaryview);
3843 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3845 gboolean threaded = FALSE;
3846 if (mainwin->menu_lock_count) return;
3847 if (!mainwin->summaryview->folder_item) return;
3849 threaded = GTK_CHECK_MENU_ITEM(widget)->active;
3851 mainwin->summaryview->folder_item->threaded = threaded;
3853 mainwin->summaryview->threaded = threaded;
3855 summary_show(mainwin->summaryview,
3856 mainwin->summaryview->folder_item);
3859 static void expand_threads_cb(MainWindow *mainwin, guint action,
3862 summary_expand_threads(mainwin->summaryview);
3865 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3868 summary_collapse_threads(mainwin->summaryview);
3871 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
3874 prefs_summary_column_open();
3877 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
3880 prefs_folder_column_open();
3883 static void sort_summary_cb(MainWindow *mainwin, guint action,
3886 FolderItem *item = mainwin->summaryview->folder_item;
3887 GtkWidget *menuitem;
3889 if (mainwin->menu_lock_count) return;
3891 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
3892 menuitem = gtk_item_factory_get_item
3893 (mainwin->menu_factory, "/View/Sort/Ascending");
3894 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3895 GTK_CHECK_MENU_ITEM(menuitem)->active
3896 ? SORT_ASCENDING : SORT_DESCENDING);
3897 item->sort_key = action;
3901 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3904 FolderItem *item = mainwin->summaryview->folder_item;
3906 if (mainwin->menu_lock_count) return;
3908 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
3909 summary_sort(mainwin->summaryview,
3910 item->sort_key, (FolderSortType)action);
3913 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3916 summary_attract_by_subject(mainwin->summaryview);
3919 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3924 item = folderview_get_selected_item(mainwin->folderview);
3926 main_window_cursor_wait(mainwin);
3927 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
3929 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
3930 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
3932 STATUSBAR_POP(mainwin);
3933 main_window_cursor_normal(mainwin);
3943 static void deldup_all(FolderItem *item, gpointer _data)
3945 struct DelDupsData *data = _data;
3948 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
3950 data->dups += result;
3955 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
3958 struct DelDupsData data = {0, 0};
3960 main_window_cursor_wait(mainwin);
3961 folder_func_to_all_folders(deldup_all, &data);
3962 main_window_cursor_normal(mainwin);
3964 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
3965 "Deleted %d duplicate messages in %d folders.\n",
3967 data.dups, data.folders);
3970 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3972 summary_filter(mainwin->summaryview, (gboolean)action);
3975 static void process_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3977 FolderItem *item = mainwin->summaryview->folder_item;
3978 g_return_if_fail(item != NULL);
3980 folder_item_apply_processing(item);
3983 static void execute_summary_cb(MainWindow *mainwin, guint action,
3986 summary_execute(mainwin->summaryview);
3989 static void update_summary_cb(MainWindow *mainwin, guint action,
3993 FolderView *folderview = mainwin->folderview;
3995 if (!mainwin->summaryview->folder_item) return;
3996 if (!folderview->opened) return;
3998 folder_update_op_count();
4000 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
4001 folderview->opened);
4004 folder_item_scan(fitem);
4005 summary_show(mainwin->summaryview, fitem);
4008 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4010 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
4013 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4015 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
4018 static void prev_unread_cb(MainWindow *mainwin, guint action,
4021 summary_select_prev_unread(mainwin->summaryview);
4024 static void next_unread_cb(MainWindow *mainwin, guint action,
4027 summary_select_next_unread(mainwin->summaryview);
4030 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4032 summary_select_prev_new(mainwin->summaryview);
4035 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4037 summary_select_next_new(mainwin->summaryview);
4040 static void prev_marked_cb(MainWindow *mainwin, guint action,
4043 summary_select_prev_marked(mainwin->summaryview);
4046 static void next_marked_cb(MainWindow *mainwin, guint action,
4049 summary_select_next_marked(mainwin->summaryview);
4052 static void prev_labeled_cb(MainWindow *mainwin, guint action,
4055 summary_select_prev_labeled(mainwin->summaryview);
4058 static void next_labeled_cb(MainWindow *mainwin, guint action,
4061 summary_select_next_labeled(mainwin->summaryview);
4064 static void last_read_cb(MainWindow *mainwin, guint action,
4067 summary_select_last_read(mainwin->summaryview);
4070 static void parent_cb(MainWindow *mainwin, guint action,
4073 summary_select_parent(mainwin->summaryview);
4076 static void goto_folder_cb(MainWindow *mainwin, guint action,
4079 FolderItem *to_folder;
4081 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
4084 folderview_select(mainwin->folderview, to_folder);
4087 static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
4090 folderview_select_next_unread(mainwin->folderview, FALSE);
4093 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4095 messageview_copy_clipboard(mainwin->messageview);
4098 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4100 MessageView *msgview = mainwin->messageview;
4102 if (messageview_is_visible(msgview) &&
4103 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
4104 messageview_select_all(mainwin->messageview);
4106 summary_select_all(mainwin->summaryview);
4109 static void select_thread_cb(MainWindow *mainwin, guint action,
4112 summary_select_thread(mainwin->summaryview, FALSE);
4115 static void delete_thread_cb(MainWindow *mainwin, guint action,
4118 summary_select_thread(mainwin->summaryview, TRUE);
4121 static void create_filter_cb(MainWindow *mainwin, guint action,
4124 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
4127 static void create_processing_cb(MainWindow *mainwin, guint action,
4130 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
4133 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
4136 prefs_filtering_open(&pre_global_processing,
4137 _("Processing rules to apply before folder rules"),
4138 MANUAL_ANCHOR_PROCESSING,
4142 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
4145 prefs_filtering_open(&post_global_processing,
4146 _("Processing rules to apply after folder rules"),
4147 MANUAL_ANCHOR_PROCESSING,
4151 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
4154 prefs_filtering_open(&filtering_rules,
4155 _("Filtering configuration"),
4156 MANUAL_ANCHOR_FILTERING,
4160 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
4163 prefs_template_open();
4166 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
4169 prefs_actions_open(mainwin);
4172 static void prefs_tags_open_cb(MainWindow *mainwin, guint action,
4175 prefs_tags_open(mainwin);
4178 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
4181 ssl_manager_open(mainwin);
4184 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
4188 new_account_cb(mainwin, 0, widget);
4190 account_open(cur_account);
4194 static void new_account_cb(MainWindow *mainwin, guint action,
4197 account_edit_open();
4198 if (!compose_get_compose_list()) account_add();
4201 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
4203 FolderItem *item = NULL;
4204 cur_account = (PrefsAccount *)data;
4206 if (!mainwindow_get_mainwindow())
4208 main_window_show_cur_account(mainwindow_get_mainwindow());
4209 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
4210 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
4211 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
4212 item = folderview_get_selected_item(
4213 mainwindow_get_mainwindow()->folderview);
4215 toolbar_set_compose_button
4216 (mainwindow_get_mainwindow()->toolbar,
4217 FOLDER_TYPE(item->folder) == F_NEWS ?
4218 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
4222 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
4224 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
4225 PrefsAccount *account = (PrefsAccount *)data;
4227 inc_account_mail(mainwin, account);
4230 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
4232 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
4233 PrefsAccount *account = (PrefsAccount *)data;
4234 FolderItem *item = mainwin->summaryview->folder_item;
4236 compose_new_with_folderitem(account, NULL, NULL);
4239 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
4244 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
4246 pluginwindow_create();
4249 static void manual_open_cb(MainWindow *mainwin, guint action,
4252 manual_open((ManualType)action, NULL);
4255 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
4260 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
4262 MainWindow *mainwin = (MainWindow *)data;
4266 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
4267 LOCAL_FOLDER(folder)->rootpath,
4271 str = g_strdup_printf(_("Scanning folder %s ..."),
4272 LOCAL_FOLDER(folder)->rootpath);
4274 STATUSBAR_PUSH(mainwin, str);
4275 STATUSBAR_POP(mainwin);
4279 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
4282 SummaryView *summary;
4284 g_return_val_if_fail(data, FALSE);
4285 if (!g_list_find(mainwin_list, data))
4287 summary = ((MainWindow *)data)->summaryview;
4288 g_return_val_if_fail(summary, FALSE);
4290 if (GTK_CLIST(summary->ctree)->selection &&
4291 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
4297 static gboolean mainwindow_visibility_event_cb(GtkWidget *widget, GdkEventVisibility *event,
4300 is_obscured = (event->state == GDK_VISIBILITY_FULLY_OBSCURED);
4304 static gboolean mainwindow_state_event_cb(GtkWidget *widget, GdkEventWindowState *state,
4307 if (!claws_is_starting()
4308 && state->changed_mask&GDK_WINDOW_STATE_ICONIFIED
4309 && state->new_window_state&GDK_WINDOW_STATE_ICONIFIED) {
4311 if (iconified_count > 0)
4312 hooks_invoke(MAIN_WINDOW_GOT_ICONIFIED, NULL);
4315 if (state->new_window_state == 0)
4316 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
4320 gboolean mainwindow_is_obscured(void)
4325 #define BREAK_ON_MODIFIER_KEY() \
4326 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
4328 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
4331 MainWindow *mainwin = (MainWindow*) data;
4333 if (!mainwin || !event)
4336 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
4338 lastkey = event->keyval;
4342 switch (event->keyval) {
4343 case GDK_Q: /* Quit */
4344 BREAK_ON_MODIFIER_KEY();
4346 app_exit_cb(mainwin, 0, NULL);
4349 if (mainwin->folderview && mainwin->summaryview
4350 && ((!mainwin->summaryview->displayed
4351 && !mainwin->summaryview->selected)
4352 || (mainwin->summaryview->folder_item
4353 && mainwin->summaryview->folder_item->total_msgs == 0))) {
4354 g_signal_stop_emission_by_name(G_OBJECT(widget),
4356 folderview_select_next_unread(mainwin->folderview, TRUE);
4361 if (maemo_mainwindow_is_fullscreen(widget)) {
4362 gtk_window_unfullscreen(GTK_WINDOW(widget));
4364 gtk_window_fullscreen(GTK_WINDOW(widget));
4368 if (mainwin->summaryview &&
4369 mainwin->summaryview->ext_messageview &&
4370 mainwin->summaryview->ext_messageview->window &&
4371 widget == mainwin->summaryview->ext_messageview->window) {
4372 messageview_destroy(mainwin->summaryview->ext_messageview);
4382 #undef BREAK_ON_MODIFIER_KEY
4385 * Harvest addresses for selected folder.
4387 static void addr_harvest_cb( MainWindow *mainwin,
4391 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
4395 * Harvest addresses for selected messages in summary view.
4397 static void addr_harvest_msg_cb( MainWindow *mainwin,
4401 summary_harvest_address( mainwin->summaryview );
4405 *\brief get a MainWindow
4407 *\return MainWindow * The first mainwindow in the mainwin_list
4409 MainWindow *mainwindow_get_mainwindow(void)
4411 if (mainwin_list && mainwin_list->data)
4412 return (MainWindow *)(mainwin_list->data);
4417 static gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
4419 ProgressData *data = (ProgressData *) source;
4420 MainWindow *mainwin = (MainWindow *) userdata;
4422 switch (data->cmd) {
4423 case PROGRESS_COMMAND_START:
4424 case PROGRESS_COMMAND_STOP:
4425 gtk_progress_bar_set_fraction
4426 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
4428 case PROGRESS_COMMAND_SET_PERCENTAGE:
4429 gtk_progress_bar_set_fraction
4430 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
4433 while (gtk_events_pending()) gtk_main_iteration ();
4438 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4440 mainwindow_check_synchronise(mainwin, FALSE);
4443 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
4445 summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
4448 void mainwindow_jump_to(const gchar *target, gboolean popup)
4452 FolderItem *item = NULL;
4454 MainWindow *mainwin = mainwindow_get_mainwindow();
4460 g_print("not initialized\n");
4464 tmp = g_strdup(target);
4466 if ((p = strstr(tmp, "\r")) != NULL)
4468 if ((p = strstr(tmp, "\n")) != NULL)
4471 if ((item = folder_find_item_from_identifier(tmp))) {
4472 g_print("selecting folder '%s'\n", tmp);
4473 folderview_select(mainwin->folderview, item);
4475 main_window_popup(mainwin);
4480 msg = strrchr(tmp, G_DIR_SEPARATOR);
4483 if ((item = folder_find_item_from_identifier(tmp))) {
4484 g_print("selecting folder '%s'\n", tmp);
4485 folderview_select(mainwin->folderview, item);
4487 g_print("'%s' not found\n", tmp);
4489 if (item && msg && atoi(msg)) {
4490 g_print("selecting message %d\n", atoi(msg));
4491 summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
4492 summary_display_msg_selected(mainwin->summaryview, FALSE);
4494 main_window_popup(mainwin);
4497 } else if (item && msg[0] == '<' && msg[strlen(msg)-1] == '>') {
4498 MsgInfo *msginfo = NULL;
4500 msg[strlen(msg)-1] = '\0';
4501 msginfo = folder_item_get_msginfo_by_msgid(item, msg);
4503 g_print("selecting message %s\n", msg);
4504 summary_select_by_msgnum(mainwin->summaryview, msginfo->msgnum);
4505 summary_display_msg_selected(mainwin->summaryview, FALSE);
4507 main_window_popup(mainwin);
4509 procmsg_msginfo_free(msginfo);
4512 g_print("'%s' not found\n", msg);
4515 g_print("'%s' not found\n", msg);
4518 g_print("'%s' not found\n", tmp);
4524 void mainwindow_exit_folder(MainWindow *mainwin) {
4525 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4526 folderview_close_opened(mainwin->folderview);
4527 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
4529 mainwin->in_folder = FALSE;
4532 void mainwindow_enter_folder(MainWindow *mainwin) {
4533 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4534 mainwin_paned_show_last(GTK_PANED(mainwin->hpaned));
4536 mainwin->in_folder = TRUE;
4540 gboolean maemo_mainwindow_is_fullscreen(GtkWidget *widget)
4543 gtk_window_get_size(GTK_WINDOW(widget), &w, &h);
4547 void maemo_window_full_screen_if_needed (GtkWindow *window)
4549 if (maemo_mainwindow_is_fullscreen(mainwindow_get_mainwindow()->window)) {
4550 gtk_window_fullscreen(GTK_WINDOW(window));
4554 void maemo_connect_key_press_to_mainwindow (GtkWindow *window)
4556 g_signal_connect(G_OBJECT(window), "key_press_event",
4557 G_CALLBACK(mainwindow_key_pressed), mainwindow_get_mainwindow());