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/_Toolbar"),
570 NULL, NULL, 0, "<Branch>"},
571 {N_("/_View/Show or hi_de/_Toolbar/Text _below icons"),
572 NULL, toggle_toolbar_cb, TOOLBAR_BOTH, "<RadioItem>"},
573 {N_("/_View/Show or hi_de/_Toolbar/Text be_side icons"),
574 NULL, toggle_toolbar_cb, TOOLBAR_BOTH_HORIZ, "/View/Show or hide/Toolbar/Text below icons"},
575 {N_("/_View/Show or hi_de/_Toolbar/_Icons only"),
576 NULL, toggle_toolbar_cb, TOOLBAR_ICON, "/View/Show or hide/Toolbar/Text below icons"},
577 {N_("/_View/Show or hi_de/_Toolbar/_Text only"),
578 NULL, toggle_toolbar_cb, TOOLBAR_TEXT, "/View/Show or hide/Toolbar/Text below icons"},
579 {N_("/_View/Show or hi_de/_Toolbar/_Hide"),
580 NULL, toggle_toolbar_cb, TOOLBAR_NONE, "/View/Show or hide/Toolbar/Text below icons"},
581 {N_("/_View/Show or hi_de/_Message view"),
582 "V", toggle_message_cb, 0, "<ToggleItem>"},
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>"},
673 {N_("/_View/Character _encoding/7bit ascii (US-ASC_II)"),
674 ENC_ACTION(C_US_ASCII)},
675 {N_("/_View/Character _encoding/Unicode (_UTF-8)"),
676 ENC_ACTION(C_UTF_8)},
679 {N_("/_View/Character _encoding/Western European"),NULL, NULL, 0, "<Branch>"},
680 {N_("/_View/Character _encoding/Western European/ISO-8859-_1"),
681 ENC_ACTION(C_ISO_8859_1)},
682 {N_("/_View/Character _encoding/Western European/ISO-8859-15"),
683 ENC_ACTION(C_ISO_8859_15)},
684 {N_("/_View/Character _encoding/Western European/Windows-1252"),
685 ENC_ACTION(C_WINDOWS_1252)},
687 {N_("/_View/Character _encoding/Central European (ISO-8859-_2)"),
688 ENC_ACTION(C_ISO_8859_2)},
690 {N_("/_View/Character _encoding/Baltic"), NULL, NULL, 0, "<Branch>"},
691 {N_("/_View/Character _encoding/Baltic/ISO-8859-13"),
692 ENC_ACTION(C_ISO_8859_13)},
693 {N_("/_View/Character _encoding/Baltic/ISO-8859-_4"),
694 ENC_ACTION(C_ISO_8859_4)},
696 {N_("/_View/Character _encoding/Greek (ISO-8859-_7)"),
697 ENC_ACTION(C_ISO_8859_7)},
699 {N_("/_View/Character _encoding/Hebrew"), NULL, NULL, 0, "<Branch>"},
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)},
705 {N_("/_View/Character _encoding/Arabic"), NULL, NULL, 0, "<Branch>"},
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)},
711 {N_("/_View/Character _encoding/Turkish (ISO-8859-_9)"),
712 ENC_ACTION(C_ISO_8859_9)},
714 {N_("/_View/Character _encoding/Cyrillic"), NULL, NULL, 0, "<Branch>"},
715 {N_("/_View/Character _encoding/Cyrillic/ISO-8859-_5"),
716 ENC_ACTION(C_ISO_8859_5)},
717 {N_("/_View/Character _encoding/Cyrillic/KOI8-_R"),
718 ENC_ACTION(C_KOI8_R)},
719 {N_("/_View/Character _encoding/Cyrillic/KOI8-U"),
720 ENC_ACTION(C_KOI8_U)},
721 {N_("/_View/Character _encoding/Cyrillic/Windows-1251"),
722 ENC_ACTION(C_CP1251)},
724 {N_("/_View/Character _encoding/Japanese"), NULL, NULL, 0, "<Branch>"},
725 {N_("/_View/Character _encoding/Japanese/ISO-2022-_JP"),
726 ENC_ACTION(C_ISO_2022_JP)},
727 {N_("/_View/Character _encoding/Japanese/ISO-2022-JP-2"),
728 ENC_ACTION(C_ISO_2022_JP_2)},
729 {N_("/_View/Character _encoding/Japanese/_EUC-JP"),
730 ENC_ACTION(C_EUC_JP)},
731 {N_("/_View/Character _encoding/Japanese/_Shift__JIS"),
732 ENC_ACTION(C_SHIFT_JIS)},
734 {N_("/_View/Character _encoding/Chinese"), NULL, NULL, 0, "<Branch>"},
735 {N_("/_View/Character _encoding/Chinese/Simplified (_GB2312)"),
736 ENC_ACTION(C_GB2312)},
737 {N_("/_View/Character _encoding/Chinese/Simplified (GBK)"),
739 {N_("/_View/Character _encoding/Chinese/Traditional (_Big5)"),
741 {N_("/_View/Character _encoding/Chinese/Traditional (EUC-_TW)"),
742 ENC_ACTION(C_EUC_TW)},
743 {N_("/_View/Character _encoding/Chinese/ISO-2022-_CN"),
744 ENC_ACTION(C_ISO_2022_CN)},
746 {N_("/_View/Character _encoding/Korean"), NULL, NULL, 0, "<Branch>"},
747 {N_("/_View/Character _encoding/Korean/EUC-_KR"),
748 ENC_ACTION(C_EUC_KR)},
749 {N_("/_View/Character _encoding/Korean/ISO-2022-KR"),
750 ENC_ACTION(C_ISO_2022_KR)},
752 {N_("/_View/Character _encoding/Thai"), NULL, NULL, 0, "<Branch>"},
753 {N_("/_View/Character _encoding/Thai/TIS-620"),
754 ENC_ACTION(C_TIS_620)},
755 {N_("/_View/Character _encoding/Thai/Windows-874"),
756 ENC_ACTION(C_WINDOWS_874)},
761 #define DEC_SEPARATOR \
762 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"}
763 #define DEC_ACTION(action) \
764 NULL, set_decode_cb, action, "/View/Decode/Auto detect"
765 {N_("/_View/Decode"), NULL, NULL, 0, "<Branch>"},
766 {N_("/_View/Decode/_Auto detect"),
767 NULL, set_decode_cb, 0, "<RadioItem>"},
768 {N_("/_View/Decode/---"), NULL, NULL, 0, "<Separator>"},
769 {N_("/_View/Decode/_8bit"), DEC_ACTION(ENC_8BIT)},
770 {N_("/_View/Decode/_Quoted printable"), DEC_ACTION(ENC_QUOTED_PRINTABLE)},
771 {N_("/_View/Decode/_Base64"), DEC_ACTION(ENC_BASE64)},
772 {N_("/_View/Decode/_Uuencode"), DEC_ACTION(ENC_X_UUENCODE)},
777 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
778 {N_("/_View/Open in new _window"), "<control><alt>N", open_msg_cb, 0, NULL},
779 {N_("/_View/Mess_age source"), "<control>U", view_source_cb, 0, NULL},
780 {N_("/_View/All headers"), "<control>H", show_all_header_cb, 0, "<ToggleItem>"},
781 {N_("/_View/Quotes"), NULL, NULL, 0, "<Branch>"},
782 {N_("/_View/Quotes/_Fold all"), "<control><shift>Q", hide_quotes_cb, 1, "<ToggleItem>"},
783 {N_("/_View/Quotes/Fold from level _2"),NULL, hide_quotes_cb, 2, "<ToggleItem>"},
784 {N_("/_View/Quotes/Fold from level _3"),NULL, hide_quotes_cb, 3, "<ToggleItem>"},
785 {N_("/_View/---"), NULL, NULL, 0, "<Separator>"},
786 {N_("/_View/_Update summary"), "<control><alt>U", update_summary_cb, 0, NULL},
788 {N_("/_Message"), NULL, NULL, 0, "<Branch>"},
789 {N_("/_Message/Recei_ve"), NULL, NULL, 0, "<Branch>"},
790 {N_("/_Message/Recei_ve/Get from _current account"),
791 "<control>I", inc_mail_cb, 0, NULL},
792 {N_("/_Message/Recei_ve/Get from _all accounts"),
793 "<shift><control>I", inc_all_account_mail_cb, 0, NULL},
794 {N_("/_Message/Recei_ve/Cancel receivin_g"),
795 NULL, inc_cancel_cb, 0, NULL},
796 {N_("/_Message/Recei_ve/---"), NULL, NULL, 0, "<Separator>"},
797 {N_("/_Message/_Send queued messages"), NULL, send_queue_cb, 0, NULL},
798 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
799 {N_("/_Message/Compose a_n email message"), "<control>M", compose_mail_cb, 0, NULL},
800 {N_("/_Message/Compose a news message"), NULL, compose_news_cb, 0, NULL},
801 {N_("/_Message/_Reply"), "<control>R", main_window_reply_cb, COMPOSE_REPLY, NULL},
802 {N_("/_Message/Repl_y to"), NULL, NULL, 0, "<Branch>"},
803 {N_("/_Message/Repl_y to/_all"), "<shift><control>R", main_window_reply_cb, COMPOSE_REPLY_TO_ALL, NULL},
804 {N_("/_Message/Repl_y to/_sender"), NULL, main_window_reply_cb, COMPOSE_REPLY_TO_SENDER, NULL},
805 {N_("/_Message/Repl_y to/mailing _list"),
806 "<control>L", main_window_reply_cb, COMPOSE_REPLY_TO_LIST, NULL},
807 {N_("/_Message/Follow-up and reply to"),NULL, main_window_reply_cb, COMPOSE_FOLLOWUP_AND_REPLY_TO, NULL},
808 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
809 {N_("/_Message/_Forward"), "<control><alt>F", main_window_reply_cb, COMPOSE_FORWARD_INLINE, NULL},
810 {N_("/_Message/For_ward as attachment"), NULL, main_window_reply_cb, COMPOSE_FORWARD_AS_ATTACH, NULL},
811 {N_("/_Message/Redirect"), NULL, main_window_reply_cb, COMPOSE_REDIRECT, NULL},
813 {N_("/_Message/Mailing-_List"), NULL, NULL, 0, "<Branch>"},
814 {N_("/_Message/Mailing-_List/Post"), NULL, NULL, 0, "<Branch>"},
815 {N_("/_Message/Mailing-_List/Help"), NULL, NULL, 0, "<Branch>"},
816 {N_("/_Message/Mailing-_List/Subscribe"), NULL, NULL, 0, "<Branch>"},
817 {N_("/_Message/Mailing-_List/Unsubscribe"), NULL, NULL, 0, "<Branch>"},
818 {N_("/_Message/Mailing-_List/View archive"), NULL, NULL, 0, "<Branch>"},
819 {N_("/_Message/Mailing-_List/Contact owner"), NULL, NULL, 0, "<Branch>"},
821 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
822 {N_("/_Message/M_ove..."), "<control>O", move_to_cb, 0, NULL},
823 {N_("/_Message/_Copy..."), "<shift><control>O", copy_to_cb, 0, NULL},
824 {N_("/_Message/Move to _trash"), "<control>D", delete_trash_cb, 0, NULL},
825 {N_("/_Message/_Delete..."), NULL, delete_cb, 0, NULL},
826 {N_("/_Message/Cancel a news message"), "", cancel_cb, 0, NULL},
827 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
828 {N_("/_Message/_Mark"), NULL, NULL, 0, "<Branch>"},
829 {N_("/_Message/_Mark/_Mark"), "<shift>asterisk", mark_cb, 0, NULL},
830 {N_("/_Message/_Mark/_Unmark"), "U", unmark_cb, 0, NULL},
831 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
832 {N_("/_Message/_Mark/Mark as unr_ead"), "<shift>exclam", mark_as_unread_cb, 0, NULL},
833 {N_("/_Message/_Mark/Mark as rea_d"), NULL, mark_as_read_cb, 0, NULL},
834 {N_("/_Message/_Mark/Mark all _read"), NULL, mark_all_read_cb, 0, NULL},
835 {N_("/_Message/_Mark/Ignore thread"), NULL, ignore_thread_cb, 0, NULL},
836 {N_("/_Message/_Mark/Unignore thread"), NULL, unignore_thread_cb, 0, NULL},
837 {N_("/_Message/_Mark/Watch thread"), NULL, watch_thread_cb, 0, NULL},
838 {N_("/_Message/_Mark/Unwatch thread"), NULL, unwatch_thread_cb, 0, NULL},
839 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
840 {N_("/_Message/_Mark/Mark as _spam"), NULL, mark_as_spam_cb, 1, NULL},
841 {N_("/_Message/_Mark/Mark as _ham"), NULL, mark_as_spam_cb, 0, NULL},
842 {N_("/_Message/_Mark/---"), NULL, NULL, 0, "<Separator>"},
843 {N_("/_Message/_Mark/Lock"), NULL, lock_msgs_cb, 0, NULL},
844 {N_("/_Message/_Mark/Unlock"), NULL, unlock_msgs_cb, 0, NULL},
845 {N_("/_Message/Color la_bel"), NULL, NULL, 0, NULL},
846 {N_("/_Message/T_ags"), NULL, NULL, 0, NULL},
847 {N_("/_Message/---"), NULL, NULL, 0, "<Separator>"},
848 {N_("/_Message/Re-_edit"), NULL, reedit_cb, 0, NULL},
850 {N_("/_Tools"), NULL, NULL, 0, "<Branch>"},
851 {N_("/_Tools/_Address book..."), "<shift><control>A", addressbook_open_cb, 0, NULL},
852 {N_("/_Tools/Add sender to address boo_k"),
853 NULL, add_address_cb, 0, NULL},
854 {N_("/_Tools/_Harvest addresses"), NULL, NULL, 0, "<Branch>"},
855 {N_("/_Tools/_Harvest addresses/from _Folder..."),
856 NULL, addr_harvest_cb, 0, NULL},
857 {N_("/_Tools/_Harvest addresses/from _Messages..."),
858 NULL, addr_harvest_msg_cb, 0, NULL},
859 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
860 {N_("/_Tools/_Filter all messages in folder"),
861 NULL, filter_cb, 0, NULL},
862 {N_("/_Tools/Filter _selected messages"),
863 NULL, filter_cb, 1, NULL},
864 {N_("/_Tools/Run folder processing rules"),
865 NULL, process_cb, 0, NULL},
866 {N_("/_Tools/_Create filter rule"), NULL, NULL, 0, "<Branch>"},
867 {N_("/_Tools/_Create filter rule/_Automatically"),
868 NULL, create_filter_cb, FILTER_BY_AUTO, NULL},
869 {N_("/_Tools/_Create filter rule/by _From"),
870 NULL, create_filter_cb, FILTER_BY_FROM, NULL},
871 {N_("/_Tools/_Create filter rule/by _To"),
872 NULL, create_filter_cb, FILTER_BY_TO, NULL},
873 {N_("/_Tools/_Create filter rule/by _Subject"),
874 NULL, create_filter_cb, FILTER_BY_SUBJECT, NULL},
875 {N_("/_Tools/C_reate processing rule"), NULL, NULL, 0, "<Branch>"},
876 {N_("/_Tools/C_reate processing rule/_Automatically"),
877 NULL, create_processing_cb, FILTER_BY_AUTO, NULL},
878 {N_("/_Tools/C_reate processing rule/by _From"),
879 NULL, create_processing_cb, FILTER_BY_FROM, NULL},
880 {N_("/_Tools/C_reate processing rule/by _To"),
881 NULL, create_processing_cb, FILTER_BY_TO, NULL},
882 {N_("/_Tools/C_reate processing rule/by _Subject"),
883 NULL, create_processing_cb, FILTER_BY_SUBJECT, NULL},
884 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
885 {N_("/_Tools/List _URLs..."), "<shift><control>U", open_urls_cb, 0, NULL},
886 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
887 {N_("/_Tools/Actio_ns"), NULL, NULL, 0, "<Branch>"},
888 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
889 {N_("/_Tools/Ch_eck for new messages in all folders"),
890 NULL, update_folderview_cb, 0, NULL},
891 {N_("/_Tools/Delete du_plicated messages"),
892 NULL, NULL, 0, "<Branch>"},
893 {N_("/_Tools/Delete du_plicated messages/In selected folder"),
894 NULL, delete_duplicated_cb, 0, NULL},
895 {N_("/_Tools/Delete du_plicated messages/In all folders"),
896 NULL, delete_duplicated_all_cb, 0, NULL},
897 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
898 {N_("/_Tools/E_xecute"), "X", execute_summary_cb, 0, NULL},
900 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
901 {N_("/_Tools/SSL cer_tificates..."),
902 NULL, ssl_manager_open_cb, 0, NULL},
904 {N_("/_Tools/---"), NULL, NULL, 0, "<Separator>"},
905 {N_("/_Tools/Filtering Log"), NULL, filtering_debug_window_show_cb, 0, NULL},
906 {N_("/_Tools/Network _Log"), "<shift><control>L", log_window_show_cb, 0, NULL},
908 {N_("/_Configuration"), NULL, NULL, 0, "<Branch>"},
909 {N_("/_Configuration/C_hange current account"),
910 NULL, NULL, 0, "<Branch>"},
911 {N_("/_Configuration/_Preferences for current account..."),
912 NULL, prefs_account_open_cb, 0, NULL},
913 {N_("/_Configuration/Create _new account..."),
914 NULL, new_account_cb, 0, NULL},
915 {N_("/_Configuration/_Edit accounts..."),
916 NULL, account_edit_open, 0, NULL},
917 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
918 {N_("/_Configuration/P_references..."),
919 NULL, prefs_open_cb, 0, NULL},
920 {N_("/_Configuration/Pre-pr_ocessing..."),
921 NULL, prefs_pre_processing_open_cb, 0, NULL},
922 {N_("/_Configuration/Post-pro_cessing..."),
923 NULL, prefs_post_processing_open_cb, 0, NULL},
924 {N_("/_Configuration/_Filtering..."),
925 NULL, prefs_filtering_open_cb, 0, NULL},
926 {N_("/_Configuration/_Templates..."), NULL, prefs_template_open_cb, 0, NULL},
927 {N_("/_Configuration/_Actions..."), NULL, prefs_actions_open_cb, 0, NULL},
928 {N_("/_Configuration/Tag_s..."), NULL, prefs_tags_open_cb, 0, NULL},
929 {N_("/_Configuration/---"), NULL, NULL, 0, "<Separator>"},
930 {N_("/_Configuration/Plu_gins..."), NULL, plugins_open_cb, 0, NULL},
932 {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
933 {N_("/_Help/_Manual"), NULL, manual_open_cb, MANUAL_MANUAL_CLAWS, NULL},
934 {N_("/_Help/_Online User-contributed FAQ"),
935 NULL, manual_open_cb, MANUAL_FAQ_CLAWS, NULL},
936 {N_("/_Help/Icon _Legend"), NULL, legend_open_cb, 0, NULL},
937 {N_("/_Help/---"), NULL, NULL, 0, "<Separator>"},
938 {N_("/_Help/_About"), NULL, about_show, 0, NULL}
941 static gboolean offline_ask_sync = TRUE;
942 static guint lastkey;
943 static gboolean is_obscured = FALSE;
945 static gboolean main_window_accel_activate (GtkAccelGroup *accelgroup,
951 MainWindow *mainwin = (MainWindow *)user_data;
953 if (mainwin->summaryview &&
954 mainwin->summaryview->quicksearch &&
955 quicksearch_has_focus(mainwin->summaryview->quicksearch) &&
956 (mod == 0 || mod == GDK_SHIFT_MASK)) {
957 quicksearch_pass_key(mainwin->summaryview->quicksearch, lastkey, mod);
963 #define N_COLOR_LABELS colorlabel_get_color_count()
965 static void mainwindow_colorlabel_menu_item_activate_item_cb(GtkMenuItem *menu_item,
970 GtkCheckMenuItem **items;
975 mainwin = (MainWindow *)data;
976 g_return_if_fail(mainwin != NULL);
978 sel = summary_get_selection(mainwin->summaryview);
981 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
982 g_return_if_fail(menu != NULL);
984 Xalloca(items, (N_COLOR_LABELS + 1) * sizeof(GtkWidget *), return);
986 /* NOTE: don't return prematurely because we set the "dont_toggle"
987 * state for check menu items */
988 g_object_set_data(G_OBJECT(menu), "dont_toggle",
991 /* clear items. get item pointers. */
992 for (n = 0, cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
993 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
994 gtk_check_menu_item_set_active
995 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
996 items[n] = GTK_CHECK_MENU_ITEM(cur->data);
1001 if (n == (N_COLOR_LABELS + 1)) {
1002 /* iterate all messages and set the state of the appropriate
1004 for (; sel != NULL; sel = sel->next) {
1008 msginfo = (MsgInfo *)sel->data;
1010 clabel = MSG_GET_COLORLABEL_VALUE(msginfo->flags);
1011 if (!items[clabel]->active)
1012 gtk_check_menu_item_set_active
1013 (items[clabel], TRUE);
1017 g_warning("invalid number of color elements (%d)\n", n);
1020 /* reset "dont_toggle" state */
1021 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1022 GINT_TO_POINTER(0));
1025 static void mainwindow_colorlabel_menu_item_activate_cb(GtkWidget *widget,
1028 guint color = GPOINTER_TO_UINT(data);
1029 MainWindow *mainwin;
1031 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1032 g_return_if_fail(mainwin != NULL);
1034 /* "dont_toggle" state set? */
1035 if (g_object_get_data(G_OBJECT(mainwin->colorlabel_menu),
1039 summary_set_colorlabel(mainwin->summaryview, color, NULL);
1042 static void mainwindow_tags_menu_item_activate_item_cb(GtkMenuItem *menu_item,
1045 MainWindow *mainwin;
1049 GHashTable *menu_table = g_hash_table_new_full(
1053 GHashTable *menu_allsel_table = g_hash_table_new_full(
1058 mainwin = (MainWindow *)data;
1059 g_return_if_fail(mainwin != NULL);
1061 sel = summary_get_selection(mainwin->summaryview);
1064 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1065 g_return_if_fail(menu != NULL);
1067 /* NOTE: don't return prematurely because we set the "dont_toggle"
1068 * state for check menu items */
1069 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1070 GINT_TO_POINTER(1));
1072 /* clear items. get item pointers. */
1073 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1074 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
1075 gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
1077 gtk_check_menu_item_set_active
1078 (GTK_CHECK_MENU_ITEM(cur->data), FALSE);
1080 g_hash_table_insert(menu_table, GINT_TO_POINTER(id), GTK_CHECK_MENU_ITEM(cur->data));
1081 g_hash_table_insert(menu_allsel_table, GINT_TO_POINTER(id), GINT_TO_POINTER(0));
1085 /* iterate all messages and set the state of the appropriate
1088 for (; sel != NULL; sel = sel->next) {
1090 GSList *tags = NULL;
1092 GtkCheckMenuItem *item;
1093 msginfo = (MsgInfo *)sel->data;
1096 tags = msginfo->tags;
1100 for (; tags; tags = tags->next) {
1101 gint num_checked = GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table, tags->data));
1102 id = GPOINTER_TO_INT(tags->data);
1103 item = g_hash_table_lookup(menu_table, GINT_TO_POINTER(tags->data));
1104 if (item && !item->active) {
1105 gtk_check_menu_item_set_active
1109 g_hash_table_replace(menu_allsel_table, tags->data, GINT_TO_POINTER(num_checked));
1114 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1115 if (GTK_IS_CHECK_MENU_ITEM(cur->data)) {
1116 gint id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cur->data),
1118 gint num_checked = GPOINTER_TO_INT(g_hash_table_lookup(menu_allsel_table, GINT_TO_POINTER(id)));
1119 if (num_checked < sel_len && num_checked > 0)
1120 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur->data), TRUE);
1122 gtk_check_menu_item_set_inconsistent(GTK_CHECK_MENU_ITEM(cur->data), FALSE);
1126 g_hash_table_destroy(menu_table);
1127 g_hash_table_destroy(menu_allsel_table);
1128 /* reset "dont_toggle" state */
1129 g_object_set_data(G_OBJECT(menu), "dont_toggle",
1130 GINT_TO_POINTER(0));
1133 static void mainwindow_tags_menu_item_activate_cb(GtkWidget *widget,
1136 gint id = GPOINTER_TO_INT(data);
1137 gboolean set = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget));
1138 MainWindow *mainwin;
1140 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1141 g_return_if_fail(mainwin != NULL);
1143 /* "dont_toggle" state set? */
1144 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1150 summary_set_tag(mainwin->summaryview, id, NULL);
1153 static void mainwindow_colorlabel_menu_create(MainWindow *mainwin, gboolean refresh)
1155 GtkWidget *label_menuitem;
1160 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1161 "/Message/Color label");
1162 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1163 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_item_cb),
1165 gtk_widget_show(label_menuitem);
1167 menu = gtk_menu_new();
1169 /* create sub items. for the menu item activation callback we pass the
1170 * index of label_colors[] as data parameter. for the None color we
1171 * pass an invalid (high) value. also we attach a data pointer so we
1172 * can always get back the Mainwindow pointer. */
1174 item = gtk_check_menu_item_new_with_label(_("None"));
1175 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1176 g_signal_connect(G_OBJECT(item), "activate",
1177 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1178 GUINT_TO_POINTER(0));
1179 g_object_set_data(G_OBJECT(item), "mainwin", mainwin);
1180 gtk_widget_show(item);
1182 gtk_widget_add_accelerator(item, "activate",
1183 mainwin->menu_factory->accel_group,
1184 GDK_0, GDK_CONTROL_MASK,
1185 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1187 item = gtk_menu_item_new();
1188 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1189 gtk_widget_show(item);
1191 /* create pixmap/label menu items */
1192 for (i = 0; i < N_COLOR_LABELS; i++) {
1193 item = colorlabel_create_check_color_menu_item(
1194 i, refresh, MAINWIN_COLORMENU);
1195 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1196 g_signal_connect(G_OBJECT(item), "activate",
1197 G_CALLBACK(mainwindow_colorlabel_menu_item_activate_cb),
1198 GUINT_TO_POINTER(i + 1));
1199 g_object_set_data(G_OBJECT(item), "mainwin",
1201 gtk_widget_show(item);
1203 gtk_widget_add_accelerator(item, "activate",
1204 mainwin->menu_factory->accel_group,
1205 GDK_1+i, GDK_CONTROL_MASK,
1206 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1208 gtk_widget_show(menu);
1209 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1210 mainwin->colorlabel_menu = menu;
1213 static void mainwindow_tags_menu_item_apply_tags_activate_cb(GtkWidget *widget,
1216 MainWindow *mainwin;
1218 mainwin = g_object_get_data(G_OBJECT(widget), "mainwin");
1219 g_return_if_fail(mainwin != NULL);
1221 /* "dont_toggle" state set? */
1222 if (g_object_get_data(G_OBJECT(mainwin->tags_menu),
1226 tag_apply_open(summary_get_selection(mainwin->summaryview));
1229 static void mainwindow_tags_menu_create(MainWindow *mainwin, gboolean refresh)
1231 GtkWidget *label_menuitem;
1234 GSList *cur = tags_get_list();
1236 gboolean existing_tags = FALSE;
1238 label_menuitem = gtk_item_factory_get_item(mainwin->menu_factory,
1240 g_signal_connect(G_OBJECT(label_menuitem), "activate",
1241 G_CALLBACK(mainwindow_tags_menu_item_activate_item_cb),
1244 gtk_widget_show(label_menuitem);
1246 menu = gtk_menu_new();
1248 /* create tags menu items */
1249 for (; cur; cur = cur->next) {
1250 gint id = GPOINTER_TO_INT(cur->data);
1251 const gchar *tag = tags_get_tag(id);
1253 item = gtk_check_menu_item_new_with_label(tag);
1254 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1255 g_signal_connect(G_OBJECT(item), "activate",
1256 G_CALLBACK(mainwindow_tags_menu_item_activate_cb),
1257 GINT_TO_POINTER(id));
1258 g_object_set_data(G_OBJECT(item), "mainwin",
1260 g_object_set_data(G_OBJECT(item), "tag_id",
1261 GINT_TO_POINTER(id));
1262 gtk_widget_show(item);
1263 existing_tags = TRUE;
1265 if (existing_tags) {
1267 item = gtk_menu_item_new();
1268 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1269 gtk_widget_show(item);
1272 item = gtk_menu_item_new_with_label(_("Apply tags..."));
1273 gtk_widget_add_accelerator(item, "activate",
1274 mainwin->menu_factory->accel_group,
1275 GDK_T, GDK_CONTROL_MASK|GDK_SHIFT_MASK,
1276 GTK_ACCEL_LOCKED | GTK_ACCEL_VISIBLE);
1277 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
1278 g_signal_connect(G_OBJECT(item), "activate",
1279 G_CALLBACK(mainwindow_tags_menu_item_apply_tags_activate_cb),
1281 g_object_set_data(G_OBJECT(item), "mainwin",
1283 gtk_widget_show(item);
1286 gtk_widget_show(menu);
1287 gtk_menu_item_set_submenu(GTK_MENU_ITEM(label_menuitem), menu);
1288 mainwin->tags_menu = menu;
1291 static gboolean warning_icon_pressed(GtkWidget *widget, GdkEventButton *evt,
1292 MainWindow *mainwindow)
1294 if (evt && evt->button == 1) {
1295 log_window_show_error(mainwindow->logwin);
1296 gtk_widget_hide(mainwindow->warning_btn);
1301 static gboolean warning_visi_notify(GtkWidget *widget,
1302 GdkEventVisibility *event,
1303 MainWindow *mainwindow)
1305 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1309 static gboolean warning_leave_notify(GtkWidget *widget,
1310 GdkEventCrossing *event,
1311 MainWindow *mainwindow)
1313 gdk_window_set_cursor(mainwindow->warning_btn->window, NULL);
1317 static gboolean warning_enter_notify(GtkWidget *widget,
1318 GdkEventCrossing *event,
1319 MainWindow *mainwindow)
1321 gdk_window_set_cursor(mainwindow->warning_btn->window, hand_cursor);
1325 void mainwindow_show_error(void)
1327 MainWindow *mainwin = mainwindow_get_mainwindow();
1328 gtk_widget_show(mainwin->warning_btn);
1331 void mainwindow_clear_error(MainWindow *mainwin)
1333 gtk_widget_hide(mainwin->warning_btn);
1336 MainWindow *main_window_create()
1338 MainWindow *mainwin;
1342 GtkWidget *handlebox;
1343 GtkWidget *vbox_body;
1345 GtkWidget *hbox_stat;
1346 GtkWidget *statusbar;
1347 GtkWidget *progressbar;
1348 GtkWidget *statuslabel;
1349 GtkWidget *ac_button;
1350 GtkWidget *ac_label;
1351 GtkWidget *online_pixmap;
1352 GtkWidget *offline_pixmap;
1354 GtkWidget *warning_icon;
1355 GtkWidget *warning_btn;
1357 GtkWidget *online_switch;
1358 GtkWidget *offline_switch;
1359 FolderView *folderview;
1360 SummaryView *summaryview;
1361 MessageView *messageview;
1362 GdkColormap *colormap;
1364 gboolean success[4];
1365 GtkItemFactory *ifactory;
1367 GtkWidget *menuitem;
1369 guint n_menu_entries;
1371 static GdkGeometry geometry;
1373 debug_print("Creating main window...\n");
1374 mainwin = g_new0(MainWindow, 1);
1377 window = GTK_WIDGET(gtkut_window_new(GTK_WINDOW_TOPLEVEL, "mainwindow"));
1378 gtk_window_set_title(GTK_WINDOW(window), PROG_VERSION);
1379 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
1381 prefs_common.layout_mode = SMALL_LAYOUT;
1383 if (!geometry.min_height) {
1384 geometry.min_width = 320;
1385 geometry.min_height = 200;
1387 gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
1390 g_signal_connect(G_OBJECT(window), "delete_event",
1391 G_CALLBACK(main_window_close_cb), mainwin);
1392 MANAGE_WINDOW_SIGNALS_CONNECT(window);
1393 g_signal_connect(G_OBJECT(window), "focus_in_event",
1394 G_CALLBACK(mainwindow_focus_in_event),
1396 g_signal_connect(G_OBJECT(window), "key_press_event",
1397 G_CALLBACK(mainwindow_key_pressed), mainwin);
1399 gtk_widget_realize(window);
1400 gtk_widget_add_events(window, GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK);
1403 gtkut_widget_set_app_icon(window);
1405 vbox = gtk_vbox_new(FALSE, 0);
1406 gtk_widget_show(vbox);
1407 gtk_container_add(GTK_CONTAINER(window), vbox);
1410 n_menu_entries = sizeof(mainwin_entries) / sizeof(mainwin_entries[0]);
1411 menubar = menubar_create(window, mainwin_entries,
1412 n_menu_entries, "<Main>", mainwin);
1413 gtk_widget_show(menubar);
1416 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
1419 ifactory = gtk_item_factory_from_widget(menubar);
1421 /* gtk_widget_show(gtk_item_factory_get_item(ifactory,"/Message/Mailing-List"));
1422 main_create_mailing_list_menu (mainwin, NULL); */
1424 if (prefs_common.toolbar_detachable) {
1425 handlebox = gtk_handle_box_new();
1426 gtk_widget_show(handlebox);
1427 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1428 g_signal_connect(G_OBJECT(handlebox), "child_attached",
1429 G_CALLBACK(toolbar_child_attached), mainwin);
1430 g_signal_connect(G_OBJECT(handlebox), "child_detached",
1431 G_CALLBACK(toolbar_child_detached), mainwin);
1433 handlebox = gtk_hbox_new(FALSE, 0);
1434 gtk_widget_show(handlebox);
1435 gtk_box_pack_start(GTK_BOX(vbox), handlebox, FALSE, FALSE, 0);
1437 /* link window to mainwin->window to avoid gdk warnings */
1438 mainwin->window = window;
1439 mainwin_list = g_list_append(mainwin_list, mainwin);
1442 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1446 mainwin->toolbar = toolbar_create(TOOLBAR_MAIN,
1450 toolbar_set_learn_button
1454 /* vbox that contains body */
1455 vbox_body = gtk_vbox_new(FALSE, BORDER_WIDTH);
1456 gtk_widget_show(vbox_body);
1457 gtk_container_set_border_width(GTK_CONTAINER(vbox_body), BORDER_WIDTH);
1458 gtk_box_pack_start(GTK_BOX(vbox), vbox_body, TRUE, TRUE, 0);
1461 hbox_stat = gtk_hbox_new(FALSE, 2);
1462 gtk_box_pack_end(GTK_BOX(vbox_body), hbox_stat, FALSE, FALSE, 0);
1464 tips = gtk_tooltips_new();
1466 warning_icon = gtk_image_new_from_stock
1467 (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1468 warning_btn = gtk_event_box_new();
1469 gtk_event_box_set_visible_window(GTK_EVENT_BOX(warning_btn), FALSE);
1471 mainwin->warning_btn = warning_btn;
1473 g_signal_connect(G_OBJECT(warning_btn), "button-press-event",
1474 G_CALLBACK(warning_icon_pressed),
1475 (gpointer) mainwin);
1476 g_signal_connect(G_OBJECT(warning_btn), "visibility-notify-event",
1477 G_CALLBACK(warning_visi_notify), mainwin);
1478 g_signal_connect(G_OBJECT(warning_btn), "motion-notify-event",
1479 G_CALLBACK(warning_visi_notify), mainwin);
1480 g_signal_connect(G_OBJECT(warning_btn), "leave-notify-event",
1481 G_CALLBACK(warning_leave_notify), mainwin);
1482 g_signal_connect(G_OBJECT(warning_btn), "enter-notify-event",
1483 G_CALLBACK(warning_enter_notify), mainwin);
1485 gtk_container_add (GTK_CONTAINER(warning_btn), warning_icon);
1487 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),warning_btn,
1488 _("Some error(s) happened. Click here to view log."), NULL);
1489 gtk_box_pack_start(GTK_BOX(hbox_stat), warning_btn, FALSE, FALSE, 0);
1491 statusbar = statusbar_create();
1492 gtk_box_pack_start(GTK_BOX(hbox_stat), statusbar, TRUE, TRUE, 0);
1494 progressbar = gtk_progress_bar_new();
1495 gtk_widget_set_size_request(progressbar, 120, 1);
1496 gtk_box_pack_start(GTK_BOX(hbox_stat), progressbar, FALSE, FALSE, 0);
1498 online_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_ONLINE);
1499 offline_pixmap = stock_pixmap_widget(hbox_stat, STOCK_PIXMAP_OFFLINE);
1500 online_switch = gtk_button_new ();
1501 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),online_switch,
1502 _("You are online. Click the icon to go offline"), NULL);
1503 offline_switch = gtk_button_new ();
1504 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),offline_switch,
1505 _("You are offline. Click the icon to go online"),
1507 gtk_container_add (GTK_CONTAINER(online_switch), online_pixmap);
1508 gtk_button_set_relief (GTK_BUTTON(online_switch), GTK_RELIEF_NONE);
1509 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1510 gtk_box_pack_start (GTK_BOX(hbox_stat), online_switch, FALSE, FALSE, 0);
1511 gtk_container_add (GTK_CONTAINER(offline_switch), offline_pixmap);
1512 gtk_button_set_relief (GTK_BUTTON(offline_switch), GTK_RELIEF_NONE);
1513 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1514 gtk_box_pack_start (GTK_BOX(hbox_stat), offline_switch, FALSE, FALSE, 0);
1516 statuslabel = gtk_label_new("");
1517 gtk_box_pack_start(GTK_BOX(hbox_stat), statuslabel, FALSE, FALSE, 0);
1519 ac_button = gtk_button_new();
1520 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips),
1521 ac_button, _("Select account"), NULL);
1522 GTK_WIDGET_UNSET_FLAGS(ac_button, GTK_CAN_FOCUS);
1523 gtk_widget_set_size_request(ac_button, -1, 0);
1524 gtk_box_pack_end(GTK_BOX(hbox_stat), ac_button, FALSE, FALSE, 0);
1525 g_signal_connect(G_OBJECT(ac_button), "button_press_event",
1526 G_CALLBACK(ac_label_button_pressed), mainwin);
1528 ac_label = gtk_label_new("");
1529 gtk_container_add(GTK_CONTAINER(ac_button), ac_label);
1531 gtk_widget_show_all(hbox_stat);
1533 gtk_widget_hide(offline_switch);
1534 gtk_widget_hide(warning_btn);
1536 online_switch = gtk_button_new ();
1537 offline_switch = gtk_button_new ();
1538 g_signal_connect (G_OBJECT(online_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1539 g_signal_connect (G_OBJECT(offline_switch), "clicked", G_CALLBACK(online_switch_clicked), mainwin);
1542 mainwin->folderview = folderview = folderview_create();
1543 mainwin->summaryview = summaryview = summary_create();
1544 mainwin->messageview = messageview = messageview_create(mainwin);
1546 /* init log instances data before creating log views */
1547 set_log_title(LOG_PROTOCOL, _("Network log"));
1548 set_log_prefs(LOG_PROTOCOL,
1549 &prefs_common.logwin_width,
1550 &prefs_common.logwin_height);
1551 set_log_title(LOG_DEBUG_FILTERING, _("Filtering/processing debug log"));
1552 set_log_prefs(LOG_DEBUG_FILTERING,
1553 &prefs_common.filtering_debugwin_width,
1554 &prefs_common.filtering_debugwin_height);
1556 /* setup log windows */
1557 mainwin->logwin = log_window_create(LOG_PROTOCOL);
1558 log_window_init(mainwin->logwin);
1560 mainwin->filtering_debugwin = log_window_create(LOG_DEBUG_FILTERING);
1561 log_window_set_clipping(mainwin->logwin,
1562 prefs_common.cliplog,
1563 prefs_common.loglength);
1565 log_window_init(mainwin->filtering_debugwin);
1566 log_window_set_clipping(mainwin->filtering_debugwin,
1567 prefs_common.filtering_debug_cliplog,
1568 prefs_common.filtering_debug_loglength);
1569 if (prefs_common.enable_filtering_debug)
1570 log_message(LOG_DEBUG_FILTERING, _("filtering log enabled\n"));
1572 log_message(LOG_DEBUG_FILTERING, _("filtering log disabled\n"));
1574 folderview->mainwin = mainwin;
1575 folderview->summaryview = summaryview;
1577 summaryview->mainwin = mainwin;
1578 summaryview->folderview = folderview;
1579 summaryview->messageview = messageview;
1580 summaryview->window = window;
1582 mainwin->vbox = vbox;
1583 mainwin->menubar = menubar;
1584 mainwin->menu_factory = ifactory;
1585 mainwin->handlebox = handlebox;
1586 mainwin->vbox_body = vbox_body;
1587 mainwin->online_switch = online_switch;
1588 mainwin->offline_switch = offline_switch;
1590 messageview->statusbar = statusbar;
1591 mainwin->statusbar = statusbar;
1592 mainwin->hbox_stat = hbox_stat;
1593 mainwin->progressbar = progressbar;
1594 mainwin->statuslabel = statuslabel;
1595 mainwin->online_pixmap = online_pixmap;
1596 mainwin->offline_pixmap = offline_pixmap;
1597 mainwin->ac_button = ac_button;
1598 mainwin->ac_label = ac_label;
1599 /* set context IDs for status bar */
1600 mainwin->mainwin_cid = gtk_statusbar_get_context_id
1601 (GTK_STATUSBAR(statusbar), "Main Window");
1602 mainwin->folderview_cid = gtk_statusbar_get_context_id
1603 (GTK_STATUSBAR(statusbar), "Folder View");
1604 mainwin->summaryview_cid = gtk_statusbar_get_context_id
1605 (GTK_STATUSBAR(statusbar), "Summary View");
1606 mainwin->messageview_cid = gtk_statusbar_get_context_id
1607 (GTK_STATUSBAR(statusbar), "Message View");
1608 messageview->statusbar_cid = mainwin->messageview_cid;
1611 messageview->statusbar = NULL;
1612 mainwin->statusbar = NULL;
1613 mainwin->hbox_stat = NULL;
1614 /* mainwin->progressbar is set in toolbar.c */
1615 mainwin->statuslabel = NULL;
1616 mainwin->online_pixmap = NULL;
1617 mainwin->offline_pixmap = NULL;
1618 mainwin->ac_button = NULL;
1619 mainwin->ac_label = NULL;
1622 /* allocate colors for summary view and folder view */
1623 summaryview->color_marked.red = summaryview->color_marked.green = 0;
1624 summaryview->color_marked.blue = (guint16)65535;
1626 summaryview->color_dim.red = summaryview->color_dim.green =
1627 summaryview->color_dim.blue = COLOR_DIM;
1629 gtkut_convert_int_to_gdk_color(prefs_common.color_new,
1630 &folderview->color_new);
1632 gtkut_convert_int_to_gdk_color(prefs_common.tgt_folder_col,
1633 &folderview->color_op);
1635 summaryview->color_important.red = 0;
1636 summaryview->color_important.green = 0;
1637 summaryview->color_important.blue = (guint16)65535;
1639 color[0] = summaryview->color_marked;
1640 color[1] = summaryview->color_dim;
1641 color[2] = folderview->color_new;
1642 color[3] = folderview->color_op;
1644 colormap = gdk_drawable_get_colormap(window->window);
1645 gdk_colormap_alloc_colors(colormap, color, 4, FALSE, TRUE, success);
1646 for (i = 0; i < 4; i++) {
1647 if (success[i] == FALSE)
1648 g_warning("MainWindow: color allocation %d failed\n", i);
1651 debug_print("done.\n");
1653 messageview->visible = prefs_common.msgview_visible;
1655 main_window_set_widgets(mainwin, prefs_common.layout_mode);
1657 g_signal_connect(G_OBJECT(window), "size_allocate",
1658 G_CALLBACK(main_window_size_allocate_cb),
1661 /* set menu items */
1662 menuitem = gtk_item_factory_get_item
1663 (ifactory, "/View/Character encoding/Auto detect");
1664 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1666 switch (prefs_common.toolbar_style) {
1668 menuitem = gtk_item_factory_get_item
1669 (ifactory, "/View/Show or hide/Toolbar/Hide");
1672 menuitem = gtk_item_factory_get_item
1673 (ifactory, "/View/Show or hide/Toolbar/Icons only");
1676 menuitem = gtk_item_factory_get_item
1677 (ifactory, "/View/Show or hide/Toolbar/Text only");
1680 menuitem = gtk_item_factory_get_item
1681 (ifactory, "/View/Show or hide/Toolbar/Text below icons");
1683 case TOOLBAR_BOTH_HORIZ:
1684 menuitem = gtk_item_factory_get_item
1686 "/View/Show or hide/Toolbar/Text beside icons");
1688 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
1691 gtk_widget_hide(mainwin->hbox_stat);
1692 menuitem = gtk_item_factory_get_item
1693 (ifactory, "/View/Show or hide/Status bar");
1694 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1695 prefs_common.show_statusbar);
1697 menuitem = gtk_item_factory_get_item
1698 (ifactory, "/View/Show or hide/Column headers");
1699 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem),
1700 prefs_common.show_col_headers);
1701 /* set account selection menu */
1702 ac_menu = gtk_item_factory_get_widget
1703 (ifactory, "/Configuration/Change current account");
1704 mainwin->ac_menu = ac_menu;
1706 toolbar_main_set_sensitive(mainwin);
1708 /* create actions menu */
1709 main_window_update_actions_menu(mainwin);
1711 main_create_mailing_list_menu (mainwin, NULL);
1713 /* attach accel groups to main window */
1714 #define ADD_MENU_ACCEL_GROUP_TO_WINDOW(menu,win) \
1715 gtk_window_add_accel_group \
1717 gtk_item_factory_from_widget(menu)->accel_group); \
1718 g_signal_connect(G_OBJECT(gtk_item_factory_from_widget(menu)->accel_group), \
1720 G_CALLBACK(main_window_accel_activate), mainwin);
1723 ADD_MENU_ACCEL_GROUP_TO_WINDOW(summaryview->popupmenu, mainwin->window);
1725 /* connect the accelerators for equivalent
1726 menu items in different menus */
1727 menu_connect_identical_items();
1730 gtk_window_iconify(GTK_WINDOW(mainwin->window));
1733 g_signal_connect(G_OBJECT(window), "window_state_event",
1734 G_CALLBACK(mainwindow_state_event_cb), mainwin);
1735 g_signal_connect(G_OBJECT(window), "visibility_notify_event",
1736 G_CALLBACK(mainwindow_visibility_event_cb), mainwin);
1737 gtk_widget_add_events(GTK_WIDGET(window), GDK_VISIBILITY_NOTIFY_MASK);
1739 if (prefs_common.layout_mode == VERTICAL_LAYOUT ||
1740 prefs_common.layout_mode == SMALL_LAYOUT) {
1741 summary_relayout(mainwin->summaryview);
1743 summary_update_unread(mainwin->summaryview, NULL);
1745 gtk_widget_show(mainwin->window);
1747 /* initialize views */
1748 folderview_init(folderview);
1749 summary_init(summaryview);
1750 messageview_init(messageview);
1752 sslcertwindow_register_hook();
1754 mainwin->lock_count = 0;
1755 mainwin->menu_lock_count = 0;
1756 mainwin->cursor_count = 0;
1758 mainwin->progressindicator_hook =
1759 hooks_register_hook(PROGRESSINDICATOR_HOOKLIST, mainwindow_progressindicator_hook, mainwin);
1762 watch_cursor = gdk_cursor_new(GDK_WATCH);
1764 hand_cursor = gdk_cursor_new(GDK_HAND2);
1766 /* init work_offline */
1767 if (prefs_common.work_offline)
1768 online_switch_clicked (GTK_BUTTON(online_switch), mainwin);
1770 mainwindow_colorlabel_menu_create(mainwin, FALSE);
1771 mainwindow_tags_menu_create(mainwin, FALSE);
1776 void main_window_destroy(MainWindow *mainwin)
1778 /* TODO : destroy other component */
1779 messageview_destroy(mainwin->messageview);
1780 mainwin->messageview = NULL;
1783 void main_window_update_actions_menu(MainWindow *mainwin)
1785 GtkItemFactory *ifactory;
1787 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
1788 action_update_mainwin_menu(ifactory, "/Tools/Actions", mainwin);
1791 void main_window_cursor_wait(MainWindow *mainwin)
1794 if (mainwin->cursor_count == 0) {
1795 gdk_window_set_cursor(mainwin->window->window, watch_cursor);
1796 textview_cursor_wait(mainwin->messageview->mimeview->textview);
1799 mainwin->cursor_count++;
1804 void main_window_cursor_normal(MainWindow *mainwin)
1806 if (mainwin->cursor_count)
1807 mainwin->cursor_count--;
1809 if (mainwin->cursor_count == 0) {
1810 gdk_window_set_cursor(mainwin->window->window, NULL);
1811 textview_cursor_normal(mainwin->messageview->mimeview->textview);
1816 /* lock / unlock the user-interface */
1817 void main_window_lock(MainWindow *mainwin)
1819 if (mainwin->lock_count == 0 && mainwin->ac_button)
1820 gtk_widget_set_sensitive(mainwin->ac_button, FALSE);
1822 mainwin->lock_count++;
1824 main_window_set_menu_sensitive(mainwin);
1825 toolbar_main_set_sensitive(mainwin);
1828 void main_window_unlock(MainWindow *mainwin)
1830 if (mainwin->lock_count)
1831 mainwin->lock_count--;
1833 main_window_set_menu_sensitive(mainwin);
1834 toolbar_main_set_sensitive(mainwin);
1836 if (mainwin->lock_count == 0 && mainwin->ac_button)
1837 gtk_widget_set_sensitive(mainwin->ac_button, TRUE);
1840 static void main_window_menu_callback_block(MainWindow *mainwin)
1842 mainwin->menu_lock_count++;
1845 static void main_window_menu_callback_unblock(MainWindow *mainwin)
1847 if (mainwin->menu_lock_count)
1848 mainwin->menu_lock_count--;
1851 static guint prefs_tag = 0;
1853 void main_window_reflect_prefs_all(void)
1855 main_window_reflect_prefs_all_real(FALSE);
1858 static gboolean reflect_prefs_timeout_cb(gpointer data)
1860 gboolean pixmap_theme_changed = GPOINTER_TO_INT(data);
1862 MainWindow *mainwin;
1865 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1866 mainwin = (MainWindow *)cur->data;
1868 main_window_show_cur_account(mainwin);
1869 main_window_set_menu_sensitive(mainwin);
1870 toolbar_main_set_sensitive(mainwin);
1873 if (pixmap_theme_changed) {
1874 toolbar_update(TOOLBAR_MAIN, mainwin);
1875 messageview_reflect_prefs_pixmap_theme();
1876 compose_reflect_prefs_pixmap_theme();
1877 folderview_reflect_prefs_pixmap_theme(mainwin->folderview);
1878 summary_reflect_prefs_pixmap_theme(mainwin->summaryview);
1880 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_ONLINE);
1881 gtk_container_remove(GTK_CONTAINER(mainwin->online_switch),
1882 mainwin->online_pixmap);
1883 gtk_container_add (GTK_CONTAINER(mainwin->online_switch), pixmap);
1884 gtk_widget_show(pixmap);
1885 mainwin->online_pixmap = pixmap;
1886 pixmap = stock_pixmap_widget(mainwin->hbox_stat, STOCK_PIXMAP_OFFLINE);
1887 gtk_container_remove(GTK_CONTAINER(mainwin->offline_switch),
1888 mainwin->offline_pixmap);
1889 gtk_container_add (GTK_CONTAINER(mainwin->offline_switch), pixmap);
1890 gtk_widget_show(pixmap);
1891 mainwin->offline_pixmap = pixmap;
1895 headerview_set_font(mainwin->messageview->headerview);
1896 headerview_set_visibility(mainwin->messageview->headerview,
1897 prefs_common.display_header_pane);
1898 textview_reflect_prefs(mainwin->messageview->mimeview->textview);
1899 folderview_reflect_prefs();
1900 summary_reflect_prefs();
1902 summary_redisplay_msg(mainwin->summaryview);
1904 if (prefs_common.layout_mode == SMALL_LAYOUT) {
1905 if (mainwin->in_folder) {
1906 mainwindow_enter_folder(mainwin);
1908 mainwindow_exit_folder(mainwin);
1916 void main_window_reflect_prefs_all_now(void)
1918 reflect_prefs_timeout_cb(GINT_TO_POINTER(FALSE));
1921 void main_window_reflect_prefs_custom_colors(MainWindow *mainwin)
1926 /* re-create colorlabel submenu */
1927 menu = GTK_MENU_SHELL(mainwin->colorlabel_menu);
1928 g_return_if_fail(menu != NULL);
1930 /* clear items. get item pointers. */
1931 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1932 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1934 mainwindow_colorlabel_menu_create(mainwin, TRUE);
1935 summary_reflect_prefs_custom_colors(mainwin->summaryview);
1939 void main_window_reflect_tags_changes(MainWindow *mainwin)
1944 /* re-create tags submenu */
1945 menu = GTK_MENU_SHELL(mainwin->tags_menu);
1946 g_return_if_fail(menu != NULL);
1948 /* clear items. get item pointers. */
1949 for (cur = menu->children; cur != NULL && cur->data != NULL; cur = cur->next) {
1950 gtk_menu_item_remove_submenu(GTK_MENU_ITEM(cur->data));
1952 mainwindow_tags_menu_create(mainwin, TRUE);
1953 summary_reflect_tags_changes(mainwin->summaryview);
1957 void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
1959 if (prefs_tag == 0 || pixmap_theme_changed) {
1960 prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb,
1961 GINT_TO_POINTER(pixmap_theme_changed));
1965 void main_window_set_summary_column(void)
1968 MainWindow *mainwin;
1970 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1971 mainwin = (MainWindow *)cur->data;
1972 summary_set_column_order(mainwin->summaryview);
1976 void main_window_set_folder_column(void)
1979 MainWindow *mainwin;
1981 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
1982 mainwin = (MainWindow *)cur->data;
1983 folderview_set_column_order(mainwin->folderview);
1987 static void main_window_set_account_selector_menu(MainWindow *mainwin,
1988 GList *account_list)
1990 GList *cur_ac, *cur_item;
1991 GtkWidget *menuitem;
1992 PrefsAccount *ac_prefs;
1994 /* destroy all previous menu item */
1995 cur_item = GTK_MENU_SHELL(mainwin->ac_menu)->children;
1996 while (cur_item != NULL) {
1997 GList *next = cur_item->next;
1998 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
2002 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2003 ac_prefs = (PrefsAccount *)cur_ac->data;
2005 menuitem = gtk_menu_item_new_with_label
2006 (ac_prefs->account_name
2007 ? ac_prefs->account_name : _("Untitled"));
2008 gtk_widget_show(menuitem);
2009 gtk_menu_append(GTK_MENU(mainwin->ac_menu), menuitem);
2010 g_signal_connect(G_OBJECT(menuitem), "activate",
2011 G_CALLBACK(account_selector_menu_cb),
2016 static void main_window_set_account_receive_menu(MainWindow *mainwin,
2017 GList *account_list)
2019 GList *cur_ac, *cur_item;
2021 GtkWidget *menuitem;
2022 PrefsAccount *ac_prefs;
2024 menu = gtk_item_factory_get_widget(mainwin->menu_factory,
2025 "/Message/Receive");
2027 /* search for separator */
2028 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2029 cur_item = cur_item->next) {
2030 if (GTK_BIN(cur_item->data)->child == NULL) {
2031 cur_item = cur_item->next;
2036 /* destroy all previous menu item */
2037 while (cur_item != NULL) {
2038 GList *next = cur_item->next;
2039 gtk_widget_destroy(GTK_WIDGET(cur_item->data));
2043 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2044 ac_prefs = (PrefsAccount *)cur_ac->data;
2046 menuitem = gtk_menu_item_new_with_label
2047 (ac_prefs->account_name ? ac_prefs->account_name
2049 gtk_widget_show(menuitem);
2050 gtk_menu_append(GTK_MENU(menu), menuitem);
2051 g_signal_connect(G_OBJECT(menuitem), "activate",
2052 G_CALLBACK(account_receive_menu_cb),
2057 static void main_window_set_toolbar_combo_receive_menu(MainWindow *mainwin,
2058 GList *account_list)
2061 GtkWidget *menuitem;
2062 PrefsAccount *ac_prefs;
2063 GtkWidget *menu = NULL;
2065 if (mainwin->toolbar->getall_btn == NULL) /* button doesn't exist */
2068 menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn));
2070 gtk_widget_destroy(menu);
2071 menu = gtk_menu_new();
2073 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2074 ac_prefs = (PrefsAccount *)cur_ac->data;
2076 menuitem = gtk_menu_item_new_with_label
2077 (ac_prefs->account_name
2078 ? ac_prefs->account_name : _("Untitled"));
2079 gtk_widget_show(menuitem);
2080 gtk_menu_append(GTK_MENU(menu), menuitem);
2081 g_signal_connect(G_OBJECT(menuitem), "activate",
2082 G_CALLBACK(account_receive_menu_cb),
2085 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->getall_btn), menu);
2088 static void main_window_set_toolbar_combo_compose_menu(MainWindow *mainwin,
2089 GList *account_list)
2093 GtkWidget *menuitem;
2094 PrefsAccount *ac_prefs;
2095 GtkWidget *menu = NULL;
2097 if (mainwin->toolbar->compose_mail_btn == NULL) /* button doesn't exist */
2100 menu = gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn));
2102 gtk_widget_destroy(menu);
2103 menu = gtk_menu_new();
2105 for (cur_ac = account_list; cur_ac != NULL; cur_ac = cur_ac->next) {
2106 ac_prefs = (PrefsAccount *)cur_ac->data;
2108 menuitem = gtk_menu_item_new_with_label
2109 (ac_prefs->account_name
2110 ? ac_prefs->account_name : _("Untitled"));
2111 gtk_widget_show(menuitem);
2112 gtk_menu_append(GTK_MENU(menu), menuitem);
2113 g_signal_connect(G_OBJECT(menuitem), "activate",
2114 G_CALLBACK(account_compose_menu_cb),
2117 gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(mainwin->toolbar->compose_mail_btn), menu);
2121 void main_window_set_account_menu(GList *account_list)
2124 MainWindow *mainwin;
2126 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2127 mainwin = (MainWindow *)cur->data;
2128 main_window_set_account_selector_menu(mainwin, account_list);
2129 main_window_set_account_receive_menu(mainwin, account_list);
2130 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2131 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2133 hooks_invoke(ACCOUNT_LIST_CHANGED_HOOKLIST, NULL);
2136 void main_window_set_account_menu_only_toolbar(GList *account_list)
2139 MainWindow *mainwin;
2141 for (cur = mainwin_list; cur != NULL; cur = cur->next) {
2142 mainwin = (MainWindow *)cur->data;
2143 main_window_set_toolbar_combo_receive_menu(mainwin, account_list);
2144 main_window_set_toolbar_combo_compose_menu(mainwin, account_list);
2148 static void main_window_show_cur_account(MainWindow *mainwin)
2153 ac_name = g_strdup(cur_account
2154 ? (cur_account->account_name
2155 ? cur_account->account_name : _("Untitled"))
2159 buf = g_strdup_printf("%s - %s", ac_name, PROG_VERSION);
2161 buf = g_strdup(PROG_VERSION);
2162 gtk_window_set_title(GTK_WINDOW(mainwin->window), buf);
2165 gtk_label_set_text(GTK_LABEL(mainwin->ac_label), ac_name);
2166 if (mainwin->ac_button)
2167 gtk_widget_queue_resize(mainwin->ac_button);
2172 static void main_window_separation_change(MainWindow *mainwin, LayoutType layout_mode)
2174 GtkWidget *folder_wid = GTK_WIDGET_PTR(mainwin->folderview);
2175 GtkWidget *summary_wid = GTK_WIDGET_PTR(mainwin->summaryview);
2176 GtkWidget *message_wid = mainwin->messageview->vbox;
2178 if (layout_mode == prefs_common.layout_mode)
2181 debug_print("Changing window separation type from %d to %d\n",
2182 prefs_common.layout_mode, layout_mode);
2184 /* remove widgets from those containers */
2185 gtk_widget_ref(folder_wid);
2186 gtk_widget_ref(summary_wid);
2187 gtk_widget_ref(message_wid);
2188 gtkut_container_remove
2189 (GTK_CONTAINER(folder_wid->parent), folder_wid);
2190 gtkut_container_remove
2191 (GTK_CONTAINER(summary_wid->parent), summary_wid);
2192 gtkut_container_remove
2193 (GTK_CONTAINER(message_wid->parent), message_wid);
2195 gtk_widget_hide(mainwin->window);
2196 main_window_set_widgets(mainwin, layout_mode);
2197 gtk_widget_show(mainwin->window);
2199 gtk_widget_unref(folder_wid);
2200 gtk_widget_unref(summary_wid);
2201 gtk_widget_unref(message_wid);
2204 void mainwindow_reset_paned(GtkPaned *paned)
2208 if (gtk_paned_get_child1(GTK_PANED(paned)))
2209 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2210 if (gtk_paned_get_child2(GTK_PANED(paned)))
2211 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2214 g_object_get (G_OBJECT(paned),
2217 g_object_get (G_OBJECT(paned),
2221 gtk_paned_set_position(GTK_PANED(paned), mid);
2224 static void mainwin_paned_show_first(GtkPaned *paned)
2227 g_object_get (G_OBJECT(paned),
2231 if (gtk_paned_get_child1(GTK_PANED(paned)))
2232 gtk_widget_show(gtk_paned_get_child1(GTK_PANED(paned)));
2233 if (gtk_paned_get_child2(GTK_PANED(paned)))
2234 gtk_widget_hide(gtk_paned_get_child2(GTK_PANED(paned)));
2235 gtk_paned_set_position(GTK_PANED(paned), max);
2238 static void mainwin_paned_show_last(GtkPaned *paned)
2241 g_object_get (G_OBJECT(paned),
2245 if (gtk_paned_get_child1(GTK_PANED(paned)))
2246 gtk_widget_hide(gtk_paned_get_child1(GTK_PANED(paned)));
2247 if (gtk_paned_get_child2(GTK_PANED(paned)))
2248 gtk_widget_show(gtk_paned_get_child2(GTK_PANED(paned)));
2249 gtk_paned_set_position(GTK_PANED(paned), min);
2252 void main_window_toggle_message_view(MainWindow *mainwin)
2254 SummaryView *summaryview = mainwin->summaryview;
2255 GtkWidget *ppaned = NULL;
2256 GtkWidget *container = NULL;
2258 switch (prefs_common.layout_mode) {
2260 case VERTICAL_LAYOUT:
2262 ppaned = mainwin->vpaned;
2263 container = mainwin->hpaned;
2264 if (ppaned->parent != NULL) {
2265 mainwin->messageview->visible = FALSE;
2266 summaryview->displayed = NULL;
2267 gtk_widget_ref(ppaned);
2268 gtkut_container_remove(GTK_CONTAINER(container), ppaned);
2269 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), container);
2271 mainwin->messageview->visible = TRUE;
2272 gtk_widget_reparent(GTK_WIDGET_PTR(summaryview), ppaned);
2273 gtk_container_add(GTK_CONTAINER(container), ppaned);
2274 gtk_widget_unref(ppaned);
2278 ppaned = mainwin->hpaned;
2279 container = mainwin->vpaned;
2280 if (mainwin->messageview->vbox->parent != NULL) {
2281 mainwin->messageview->visible = FALSE;
2282 summaryview->displayed = NULL;
2283 gtk_widget_ref(mainwin->messageview->vbox);
2284 gtkut_container_remove(GTK_CONTAINER(container), mainwin->messageview->vbox);
2286 mainwin->messageview->visible = TRUE;
2287 gtk_container_add(GTK_CONTAINER(container), mainwin->messageview->vbox);
2288 gtk_widget_unref(mainwin->messageview->vbox);
2291 case WIDE_MSGLIST_LAYOUT:
2292 g_warning("can't hide messageview in this wide msglist layout");
2296 if (messageview_is_visible(mainwin->messageview))
2297 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2298 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
2300 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
2301 GTK_ARROW_UP, GTK_SHADOW_OUT);
2303 if (mainwin->messageview->visible == FALSE)
2304 messageview_clear(mainwin->messageview);
2306 main_window_set_menu_sensitive(mainwin);
2308 prefs_common.msgview_visible = mainwin->messageview->visible;
2310 if (messageview_is_visible(mainwin->messageview)) {
2311 gtk_widget_queue_resize(mainwin->hpaned);
2312 gtk_widget_queue_resize(mainwin->vpaned);
2314 summary_grab_focus(summaryview);
2317 void main_window_get_size(MainWindow *mainwin)
2319 GtkAllocation *allocation;
2321 if (mainwin_list == NULL || mainwin->messageview == NULL) {
2322 debug_print("called after messageview "
2323 "has been deallocated!\n");
2327 allocation = &(GTK_WIDGET_PTR(mainwin->summaryview)->allocation);
2329 if (allocation->width > 1 && allocation->height > 1) {
2330 prefs_common.summaryview_width = allocation->width;
2332 if (messageview_is_visible(mainwin->messageview))
2333 prefs_common.summaryview_height = allocation->height;
2335 prefs_common.mainview_width = allocation->width;
2338 allocation = &mainwin->window->allocation;
2339 if (allocation->width > 1 && allocation->height > 1) {
2340 prefs_common.mainview_height = allocation->height;
2341 prefs_common.mainwin_width = allocation->width;
2342 prefs_common.mainwin_height = allocation->height;
2345 allocation = &(GTK_WIDGET_PTR(mainwin->folderview)->allocation);
2346 if (allocation->width > 1 && allocation->height > 1) {
2347 prefs_common.folderview_width = allocation->width;
2348 prefs_common.folderview_height = allocation->height;
2351 allocation = &(GTK_WIDGET_PTR(mainwin->messageview)->allocation);
2352 if (allocation->width > 1 && allocation->height > 1) {
2353 prefs_common.msgview_width = allocation->width;
2354 prefs_common.msgview_height = allocation->height;
2357 /* debug_print("summaryview size: %d x %d\n",
2358 prefs_common.summaryview_width,
2359 prefs_common.summaryview_height);
2360 debug_print("folderview size: %d x %d\n",
2361 prefs_common.folderview_width,
2362 prefs_common.folderview_height);
2363 debug_print("messageview size: %d x %d\n",
2364 prefs_common.msgview_width,
2365 prefs_common.msgview_height); */
2368 void main_window_get_position(MainWindow *mainwin)
2372 gtkut_widget_get_uposition(mainwin->window, &x, &y);
2374 prefs_common.mainview_x = x;
2375 prefs_common.mainview_y = y;
2376 prefs_common.mainwin_x = x;
2377 prefs_common.mainwin_y = y;
2379 debug_print("main window position: %d, %d\n", x, y);
2382 void main_window_progress_on(MainWindow *mainwin)
2384 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2387 void main_window_progress_off(MainWindow *mainwin)
2389 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
2390 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), "");
2393 void main_window_progress_set(MainWindow *mainwin, gint cur, gint total)
2397 g_snprintf(buf, sizeof(buf), "%d / %d", cur, total);
2398 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(mainwin->progressbar), buf);
2399 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mainwin->progressbar),
2400 (total == 0) ? 0 : (gfloat)cur / (gfloat)total);
2403 void main_window_empty_trash(MainWindow *mainwin, gboolean confirm)
2405 if (confirm && procmsg_have_trashed_mails_fast()) {
2406 if (alertpanel(_("Empty trash"),
2407 _("Delete all messages in trash folders?"),
2408 GTK_STOCK_NO, "+" GTK_STOCK_YES, NULL)
2409 != G_ALERTALTERNATE)
2411 manage_window_focus_in(mainwin->window, NULL, NULL);
2414 procmsg_empty_all_trash();
2416 if (mainwin->summaryview->folder_item &&
2417 mainwin->summaryview->folder_item->stype == F_TRASH)
2418 gtk_widget_grab_focus(mainwin->folderview->ctree);
2421 void main_window_add_mailbox(MainWindow *mainwin)
2426 path = input_dialog(_("Add mailbox"),
2427 _("Input the location of mailbox.\n"
2428 "If an existing mailbox is specified, it will be\n"
2429 "scanned automatically."),
2432 if (folder_find_from_path(path)) {
2433 alertpanel_error(_("The mailbox '%s' already exists."), path);
2437 folder = folder_new(folder_get_class_from_string("mh"),
2438 !strcmp(path, "Mail") ? _("Mailbox") :
2439 g_path_get_basename(path), path);
2442 if (folder->klass->create_tree(folder) < 0) {
2443 alertpanel_error(_("Creation of the mailbox failed.\n"
2444 "Maybe some files already exist, or you don't have the permission to write there."));
2445 folder_destroy(folder);
2450 folder_set_ui_func(folder, scan_tree_func, mainwin);
2451 folder_scan_tree(folder, TRUE);
2452 folder_set_ui_func(folder, NULL, NULL);
2455 SensitiveCond main_window_get_current_state(MainWindow *mainwin)
2457 SensitiveCond state = 0;
2458 SummarySelection selection;
2459 FolderItem *item = mainwin->summaryview->folder_item;
2460 GList *account_list = account_get_list();
2463 selection = summary_get_selection_type(mainwin->summaryview);
2465 if (mainwin->lock_count == 0 && !claws_is_starting())
2466 state |= M_UNLOCKED;
2467 if (selection != SUMMARY_NONE)
2468 state |= M_MSG_EXIST;
2469 if (item && item->path && folder_item_parent(item) && !item->no_select) {
2471 /* if (item->folder->type != F_NEWS) */
2472 state |= M_ALLOW_DELETE;
2474 if (prefs_common.immediate_exec == 0
2475 && mainwin->lock_count == 0)
2476 state |= M_DELAY_EXEC;
2478 if ((selection == SUMMARY_NONE && item->hide_read_msgs)
2479 || selection != SUMMARY_NONE)
2480 state |= M_HIDE_READ_MSG;
2482 if (mainwin->summaryview->threaded)
2483 state |= M_THREADED;
2485 state |= M_UNTHREADED;
2486 if (selection == SUMMARY_SELECTED_SINGLE ||
2487 selection == SUMMARY_SELECTED_MULTIPLE)
2488 state |= M_TARGET_EXIST;
2489 if (selection == SUMMARY_SELECTED_SINGLE)
2490 state |= M_SINGLE_TARGET_EXIST;
2491 if (mainwin->summaryview->folder_item &&
2492 mainwin->summaryview->folder_item->folder->klass->type == F_NEWS)
2495 state |= M_NOT_NEWS;
2496 if (prefs_common.actions_list && g_slist_length(prefs_common.actions_list))
2497 state |= M_ACTIONS_EXIST;
2499 tmp = tags_get_list();
2500 if (tmp && g_slist_length(tmp))
2501 state |= M_TAGS_EXIST;
2504 if (procmsg_have_queued_mails_fast() && !procmsg_is_sending())
2505 state |= M_HAVE_QUEUED_MAILS;
2507 if (selection == SUMMARY_SELECTED_SINGLE &&
2509 (folder_has_parent_of_type(item, F_DRAFT) ||
2510 folder_has_parent_of_type(item, F_OUTBOX) ||
2511 folder_has_parent_of_type(item, F_QUEUE))))
2512 state |= M_ALLOW_REEDIT;
2514 state |= M_HAVE_ACCOUNT;
2516 if (any_folder_want_synchronise())
2517 state |= M_WANT_SYNC;
2519 if (item && item->prefs->processing && selection != SUMMARY_NONE)
2520 state |= M_HAVE_PROCESSING;
2522 for ( ; account_list != NULL; account_list = account_list->next) {
2523 if (((PrefsAccount*)account_list->data)->protocol == A_NNTP) {
2524 state |= M_HAVE_NEWS_ACCOUNT;
2529 if (procmsg_spam_can_learn() &&
2530 (mainwin->summaryview->folder_item &&
2531 mainwin->summaryview->folder_item->folder->klass->type != F_UNKNOWN &&
2532 mainwin->summaryview->folder_item->folder->klass->type != F_NEWS)) {
2533 state |= M_CAN_LEARN_SPAM;
2536 if (inc_is_active())
2537 state |= M_INC_ACTIVE;
2538 if (imap_cancel_all_enabled())
2539 state |= M_INC_ACTIVE;
2541 if (mainwin->summaryview->deleted > 0 ||
2542 mainwin->summaryview->moved > 0 ||
2543 mainwin->summaryview->copied > 0)
2544 state |= M_DELAY_EXEC;
2551 void main_window_set_menu_sensitive(MainWindow *mainwin)
2553 GtkItemFactory *ifactory = mainwin->menu_factory;
2554 SensitiveCond state;
2557 GtkWidget *menuitem;
2558 SummaryView *summaryview;
2563 static const struct {
2567 {"/File/Save as...", M_TARGET_EXIST},
2568 {"/File/Print..." , M_TARGET_EXIST},
2569 {"/File/Synchronise folders", M_WANT_SYNC},
2570 {"/File/Exit" , M_UNLOCKED},
2572 {"/Edit/Select thread" , M_TARGET_EXIST},
2573 {"/Edit/Delete thread" , M_TARGET_EXIST},
2574 {"/Edit/Find in current message...", M_SINGLE_TARGET_EXIST},
2576 {"/View/Set displayed columns/in Folder list..."
2578 {"/View/Sort" , M_EXEC},
2579 {"/View/Thread view" , M_EXEC},
2580 {"/View/Expand all threads" , M_MSG_EXIST},
2581 {"/View/Collapse all threads" , M_MSG_EXIST},
2582 {"/View/Hide read messages" , M_HIDE_READ_MSG},
2583 {"/View/Go to/Previous message" , M_MSG_EXIST},
2584 {"/View/Go to/Next message" , M_MSG_EXIST},
2585 {"/View/Go to/Previous unread message" , M_MSG_EXIST},
2586 {"/View/Go to/Previous new message" , M_MSG_EXIST},
2587 {"/View/Go to/Previous marked message" , M_MSG_EXIST},
2588 {"/View/Go to/Previous labeled message", M_MSG_EXIST},
2589 {"/View/Go to/Next labeled message", M_MSG_EXIST},
2590 {"/View/Go to/Last read message" , M_SINGLE_TARGET_EXIST},
2591 {"/View/Go to/Parent message" , M_SINGLE_TARGET_EXIST},
2592 {"/View/Open in new window" , M_SINGLE_TARGET_EXIST},
2593 {"/View/Message source" , M_SINGLE_TARGET_EXIST},
2594 {"/View/All headers" , M_SINGLE_TARGET_EXIST},
2595 {"/View/Quotes" , M_SINGLE_TARGET_EXIST},
2597 {"/Message/Receive/Get from current account"
2598 , M_HAVE_ACCOUNT|M_UNLOCKED},
2599 {"/Message/Receive/Get from all accounts"
2600 , M_HAVE_ACCOUNT|M_UNLOCKED},
2601 {"/Message/Receive/Cancel receiving"
2603 {"/Message/Send queued messages" , M_HAVE_ACCOUNT|M_HAVE_QUEUED_MAILS},
2604 {"/Message/Compose an email message", M_HAVE_ACCOUNT},
2605 {"/Message/Compose a news message", M_HAVE_NEWS_ACCOUNT},
2606 {"/Message/Reply" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2607 {"/Message/Reply to" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2608 {"/Message/Follow-up and reply to", M_HAVE_ACCOUNT|M_TARGET_EXIST|M_NEWS},
2609 {"/Message/Forward" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2610 {"/Message/Forward as attachment" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2611 {"/Message/Redirect" , M_HAVE_ACCOUNT|M_TARGET_EXIST},
2612 {"/Message/Move..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2613 {"/Message/Copy..." , M_TARGET_EXIST|M_EXEC},
2614 {"/Message/Move to trash" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NOT_NEWS},
2615 {"/Message/Delete..." , M_TARGET_EXIST|M_ALLOW_DELETE},
2616 {"/Message/Cancel a news message" , M_TARGET_EXIST|M_ALLOW_DELETE|M_NEWS},
2617 {"/Message/Mark" , M_TARGET_EXIST},
2618 {"/Message/Mark/Mark as spam" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2619 {"/Message/Mark/Mark as ham" , M_TARGET_EXIST|M_CAN_LEARN_SPAM},
2620 {"/Message/Mark/Ignore thread" , M_TARGET_EXIST},
2621 {"/Message/Mark/Unignore thread" , M_TARGET_EXIST},
2622 {"/Message/Mark/Lock" , M_TARGET_EXIST},
2623 {"/Message/Mark/Unlock" , M_TARGET_EXIST},
2624 {"/Message/Color label" , M_TARGET_EXIST},
2625 {"/Message/Tags" , M_TARGET_EXIST},
2626 {"/Message/Re-edit" , M_HAVE_ACCOUNT|M_ALLOW_REEDIT},
2628 {"/Tools/Add sender to address book" , M_SINGLE_TARGET_EXIST},
2629 {"/Tools/Harvest addresses" , M_MSG_EXIST},
2630 {"/Tools/Harvest addresses/from Messages..."
2632 {"/Tools/Filter all messages in folder", M_MSG_EXIST|M_EXEC},
2633 {"/Tools/Filter selected messages" , M_TARGET_EXIST|M_EXEC},
2634 {"/Tools/Run folder processing rules" , M_HAVE_PROCESSING},
2635 {"/Tools/Create filter rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2636 {"/Tools/Create processing rule" , M_SINGLE_TARGET_EXIST|M_UNLOCKED},
2637 {"/Tools/List URLs..." , M_TARGET_EXIST},
2638 {"/Tools/Actions" , M_TARGET_EXIST|M_ACTIONS_EXIST},
2639 {"/Tools/Execute" , M_DELAY_EXEC},
2640 {"/Tools/Delete duplicated messages/In selected folder" , M_MSG_EXIST|M_ALLOW_DELETE},
2642 {"/Configuration", M_UNLOCKED},
2643 {"/Configuration/Preferences for current account...", M_UNLOCKED},
2644 {"/Configuration/Create new account...", M_UNLOCKED},
2645 {"/Configuration/Edit accounts...", M_UNLOCKED},
2650 state = main_window_get_current_state(mainwin);
2652 for (i = 0; entry[i].entry != NULL; i++) {
2653 sensitive = ((entry[i].cond & state) == entry[i].cond);
2654 menu_set_sensitive(ifactory, entry[i].entry, sensitive);
2657 menu = gtk_item_factory_get_widget(ifactory, "/Message/Receive");
2659 /* search for separator */
2660 for (cur_item = GTK_MENU_SHELL(menu)->children; cur_item != NULL;
2661 cur_item = cur_item->next) {
2662 if (GTK_BIN(cur_item->data)->child == NULL) {
2663 cur_item = cur_item->next;
2668 for (; cur_item != NULL; cur_item = cur_item->next) {
2669 gtk_widget_set_sensitive(GTK_WIDGET(cur_item->data),
2670 (M_UNLOCKED & state) != 0);
2673 main_window_menu_callback_block(mainwin);
2675 #define SET_CHECK_MENU_ACTIVE(path, active) \
2677 menuitem = gtk_item_factory_get_widget(ifactory, path); \
2678 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
2681 SET_CHECK_MENU_ACTIVE("/View/Show or hide/Message view",
2682 messageview_is_visible(mainwin->messageview));
2684 summaryview = mainwin->summaryview;
2685 menu_path = "/View/Sort/Don't sort";
2687 switch (summaryview->sort_key) {
2688 case SORT_BY_NUMBER:
2689 menu_path = "/View/Sort/by number"; break;
2691 menu_path = "/View/Sort/by Size"; break;
2693 menu_path = "/View/Sort/by Date"; break;
2694 case SORT_BY_THREAD_DATE:
2695 menu_path = "/View/Sort/by Thread date"; break;
2697 menu_path = "/View/Sort/by From"; break;
2699 menu_path = "/View/Sort/by To"; break;
2700 case SORT_BY_SUBJECT:
2701 menu_path = "/View/Sort/by Subject"; break;
2703 menu_path = "/View/Sort/by color label"; break;
2705 menu_path = "/View/Sort/by mark"; break;
2706 case SORT_BY_STATUS:
2707 menu_path = "/View/Sort/by status"; break;
2709 menu_path = "/View/Sort/by attachment"; break;
2711 menu_path = "/View/Sort/by score"; break;
2712 case SORT_BY_LOCKED:
2713 menu_path = "/View/Sort/by locked"; break;
2715 menu_path = "/View/Sort/by tag"; break;
2718 menu_path = "/View/Sort/Don't sort"; break;
2720 SET_CHECK_MENU_ACTIVE(menu_path, TRUE);
2722 if (summaryview->sort_type == SORT_ASCENDING) {
2723 SET_CHECK_MENU_ACTIVE("/View/Sort/Ascending", TRUE);
2725 SET_CHECK_MENU_ACTIVE("/View/Sort/Descending", TRUE);
2728 if (summaryview->sort_key != SORT_BY_NONE) {
2729 menu_set_sensitive(ifactory, "/View/Sort/Ascending", TRUE);
2730 menu_set_sensitive(ifactory, "/View/Sort/Descending", TRUE);
2732 menu_set_sensitive(ifactory, "/View/Sort/Ascending", FALSE);
2733 menu_set_sensitive(ifactory, "/View/Sort/Descending", FALSE);
2736 if (mainwin->messageview
2737 && mainwin->messageview->mimeview
2738 && mainwin->messageview->mimeview->textview)
2739 SET_CHECK_MENU_ACTIVE("/View/All headers",
2740 mainwin->messageview->mimeview->textview->show_all_headers);
2741 SET_CHECK_MENU_ACTIVE("/View/Thread view", (state & M_THREADED) != 0);
2742 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
2743 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
2744 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
2745 if (prefs_common.hide_quotes == 1)
2746 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", TRUE);
2747 if (prefs_common.hide_quotes == 2)
2748 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", TRUE);
2749 if (prefs_common.hide_quotes == 3)
2750 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", TRUE);
2752 #undef SET_CHECK_MENU_ACTIVE
2754 main_window_menu_callback_unblock(mainwin);
2757 void main_create_mailing_list_menu (MainWindow *mainwin, MsgInfo *msginfo)
2759 GtkItemFactory *ifactory;
2761 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
2764 is_menu = mailing_list_create_submenu (ifactory, msginfo);
2766 gtk_widget_set_sensitive (gtk_item_factory_get_item
2767 (ifactory,"/Message/Mailing-List"), TRUE);
2769 gtk_widget_set_sensitive (gtk_item_factory_get_item
2770 (ifactory,"/Message/Mailing-List"), FALSE);
2773 static gint mailing_list_create_submenu (GtkItemFactory *ifactory, MsgInfo *msginfo)
2776 GtkWidget *menuitem;
2778 if (!msginfo || !msginfo->extradata) {
2779 menu_set_sensitive(ifactory, "/Message/Mailing-List/Post", FALSE);
2780 menu_set_sensitive(ifactory, "/Message/Mailing-List/Help", FALSE);
2781 menu_set_sensitive(ifactory, "/Message/Mailing-List/Subscribe", FALSE);
2782 menu_set_sensitive(ifactory, "/Message/Mailing-List/Unsubscribe", FALSE);
2783 menu_set_sensitive(ifactory, "/Message/Mailing-List/View archive", FALSE);
2784 menu_set_sensitive(ifactory, "/Message/Mailing-List/Contact owner", FALSE);
2788 /* Mailing list post */
2789 if (!strcmp2 (msginfo->extradata->list_post, "NO")) {
2790 g_free(msginfo->extradata->list_post);
2791 msginfo->extradata->list_post = g_strdup (_("No posting allowed"));
2793 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Post");
2795 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_post);
2797 /* Mailing list help */
2798 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Help");
2800 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_help);
2802 /* Mailing list subscribe */
2803 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Subscribe");
2805 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_subscribe);
2807 /* Mailing list unsubscribe */
2808 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Unsubscribe");
2810 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_unsubscribe);
2812 /* Mailing list view archive */
2813 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/View archive");
2815 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_archive);
2817 /* Mailing list contact owner */
2818 menuitem = gtk_item_factory_get_item (ifactory, "/Message/Mailing-List/Contact owner");
2820 menu_nb += mailing_list_populate_submenu (menuitem, msginfo->extradata->list_owner);
2825 static gint mailing_list_populate_submenu (GtkWidget *menuitem, const gchar * list_header)
2827 GtkWidget *item, *menu;
2828 const gchar *url_pt ;
2829 gchar url_decoded[BUFFSIZE];
2830 GList *amenu, *alist;
2833 menu = GTK_WIDGET(GTK_MENU_ITEM(menuitem)->submenu);
2835 /* First delete old submenu */
2836 /* FIXME: we can optimize this, and only change/add/delete necessary items */
2837 for (amenu = (GTK_MENU_SHELL(menu)->children) ; amenu; ) {
2838 alist = amenu->next;
2839 item = GTK_WIDGET (amenu->data);
2840 gtk_widget_destroy (item);
2844 for (url_pt = list_header; url_pt && *url_pt;) {
2845 get_url_part (&url_pt, url_decoded, BUFFSIZE);
2847 if (!g_ascii_strncasecmp(url_decoded, "mailto:", 7)) {
2848 item = gtk_menu_item_new_with_label ((url_decoded));
2849 g_signal_connect(G_OBJECT(item), "activate",
2850 G_CALLBACK(mailing_list_compose),
2853 else if (!g_ascii_strncasecmp(url_decoded, "http:", 5) ||
2854 !g_ascii_strncasecmp(url_decoded, "https:",6)) {
2856 item = gtk_menu_item_new_with_label ((url_decoded));
2857 g_signal_connect(G_OBJECT(item), "activate",
2858 G_CALLBACK(mailing_list_open_uri),
2862 gtk_menu_append (GTK_MENU(menu), item);
2863 gtk_widget_show (item);
2869 gtk_widget_set_sensitive (menuitem, TRUE);
2871 gtk_widget_set_sensitive (menuitem, FALSE);
2877 static void get_url_part (const gchar **buffer, gchar *url_decoded, gint maxlen)
2879 gchar tmp[BUFFSIZE];
2883 gboolean with_plus = TRUE;
2886 *url_decoded = '\0';
2890 /* Ignore spaces, comments and tabs () */
2891 for (;*buf == ' ' || *buf == '(' || *buf == '\t'; buf++)
2893 for (;*buf != ')' && *buf != 0x00; buf++);
2895 /* First non space and non comment must be a < */
2898 if (!strncmp(buf, "mailto:", strlen("mailto:")))
2900 for (i = 0; *buf != '>' && *buf != 0x00 && i<maxlen; tmp[i++] = *(buf++));
2905 *url_decoded = '\0';
2910 *url_decoded = '\0';
2916 decode_uri_with_plus (url_decoded, (const gchar *)tmp, with_plus);
2918 /* Prepare the work for the next url in the list */
2919 /* after the closing bracket >, ignore space, comments and tabs */
2920 for (;buf && *buf && (*buf == ' ' || *buf == '(' || *buf == '\t'); buf++)
2922 for (;*buf != ')' && *buf != 0x00; buf++);
2924 if (!buf || !*buf) {
2929 /* now first non space, non comment must be a comma */
2931 for (;*buf != 0x00; buf++);
2937 static void mailing_list_compose (GtkWidget *w, gpointer *data)
2941 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2942 compose_new(NULL, mailto+7, NULL);
2945 static void mailing_list_open_uri (GtkWidget *w, gpointer *data)
2950 gtk_label_get (GTK_LABEL (GTK_BIN (w)->child), (gchar **) &mailto);
2951 open_uri (mailto, prefs_common.uri_cmd);
2954 void main_window_popup(MainWindow *mainwin)
2956 if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(mainwin->window)))
2957 main_window_show(mainwin);
2959 gtkut_window_popup(mainwin->window);
2960 if (prefs_common.layout_mode == SMALL_LAYOUT) {
2961 if (mainwin->in_folder) {
2962 mainwindow_enter_folder(mainwin);
2964 mainwindow_exit_folder(mainwin);
2969 void main_window_show(MainWindow *mainwin)
2971 gtk_widget_show(mainwin->window);
2972 gtk_widget_show(mainwin->vbox_body);
2974 gtk_widget_set_uposition(mainwin->window,
2975 prefs_common.mainwin_x,
2976 prefs_common.mainwin_y);
2978 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
2979 prefs_common.folderview_width,
2980 prefs_common.folderview_height);
2981 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
2982 prefs_common.summaryview_width,
2983 prefs_common.summaryview_height);
2984 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
2985 prefs_common.msgview_width,
2986 prefs_common.msgview_height);
2989 void main_window_hide(MainWindow *mainwin)
2991 main_window_get_size(mainwin);
2992 main_window_get_position(mainwin);
2994 gtk_widget_hide(mainwin->window);
2995 gtk_widget_hide(mainwin->vbox_body);
2998 static void main_window_set_widgets(MainWindow *mainwin, LayoutType layout_mode)
3000 GtkWidget *folderwin = NULL;
3001 GtkWidget *messagewin = NULL;
3004 GtkWidget *vbox_body = mainwin->vbox_body;
3005 GtkItemFactory *ifactory = mainwin->menu_factory;
3006 GtkWidget *menuitem;
3007 gboolean first_set = (mainwin->hpaned == NULL);
3008 debug_print("Setting widgets... ");
3010 if (layout_mode == SMALL_LAYOUT && first_set) {
3011 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3012 prefs_common.folderview_width,
3013 prefs_common.folderview_height);
3014 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3016 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3019 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3020 prefs_common.folderview_width,
3021 prefs_common.folderview_height);
3022 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3023 prefs_common.summaryview_width,
3024 prefs_common.summaryview_height);
3025 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3026 prefs_common.msgview_width,
3027 prefs_common.msgview_height);
3031 mainwin->messageview->statusbar = mainwin->statusbar;
3032 mainwin->messageview->statusbar_cid = mainwin->messageview_cid;
3034 /* clean top-most container */
3035 if (mainwin->hpaned) {
3036 if (mainwin->hpaned->parent == mainwin->vpaned)
3037 gtk_widget_destroy(mainwin->vpaned);
3039 gtk_widget_destroy(mainwin->hpaned);
3042 menu_set_sensitive(ifactory, "/View/Show or hide/Message view",
3043 (layout_mode != WIDE_MSGLIST_LAYOUT && layout_mode != SMALL_LAYOUT));
3044 switch (layout_mode) {
3045 case VERTICAL_LAYOUT:
3048 hpaned = gtk_hpaned_new();
3049 if (layout_mode == VERTICAL_LAYOUT)
3050 vpaned = gtk_hpaned_new();
3052 vpaned = gtk_vpaned_new();
3053 gtk_box_pack_start(GTK_BOX(vbox_body), hpaned, TRUE, TRUE, 0);
3054 gtk_paned_add1(GTK_PANED(hpaned),
3055 GTK_WIDGET_PTR(mainwin->folderview));
3056 gtk_widget_show(hpaned);
3057 gtk_widget_queue_resize(hpaned);
3059 if (messageview_is_visible(mainwin->messageview)) {
3060 gtk_paned_add2(GTK_PANED(hpaned), vpaned);
3061 gtk_paned_add1(GTK_PANED(vpaned),
3062 GTK_WIDGET_PTR(mainwin->summaryview));
3064 gtk_paned_add2(GTK_PANED(hpaned),
3065 GTK_WIDGET_PTR(mainwin->summaryview));
3066 gtk_widget_ref(vpaned);
3068 gtk_paned_add2(GTK_PANED(vpaned),
3069 GTK_WIDGET_PTR(mainwin->messageview));
3070 gtk_widget_show(vpaned);
3071 if (layout_mode == SMALL_LAYOUT && first_set) {
3072 mainwin_paned_show_first(GTK_PANED(hpaned));
3074 gtk_widget_queue_resize(vpaned);
3077 vpaned = gtk_vpaned_new();
3078 hpaned = gtk_hpaned_new();
3079 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3080 gtk_paned_add1(GTK_PANED(vpaned), hpaned);
3082 gtk_paned_add1(GTK_PANED(hpaned),
3083 GTK_WIDGET_PTR(mainwin->folderview));
3084 gtk_paned_add2(GTK_PANED(hpaned),
3085 GTK_WIDGET_PTR(mainwin->summaryview));
3087 gtk_widget_show(hpaned);
3088 gtk_widget_queue_resize(hpaned);
3090 if (messageview_is_visible(mainwin->messageview)) {
3091 gtk_paned_add2(GTK_PANED(vpaned),
3092 GTK_WIDGET_PTR(mainwin->messageview));
3094 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3096 gtk_widget_show(vpaned);
3097 gtk_widget_queue_resize(vpaned);
3099 case WIDE_MSGLIST_LAYOUT:
3100 vpaned = gtk_vpaned_new();
3101 hpaned = gtk_hpaned_new();
3102 gtk_box_pack_start(GTK_BOX(vbox_body), vpaned, TRUE, TRUE, 0);
3104 gtk_paned_add1(GTK_PANED(vpaned),
3105 GTK_WIDGET_PTR(mainwin->summaryview));
3106 gtk_paned_add1(GTK_PANED(hpaned),
3107 GTK_WIDGET_PTR(mainwin->folderview));
3109 gtk_widget_show(hpaned);
3110 gtk_widget_queue_resize(hpaned);
3112 if (messageview_is_visible(mainwin->messageview)) {
3113 gtk_paned_add2(GTK_PANED(hpaned),
3114 GTK_WIDGET_PTR(mainwin->messageview));
3116 gtk_widget_ref(GTK_WIDGET_PTR(mainwin->messageview));
3118 gtk_paned_add2(GTK_PANED(vpaned), hpaned);
3120 gtk_widget_show(vpaned);
3121 gtk_widget_queue_resize(vpaned);
3124 g_warning("Unknown layout");
3128 mainwin->hpaned = hpaned;
3129 mainwin->vpaned = vpaned;
3131 if (layout_mode == SMALL_LAYOUT) {
3132 if (mainwin->messageview->visible)
3133 main_window_toggle_message_view(mainwin);
3136 if (layout_mode == SMALL_LAYOUT && first_set) {
3137 gtk_widget_realize(mainwin->window);
3138 gtk_widget_realize(mainwin->folderview->ctree);
3139 gtk_widget_realize(mainwin->summaryview->hbox);
3140 gtk_widget_realize(mainwin->summaryview->hbox_l);
3141 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->folderview),
3142 prefs_common.folderview_width,
3143 prefs_common.folderview_height);
3144 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->summaryview),
3146 gtk_widget_set_size_request(GTK_WIDGET_PTR(mainwin->messageview),
3148 gtk_widget_set_size_request(GTK_WIDGET(mainwin->window),
3149 prefs_common.mainwin_width,
3150 prefs_common.mainwin_height);
3151 gtk_paned_set_position(GTK_PANED(mainwin->hpaned), 800);
3153 /* remove headerview if not in prefs */
3154 headerview_set_visibility(mainwin->messageview->headerview,
3155 prefs_common.display_header_pane);
3157 if (messageview_is_visible(mainwin->messageview))
3158 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3159 GTK_ARROW_DOWN, GTK_SHADOW_OUT);
3161 gtk_arrow_set(GTK_ARROW(mainwin->summaryview->toggle_arrow),
3162 GTK_ARROW_UP, GTK_SHADOW_OUT);
3164 gtk_window_move(GTK_WINDOW(mainwin->window),
3165 prefs_common.mainwin_x,
3166 prefs_common.mainwin_y);
3168 gtk_widget_queue_resize(vbox_body);
3169 gtk_widget_queue_resize(mainwin->vbox);
3170 gtk_widget_queue_resize(mainwin->window);
3171 /* CLAWS: previous "gtk_widget_show_all" makes noticeview
3172 * and mimeview icon list/ctree lose track of their visibility states */
3173 if (!noticeview_is_visible(mainwin->messageview->noticeview))
3174 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->noticeview));
3175 if (!noticeview_is_visible(mainwin->messageview->mimeview->siginfoview))
3176 gtk_widget_hide(GTK_WIDGET_PTR(mainwin->messageview->mimeview->siginfoview));
3177 if (mainwin->messageview->mimeview->ctree_mode)
3178 gtk_widget_hide(mainwin->messageview->mimeview->icon_mainbox);
3180 gtk_widget_hide(mainwin->messageview->mimeview->ctree_mainbox);
3182 prefs_common.layout_mode = layout_mode;
3184 menuitem = gtk_item_factory_get_item
3185 (ifactory, "/View/Show or hide/Message view");
3186 gtk_check_menu_item_set_active
3187 (GTK_CHECK_MENU_ITEM(menuitem),
3188 messageview_is_visible(mainwin->messageview));
3190 #define SET_CHECK_MENU_ACTIVE(path, active) \
3192 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3193 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3197 switch (prefs_common.layout_mode) {
3199 SET_CHECK_MENU_ACTIVE("/View/Layout/Standard", TRUE);
3201 case VERTICAL_LAYOUT:
3202 SET_CHECK_MENU_ACTIVE("/View/Layout/Three columns", TRUE);
3205 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message", TRUE);
3207 case WIDE_MSGLIST_LAYOUT:
3208 SET_CHECK_MENU_ACTIVE("/View/Layout/Wide message list", TRUE);
3211 SET_CHECK_MENU_ACTIVE("/View/Layout/Small screen", TRUE);
3215 #undef SET_CHECK_MENU_ACTIVE
3219 (G_OBJECT(folderwin), "size_allocate",
3220 G_CALLBACK(folder_window_size_allocate_cb),
3225 (G_OBJECT(messagewin), "size_allocate",
3226 G_CALLBACK(message_window_size_allocate_cb),
3230 debug_print("done.\n");
3233 void main_window_destroy_all(void)
3235 while (mainwin_list != NULL) {
3236 MainWindow *mainwin = (MainWindow*)mainwin_list->data;
3238 /* free toolbar stuff */
3239 toolbar_clear_list(TOOLBAR_MAIN);
3240 TOOLBAR_DESTROY_ACTIONS(mainwin->toolbar->action_list);
3241 TOOLBAR_DESTROY_ITEMS(mainwin->toolbar->item_list);
3243 mainwin->folderview->mainwin = NULL;
3244 mainwin->summaryview->mainwin = NULL;
3245 mainwin->messageview->mainwin = NULL;
3247 g_free(mainwin->toolbar);
3250 mainwin_list = g_list_remove(mainwin_list, mainwin);
3252 g_list_free(mainwin_list);
3253 mainwin_list = NULL;
3256 static void toolbar_child_attached(GtkWidget *widget, GtkWidget *child,
3259 gtk_widget_set_size_request(child, 1, -1);
3262 static void toolbar_child_detached(GtkWidget *widget, GtkWidget *child,
3265 gtk_widget_set_size_request(child, -1, -1);
3268 static gboolean ac_label_button_pressed(GtkWidget *widget, GdkEventButton *event,
3271 MainWindow *mainwin = (MainWindow *)data;
3273 if (!event) return FALSE;
3275 gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NORMAL);
3276 g_object_set_data(G_OBJECT(mainwin->ac_menu), "menu_button",
3279 gtk_menu_popup(GTK_MENU(mainwin->ac_menu), NULL, NULL,
3280 menu_button_position, widget,
3281 event->button, event->time);
3286 static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
3289 MainWindow *mainwin = (MainWindow *)data;
3290 gboolean close_allowed = TRUE;
3292 hooks_invoke(MAIN_WINDOW_CLOSE, &close_allowed);
3294 if (close_allowed && mainwin->lock_count == 0)
3295 app_exit_cb(data, 0, widget);
3300 static void main_window_size_allocate_cb(GtkWidget *widget,
3301 GtkAllocation *allocation,
3304 MainWindow *mainwin = (MainWindow *)data;
3305 main_window_get_size(mainwin);
3308 static void folder_window_size_allocate_cb(GtkWidget *widget,
3309 GtkAllocation *allocation,
3312 MainWindow *mainwin = (MainWindow *)data;
3314 main_window_get_size(mainwin);
3317 static void message_window_size_allocate_cb(GtkWidget *widget,
3318 GtkAllocation *allocation,
3321 MainWindow *mainwin = (MainWindow *)data;
3323 main_window_get_size(mainwin);
3326 static void add_mailbox_cb(MainWindow *mainwin, guint action,
3329 main_window_add_mailbox(mainwin);
3332 static void update_folderview_cb(MainWindow *mainwin, guint action,
3335 summary_show(mainwin->summaryview, NULL);
3336 folderview_check_new_all();
3339 static void foldersort_cb(MainWindow *mainwin, guint action,
3345 static void import_mbox_cb(MainWindow *mainwin, guint action,
3348 /* only notify if import has failed */
3349 if (import_mbox(mainwin->summaryview->folder_item) == -1) {
3350 alertpanel_error(_("Mbox import has failed."));
3354 static void export_mbox_cb(MainWindow *mainwin, guint action,
3357 /* only notify if export has failed */
3358 if (export_mbox(mainwin->summaryview->folder_item) == -1) {
3359 alertpanel_error(_("Export to mbox has failed."));
3363 static void export_list_mbox_cb(MainWindow *mainwin, guint action,
3366 /* only notify if export has failed */
3367 if (summaryview_export_mbox_list(mainwin->summaryview) == -1) {
3368 alertpanel_error(_("Export to mbox has failed."));
3372 static void empty_trash_cb(MainWindow *mainwin, guint action,
3375 main_window_empty_trash(mainwin, TRUE);
3378 static void save_as_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3380 summary_save_as(mainwin->summaryview);
3383 static void print_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3385 summary_print(mainwin->summaryview);
3388 #if GTK_CHECK_VERSION(2,10,0) && !defined(USE_GNOMEPRINT)
3389 static void page_setup_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3391 MainWindow *mainwindow;
3394 mainwindow = mainwindow_get_mainwindow();
3395 win = (mainwindow ? GTK_WINDOW(mainwindow->window) : NULL);
3397 printing_page_setup(win);
3401 static void app_exit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3403 if (prefs_common.confirm_on_exit) {
3404 if (alertpanel(_("Exit"), _("Exit Claws Mail?"),
3405 GTK_STOCK_CANCEL, GTK_STOCK_QUIT, NULL)
3406 != G_ALERTALTERNATE)
3408 manage_window_focus_in(mainwin->window, NULL, NULL);
3411 app_will_exit(widget, mainwin);
3414 static void search_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3417 summary_search(mainwin->summaryview);
3419 message_search(mainwin->messageview);
3422 static void mainwindow_quicksearch(MainWindow *mainwin, guint action, GtkWidget *widget)
3424 summaryview_activate_quicksearch(mainwin->summaryview, TRUE);
3427 static void toggle_message_cb(MainWindow *mainwin, guint action,
3432 active = GTK_CHECK_MENU_ITEM(widget)->active;
3434 if (active != messageview_is_visible(mainwin->messageview))
3435 summary_toggle_view(mainwin->summaryview);
3438 static void toggle_toolbar_cb(MainWindow *mainwin, guint action,
3441 toolbar_toggle(action, mainwin);
3444 static void main_window_reply_cb(MainWindow *mainwin, guint action,
3447 MessageView *msgview = (MessageView*)mainwin->messageview;
3448 GSList *msginfo_list = NULL;
3450 g_return_if_fail(msgview != NULL);
3452 msginfo_list = summary_get_selection(mainwin->summaryview);
3453 g_return_if_fail(msginfo_list != NULL);
3454 compose_reply_from_messageview(msgview, msginfo_list, action);
3455 g_slist_free(msginfo_list);
3458 static void toggle_col_headers_cb(MainWindow *mainwin, guint action,
3461 FolderView *folderview = mainwin->folderview;
3462 SummaryView *summaryview = mainwin->summaryview;
3464 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3465 gtk_clist_column_titles_show(GTK_CLIST(folderview->ctree));
3466 gtk_clist_column_titles_show(GTK_CLIST(summaryview->ctree));
3467 prefs_common.show_col_headers = TRUE;
3469 gtk_clist_column_titles_hide(GTK_CLIST(folderview->ctree));
3470 gtk_clist_column_titles_hide(GTK_CLIST(summaryview->ctree));
3471 prefs_common.show_col_headers = FALSE;
3476 static void toggle_statusbar_cb(MainWindow *mainwin, guint action,
3479 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3480 gtk_widget_show(mainwin->hbox_stat);
3481 prefs_common.show_statusbar = TRUE;
3483 gtk_widget_hide(mainwin->hbox_stat);
3484 prefs_common.show_statusbar = FALSE;
3488 static void set_layout_cb(MainWindow *mainwin, guint action,
3491 LayoutType layout_mode = action;
3492 LayoutType old_layout_mode = prefs_common.layout_mode;
3493 if (mainwin->menu_lock_count) {
3496 if (!GTK_CHECK_MENU_ITEM(widget)->active) {
3500 if (layout_mode == prefs_common.layout_mode) {
3504 if (!mainwin->messageview->visible && layout_mode != SMALL_LAYOUT)
3505 main_window_toggle_message_view(mainwin);
3506 else if (mainwin->messageview->visible && layout_mode == SMALL_LAYOUT)
3507 main_window_toggle_message_view(mainwin);
3509 main_window_separation_change(mainwin, layout_mode);
3510 mainwindow_reset_paned(GTK_PANED(mainwin->vpaned));
3511 if (old_layout_mode == SMALL_LAYOUT && layout_mode != SMALL_LAYOUT) {
3512 mainwindow_reset_paned(GTK_PANED(mainwin->hpaned));
3514 if (old_layout_mode != SMALL_LAYOUT && layout_mode == SMALL_LAYOUT) {
3515 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
3516 mainwindow_exit_folder(mainwin);
3518 summary_relayout(mainwin->summaryview);
3519 summary_update_unread(mainwin->summaryview, NULL);
3523 void main_window_toggle_work_offline (MainWindow *mainwin, gboolean offline,
3526 offline_ask_sync = ask_sync;
3528 online_switch_clicked (GTK_BUTTON(mainwin->online_switch), mainwin);
3530 online_switch_clicked (GTK_BUTTON(mainwin->offline_switch), mainwin);
3531 offline_ask_sync = TRUE;
3534 static void toggle_work_offline_cb (MainWindow *mainwin, guint action, GtkWidget *widget)
3536 main_window_toggle_work_offline(mainwin, GTK_CHECK_MENU_ITEM(widget)->active, TRUE);
3539 static gboolean any_folder_want_synchronise(void)
3541 GList *folderlist = folder_get_list();
3543 /* see if there are synchronised folders */
3544 for (; folderlist; folderlist = folderlist->next) {
3545 Folder *folder = (Folder *)folderlist->data;
3546 if (folder_want_synchronise(folder)) {
3554 static void mainwindow_check_synchronise(MainWindow *mainwin, gboolean ask)
3557 if (!any_folder_want_synchronise())
3560 if (offline_ask_sync && ask && alertpanel(_("Folder synchronisation"),
3561 _("Do you want to synchronise your folders now?"),
3562 GTK_STOCK_CANCEL, _("+_Synchronise"), NULL) != G_ALERTALTERNATE)
3565 if (offline_ask_sync)
3566 folder_synchronise(NULL);
3569 static void online_switch_clicked (GtkButton *btn, gpointer data)
3571 MainWindow *mainwin;
3572 GtkItemFactory *ifactory;
3573 GtkCheckMenuItem *menuitem;
3575 mainwin = (MainWindow *) data;
3577 ifactory = gtk_item_factory_from_widget(mainwin->menubar);
3578 menuitem = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_widget(ifactory, "/File/Work offline"));
3580 g_return_if_fail(mainwin != NULL);
3581 g_return_if_fail(menuitem != NULL);
3583 if (btn == GTK_BUTTON(mainwin->online_switch)) {
3585 gtk_widget_hide (mainwin->online_switch);
3586 gtk_widget_show (mainwin->offline_switch);
3588 menuitem->active = TRUE;
3589 inc_autocheck_timer_remove();
3592 if (prefs_common.work_offline)
3594 mainwindow_check_synchronise(mainwin, TRUE);
3595 prefs_common.work_offline = TRUE;
3596 imap_disconnect_all();
3597 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3600 if (!prefs_common.work_offline)
3603 gtk_widget_hide (mainwin->offline_switch);
3604 gtk_widget_show (mainwin->online_switch);
3606 menuitem->active = FALSE;
3607 prefs_common.work_offline = FALSE;
3608 inc_autocheck_timer_set();
3609 refresh_resolvers();
3610 hooks_invoke(OFFLINE_SWITCH_HOOKLIST, NULL);
3614 static void addressbook_open_cb(MainWindow *mainwin, guint action,
3617 addressbook_open(NULL);
3620 static void log_window_show_cb(MainWindow *mainwin, guint action,
3623 log_window_show(mainwin->logwin);
3626 static void filtering_debug_window_show_cb(MainWindow *mainwin, guint action,
3629 log_window_show(mainwin->filtering_debugwin);
3632 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3638 static void move_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3640 summary_move_to(mainwin->summaryview);
3643 static void copy_to_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3645 summary_copy_to(mainwin->summaryview);
3648 static void delete_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3650 summary_delete(mainwin->summaryview);
3653 static void delete_trash_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3655 summary_delete_trash(mainwin->summaryview);
3658 static void cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3660 summary_cancel(mainwin->summaryview);
3663 static void open_msg_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3665 summary_open_msg(mainwin->summaryview);
3668 static void view_source_cb(MainWindow *mainwin, guint action,
3671 summary_view_source(mainwin->summaryview);
3674 static void show_all_header_cb(MainWindow *mainwin, guint action,
3677 if (mainwin->menu_lock_count) return;
3678 mainwin->summaryview->messageview->all_headers =
3679 GTK_CHECK_MENU_ITEM(widget)->active;
3680 summary_display_msg_selected(mainwin->summaryview,
3681 GTK_CHECK_MENU_ITEM(widget)->active);
3684 #define SET_CHECK_MENU_ACTIVE(path, active) \
3686 menuitem = gtk_item_factory_get_widget(ifactory, path); \
3687 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active); \
3690 static void hide_quotes_cb(MainWindow *mainwin, guint action,
3693 GtkWidget *menuitem;
3694 GtkItemFactory *ifactory = mainwin->menu_factory;
3696 if (mainwin->menu_lock_count) return;
3698 prefs_common.hide_quotes =
3699 GTK_CHECK_MENU_ITEM(widget)->active ? action : 0;
3701 mainwin->menu_lock_count++;
3702 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold all", FALSE);
3703 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 2", FALSE);
3704 SET_CHECK_MENU_ACTIVE("/View/Quotes/Fold from level 3", FALSE);
3705 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), prefs_common.hide_quotes > 0);
3706 mainwin->menu_lock_count--;
3708 summary_redisplay_msg(mainwin->summaryview);
3711 #undef SET_CHECK_MENU_ACTIVE
3712 static void mark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3714 summary_mark(mainwin->summaryview);
3717 static void unmark_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3719 summary_unmark(mainwin->summaryview);
3722 static void mark_as_unread_cb(MainWindow *mainwin, guint action,
3725 summary_mark_as_unread(mainwin->summaryview);
3728 static void mark_as_read_cb(MainWindow *mainwin, guint action,
3731 summary_mark_as_read(mainwin->summaryview);
3734 static void mark_all_read_cb(MainWindow *mainwin, guint action,
3737 summary_mark_all_read(mainwin->summaryview);
3740 static void mark_as_spam_cb(MainWindow *mainwin, guint action,
3743 summary_mark_as_spam(mainwin->summaryview, action, NULL);
3746 static void ignore_thread_cb(MainWindow *mainwin, guint action,
3749 summary_ignore_thread(mainwin->summaryview);
3752 static void unignore_thread_cb(MainWindow *mainwin, guint action,
3755 summary_unignore_thread(mainwin->summaryview);
3758 static void watch_thread_cb(MainWindow *mainwin, guint action,
3761 summary_watch_thread(mainwin->summaryview);
3764 static void unwatch_thread_cb(MainWindow *mainwin, guint action,
3767 summary_unwatch_thread(mainwin->summaryview);
3770 static void lock_msgs_cb(MainWindow *mainwin, guint action,
3773 summary_msgs_lock(mainwin->summaryview);
3776 static void unlock_msgs_cb(MainWindow *mainwin, guint action,
3779 summary_msgs_unlock(mainwin->summaryview);
3783 static void reedit_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3785 summary_reedit(mainwin->summaryview);
3788 static void open_urls_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3790 if (!mainwin->summaryview->displayed && mainwin->summaryview->selected) {
3791 summary_display_msg_selected(mainwin->summaryview,
3792 mainwin->messageview->mimeview->textview->show_all_headers);
3794 messageview_list_urls(mainwin->messageview);
3797 static void add_address_cb(MainWindow *mainwin, guint action,
3800 summary_add_address(mainwin->summaryview);
3803 static void set_charset_cb(MainWindow *mainwin, guint action,
3808 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3809 str = conv_get_charset_str((CharSet)action);
3811 g_free(mainwin->messageview->forced_charset);
3812 mainwin->messageview->forced_charset = str ? g_strdup(str) : NULL;
3813 procmime_force_charset(str);
3815 summary_redisplay_msg(mainwin->summaryview);
3817 debug_print("forced charset: %s\n", str ? str : "Auto-Detect");
3821 static void set_decode_cb(MainWindow *mainwin, guint action,
3824 if (GTK_CHECK_MENU_ITEM(widget)->active) {
3825 mainwin->messageview->forced_encoding = (EncodingType)action;
3827 summary_redisplay_msg(mainwin->summaryview);
3829 debug_print("forced encoding: %d\n", action);
3833 static void hide_read_messages (MainWindow *mainwin, guint action,
3836 if (!mainwin->summaryview->folder_item
3837 || g_object_get_data(G_OBJECT(widget), "dont_toggle"))
3839 summary_toggle_show_read_messages(mainwin->summaryview);
3842 static void thread_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3844 gboolean threaded = FALSE;
3845 if (mainwin->menu_lock_count) return;
3846 if (!mainwin->summaryview->folder_item) return;
3848 threaded = GTK_CHECK_MENU_ITEM(widget)->active;
3850 mainwin->summaryview->folder_item->threaded = threaded;
3852 mainwin->summaryview->threaded = threaded;
3854 summary_show(mainwin->summaryview,
3855 mainwin->summaryview->folder_item);
3858 static void expand_threads_cb(MainWindow *mainwin, guint action,
3861 summary_expand_threads(mainwin->summaryview);
3864 static void collapse_threads_cb(MainWindow *mainwin, guint action,
3867 summary_collapse_threads(mainwin->summaryview);
3870 static void set_summary_display_item_cb(MainWindow *mainwin, guint action,
3873 prefs_summary_column_open();
3876 static void set_folder_display_item_cb(MainWindow *mainwin, guint action,
3879 prefs_folder_column_open();
3882 static void sort_summary_cb(MainWindow *mainwin, guint action,
3885 FolderItem *item = mainwin->summaryview->folder_item;
3886 GtkWidget *menuitem;
3888 if (mainwin->menu_lock_count) return;
3890 if (GTK_CHECK_MENU_ITEM(widget)->active && item) {
3891 menuitem = gtk_item_factory_get_item
3892 (mainwin->menu_factory, "/View/Sort/Ascending");
3893 summary_sort(mainwin->summaryview, (FolderSortKey)action,
3894 GTK_CHECK_MENU_ITEM(menuitem)->active
3895 ? SORT_ASCENDING : SORT_DESCENDING);
3896 item->sort_key = action;
3900 static void sort_summary_type_cb(MainWindow *mainwin, guint action,
3903 FolderItem *item = mainwin->summaryview->folder_item;
3905 if (mainwin->menu_lock_count) return;
3907 if (GTK_CHECK_MENU_ITEM(widget)->active && item)
3908 summary_sort(mainwin->summaryview,
3909 item->sort_key, (FolderSortType)action);
3912 static void attract_by_subject_cb(MainWindow *mainwin, guint action,
3915 summary_attract_by_subject(mainwin->summaryview);
3918 static void delete_duplicated_cb(MainWindow *mainwin, guint action,
3923 item = folderview_get_selected_item(mainwin->folderview);
3925 main_window_cursor_wait(mainwin);
3926 STATUSBAR_PUSH(mainwin, _("Deleting duplicated messages..."));
3928 folderutils_delete_duplicates(item, prefs_common.immediate_exec ?
3929 DELETE_DUPLICATES_REMOVE : DELETE_DUPLICATES_SETFLAG);
3931 STATUSBAR_POP(mainwin);
3932 main_window_cursor_normal(mainwin);
3942 static void deldup_all(FolderItem *item, gpointer _data)
3944 struct DelDupsData *data = _data;
3947 result = folderutils_delete_duplicates(item, DELETE_DUPLICATES_REMOVE);
3949 data->dups += result;
3954 static void delete_duplicated_all_cb(MainWindow *mainwin, guint action,
3957 struct DelDupsData data = {0, 0};
3959 main_window_cursor_wait(mainwin);
3960 folder_func_to_all_folders(deldup_all, &data);
3961 main_window_cursor_normal(mainwin);
3963 alertpanel_notice(ngettext("Deleted %d duplicate message in %d folders.\n",
3964 "Deleted %d duplicate messages in %d folders.\n",
3966 data.dups, data.folders);
3969 static void filter_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3971 summary_filter(mainwin->summaryview, (gboolean)action);
3974 static void process_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
3976 FolderItem *item = mainwin->summaryview->folder_item;
3977 g_return_if_fail(item != NULL);
3979 folder_item_apply_processing(item);
3982 static void execute_summary_cb(MainWindow *mainwin, guint action,
3985 summary_execute(mainwin->summaryview);
3988 static void update_summary_cb(MainWindow *mainwin, guint action,
3992 FolderView *folderview = mainwin->folderview;
3994 if (!mainwin->summaryview->folder_item) return;
3995 if (!folderview->opened) return;
3997 folder_update_op_count();
3999 fitem = gtk_ctree_node_get_row_data(GTK_CTREE(folderview->ctree),
4000 folderview->opened);
4003 folder_item_scan(fitem);
4004 summary_show(mainwin->summaryview, fitem);
4007 static void prev_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4009 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_BACKWARD);
4012 static void next_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4014 summary_step(mainwin->summaryview, GTK_SCROLL_STEP_FORWARD);
4017 static void prev_unread_cb(MainWindow *mainwin, guint action,
4020 summary_select_prev_unread(mainwin->summaryview);
4023 static void next_unread_cb(MainWindow *mainwin, guint action,
4026 summary_select_next_unread(mainwin->summaryview);
4029 static void prev_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4031 summary_select_prev_new(mainwin->summaryview);
4034 static void next_new_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4036 summary_select_next_new(mainwin->summaryview);
4039 static void prev_marked_cb(MainWindow *mainwin, guint action,
4042 summary_select_prev_marked(mainwin->summaryview);
4045 static void next_marked_cb(MainWindow *mainwin, guint action,
4048 summary_select_next_marked(mainwin->summaryview);
4051 static void prev_labeled_cb(MainWindow *mainwin, guint action,
4054 summary_select_prev_labeled(mainwin->summaryview);
4057 static void next_labeled_cb(MainWindow *mainwin, guint action,
4060 summary_select_next_labeled(mainwin->summaryview);
4063 static void last_read_cb(MainWindow *mainwin, guint action,
4066 summary_select_last_read(mainwin->summaryview);
4069 static void parent_cb(MainWindow *mainwin, guint action,
4072 summary_select_parent(mainwin->summaryview);
4075 static void goto_folder_cb(MainWindow *mainwin, guint action,
4078 FolderItem *to_folder;
4080 to_folder = foldersel_folder_sel(NULL, FOLDER_SEL_ALL, NULL);
4083 folderview_select(mainwin->folderview, to_folder);
4086 static void goto_unread_folder_cb(MainWindow *mainwin, guint action,
4089 folderview_select_next_unread(mainwin->folderview, FALSE);
4092 static void copy_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4094 messageview_copy_clipboard(mainwin->messageview);
4097 static void allsel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4099 MessageView *msgview = mainwin->messageview;
4101 if (messageview_is_visible(msgview) &&
4102 (GTK_WIDGET_HAS_FOCUS(msgview->mimeview->textview->text)))
4103 messageview_select_all(mainwin->messageview);
4105 summary_select_all(mainwin->summaryview);
4108 static void select_thread_cb(MainWindow *mainwin, guint action,
4111 summary_select_thread(mainwin->summaryview, FALSE);
4114 static void delete_thread_cb(MainWindow *mainwin, guint action,
4117 summary_select_thread(mainwin->summaryview, TRUE);
4120 static void create_filter_cb(MainWindow *mainwin, guint action,
4123 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 0);
4126 static void create_processing_cb(MainWindow *mainwin, guint action,
4129 summary_filter_open(mainwin->summaryview, (PrefsFilterType)action, 1);
4132 static void prefs_pre_processing_open_cb(MainWindow *mainwin, guint action,
4135 prefs_filtering_open(&pre_global_processing,
4136 _("Processing rules to apply before folder rules"),
4137 MANUAL_ANCHOR_PROCESSING,
4141 static void prefs_post_processing_open_cb(MainWindow *mainwin, guint action,
4144 prefs_filtering_open(&post_global_processing,
4145 _("Processing rules to apply after folder rules"),
4146 MANUAL_ANCHOR_PROCESSING,
4150 static void prefs_filtering_open_cb(MainWindow *mainwin, guint action,
4153 prefs_filtering_open(&filtering_rules,
4154 _("Filtering configuration"),
4155 MANUAL_ANCHOR_FILTERING,
4159 static void prefs_template_open_cb(MainWindow *mainwin, guint action,
4162 prefs_template_open();
4165 static void prefs_actions_open_cb(MainWindow *mainwin, guint action,
4168 prefs_actions_open(mainwin);
4171 static void prefs_tags_open_cb(MainWindow *mainwin, guint action,
4174 prefs_tags_open(mainwin);
4177 static void ssl_manager_open_cb(MainWindow *mainwin, guint action,
4180 ssl_manager_open(mainwin);
4183 static void prefs_account_open_cb(MainWindow *mainwin, guint action,
4187 new_account_cb(mainwin, 0, widget);
4189 account_open(cur_account);
4193 static void new_account_cb(MainWindow *mainwin, guint action,
4196 account_edit_open();
4197 if (!compose_get_compose_list()) account_add();
4200 static void account_selector_menu_cb(GtkMenuItem *menuitem, gpointer data)
4202 FolderItem *item = NULL;
4203 cur_account = (PrefsAccount *)data;
4205 if (!mainwindow_get_mainwindow())
4207 main_window_show_cur_account(mainwindow_get_mainwindow());
4208 toolbar_update(TOOLBAR_MAIN, mainwindow_get_mainwindow());
4209 main_window_set_menu_sensitive(mainwindow_get_mainwindow());
4210 toolbar_main_set_sensitive(mainwindow_get_mainwindow());
4211 item = folderview_get_selected_item(
4212 mainwindow_get_mainwindow()->folderview);
4214 toolbar_set_compose_button
4215 (mainwindow_get_mainwindow()->toolbar,
4216 FOLDER_TYPE(item->folder) == F_NEWS ?
4217 COMPOSEBUTTON_NEWS : COMPOSEBUTTON_MAIL);
4221 static void account_receive_menu_cb(GtkMenuItem *menuitem, gpointer data)
4223 MainWindow *mainwin = (MainWindow *)mainwin_list->data;
4224 PrefsAccount *account = (PrefsAccount *)data;
4226 inc_account_mail(mainwin, account);
4229 static void account_compose_menu_cb(GtkMenuItem *menuitem, gpointer data)
4231 PrefsAccount *account = (PrefsAccount *)data;
4233 compose_new_with_folderitem(account, NULL, NULL);
4236 static void prefs_open_cb(GtkMenuItem *menuitem, gpointer data)
4241 static void plugins_open_cb(GtkMenuItem *menuitem, gpointer data)
4243 pluginwindow_create();
4246 static void manual_open_cb(MainWindow *mainwin, guint action,
4249 manual_open((ManualType)action, NULL);
4252 static void legend_open_cb(GtkMenuItem *menuitem, gpointer data)
4257 static void scan_tree_func(Folder *folder, FolderItem *item, gpointer data)
4259 MainWindow *mainwin = (MainWindow *)data;
4263 str = g_strdup_printf(_("Scanning folder %s%c%s ..."),
4264 LOCAL_FOLDER(folder)->rootpath,
4268 str = g_strdup_printf(_("Scanning folder %s ..."),
4269 LOCAL_FOLDER(folder)->rootpath);
4271 STATUSBAR_PUSH(mainwin, str);
4272 STATUSBAR_POP(mainwin);
4276 static gboolean mainwindow_focus_in_event(GtkWidget *widget, GdkEventFocus *focus,
4279 SummaryView *summary;
4281 g_return_val_if_fail(data, FALSE);
4282 if (!g_list_find(mainwin_list, data))
4284 summary = ((MainWindow *)data)->summaryview;
4285 g_return_val_if_fail(summary, FALSE);
4287 if (GTK_CLIST(summary->ctree)->selection &&
4288 g_list_length(GTK_CLIST(summary->ctree)->selection) > 1)
4294 static gboolean mainwindow_visibility_event_cb(GtkWidget *widget, GdkEventVisibility *event,
4297 is_obscured = (event->state == GDK_VISIBILITY_FULLY_OBSCURED);
4301 static gboolean mainwindow_state_event_cb(GtkWidget *widget, GdkEventWindowState *state,
4304 if (!claws_is_starting()
4305 && state->changed_mask&GDK_WINDOW_STATE_ICONIFIED
4306 && state->new_window_state&GDK_WINDOW_STATE_ICONIFIED) {
4308 if (iconified_count > 0)
4309 hooks_invoke(MAIN_WINDOW_GOT_ICONIFIED, NULL);
4312 if (state->new_window_state == 0)
4313 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(widget), FALSE);
4317 gboolean mainwindow_is_obscured(void)
4322 #define BREAK_ON_MODIFIER_KEY() \
4323 if ((event->state & (GDK_MOD1_MASK|GDK_CONTROL_MASK)) != 0) break
4325 gboolean mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event,
4328 MainWindow *mainwin = (MainWindow*) data;
4330 if (!mainwin || !event)
4333 if (quicksearch_has_focus(mainwin->summaryview->quicksearch))
4335 lastkey = event->keyval;
4339 switch (event->keyval) {
4340 case GDK_Q: /* Quit */
4341 BREAK_ON_MODIFIER_KEY();
4343 app_exit_cb(mainwin, 0, NULL);
4346 if (mainwin->folderview && mainwin->summaryview
4347 && ((!mainwin->summaryview->displayed
4348 && !mainwin->summaryview->selected)
4349 || (mainwin->summaryview->folder_item
4350 && mainwin->summaryview->folder_item->total_msgs == 0))) {
4351 g_signal_stop_emission_by_name(G_OBJECT(widget),
4353 folderview_select_next_unread(mainwin->folderview, TRUE);
4358 if (maemo_mainwindow_is_fullscreen(widget)) {
4359 gtk_window_unfullscreen(GTK_WINDOW(widget));
4361 gtk_window_fullscreen(GTK_WINDOW(widget));
4365 if (mainwin->summaryview &&
4366 mainwin->summaryview->ext_messageview &&
4367 mainwin->summaryview->ext_messageview->window &&
4368 widget == mainwin->summaryview->ext_messageview->window) {
4369 messageview_destroy(mainwin->summaryview->ext_messageview);
4379 #undef BREAK_ON_MODIFIER_KEY
4382 * Harvest addresses for selected folder.
4384 static void addr_harvest_cb( MainWindow *mainwin,
4388 addressbook_harvest( mainwin->summaryview->folder_item, FALSE, NULL );
4392 * Harvest addresses for selected messages in summary view.
4394 static void addr_harvest_msg_cb( MainWindow *mainwin,
4398 summary_harvest_address( mainwin->summaryview );
4402 *\brief get a MainWindow
4404 *\return MainWindow * The first mainwindow in the mainwin_list
4406 MainWindow *mainwindow_get_mainwindow(void)
4408 if (mainwin_list && mainwin_list->data)
4409 return (MainWindow *)(mainwin_list->data);
4414 static gboolean mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
4416 ProgressData *data = (ProgressData *) source;
4417 MainWindow *mainwin = (MainWindow *) userdata;
4419 switch (data->cmd) {
4420 case PROGRESS_COMMAND_START:
4421 case PROGRESS_COMMAND_STOP:
4422 gtk_progress_bar_set_fraction
4423 (GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
4425 case PROGRESS_COMMAND_SET_PERCENTAGE:
4426 gtk_progress_bar_set_fraction
4427 (GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
4430 while (gtk_events_pending()) gtk_main_iteration ();
4435 static void sync_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
4437 mainwindow_check_synchronise(mainwin, FALSE);
4440 void mainwindow_learn (MainWindow *mainwin, gboolean is_spam)
4442 summary_mark_as_spam(mainwin->summaryview, is_spam, NULL);
4445 void mainwindow_jump_to(const gchar *target, gboolean popup)
4449 FolderItem *item = NULL;
4451 MainWindow *mainwin = mainwindow_get_mainwindow();
4457 g_print("not initialized\n");
4461 tmp = g_strdup(target);
4463 if ((p = strstr(tmp, "\r")) != NULL)
4465 if ((p = strstr(tmp, "\n")) != NULL)
4468 if ((item = folder_find_item_from_identifier(tmp))) {
4469 g_print("selecting folder '%s'\n", tmp);
4470 folderview_select(mainwin->folderview, item);
4472 main_window_popup(mainwin);
4477 msg = strrchr(tmp, G_DIR_SEPARATOR);
4480 if ((item = folder_find_item_from_identifier(tmp))) {
4481 g_print("selecting folder '%s'\n", tmp);
4482 folderview_select(mainwin->folderview, item);
4484 g_print("'%s' not found\n", tmp);
4486 if (item && msg && atoi(msg)) {
4487 g_print("selecting message %d\n", atoi(msg));
4488 summary_select_by_msgnum(mainwin->summaryview, atoi(msg));
4489 summary_display_msg_selected(mainwin->summaryview, FALSE);
4491 main_window_popup(mainwin);
4494 } else if (item && msg[0] == '<' && msg[strlen(msg)-1] == '>') {
4495 MsgInfo *msginfo = NULL;
4497 msg[strlen(msg)-1] = '\0';
4498 msginfo = folder_item_get_msginfo_by_msgid(item, msg);
4500 g_print("selecting message %s\n", msg);
4501 summary_select_by_msgnum(mainwin->summaryview, msginfo->msgnum);
4502 summary_display_msg_selected(mainwin->summaryview, FALSE);
4504 main_window_popup(mainwin);
4506 procmsg_msginfo_free(msginfo);
4509 g_print("'%s' not found\n", msg);
4512 g_print("'%s' not found\n", msg);
4515 g_print("'%s' not found\n", tmp);
4521 void mainwindow_exit_folder(MainWindow *mainwin) {
4522 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4523 folderview_close_opened(mainwin->folderview);
4524 mainwin_paned_show_first(GTK_PANED(mainwin->hpaned));
4526 mainwin->in_folder = FALSE;
4529 void mainwindow_enter_folder(MainWindow *mainwin) {
4530 if (prefs_common.layout_mode == SMALL_LAYOUT) {
4531 mainwin_paned_show_last(GTK_PANED(mainwin->hpaned));
4533 mainwin->in_folder = TRUE;
4537 gboolean maemo_mainwindow_is_fullscreen(GtkWidget *widget)
4540 gtk_window_get_size(GTK_WINDOW(widget), &w, &h);
4544 void maemo_window_full_screen_if_needed (GtkWindow *window)
4546 if (maemo_mainwindow_is_fullscreen(mainwindow_get_mainwindow()->window)) {
4547 gtk_window_fullscreen(GTK_WINDOW(window));
4551 void maemo_connect_key_press_to_mainwindow (GtkWindow *window)
4553 g_signal_connect(G_OBJECT(window), "key_press_event",
4554 G_CALLBACK(mainwindow_key_pressed), mainwindow_get_mainwindow());